ERP and integrations · 9 min · 2026-11-07
Shopify discount codes in your ERP: how to split the discount by line and VAT rate
A discount code sent to the ERP as one negative line at 23% leaves VAT wrong in mixed rate orders. How Shopify allocates discounts and how to pass them.
Summary
What matters before moving forward.
- In the Shopify to Primavera integration we mapped, discount codes were the hardest part. Not because of the discount amount, but because of how it changes the VAT on each line.
- Shopify stores discounts in two places: the discount applications at order level and the share of each discount allocated to each line. The second is what the ERP needs.
- Sending the discount code as a single negative line is only correct when every item has the same VAT rate. With mixed rates, VAT is wrong even if the total matches.
- Free shipping, buy 3 pay 2 and gift cards look like discounts and are not handled the same way. In Shopify, a gift card is a payment method.
- A badly split discount shows up again on refunds: the credit note has to return what was actually paid for that line.
A discount is not a line, it is an allocation
When a customer uses a 10% code on the order, Shopify shows a discount on the total. Internally it does something else: it spreads that discount across the lines in proportion to their value. In the API, the order has the list of applied discounts and each line has its own discount allocations, with the amount it received.
For the ERP, what matters is the amount actually paid for each line after the discount. That is the value base and VAT are calculated on. Reading only the order's total discount and inventing a way to distribute it is the fastest route to numbers that do not match Shopify.
Why a single negative line fails
The most common and most tempting solution is to send items at full price and add a negative discount line at the end of the document. It works when every item has the same rate. It stops working when the order mixes rates.
An example with VAT inclusive prices. The order has item A at 30 euros at 23% and item B at 10 euros at 6%, with a 5 euro code. Shopify splits the code proportionally: 3.75 on item A and 1.25 on item B. Item A becomes 26.25, with 4.91 VAT; item B becomes 8.75, with 0.50 VAT. Total VAT: 5.41.
With a single negative line at 23%: item A at 30 has 5.61 VAT, item B at 10 has 0.57, and the 5 euro discount line removes 0.93. Total VAT: 5.25. The customer paid the same, the document total matches, but VAT charged is 16 cents too low. Multiplied by thousands of orders, it is an error that shows up in the VAT return.
Discounts that look the same and are not
Product discount. A code for one collection or product is allocated only to the lines it covers. The integration must not spread it across the whole order.
Buy 3 pay 2. The discount is allocated to the free item's line or split across the covered lines, depending on configuration. How to show the offer in the ERP should be agreed with your accountant, but each line's value must come from Shopify.
Free shipping. It is a discount on the shipping line, not on the items. If the integration treats it as an item discount, it reduces the wrong base.
Gift cards. In Shopify a gift card is a payment method, not a discount. It does not reduce the value of the items or the VAT on the sale; it only reduces what the customer paid by another method. Treating it as a discount code in the ERP is a frequent mistake.
The discount comes back on refunds
When the customer returns item A from the order above, how much should be refunded and credited? Not 30 euros, but 26.25, which is what they actually paid for that item after the code.
If the ERP received the discount as a single negative line, it does not know how much of the code belongs to item A. The credit note either returns too much or requires a manual calculation. With the discount split per line from the sale, the credit note comes out right automatically.
That is why the discount decision should be made with returns in mind, not just the sale.
How to map discounts to the ERP
Use Shopify's per line allocation as the source. For each line, the value sent to the ERP is the original total minus that line's discount allocations.
Decide how to show the discount on the document: as an already discounted unit price, or as full price with a line discount. Both are correct as long as the discount sits on the right line with the right rate. The choice depends on the ERP and what your accountant prefers to see.
Test with orders that have mixed rates, percentage and fixed amount codes, free shipping and a gift card. These are the cases where integrations usually fail.
How Vokzar handles discounts in the integration
We read discount allocations line by line directly from Shopify and pass the ERP the amount actually paid on each line, with the correct VAT rate.
We separate free shipping, offers and gift cards, each with its proper treatment, and make sure the same per line value is used for credit notes.
We deliver a set of test orders with the hard cases, so every future change to the integration is validated against them.
Related next steps
Next steps.
Proof and validation
- The discountApplications and discountAllocations fields come from Shopify's official Admin API documentation.
- The example uses 23% and 6% VAT, VAT inclusive prices and rounding to 2 decimals. How discounts appear on the document should be confirmed with your accountant.
- The mapping experience refers to a Shopify to Primavera integration built for a large company.
Official documentation
Validated sources.
Technical strategy should be auditable. These sources link directly to the official documentation behind this guide.
Frequently asked questions
Common questions about this topic.
Can I send the discount code to the ERP as a negative line?
Only when every item in the order has the same VAT rate. With mixed rates, the total matches but VAT is wrong, because the discount does not reduce each rate's base in the right proportion.
Where is the discount split stored in Shopify?
On each order line, in the Admin API discount allocations. The order also lists the applied discounts, but the per line allocation is what should go to the ERP.
Are gift cards discounts?
Not in Shopify. A gift card is a payment method: it does not reduce the value of the items or the VAT on the sale.
Why does the discount affect returns?
Because the amount to refund and credit is what the customer paid for the line after the discount. Without the per line split, the credit note returns too much or needs a manual calculation.

