Skip to content

Commit

Permalink
Merge pull request #2830 from vorasmit/no-qty-value
Browse files Browse the repository at this point in the history
fix: taxable value for invoice without qty and value
  • Loading branch information
vorasmit authored Dec 12, 2024
2 parents 8127f0b + 159ed75 commit 231650e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
38 changes: 38 additions & 0 deletions india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,44 @@ def test_taxable_value_with_charges_after_tax(self):
doc.insert()
self.assertDocumentEqual({"taxable_value": 100}, doc.items[0])

def test_credit_note_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()

# Ensure correct taxable_value and gst details
for item in doc.items:
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)
doc.place_of_supply = "96-Others"
Expand Down
14 changes: 11 additions & 3 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -100,16 +101,23 @@ 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

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),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 231650e

Please sign in to comment.