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:
@@ -265,6 +265,10 @@ def get_overseas_address_details(address_name):
|
|||||||
def get_item_list(invoice):
|
def get_item_list(invoice):
|
||||||
item_list = []
|
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:
|
for d in invoice.items:
|
||||||
einvoice_item_schema = read_json("einv_item_template")
|
einvoice_item_schema = read_json("einv_item_template")
|
||||||
item = frappe._dict({})
|
item = frappe._dict({})
|
||||||
@@ -276,17 +280,12 @@ def get_item_list(invoice):
|
|||||||
item.qty = abs(item.qty)
|
item.qty = abs(item.qty)
|
||||||
item_qty = item.qty
|
item_qty = item.qty
|
||||||
|
|
||||||
item.discount_amount = abs(item.discount_amount)
|
|
||||||
item.taxable_value = abs(item.taxable_value)
|
item.taxable_value = abs(item.taxable_value)
|
||||||
|
|
||||||
if invoice.get("is_return") or invoice.get("is_debit_note"):
|
if invoice.get("is_return") or invoice.get("is_debit_note"):
|
||||||
item_qty = item_qty or 1
|
item_qty = item_qty or 1
|
||||||
|
|
||||||
hide_discount_in_einvoice = cint(
|
if hide_discount_in_einvoice or invoice.is_internal_customer or (item.discount_amount <= 0):
|
||||||
frappe.db.get_single_value("E Invoice Settings", "dont_show_discounts_in_e_invoice")
|
|
||||||
)
|
|
||||||
|
|
||||||
if hide_discount_in_einvoice:
|
|
||||||
item.unit_rate = item.taxable_value / item_qty
|
item.unit_rate = item.taxable_value / item_qty
|
||||||
item.gross_amount = item.taxable_value
|
item.gross_amount = item.taxable_value
|
||||||
item.discount_amount = 0
|
item.discount_amount = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user