Skip to content

fix(dashboard): honor order options.incoterm in createShipmentFromOrders#1130

Open
DarkSwoop wants to merge 1 commit into
karrioapi:mainfrom
DarkSwoop:fix-order-incoterm-option
Open

fix(dashboard): honor order options.incoterm in createShipmentFromOrders#1130
DarkSwoop wants to merge 1 commit into
karrioapi:mainfrom
DarkSwoop:fix-order-incoterm-option

Conversation

@DarkSwoop

Copy link
Copy Markdown
Collaborator

Problem

createShipmentFromOrders (packages/lib/helper.ts) derives the customs incoterm
solely from the freight payer:

incoterm: payment?.paid_by == "sender" ? "DDP" : "DDU",

Since paid_by defaults to sender, every shipment built from an order is forced
to DDP, and there is no way to request a different term of trade through the
order's options.

Impact (dhl_express)

Freight payer and terms of trade are independent at the carrier level — dhl_express
maps payment.paid_byShippingPaymentType and customs.incotermTermsOfTrade
separately. Coupling them in the dashboard means a sender-paid DHL shipment can never
be DDU: the recipient can't be made to pay duties while freight stays billed to the
sender.

Fix

Honor an explicit options.incoterm from the order, normalized and validated against
the INCOTERMS enum; fall back to the existing paid_by-derived default when absent
or invalid:

const order_incoterm = `${order_options.incoterm || ""}`.toUpperCase();
const incoterm =
  (INCOTERMS.includes(order_incoterm) ? order_incoterm : null) ||
  (payment?.paid_by == "sender" ? "DDP" : "DDU");

Now possible: an order with options.incoterm = "DDU" produces a DHL label with
TermsOfTrade=DDU while freight stays billed to the sender (ShippingPaymentType=S).
Additive change — orders without options.incoterm behave exactly as before, and the
value remains a pre-fill users can still edit in the customs form.

@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

@DarkSwoop is attempting to deploy a commit to the karrio Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant