Building a Secondary Claim / Ship-and-Debit / Chargeback Workflow in ERPNext

Hi ERPNext community,

I am working on implementing a Special Pricing Agreement (SPA) and Secondary Claim (Chargeback) workflow for a distributor in India. Before I go deep into custom development, I wanted to open this up to the community to see if anyone has solved this — or parts of it — already.


The Business Context

A distributor buys products from multiple brands and manufacturers and sells to a mix of general customers and contracted customers. Some customers — typically large supermarket chains, HoReCa (Hotels, Restaurants, Cafes), and institutional buyers — have a direct pricing agreement with the brand (SPA), which means the distributor is required to sell to them at a negotiated Special Selling Price that sits below the standard market rate.

To protect the distributor’s margin on these sales, the brand compensates the difference monthly via a chargeback — triggered by a Secondary Claim Report that proves the units were actually sold to that specific contracted customer.


The Five Pricing Tiers

We have defined five pricing tiers that need to coexist in the system:

RP — Retail Price
The brand’s retail price, inclusive of taxes. Always a fixed value. Serves purely as a reference point — other prices may be derived from it as a percentage discount or markup.

DP — Distributor Price
The price at which the brand or manufacturer invoices the distributor. This is the distributor’s stocking cost. The actual purchase invoice rate is always the authoritative DP. A DP price list may also be maintained as a reference or for derived price calculations, but the invoice rate takes precedence.

SDP — Special Distributor Price
A lower effective cost that the brand agrees to bear for the distributor on sales made to contracted customers. The chargeback recovers the gap between DP and SDP. Can be a fixed rate or derived from DP, RP, or SP. Scoped per item, per customer or customer group.

SP — Selling Price
The distributor’s standard selling price to general open-market customers with no SPA. Can be fixed or derived from DP or RP.

SSP — Special Selling Price
The price the distributor charges a contracted customer, as negotiated between the brand and that customer. Always below SP. Can be fixed or derived from DP, RP, or SP. Scoped per item, per customer or customer group.

Derived = a fixed amount or percentage markup or discount applied on top of another price tier.


The Chargeback Logic

For every unit sold to an SSP customer:

Chargeback = (DP − SDP) × Qty Sold

Where DP is the actual purchase invoice rate for that item — not a price list value. SDP is fetched from the agreed rate master for that supplier-customer-item combination at the time of sale. At the end of each month, the distributor submits a Secondary Claim Report to the brand summarising all SSP sales and the total chargeback due.


Questions for the Community

  • Has anyone implemented a similar SPA / chargeback workflow in ERPNext? What approach did you take?
  • How are you managing derived pricing (formula-based prices that depend on another price tier) within ERPNext’s price list structure?
  • How are you linking the actual purchase invoice rate (DP) to the corresponding sales transactions for chargeback calculation?
  • How are you handling SDP and SSP at customer group level across a large item catalogue?
  • Any existing apps or modules in the ERPNext ecosystem that address this use case?

Happy to share more details on the business process if it helps. Would also be glad to document and share whatever we build here for the community.

Running ERPNext v16. Thanks in advance.