Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: item wise tax details and net amounts #43372

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

blaggacao
Copy link
Collaborator

@blaggacao blaggacao commented Sep 24, 2024

  • feat: Add net_total to Taxes And Charges doctypes and modify relevant controllers
  • test: add test for item tax detail

Net Amount Field Addition for Tax Doctype

This pull request introduces a new "Net Amount" field to various tax-related doctypes in ERPNext, enhancing the granularity of tax calculations and reporting.

Changes Overview

  1. Added "Net Amount" and "Base Net Amount" fields to:

  2. Updated the calculate_taxes_and_totals class to incorporate the new net amount fields in tax calculations.

  3. Modified the get_current_tax_amount method to get_current_tax_and_net_amount, now returning both net and tax amounts.

  4. Adjusted the item-wise tax calculation to include net amount information.

Key Updates

  • New Fields: "Net Amount" and "Base Net Amount" added to tax doctypes for more detailed financial tracking[1].
  • Calculation Logic: Updated to handle net amounts separately from tax amounts, providing more accurate tax breakdowns[1].
  • Item-wise Tax Details: Now includes net amount information, offering a more comprehensive view of tax application per item[1].

Impact

This change will provide users with more detailed tax information, allowing for:

  • Better tracking of net amounts before tax application
  • More accurate reporting of tax breakdowns
  • Enhanced visibility into tax calculations at the item level

Testing Recommendations

  • Verify that net amounts are correctly calculated and displayed in all relevant doctypes
  • Ensure that existing tax calculations remain accurate with the introduction of the new fields
  • Test various tax scenarios to confirm the correct interaction between net amounts and tax amounts

This update significantly improves the granularity and accuracy of tax-related information in ERPNext, providing users with more detailed financial insights. Additionally, it enhances compatibility with UBL2.1 (Universal Business Language) electronic documents, allowing for more precise representation of net amounts and tax calculations in standardized e-invoicing formats. This improvement facilitates better interoperability with various e-invoicing systems and ensures compliance with digital reporting requirements in jurisdictions that mandate UBL2.1 format for electronic invoices.

Migration Recommendations

  • DO NOT migrate while you have a POS Invoice Merge pending: the change in json datastructure will be incompatible. Make sure to migrate after a completed merge to only merge invoices with compatible data structures.

cc/ @barredterra

@blaggacao
Copy link
Collaborator Author

blaggacao commented Sep 26, 2024

In order for this to be merge-able with confidence for migration purposes, we first need a calculate_taxes_and_totals controller who is able to recalculate taxes with a guarantee to not create inconsistent data or data which violates prior (legally settled) state. We need a controller which enough flexibility to:

  • add the new amounts to existing data
  • provides a dry-run mode for validation before committing changes
  • offers detailed logging for audit and troubleshooting purposes

There is currently no reasonable way (I tried to find one for 2 hours, already) to recalculate item-wise net amounts into the item_wise_tax_detail with the current controller. However, any existing json datastructure is incompatible with merge_tax, which might be triggered on old data but post migration.

@blaggacao blaggacao force-pushed the feat/log-net-total-on-taxes-and-charges branch from d0947ad to 158e1f5 Compare September 29, 2024 14:57
@barredterra
Copy link
Collaborator

This is also a requirement for the UN/CEFACT Cross Industry Invoice, not only UBL.

Btw, the India Compliance app already calculates net amounts per Item (in case that is helpful here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants