mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 17:15:04 +00:00
fix: (india) (e-invoice) qty should not be changed to 1
Qty of 0 is allowed so can't change item.qty to 1 instead created item_qty and used it.
This commit is contained in:
@@ -273,39 +273,41 @@ def get_item_list(invoice):
|
|||||||
item.sr_no = d.idx
|
item.sr_no = d.idx
|
||||||
item.description = sanitize_for_json(d.item_name)
|
item.description = sanitize_for_json(d.item_name)
|
||||||
|
|
||||||
item.qty = abs(item.qty) or 1
|
item.qty = abs(item.qty)
|
||||||
|
item_qty = item.qty
|
||||||
|
|
||||||
item.discount_amount = abs(item.discount_amount)
|
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"):
|
||||||
|
item_qty = item_qty or 1
|
||||||
|
|
||||||
hide_discount_in_einvoice = cint(
|
hide_discount_in_einvoice = cint(
|
||||||
frappe.db.get_single_value("E Invoice Settings", "dont_show_discounts_in_e_invoice")
|
frappe.db.get_single_value("E Invoice Settings", "dont_show_discounts_in_e_invoice")
|
||||||
)
|
)
|
||||||
|
|
||||||
if hide_discount_in_einvoice:
|
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
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if invoice.get("apply_discount_on") and (abs(invoice.get("base_discount_amount") or 0.0) > 0.0):
|
if invoice.get("apply_discount_on") and (abs(invoice.get("base_discount_amount") or 0.0) > 0.0):
|
||||||
# TODO: need to handle case when tax included in basic rate is checked.
|
# TODO: need to handle case when tax included in basic rate is checked.
|
||||||
item.discount_amount = (item.discount_amount * item.qty) + (
|
item.discount_amount = (item.discount_amount * item_qty) + (
|
||||||
abs(item.base_amount) - abs(item.base_net_amount)
|
abs(item.base_amount) - abs(item.base_net_amount)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
item.discount_amount = item.discount_amount * item.qty
|
item.discount_amount = item.discount_amount * item_qty
|
||||||
|
|
||||||
if invoice.get("is_return") or invoice.get("is_debit_note"):
|
try:
|
||||||
item.unit_rate = (item.taxable_value + item.discount_amount) / item.qty
|
item.unit_rate = (item.taxable_value + item.discount_amount) / item_qty
|
||||||
else:
|
except ZeroDivisionError:
|
||||||
try:
|
# This will never run but added as safety measure
|
||||||
item.unit_rate = (item.taxable_value + item.discount_amount) / item.qty
|
frappe.throw(
|
||||||
except ZeroDivisionError:
|
title=_("Error: Qty is Zero"),
|
||||||
# This will never run but added as safety measure
|
msg=_("Quantity can't be zero unless it's Credit/Debit Note."),
|
||||||
frappe.throw(
|
)
|
||||||
title=_("Error: Qty is Zero"),
|
|
||||||
msg=_("Quantity can't be zero unless it's Credit/Debit Note."),
|
|
||||||
)
|
|
||||||
|
|
||||||
item.gross_amount = item.taxable_value + item.discount_amount
|
item.gross_amount = item.taxable_value + item.discount_amount
|
||||||
item.taxable_value = item.taxable_value
|
item.taxable_value = item.taxable_value
|
||||||
|
|||||||
Reference in New Issue
Block a user