Describe the issue
Codeunit 30246 Shpfy Create Sales Doc. Refund currently writes every refunded shipping charge as a G/L Account line posted to Shpfy Shop."Shipping Charges Account" and unconditionally calls TestField on that account.
This diverges from the sales order flow in codeunit Shpfy Process Order (CreateSalesLines, the shipping-charges loop), which:
- Looks up
Shpfy Shipment Method Mapping by Shop Code + shipping title
- When the mapping's
Shipping Charges Type is set, writes the line as that Type/No. (G/L Account, Item, or Charge (Item))
- Only falls back to
Shop."Shipping Charges Account" when no mapping applies
Result: Shops that represent freight as an Item (or Charge (Item)) on sales orders are forced to use a G/L account when creating refund credit memos, creating inconsistent shipping line shapes between orders and their corresponding refunds.
Expected behavior
When a refund credit memo is created with a shipping charge:
- The system should look up
Shpfy Shipment Method Mapping using Shop Code + RefundShippingLine.Title
- If a mapping exists and
Shipping Charges Type <> " ", the shipping line should be created as the mapped Type/No. (G/L Account, Item, or Charge (Item))
- If no mapping exists or
Shipping Charges Type = " ", the system should fall back to posting as a G/L Account line to Shop."Shipping Charges Account" (current behavior)
- Refund credit memos should produce the same shipping line shape as the originating sales order
Shipping Agent Code and Shipping Agent Service Code should be propagated from the mapping
Steps to reproduce
When a refund credit memo is created with a shipping charge:
- The system should look up
Shpfy Shipment Method Mapping using Shop Code + RefundShippingLine.Title
- If a mapping exists and
Shipping Charges Type <> " ", the shipping line should be created as the mapped Type/No. (G/L Account, Item, or Charge (Item))
- If no mapping exists or
Shipping Charges Type = " ", the system should fall back to posting as a G/L Account line to Shop."Shipping Charges Account" (current behavior)
- Refund credit memos should produce the same shipping line shape as the originating sales order
Shipping Agent Code and Shipping Agent Service Code should be propagated from the mapping
Additional context
- Affected codeunit:
ShpfyCreateSalesDocRefund.Codeunit.al — specifically CreateSalesLinesFromRefundShippingLines
- Related codeunit:
Shpfy Process Order (CreateSalesLines shipping-charges loop) — this is the order-side pattern to mirror
- Table:
Shpfy Shipment Method Mapping (table 30131) is keyed on Shop Code + Name, which covers both order and refund lookups
- Risk: Low. New code is gated on the presence of an explicit mapping row; the default path is unchanged. Feature reuses an already-shipped table and the well-tested order-side pattern.
- No schema changes required
I will provide a fix for a bug
Describe the issue
Codeunit 30246
Shpfy Create Sales Doc. Refundcurrently writes every refunded shipping charge as a G/L Account line posted toShpfy Shop."Shipping Charges Account"and unconditionally callsTestFieldon that account.This diverges from the sales order flow in codeunit
Shpfy Process Order(CreateSalesLines, the shipping-charges loop), which:Shpfy Shipment Method MappingbyShop Code+ shipping titleShipping Charges Typeis set, writes the line as that Type/No. (G/L Account, Item, or Charge (Item))Shop."Shipping Charges Account"when no mapping appliesResult: Shops that represent freight as an Item (or Charge (Item)) on sales orders are forced to use a G/L account when creating refund credit memos, creating inconsistent shipping line shapes between orders and their corresponding refunds.
Expected behavior
When a refund credit memo is created with a shipping charge:
Shpfy Shipment Method MappingusingShop Code+RefundShippingLine.TitleShipping Charges Type <> " ", the shipping line should be created as the mapped Type/No. (G/L Account, Item, or Charge (Item))Shipping Charges Type = " ", the system should fall back to posting as a G/L Account line toShop."Shipping Charges Account"(current behavior)Shipping Agent CodeandShipping Agent Service Codeshould be propagated from the mappingSteps to reproduce
When a refund credit memo is created with a shipping charge:
Shpfy Shipment Method MappingusingShop Code+RefundShippingLine.TitleShipping Charges Type <> " ", the shipping line should be created as the mapped Type/No. (G/L Account, Item, or Charge (Item))Shipping Charges Type = " ", the system should fall back to posting as a G/L Account line toShop."Shipping Charges Account"(current behavior)Shipping Agent CodeandShipping Agent Service Codeshould be propagated from the mappingAdditional context
ShpfyCreateSalesDocRefund.Codeunit.al— specificallyCreateSalesLinesFromRefundShippingLinesShpfy Process Order(CreateSalesLinesshipping-charges loop) — this is the order-side pattern to mirrorShpfy Shipment Method Mapping(table 30131) is keyed onShop Code+Name, which covers both order and refund lookupsI will provide a fix for a bug