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.
This commit is contained in:
Maharshi Patel
2022-07-26 12:57:47 +05:30
parent bc7cfe6919
commit b97d30aad0

View File

@@ -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