Skip to content

Commit

Permalink
fix(picqer): always send to picqer, log failed fulfilment
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvdbrug committed Oct 31, 2023
1 parent 12b0179 commit 2216aee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 4 additions & 0 deletions packages/vendure-plugin-picqer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 2.0.0

- Push to Picqer even when fulfilling failed. Log order codes and manual steps needed when fulfillment fails.

# 2.0.0

- Complete orders on `orders.status_changed` webhooks, instead of `picklists.closed` hooks. ([#281](https://github.com/Pinelab-studio/pinelab-vendure-plugins/pull/281))

# 1.0.13
Expand Down
2 changes: 1 addition & 1 deletion packages/vendure-plugin-picqer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinelab/vendure-plugin-picqer",
"version": "2.0.0",
"version": "2.0.1",
"description": "Vendure plugin syncing to orders and stock with Picqer",
"author": "Martijn van de Brug <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
Expand Down
38 changes: 22 additions & 16 deletions packages/vendure-plugin-picqer/src/api/picqer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ export class PicqerService implements OnApplicationBootstrap {
);
}
Logger.info(`Successfully handled job '${data.action}'`, loggerCtx);
} catch (e: unknown) {
if (e instanceof Error) {
// Only log a warning, because this is a background function that will be retried by the JobQueue
Logger.warn(
`Failed to handle job '${data.action}': ${e?.message}`,
loggerCtx
);
}
} catch (e: any) {
// Only log a warning, because this is a background function that will be retried by the JobQueue
const orderCode = Logger.warn(
`Failed to handle job '${data.action}': ${e?.message}`,
loggerCtx
);
throw e;
}
},
Expand Down Expand Up @@ -730,14 +728,22 @@ export class PicqerService implements OnApplicationBootstrap {
return;
}
// Fulfill order first
const fulfillment = await fulfillAll(ctx, this.orderService, order, {
code: picqerHandler.code,
arguments: [],
});
Logger.info(
`Created fulfillment (${fulfillment.id}) for order ${order.code}`,
loggerCtx
);
try {
const fulfillment = await fulfillAll(ctx, this.orderService, order, {
code: picqerHandler.code,
arguments: [],
});
Logger.info(
`Created fulfillment (${fulfillment.id}) for order ${order.code}`,
loggerCtx
);
} catch (e: any) {
Logger.error(
`Failed to fulfill order ${order.code}: ${e?.message}. Transition this order manually to 'Delivered' if it has been sent to Picqer, to prevent future errors related to status changes for this order.`,
loggerCtx,
util.inspect(e)
);
}
// Push the order to Picqer
await this.pushOrderToPicqer(ctx, order, client);
}
Expand Down

0 comments on commit 2216aee

Please sign in to comment.