Skip to content

Commit

Permalink
fix: save convertDealId when pos order sync
Browse files Browse the repository at this point in the history
  • Loading branch information
munkhsaikhan committed Apr 10, 2024
1 parent d6457be commit f5c8dfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/plugin-pos-api/src/utils.ts
Expand Up @@ -289,7 +289,7 @@ const createDeliveryDeal = async ({ subdomain, models, doneOrder, pos }) => {
},
stringValue: `${marker.longitude || marker.lng},${
marker.latitude || marker.lat
}`,
}`,
},
];
}
Expand Down Expand Up @@ -486,8 +486,12 @@ const createDealPerOrder = async ({ subdomain, pos, newOrder }) => {
},
},
});

await newOrder.updateOne({ _id: newOrder._id }, { $set: { convertDealId: cardDeal._id } });
return cardDeal._id
}
// end sync cards config then <
return;
};

const syncErkhetRemainder = async ({ subdomain, models, pos, newOrder }) => {
Expand Down Expand Up @@ -705,7 +709,7 @@ export const syncOrderFromClient = async ({
await confirmLoyalties(subdomain, newOrder);
await otherPlugins(subdomain, newOrder, oldOrder, newOrder.userId);

await createDealPerOrder({ subdomain, pos, newOrder });
const convertDealId = await createDealPerOrder({ subdomain, pos, newOrder });

if (pos.isOnline && newOrder.subBranchId) {
const toPos = await models.Pos.findOne({
Expand All @@ -721,7 +725,7 @@ export const syncOrderFromClient = async ({
subdomain,
action: 'erxes-posclient-to-pos-api',
data: {
order: { ...newOrder, posToken, subToken: toPos.token },
order: { ...newOrder, convertDealId, posToken, subToken: toPos.token },
},
pos: toPos,
});
Expand Down Expand Up @@ -776,6 +780,7 @@ export const syncOrderFromClient = async ({
posToken,
responseIds: syncedResponeIds,
orderId: newOrder._id,
convertDealId
},
pos,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-posclient-api/src/messageBroker.ts
Expand Up @@ -112,11 +112,11 @@ export const setupMessageConsumers = async () => {
`posclient:updateSynced${channelToken}`,
async ({ subdomain, data }) => {
const models = await generateModels(subdomain);
const { responseIds, orderId } = data;
const { responseIds, orderId, convertDealId } = data;

await models.Orders.updateOne(
{ _id: orderId },
{ $set: { synced: true } },
{ $set: { synced: true, convertDealId } },
);
await models.PutResponses.updateMany(
{ _id: { $in: responseIds } },
Expand Down

0 comments on commit f5c8dfd

Please sign in to comment.