fix: tax net_amount and not_applicable#54687
fix: tax net_amount and not_applicable#54687barredterra wants to merge 5 commits intofrappe:version-15-hotfixfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughAdds read-only currency fields 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Review notes
Skipping
Residual risk is mostly custom code that assumed every item key exists on every tax row or treated Semantics of In That’s consistent with existing total logic but it’s easy to misread when summing rows or building new reports. |
Summary
Brings two related v16 behaviors to v15:
net_amount/base_net_amounton Sales / Purchase / Advance Taxes and Charges so each tax row records the taxable basis that contributed to it. The JS controller already aggregated this (fix(account): compute tax net_amount in JS controller #52630, backported as6ad84d6and516ad90); the doctype field and Python-side mirror were missing.0%in a template still inflates that tax row's Net Amount with the item's net.Why
Templates that enumerate every regional tax with
0%for the inapplicable ones (e.g. a "VAT 7% Only" template that listsVAT 19%: 0) cause the wrong tax-row Net Amounts when items with mixed templates appear on the same invoice. The 0% rate is ambiguous — could mean "exempt" or "applies but at zero" — and v15 currently treats it as the latter unconditionally.Reproducer (from #50898)
Two templates: A =
VAT 7% @ 7,VAT 19% @ 0 (Not Applicable); B =VAT 7% @ 0 (Not Applicable),VAT 19% @ 19. Sales Invoice with one item per template, both at rate 100.net_amountChanges
New schema fields:
Sales Taxes and Charges,Purchase Taxes and Charges,Advance Taxes and Charges:net_amount,base_net_amount(Currency, read-only)Item Tax Template Detail:not_applicable(Check, withread_only_depends_onontax_rate)Server (
erpnext/controllers/taxes_and_totals.py):get_current_tax_and_net_amount()returning(net, tax). Oldget_current_tax_amount()kept as a thin shim for external callers.tax.net_amountaccumulated incalculate_taxes; included in_set_in_company_currencyand theinitialize_taxesreset list._get_tax_rate,get_current_tax_fraction,get_current_tax_and_net_amountshort-circuit when the rate is theNOT_APPLICABLE_TAXsentinel.Sentinel propagation:
erpnext/stock/get_item_details.py: exposesNOT_APPLICABLE_TAX = "N/A";get_item_tax_mapemits the sentinel fornot_applicablerows.erpnext/controllers/accounts_controller.py:add_taxes_from_tax_templateskips not-applicable rows.Client (
erpnext/public/js/controllers/taxes_and_totals.js):_get_tax_rate,get_current_tax_fraction,get_current_tax_amount,add_taxes_from_item_tax_template).Item Tax Template UX:
tax_rate = 0(UI handler + servervalidate).Intentional non-changes
item_wise_tax_detailkeeps the v15[rate, amount]list shape — the v16 dict refactor (fix: item wise tax details and net amounts #43372 / feat!: Item Wise Tax Details Table #48692) and its migration patch are not backported. Out of scope for the basis-amount fix and would ripple intopos_invoice_merge_log,item_wise_sales_register,regional/italy/utils.py, andvat_audit_report.buying_controller.get_item_tax_amountandtransaction_base.add_taxes_from_item_templatedon't exist in v15 — nothing to plumb there.net_amount = 0until the parent doc is re-saved. If regulatory reports rely on this field for historical data, a one-shot replay can be added.Test plan
Summary by CodeRabbit
New Features
Improvements