fix(India): Discounts in E-Invoicing
This commit is contained in:
parent
169ff5a0dd
commit
f337213f33
@ -271,14 +271,18 @@ def get_item_list(invoice):
|
||||
item.description = sanitize_for_json(d.item_name)
|
||||
|
||||
item.qty = abs(item.qty)
|
||||
if flt(item.qty) != 0.0:
|
||||
item.unit_rate = abs(item.taxable_value / item.qty)
|
||||
|
||||
if invoice.get("apply_discount_on"):
|
||||
item.discount_amount = item.base_amount - item.base_net_amount
|
||||
elif item.discount_amount > 0:
|
||||
item.discount_amount = item.discount_amount
|
||||
else:
|
||||
item.unit_rate = abs(item.taxable_value)
|
||||
item.gross_amount = abs(item.taxable_value)
|
||||
item.taxable_value = abs(item.taxable_value)
|
||||
item.discount_amount = 0
|
||||
|
||||
item.unit_rate = abs(item.taxable_value - item.discount_amount) / item.qty
|
||||
|
||||
item.gross_amount = abs(item.taxable_value) + item.discount_amount
|
||||
item.taxable_value = abs(item.taxable_value)
|
||||
item.is_service_item = "Y" if item.gst_hsn_code and item.gst_hsn_code[:2] == "99" else "N"
|
||||
item.serial_no = ""
|
||||
|
||||
@ -352,6 +356,13 @@ def update_item_taxes(invoice, item):
|
||||
def get_invoice_value_details(invoice):
|
||||
invoice_value_details = frappe._dict(dict())
|
||||
invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get("items")]))
|
||||
if (
|
||||
invoice.apply_discount_on == "Grand Total"
|
||||
and invoice.discount_amount
|
||||
and invoice.get("is_cash_or_non_trade_discount")
|
||||
):
|
||||
invoice_value_details.invoice_discount_amt = invoice.base_discount_amount
|
||||
else:
|
||||
invoice_value_details.invoice_discount_amt = 0
|
||||
|
||||
invoice_value_details.round_off = invoice.base_rounding_adjustment
|
||||
|
@ -1060,6 +1060,14 @@ def update_taxable_values(doc, method):
|
||||
considered_rows.append(prev_row_id)
|
||||
|
||||
for item in doc.get("items"):
|
||||
if (
|
||||
doc.apply_discount_on == "Grand Total"
|
||||
and doc.discount_amount
|
||||
and doc.get("is_cash_or_non_trade_discount")
|
||||
):
|
||||
proportionate_value = item.base_amount if doc.base_total else item.qty
|
||||
total_value = doc.base_total if doc.base_total else doc.total_qty
|
||||
else:
|
||||
proportionate_value = item.base_net_amount if doc.base_net_total else item.qty
|
||||
total_value = doc.base_net_total if doc.base_net_total else doc.total_qty
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user