fix: paid amount handling on refunded orders#53
Conversation
|
FWIW, the linter is throwing errors on unchanged files: |
|
whoops! I thought I had tested thoroughly, but my code must have been cached. now I'm getting: |
|
@agritheory I think this is ready. |
📝 Draft Changelog EntryChangelogFixed an issue where refunded orders from Shopify were causing order imports to fail. When orders are refunded through the Shopify to ShipStation integration, the system records negative amounts for both the order total and amount paid. The previous order handling logic did not account for negative paid amounts, which resulted in validation errors that would halt all order imports. This update adds a check to prevent incorrect calculations when processing refunded orders, allowing order imports to continue without interruption. This changelog entry was automatically generated by the Changelog Generator Action. |
Draft Changelog EntryChangelogFixed an issue where refunded orders from Shopify were causing order imports to fail. When orders are refunded through the Shopify to ShipStation integration, the system records negative amounts for both the order total and amount paid. The previous logic attempted to calculate a difference between these values, which resulted in validation errors that halted the entire import process. The order import process now handles refunded orders correctly and continues processing without interruption. This changelog entry was automatically generated by the Changelog Generator Action. |
This is a very simple tweak to avoid calculating a difference amount when the "amount_paid" is a negative number. I can't speak to all channels, but at least the Shopify -> ShipStation integration changes "amount_paid" to a negative number when an order is refunded, as illustrated by the following order API result:
This creates a real quandary with the current order handling code, leading to an error that completely freezes the order imports, since ERPNext Sales Order validation will not accept a negative order total.
I'm not sure if my fix is sufficient, but I'm at least happy with the ability to continue importing orders and the functionality from the
so_statusbranch is sufficient for differentiating which orders have been canceled/refunded from others.