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.description = sanitize_for_json(d.item_name)
|
||||||
|
|
||||||
item.qty = abs(item.qty)
|
item.qty = abs(item.qty)
|
||||||
if flt(item.qty) != 0.0:
|
|
||||||
item.unit_rate = abs(item.taxable_value / item.qty)
|
|
||||||
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
|
|
||||||
|
|
||||||
|
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.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.is_service_item = "Y" if item.gst_hsn_code and item.gst_hsn_code[:2] == "99" else "N"
|
||||||
item.serial_no = ""
|
item.serial_no = ""
|
||||||
|
|
||||||
@ -352,7 +356,14 @@ def update_item_taxes(invoice, item):
|
|||||||
def get_invoice_value_details(invoice):
|
def get_invoice_value_details(invoice):
|
||||||
invoice_value_details = frappe._dict(dict())
|
invoice_value_details = frappe._dict(dict())
|
||||||
invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get("items")]))
|
invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get("items")]))
|
||||||
invoice_value_details.invoice_discount_amt = 0
|
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
|
invoice_value_details.round_off = invoice.base_rounding_adjustment
|
||||||
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(
|
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(
|
||||||
|
@ -1060,8 +1060,16 @@ def update_taxable_values(doc, method):
|
|||||||
considered_rows.append(prev_row_id)
|
considered_rows.append(prev_row_id)
|
||||||
|
|
||||||
for item in doc.get("items"):
|
for item in doc.get("items"):
|
||||||
proportionate_value = item.base_net_amount if doc.base_net_total else item.qty
|
if (
|
||||||
total_value = doc.base_net_total if doc.base_net_total else doc.total_qty
|
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
|
||||||
|
|
||||||
applicable_charges = flt(
|
applicable_charges = flt(
|
||||||
flt(
|
flt(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user