fix(warehouse): correct label extension, surface print errors, revert…#94
Open
thesleepyniko wants to merge 1 commit into
Open
fix(warehouse): correct label extension, surface print errors, revert…#94thesleepyniko wants to merge 1 commit into
thesleepyniko wants to merge 1 commit into
Conversation
… status on carrier failure - Use .png extension for Chit Chats PNG labels (was hardcoded .pdf, breaking PDF readers) - Wrap QZ Tray qz.print() calls in try/catch and surface failures via labelErrors[orderId] - Revert warehouseOrder.status back to APPROVED if carrier throws after the SHIPPED claim, so retries don't hit "already shipped" 409 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves warehouse label/packing-slip handling by fixing Chit Chats label download filenames, surfacing QZ Tray print failures in the UI, and making /api/fulfillment/get-label resilient to carrier failures by rolling back an order’s status when shipment creation fails after the “SHIPPED” claim.
Changes:
- Generate label download filenames with a
.pngextension when the label is a PNG data URL. - Wrap QZ Tray
qz.print()calls intry/catchand report failures vialabelErrors[orderId]. - Add a
try/catcharound post-claim shipment creation so failures revertwarehouseOrder.statusfromSHIPPEDback toAPPROVEDto allow retries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| resolution-frontend/src/routes/app/warehouse/fulfillment/+page.svelte | Adds label filename inference for PNG/PDF and surfaces QZ print errors per order. |
| resolution-frontend/src/routes/api/fulfillment/get-label/+server.ts | Rolls back status to APPROVED on post-claim carrier failures to avoid “already shipped” retry dead-ends. |
Comments suppressed due to low confidence (2)
resolution-frontend/src/routes/app/warehouse/fulfillment/+page.svelte:112
printAllnow records print failures inlabelErrors, but it never clears a previous error when the user retries printing. This can leave a stale error displayed even after a subsequent successful print. Consider resettinglabelErrors[orderId]at the start ofprintAll(and/or clearing it after successful label + slip printing).
async function printAll(orderId: string, result: { labelUrl: string | null; packingSlipBase64: string }) {
if (!qz || qzStatus !== 'connected') return;
const settings = getQZSettings();
if (!settings.printer) { alert('No printer selected. Go to Settings to configure.'); return; }
const config = () => qz.configs.create(settings.printer, {
resolution-frontend/src/routes/api/fulfillment/get-label/+server.ts:160
- The
try {block introduced here isn't indented, which makes it harder to visually see what is covered by the rollbackcatch. Re-indent the code inside thetryto match the surrounding style.
try {
// Total weight always comes from items. Dimensions come from the packaging
// record chosen at estimate time so the carrier request matches the quote.
// Fall back to item-derived dims for legacy orders without packaging info.
const MAX_HEIGHT_IN = 48;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
+137
| try { | ||
| await qz.print(config(), [{ type: 'html', format: 'plain', data: html }]); | ||
| } catch (e: any) { | ||
| labelErrors[orderId] = `Packing slip print failed: ${e?.message || e}`; | ||
| } |
Comment on lines
+370
to
+375
| await db.update(warehouseOrder) | ||
| .set({ status: 'APPROVED', updatedAt: new Date() }) | ||
| .where(and( | ||
| eq(warehouseOrder.id, orderId), | ||
| eq(warehouseOrder.status, 'SHIPPED') | ||
| )); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… status on carrier failure