test: Update test case
This commit is contained in:
@@ -2626,15 +2626,15 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
# Normal Itemized Discount
|
||||
si = get_sales_invoice_for_e_invoice()
|
||||
si.apply_discount_on = ""
|
||||
si.items[0].discount_amount = 4000
|
||||
si.items[1].discount_amount = 300
|
||||
si.items[0].discount_amount = 2
|
||||
si.items[1].discount_amount = 5
|
||||
si.save()
|
||||
|
||||
einvoice = make_einvoice(si)
|
||||
validate_totals(einvoice)
|
||||
|
||||
self.assertEqual(einvoice["ItemList"][0]["Discount"], 4000)
|
||||
self.assertEqual(einvoice["ItemList"][1]["Discount"], 300)
|
||||
self.assertEqual(einvoice["ItemList"][1]["Discount"], 2100)
|
||||
self.assertEqual(einvoice["ValDtls"]["Discount"], 0)
|
||||
|
||||
# Invoice Discount on net total
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"section_break_2",
|
||||
"sandbox_mode",
|
||||
"applicable_from",
|
||||
"column_break_4",
|
||||
"dont_show_discounts_in_e_invoice",
|
||||
"section_break_7",
|
||||
"credentials",
|
||||
"advanced_settings_section",
|
||||
"client_id",
|
||||
@@ -80,12 +83,28 @@
|
||||
{
|
||||
"fieldname": "column_break_8",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "Enabling this will directly report net rates in e-Invoice post discounts",
|
||||
"fieldname": "dont_show_discounts_in_e_invoice",
|
||||
"fieldtype": "Check",
|
||||
"label": "Don't show discounts in e-Invoice"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break",
|
||||
"hide_border": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2021-11-16 19:50:28.029517",
|
||||
"modified": "2022-07-16 09:45:23.862046",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "E Invoice Settings",
|
||||
|
||||
@@ -273,7 +273,7 @@ def get_item_list(invoice):
|
||||
|
||||
item.qty = abs(item.qty)
|
||||
|
||||
if invoice.get("apply_discount_on") and (abs(invoice.get("base_discount_amount")) > 0.00):
|
||||
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.
|
||||
item.discount_amount = (item.discount_amount * item.qty) + (
|
||||
abs(item.base_amount) - abs(item.base_net_amount)
|
||||
|
||||
@@ -163,5 +163,12 @@ class TestItemPrice(FrappeTestCase):
|
||||
|
||||
self.assertEqual(price, 21)
|
||||
|
||||
def make_item_price(item_code, price_list, price_list_rate):
|
||||
item_price = frappe.new_doc("Item Price")
|
||||
item_price.price_list = price_list
|
||||
item_price.item_code = item_code
|
||||
item_price.price_list_rate = price_list_rate
|
||||
item_price.insert()
|
||||
return item_price
|
||||
|
||||
test_records = frappe.get_test_records("Item Price")
|
||||
|
||||
Reference in New Issue
Block a user