Repository navigation
fix: multiple rounding issue (backport #4953) - #4987
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -6 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
| return flt( | ||
| amount * base_allocated_amount / base_amount, | ||
| get_field_precision(frappe.get_meta("Advance Taxes and Charges").get_field("base_tax_amount")), | ||
| ) |
There was a problem hiding this comment.
Advance GST stays partly unreversed
If currency_precision is unset and currency-specific number formats are enabled, get_proportionate_tax chooses precision without the payment document or company currency. This can use the site's decimal count instead of the company's, while ERPNext rounds ledger amounts to the company currency.
For an INR company with two decimals on a site with three, separately allocating ₹33.30, ₹33.30, and ₹933.40 against a ₹1,000 advance with ₹180 GST calculates reversal shares of ₹5.994, ₹5.994, and ₹168.012. Ledger rounding reduces those to ₹5.99, ₹5.99, and ₹168.01, reversing only ₹179.99. The final allocation enters balance_taxes, but subtracts the earlier three-decimal shares rather than their rounded ledger amounts, so it cannot recover the missing paisa.
Use company-currency precision for proportional calculations and final balancing, and cover separate allocations with different site and currency formats in a regression test. This financial accuracy issue must be fixed before merging.
Artifacts
Complete executable GST precision check
- The authored script extracts and executes real base/head functions and snapshot/version-16 contracts with explicit service stubs, making the focused reproduction inspectable.
Base execution with full GST reversal
- Executed the three separate allocations against base with both contract sets and captured all extracted source and output, showing ₹180.00 reversed with no residual.
Head execution with one paisa left unreversed
- Executed the identical allocations against head with both contract sets and captured the final balancing and GL rounding output, showing ₹179.99 reversed and ₹0.01 remaining.
This is an automatic backport of pull request #4953 done by [Mergify](https://mergify.com).