From fb7a785cdd65e2aa1d2cc8ac72da45dde804b9fc Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Mon, 9 Dec 2024 16:08:14 +0530 Subject: [PATCH 1/3] fix: taxable value for invoice without qty and value --- .../gst_india/overrides/transaction.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/india_compliance/gst_india/overrides/transaction.py b/india_compliance/gst_india/overrides/transaction.py index 6e953bddf..bdc75d0ae 100644 --- a/india_compliance/gst_india/overrides/transaction.py +++ b/india_compliance/gst_india/overrides/transaction.py @@ -69,6 +69,7 @@ def update_taxable_values(doc): total_charges = 0 apportioned_charges = 0 tax_witholding_amount = 0 + has_no_qty_value = False if doc.taxes: if any( @@ -100,8 +101,10 @@ def update_taxable_values(doc): # base net total may be zero if invoice has zero rated items + shipping total_value = doc.base_net_total if doc.base_net_total else doc.total_qty + # credit note without item qty and value but with charges if not total_value: - return + total_value = len(doc.items) + has_no_qty_value = True for item in doc.items: item.taxable_value = item.base_net_amount @@ -109,7 +112,12 @@ def update_taxable_values(doc): if not total_charges: continue - proportionate_value = item.base_net_amount if doc.base_net_total else item.qty + if has_no_qty_value: + proportionate_value = 1 + elif doc.base_net_total: + proportionate_value = item.base_net_amount + else: + proportionate_value = item.qty applicable_charges = flt( proportionate_value * (total_charges / total_value), @@ -498,7 +506,7 @@ def validate_for_charge_type(self): ) if row.charge_type == "On Previous Row Total": - previous_row_references.add(row.row_id) + previous_row_references.add(flt(row.row_id)) # validating charge type "On Item Quantity" and non_cess_advol_account self.validate_charge_type_for_cess_non_advol_accounts(row) From fbb6d2eb522f766fa5e70fb85106a0a5aa27aa1a Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Wed, 11 Dec 2024 22:47:02 +0530 Subject: [PATCH 2/3] test: added the test case --- .../gst_india/overrides/test_transaction.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index ed4912829..b4299d00e 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -466,6 +466,41 @@ def test_taxable_value_with_charges_after_tax(self): doc.insert() self.assertDocumentEqual({"taxable_value": 100}, doc.items[0]) + def test_credit_not_without_quantity(self): + if self.doctype != "Sales Invoice": + return + + doc = create_transaction( + **self.transaction_details, is_return=True, do_not_save=True + ) + append_item(doc) + + for item in doc.items: + item.qty = 0 + item.rate = 0 + item.price_list_rate = 0 + + # Adding charges + doc.append( + "taxes", + { + "charge_type": "Actual", + "account_head": "Freight and Forwarding Charges - _TIRC", + "description": "Freight", + "tax_amount": 20, + "cost_center": "Main - _TIRC", + }, + ) + + # Adding taxes + _append_taxes( + doc, ("CGST", "SGST"), charge_type="On Previous Row Total", row_id=1 + ) + doc.insert() + + for item in doc.items: + self.assertDocumentEqual({"taxable_value": 10}, item) + def test_validate_place_of_supply(self): doc = create_transaction(**self.transaction_details, do_not_save=True) doc.place_of_supply = "96-Others" From 159ed7573494dc0c89798b4eb16e68ce02b1b221 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 12 Dec 2024 17:44:45 +0530 Subject: [PATCH 3/3] test: additionally test gst details for credit note with zero value --- india_compliance/gst_india/overrides/test_transaction.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index b4299d00e..4493116b2 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -466,7 +466,7 @@ def test_taxable_value_with_charges_after_tax(self): doc.insert() self.assertDocumentEqual({"taxable_value": 100}, doc.items[0]) - def test_credit_not_without_quantity(self): + def test_credit_note_without_quantity(self): if self.doctype != "Sales Invoice": return @@ -498,8 +498,11 @@ def test_credit_not_without_quantity(self): ) doc.insert() + # Ensure correct taxable_value and gst details for item in doc.items: - self.assertDocumentEqual({"taxable_value": 10}, item) + self.assertDocumentEqual( + {"taxable_value": 10, "cgst_amount": 0.9, "sgst_amount": 0.9}, item + ) def test_validate_place_of_supply(self): doc = create_transaction(**self.transaction_details, do_not_save=True)