Handling Discount Logic

Some aggregators send the discount inside item array and some are on order details level. In order to handle this, you can refer to the below document.

Written By Ops UrbanPiper (Collaborator)

Updated at June 6th, 2019

ITEM LEVEL DISCOUNT

Let's take the below example for an order -

ORDER LEVEL DATA

order_subtotal = 200
discount = 100
total_external_discount = 70
Merchant discount = (discount - total_external_discount) = 30
order_total = 178.5


ITEM LEVEL DATA

Item - 1

item level sub-total i.e, total = 120
discount = (item level sub-total/order_subtotal)*(merchant discount)=(120/200)*30=18
Taxable amount = (item level sub-total - discount) = (120-18)=102
Tax = (taxable amount*5% gst) = (102*0.05) = 5.1
Total with tax = (taxable amount + tax) = (102 + 5.1) = 107.1

Item-2

item level subtotal i.e, total = 80
discount = (item level sub-total/order_subtotal)*(merchant discount)=(80/200)*30=12
Taxable amount= (item level sub-total - discount) = (80-12)=68
Tax = (taxable amount*5% gst) = (68*0.05) = 3.4
Total with tax = (taxable amount + tax) = (68 + 3.4) = 71.4


CROSS VERIFICATION

(total with tax of Item1 + total with tax of item2) = (107.1 + 71.4) = 178.5
Which is equal to order_total in the payload.



ORDER LEVEL DISCOUNT

Let's take the below example of an order - 

order_subtotal: 100
discount: 50
total_external_discount: 20.0

Merchant sponsored Discount = (discount - total_external_discount)
i.e, Merchant Sponsored Discount = 30

Taxable amount = (order_subtotal - Merchant Sponsored Discount)
i.e, Taxable amount = 70

Tax on Taxable amount = 70 * 0.05 = 3.5

Merchant Total Collecting from Aggregators = (Taxable Amount + Tax)
i.e, Merchant Total Collecting from Aggregators = 70+3.5 = 73.5

Total you get in the payload = ("Merchant Total" - "Total_external_discount")
i.e, Total you get in the payload = 73.5 - 20 = 53.5

Now on the bill what you have to show is the Merchant Total Collecting from Aggregators. You can simply use the formula,

Receivable Amount From Aggregators = total + total_external_discount

i.e, Receivable Amount From Aggregators = 53.5 + 20 = 73.5

Was this article helpful?