From b97d30aad098d87e6c95ff1dab37360ac574e17a Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Tue, 26 Jul 2022 12:57:47 +0530 Subject: [PATCH] fix: (india) (e-invoice) margin & internal company transfer When the item price is more than the price list rate ( margin added ) discount value becomes negative. The previous attempt to solve this was to convert discount to absolute value. However, that gives incorrect unit price and discount value. To solve this, I have made changes to report net rates in cases where the margin is added or is an internal company transfer. --- erpnext/regional/india/e_invoice/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index bf304bc10dc..8e652bbb163 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -265,6 +265,10 @@ def get_overseas_address_details(address_name): def get_item_list(invoice): item_list = [] + hide_discount_in_einvoice = cint( + frappe.db.get_single_value("E Invoice Settings", "dont_show_discounts_in_e_invoice") + ) + for d in invoice.items: einvoice_item_schema = read_json("einv_item_template") item = frappe._dict({}) @@ -276,17 +280,12 @@ def get_item_list(invoice): item.qty = abs(item.qty) item_qty = item.qty - item.discount_amount = abs(item.discount_amount) item.taxable_value = abs(item.taxable_value) if invoice.get("is_return") or invoice.get("is_debit_note"): item_qty = item_qty or 1 - hide_discount_in_einvoice = cint( - frappe.db.get_single_value("E Invoice Settings", "dont_show_discounts_in_e_invoice") - ) - - if hide_discount_in_einvoice: + if hide_discount_in_einvoice or invoice.is_internal_customer or (item.discount_amount <= 0): item.unit_rate = item.taxable_value / item_qty item.gross_amount = item.taxable_value item.discount_amount = 0