-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
fix: item wise tax details and net amounts #43372
Conversation
bab5d93
to
21d8234
Compare
This comment was marked as outdated.
This comment was marked as outdated.
d0947ad
to
158e1f5
Compare
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). |
158e1f5
to
6e7506e
Compare
783ceb4
to
5f66683
Compare
This restriction seems hard to enforce (or even communicate). We'll probably have to find a workaround. |
Indeed, I added a migration script yesterday (wasn't yet able to test). It's not reconstructing the missing value, because that is very difficult to accurately infer in all cases, but it conforms the structure and removes that limitation. |
Can you provide a simple example scenario with expected outcomes, along with
|
I've added a unit example of how the new datastructure can be worked with to the end of the PR description. The key is the addition of Several localization apps, even in-tree ones, have used brittle inference in the past to determine The change from a So to sum it up:
Maybe a word on brittleness:
|
Can confirm 😁 |
5f66683
to
ee8f9ff
Compare
ee8f9ff
to
3732dd1
Compare
@deprecated( | ||
"erpnext.controllers.taxes_and_totals.get_itemised_taxable_amount", | ||
"2024-11-07", | ||
"v17", | ||
"The field item_wise_tax_detail now already contains the net_amount per tax.", | ||
) | ||
def taxes_and_totals_get_itemised_taxable_amount(items): | ||
import frappe | ||
|
||
itemised_taxable_amount = frappe._dict() | ||
for item in items: | ||
item_code = item.item_code or item.item_name | ||
itemised_taxable_amount.setdefault(item_code, 0) | ||
itemised_taxable_amount[item_code] += item.net_amount | ||
|
||
return itemised_taxable_amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This proposal to deprecate has two goals:
- Prevent new usage of this method; nudging users to use the more reliable and stable means implemented by this PR
- Eventually remove the liability and cost to maintain these lines of codes
The main goal is point 1, therefore, we also can also set the graduation version beyond v17.
A good graduation point would be something that matches the natural rate of change and evolution of code within the ecosystem.
Given that current downstream users have made use of brittle work around for the previous limitations, it might be a good thing to prompt them to revisit this code within the span of roughly 1-2 years.
@ruthra-kumar even if we wouldn't be able to merge it right away, could we lock in an eventual agreement on the design principle, namely:
This would currently help a lot as ecosystem downstream work is conditioned (and currently halted) on these hypotheses. |
We can go ahead with this. As with most complex logic, edge cases will only come out the more it gets used. Will have to tackle it as and when those arise. |
Thanks @ruthra-kumar I've added a priority developer SLA pledge to the beginning of the PR description for the next two weeks. |
Developer SLA: my promise is to keep a close eye on this for two weeks after this merge and resolve any issues within 3 working days from the time of duly documented identification and notification
Companions / Fixes: (backporting dependencies)
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
Added "Net Amount" and "Base Net Amount" fields to:
Updated the
calculate_taxes_and_totals
class to incorporate the new net amount fields in tax calculations.Modified the
get_current_tax_amount
method toget_current_tax_and_net_amount
, now returning both net and tax amounts.Adjusted the item-wise tax calculation to include net amount information.
Key Updates
Impact
This change will provide users with more detailed tax information, allowing for:
Testing Recommendations
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.Data is now migrated via migration scriptcc/ @barredterra
Example interaction
Prior
Now