fix: return current_net_amount on get_current_tax_amount ovveride function on rounding#15
Conversation
…ction on rounding
📝 WalkthroughWalkthroughPackage version bumped to 0.1.5. JS tax calculation now computes a per-item Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Taxes as get_current_tax_amount
participant Boot as frappe.boot (versions)
participant ItemMap as item_tax_map / prior tax rows
Client->>Taxes: get_current_tax_amount(item, tax, item_tax_map)
Taxes->>Boot: read frappe.boot?.versions?.erpnext
Boot-->>Taxes: erpnext_version
Taxes->>ItemMap: consult item_tax_map / prior tax rows
ItemMap-->>Taxes: net amounts / previous tax amounts
Taxes-->>Client: return flt(current_tax_amount) OR [current_net_amount, flt(current_tax_amount)]
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
round_tax_amount_row_wise/public/js/taxes_and_totals_override.js (1)
45-47:⚠️ Potential issue | 🟡 MinorMissing
current_net_amountassignment for"On Item Quantity"charge type.All other charge types set
current_net_amount, but"On Item Quantity"does not, leaving it at0.0. If this is intentional, add a comment explaining why. Otherwise, determine the appropriate value (e.g.,item.qtyoritem.net_amount).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js` around lines 45 - 47, In the branch that checks tax.charge_type == "On Item Quantity" you set current_tax_amount but never assign current_net_amount, leaving it at 0.0; update that branch to set current_net_amount appropriately (e.g., current_net_amount = item.qty if the tax base is quantity, or current_net_amount = item.net_amount if it should use net value), and if the omission was intentional add a clarifying comment explaining why; reference the variables current_tax_amount, current_net_amount, tax.charge_type, item.qty and item.net_amount when making the change.
🧹 Nitpick comments (1)
round_tax_amount_row_wise/public/js/taxes_and_totals_override.js (1)
52-52: Remove commented-out code.Dead code should be removed to keep the codebase clean.
- // return [current_net_amount, flt(current_tax_amount, precision("tax_amount", tax))];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js` at line 52, Remove the dead commented-out return statement inside the tax calculation block (the commented line containing "return [current_net_amount, flt(current_tax_amount, precision("tax_amount", tax))];"); locate the code by looking for variables/functions current_net_amount, current_tax_amount, precision(...) and tax within taxes_and_totals_override.js and delete that commented line so only active code remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js`:
- Around line 27-29: The "On Net Total" branch leaves current_net_amount as 0.0
when tax.account_head is not present in item_tax_map; change it to always set
current_net_amount = item.net_amount (same as the "Actual" branch) so the value
isn't accidentally left zero—update the code that checks
tax.account_head/item_tax_map in the "On Net Total" handling to assign
item.net_amount unconditionally to current_net_amount (referencing
current_net_amount, tax.account_head, item_tax_map, and item.net_amount).
- Line 85: Remove the trailing whitespace in
public/js/taxes_and_totals_override.js (the stray space at the end of the
affected line) so the pre-commit hook/CI no longer fails; edit the file and
delete any space or tab characters at the end of that line, save, and re-run the
pre-commit checks.
- Around line 53-60: Update the client-side version check to use "16.0.0"
instead of "15.10.1" in the is_version_greater_or_equal call so the new tuple
return format is only expected for ERPNext v16+. Then update the server-side
Python override get_current_tax_amount() to return a (net_amount, tax_amount)
tuple when running on ERPNext >= 16.0.0 (or add a compatibility wrapper that
returns the tuple to match the client), ensuring both client-side
is_version_greater_or_equal and server-side get_current_tax_amount() produce the
same shape for v16+ and preserve the original single numeric return for older
versions.
---
Outside diff comments:
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js`:
- Around line 45-47: In the branch that checks tax.charge_type == "On Item
Quantity" you set current_tax_amount but never assign current_net_amount,
leaving it at 0.0; update that branch to set current_net_amount appropriately
(e.g., current_net_amount = item.qty if the tax base is quantity, or
current_net_amount = item.net_amount if it should use net value), and if the
omission was intentional add a clarifying comment explaining why; reference the
variables current_tax_amount, current_net_amount, tax.charge_type, item.qty and
item.net_amount when making the change.
---
Nitpick comments:
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js`:
- Line 52: Remove the dead commented-out return statement inside the tax
calculation block (the commented line containing "return [current_net_amount,
flt(current_tax_amount, precision("tax_amount", tax))];"); locate the code by
looking for variables/functions current_net_amount, current_tax_amount,
precision(...) and tax within taxes_and_totals_override.js and delete that
commented line so only active code remains.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c2eee689-269f-4fd6-b816-698ac1092089
📒 Files selected for processing (2)
round_tax_amount_row_wise/__init__.pyround_tax_amount_row_wise/public/js/taxes_and_totals_override.js
| if (tax.account_head in item_tax_map) { | ||
| current_net_amount = item.net_amount | ||
| }; |
There was a problem hiding this comment.
current_net_amount not set when tax.account_head is not in item_tax_map.
Unlike the "Actual" charge type (line 20) which unconditionally sets current_net_amount = item.net_amount, the "On Net Total" branch only sets it when the tax account head exists in item_tax_map. If the condition is false, current_net_amount remains 0.0, which may produce incorrect results when returned.
Is this intentional? If not, consider setting current_net_amount = item.net_amount unconditionally for this charge type as well.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js` around
lines 27 - 29, The "On Net Total" branch leaves current_net_amount as 0.0 when
tax.account_head is not present in item_tax_map; change it to always set
current_net_amount = item.net_amount (same as the "Actual" branch) so the value
isn't accidentally left zero—update the code that checks
tax.account_head/item_tax_map in the "On Net Total" handling to assign
item.net_amount unconditionally to current_net_amount (referencing
current_net_amount, tax.account_head, item_tax_map, and item.net_amount).
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b1a49706-9623-4e6f-a911-2e699a28ab01
📒 Files selected for processing (1)
round_tax_amount_row_wise/public/js/taxes_and_totals_override.js
| const erpnext_version = frappe.boot?.versions?.erpnext; | ||
| // Ensure that the version checked is formatted as semantic version strings | ||
| if (is_version_greater_or_equal(erpnext_version, "15.10.1")){ | ||
| return [current_net_amount, flt(current_tax_amount, precision("tax_amount", tax))]; | ||
|
|
||
| }else { | ||
| return flt(current_tax_amount, precision("tax_amount", tax)) | ||
| } |
There was a problem hiding this comment.
❓ Verification inconclusive
Script executed:
# First, let's examine the file in question
cat -n round_tax_amount_row_wise/public/js/taxes_and_totals_override.js | sed -n '50,65p'Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Exit code: 0
stdout:
50 this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount);
51 }
52 // return [current_net_amount, flt(current_tax_amount, precision("tax_amount", tax))];
53 const erpnext_version = frappe.boot?.versions?.erpnext;
54 // Ensure that the version checked is formatted as semantic version strings
55 if (is_version_greater_or_equal(erpnext_version, "15.10.1")){
56 return [current_net_amount, flt(current_tax_amount, precision("tax_amount", tax))];
57
58 }else {
59 return flt(current_tax_amount, precision("tax_amount", tax))
60 }
61
62 };
63
64
65 erpnext.taxes_and_totals.prototype.set_item_wise_tax = function (item, tax, tax_rate, current_tax_amount) {
Script executed:
# Also check the helper function at lines 86-110
cat -n round_tax_amount_row_wise/public/js/taxes_and_totals_override.js | sed -n '80,115p'Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Exit code: 0
stdout:
80 )
81
82 tax_detail[key] = [tax_rate, flt(item_wise_tax_amount, precision("base_tax_amount", tax))];
83 };
84 }
85
86 function is_version_greater_or_equal(current, target) {
87 if (!current) return false;
88
89 // If current is an object (some older Frappe configs stored it as object)
90 if (typeof current === "object" && current.version) {
91 current = current.version;
92 }
93
94 // Clean beta/alpha suffix e.g "15.10.1-beta" -> "15.10.1"
95 current = String(current).split("-")[0];
96 target = String(target).split("-")[0];
97
98 const c = current.split(".").map(Number);
99 const t = target.split(".").map(Number);
100
101 for (let i = 0; i < Math.max(c.length, t.length); i++) {
102 const cv = c[i] || 0;
103 const tv = t[i] || 0;
104
105 if (cv > tv) return true;
106 if (cv < tv) return false;
107 }
108
109 return true; // equal
110 }
ERPNext JavaScript API get_current_tax_amount tuple return version history
There is no public ERPNext JavaScript API function named get_current_tax_amount that returns a tuple. The function get_current_tax_amount appears in Python server-side code in erpnext/controllers/taxes_and_totals.py within the calculate_taxes_and_totals class, used for tax calculations during document processing (e.g., Sales Invoice, Purchase Invoice). In recent versions (develop branch as of 2026), it has been renamed to get_current_tax_and_net_amount, which returns two values: current_net_amount, current_tax_amount. This change was part of PR #43372 (merged Nov 2024), adding net amount tracking to item-wise tax details. Previously, related functions like get_current_tax_fraction returned tuples (current_tax_fraction, inclusive_tax_amount_per_qty). Client-side JavaScript tax calculations are handled in erpnext/public/js/controllers/taxes_and_totals.js (confirmed via code snippets and forum discussions), with methods like calculate_taxes_and_totals, calculate_taxes, but no get_current_tax_amount or tuple-returning equivalent exposed as a public API. Custom client scripts (frappe.ui.form.on) can access tax data via frm.doc.taxes but must compute amounts manually. No official documentation or version changelog explicitly documents a JS API with this name. For client-side tax access in custom scripts, parse frm.doc.taxes or item_wise_tax_detail JSON fields.
Citations:
- 1: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 2: fix: item wise tax details and net amounts frappe/erpnext#43372
- 3: https://gist.github.com/jvfiel/0e68af59fc7e8b80da71305aa5cac521
- 4: https://www.infoney.tech
- 5: https://discuss.frappe.io/t/change-fuctionality-of-taxes-and-totals-js/11545
ERPNext v15.10.1 calculate_taxes get_current_tax_amount contract
In ERPNext v15.10.1, the calculate_taxes method in the calculate_taxes_and_totals class (erpnext/controllers/taxes_and_totals.py) handles tax calculations for documents like Sales Invoices, Purchase Invoices, and those generated from Contracts (e.g., recurring invoices). The method iterates over items and taxes, calling self.get_current_tax_and_net_amount(item, tax, item_tax_map) to compute current_net_amount and current_tax_amount for each tax row and item combination. These represent the net amount base and tax amount for the current calculation step, depending on the tax charge_type (e.g., "On Net Total", "On Previous Row Amount", "Actual"). Previously, there was a get_current_tax_amount method, but it was updated to get_current_tax_and_net_amount to also return net amounts (as part of PR #43372 for improved item-wise tax details and UBL2.1 compatibility). This change enhances tax breakdown accuracy, including per-item net amounts in item_wise_tax_detail. Contracts link to Sales/Purchase Invoices, which inherit this standard tax calculation logic via AccountsController and taxes_and_totals.py. No Contract-specific overrides for these methods were found. v15.10.1 uses this updated logic, as develop branch reflects v15 changes post-2024 updates.
Citations:
- 1: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 2: fix: item wise tax details and net amounts frappe/erpnext#43372
- 3: Net amount calculated incorrectly frappe/erpnext#44219
- 4: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/selling_controller.py
- 5: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/buying_controller.py
ERPNext JavaScript calculate_taxes get_current_tax_amount return value version
The get_current_tax_amount function is a JavaScript method in ERPNext's taxes_and_totals.js file (erpnext/public/js/controllers/taxes_and_totals.js), used within the calculate_taxes method of the erpnext.taxes_and_totals controller. It calculates the tax amount for a specific item and tax row during client-side tax computation in documents like Sales Invoice. It takes three parameters: - item: The current item row object - tax: The current tax row object - item_tax_map: Object mapping tax account heads to rates from the item's tax template The function returns a single float value: current_tax_amount, which is the computed tax amount for that item-tax combination, rounded to the tax's tax_amount precision using flt(current_tax_amount, precision("tax_amount", tax)). This value is used to: 1. Accumulate into tax.tax_amount across all items 2. Populate item-wise tax details via set_item_wise_tax(item, tax, tax_rate, current_tax_amount) The computation logic branches by tax.charge_type: - "Actual": Proportional distribution: (item.net_amount / doc.net_total) * tax.tax_amount - "On Net Total": (tax_rate / 100.0) * item.net_amount - "On Previous Row Amount": (tax_rate / 100.0) * doc.taxes[cint(tax.row_id) - 1].tax_amount - "On Previous Row Total": (tax_rate / 100.0) * doc.taxes[cint(tax.row_id) - 1].grand_total_for_current_item - "On Item Quantity": (tax_rate / 100.0) * item_amount / item.qty (truncated in source) Source code from ~v13-v15 (gist 2017, GitLab v15.10.0). In v16 (current as of 2026-04-05, releases up to v16.11.0), tax calculation moved primarily server-side to Python erpnext/controllers/taxes_and_totals.py with get_current_tax_and_net_amount returning tuple (current_net_amount, current_tax_amount). Client-side JS likely simplified or deprecated for real-time preview, but function name matches older authoritative client-side implementation.
Citations:
- 1: https://gist.github.com/jvfiel/0e68af59fc7e8b80da71305aa5cac521
- 2: https://gitlab.roduq.pl/roduq/erpnext/-/blob/v15.10.0/erpnext/public/js/controllers/taxes_and_totals.js?ref_type=tags
- 3: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 4: https://github.com/frappe/erpnext/releases/tag/v16.0.0
- 5: https://github.com/frappe/erpnext/releases/tag/v16.11.0
- 6: https://github.com/frappe/erpnext/releases/tag/v16.5.0
- 7: https://github.com/frappe/erpnext/releases/tag/v16.8.0
- 8: https://github.com/frappe/erpnext/releases/tag/v16.4.0
- 9: fix: item wise tax details and net amounts frappe/erpnext#43372
ERPNext v15.10.0 v15.10.1 v15.11.0 taxes_and_totals.js calculate_taxes JavaScript
The file taxes_and_totals.js in ERPNext v15 (including versions around v15.10.0, v15.10.1, v15.11.0) is located at erpnext/public/js/controllers/taxes_and_totals.js. It contains JavaScript methods for client-side tax and totals calculation in transaction forms like Sales Invoice, Purchase Invoice, etc. A mirror of v15.10.0 is available at https://gitlab.roduq.pl/roduq/erpnext/-/blob/v15.10.0/erpnext/public/js/controllers/taxes_and_totals.js, which includes functions like calculate_commission for sales documents. The primary function for taxes is likely calculate_taxes_and_totals, which can be overridden via monkey patching in custom apps, as discussed in Frappe forums for v15. This JS file works alongside the Python backend in erpnext/controllers/taxes_and_totals.py, which has a calculate_taxes method that processes tax rows based on charge_type (Actual, On Net Total, On Previous Row Amount, etc.), item tax maps, and inclusive taxes. No specific changes or diffs were found between v15.10.0, v15.10.1, and v15.11.0 regarding calculate_taxes in the JS file; ERPNext v15 uses continuous versioning (e.g., v15.10.x as minor updates within the v15 branch). The official GitHub repo uses 'version-15' branch for stable v15 code, with tags like v15.103.1 as of 2026. For overriding: Extend via custom JS file with frappe.ui.form.on('Sales Invoice', { taxes_and_totals_update: function(frm) { ... } }) or monkey patch the class.
Citations:
- 1: https://gitlab.roduq.pl/roduq/erpnext/-/blob/v15.10.0/erpnext/public/js/controllers/taxes_and_totals.js?ref_type=tags
- 2: https://discuss.frappe.io/t/calculate-taxes-and-totals-override-not-working-in-background-jobs-on-frappe-cloud/159897
- 3: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 4: https://discuss.frappe.io/t/how-to-extend-and-override-core-functionality-like-taxes-and-totals/132531
- 5: https://github.com/frappe/erpnext/tags
- 6: https://github.com/frappe/erpnext/tree/version-15
ERPNext PR when did JavaScript calculate_taxes expect tuple array return from get_current_tax_amount
The JavaScript function get_current_tax_amount in ERPNext's taxes_and_totals.js (used in calculate_taxes) originally returned a single value (current_tax_amount). This changed to return a tuple/array [current_net_amount, current_tax_amount] to match backend changes in PR #43372 (merged September 2024), which renamed it to get_current_tax_and_net_amount in Python taxes_and_totals.py to support net amount tracking in item-wise tax details for better financial accuracy and UBL2.1 compatibility. The frontend update ensures calculate_taxes unpacks the array correctly: current_net_amount, current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map). This aligns JS tax calculations with Python backend for consistency in Sales Invoice/Purchase Invoice tax computations.
Citations:
- 1: fix: item wise tax details and net amounts frappe/erpnext#43372
- 2: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 3: https://gist.github.com/jvfiel/0e68af59fc7e8b80da71305aa5cac521
ERPNext v16.0.0 release JavaScript get_current_tax_amount tuple array PR 43372
ERPNext v16.0.0 was released on January 12, 2026. PR #43372 (merged November 14, 2024) fixed item-wise tax details and net amounts in tax calculations, enhancing the item_wise_tax_detail JSON structure to include net_amount alongside tax_rate and tax_amount (previously a tuple of two values, now a dict or extended tuple array with three values: [tax_rate, tax_amount, net_amount]). The JavaScript function get_current_tax_amount exists in erpnext/public/js/controllers/taxes_and_totals.js (confirmed in v15.10.0 and earlier snippets; present in v16 as tax logic is client-side mirrored from Python controllers.taxes_and_totals.py). It computes the tax amount for a specific item and tax row based on charge_type (Actual, On Net Total, On Previous Row Amount, On Item Quantity), using item_tax_map from item.item_tax_rate (JSON). In v16, with PR #43372 and later #48692 (Item Wise Tax Details as child table), the function supports the updated structure but primarily handles calculation/display before server-side persistence to the new Item Wise Tax Detail child table via _item_wise_tax_details buffer. Example pre-PR tuple access: rate, amount = tax_data[item_code] Post-PR: rate, amount, net_amount = tax_data[item_code] (dict-style access recommended).
Citations:
- 1: https://github.com/frappe/erpnext/releases/tag/v16.0.0
- 2: https://github.com/frappe/erpnext/releases/tag/v16.8.0
- 3: fix: item wise tax details and net amounts frappe/erpnext#43372
- 4: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 5: https://gitlab.roduq.pl/roduq/erpnext/-/blob/v15.10.0/erpnext/public/js/controllers/taxes_and_totals.js?ref_type=tags
- 6: https://github.com/frappe/erpnext/wiki/Item-Wise-Tax-Details:-JSON-%E2%86%92-Child-Table
- 7: feat!: Item Wise Tax Details Table frappe/erpnext#48692
- 8: https://gist.github.com/jvfiel/0e68af59fc7e8b80da71305aa5cac521
ERPNext version-15 branch v15.12.0 v15.13.0 get_current_tax_amount scalar tuple
In ERPNext version 15 branch, specifically around tags v15.12.0 and v15.13.0, the function related to "get_current_tax_amount" is get_current_tax_and_net_amount in erpnext/controllers/taxes_and_totals.py. This method returns a tuple containing the current net amount and tax amount (current_net_amount, current_tax_amount) for tax calculations in documents like Sales Invoice and Purchase Invoice. This function computes the tax amount for the current tax row based on the item's net amount, tax rate from item_tax_map, and tax charge type. It is called within the calculate_taxes method: current_net_amount, current_tax_amount = self.get_current_tax_and_net_amount(item, tax, item_tax_map) The return is a tuple (scalar values for net and tax amounts), not a single scalar. No direct "get_current_tax_amount" function exists; it was likely renamed or refactored in PR #43372 (fix: item wise tax details and net amounts), which changed it to return both values as a tuple for better item-wise tax detail handling, including net_amount in item_wise_tax_detail JSON. No specific changes to this function appear in v15.12.0 or v15.13.0 release notes; the core logic remains consistent across v15 releases. For exact code diff between v15.12.0 and v15.13.0, check GitHub tags, but the function signature and tuple return predate these minor releases.
Citations:
- 1: https://github.com/frappe/erpnext/blob/develop/erpnext/controllers/taxes_and_totals.py
- 2: Net amount calculated incorrectly frappe/erpnext#44219
- 3: Inconsistent Rounding Between "Total Taxes and Charges" and "Item Tax Breakdown" in Sales Invoice frappe/erpnext#43143
- 4: Tax-inclusive pricing: tax amount is wrong due to double rounding frappe/erpnext#52236
- 5: https://github.com/frappe/erpnext/blob/develop/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
- 6: fix: item wise tax details and net amounts frappe/erpnext#43372
The version cutoff 15.10.1 is incorrect for the tuple return shape.
ERPNext v15.10.1 still returns a scalar float from get_current_tax_amount(), not the [current_net_amount, current_tax_amount] tuple. Using >= 15.10.1 will return the wrong shape for v15.10.x installations and corrupt tax calculations. The tuple contract was introduced in a later v15 minor release (after v15.10.1); verify the exact ERPNext version that introduced the tuple return before setting this boundary.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js`:
- Around line 27-34: The inclusive-tax branch computes a derived net_amount but
leaves current_net_amount as item.net_amount, causing mismatch; in the block
guarded by tax.included_in_print_rate set current_net_amount to the derived
net_amount (the local variable net_amount computed from item.amount and
tax_rate) so that current_tax_amount and the returned/accumulated
current_net_amount are consistent (alternatively, replace the inclusive
calculation with current_tax_amount = (tax_rate / 100.0) * item.net_amount if
you prefer the upstream formula), updating the logic around
tax.included_in_print_rate, current_net_amount, current_tax_amount, net_amount,
item.amount and item.net_amount.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0fce0716-89fb-4e41-9d86-b570e4cb7b1f
📒 Files selected for processing (1)
round_tax_amount_row_wise/public/js/taxes_and_totals_override.js
| if (tax.account_head in item_tax_map) { | ||
| current_net_amount = item.net_amount | ||
| }; | ||
| if (tax.included_in_print_rate){ | ||
| var net_amount = item.amount / (1 + tax_rate / 100.0) | ||
| current_tax_amount = item.amount - net_amount | ||
| }else { | ||
| current_tax_amount = (tax_rate / 100.0) * item.net_amount; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n round_tax_amount_row_wise/public/js/taxes_and_totals_override.js | head -60Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Length of output: 3052
🏁 Script executed:
fd -t f "taxes_and_totals_override.js" -x wc -l {}Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Length of output: 152
🏁 Script executed:
curl -s "https://raw.githubusercontent.com/frappe/erpnext/v15.101.0/erpnext/public/js/controllers/taxes_and_totals.js" | head -200Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Length of output: 6771
🏁 Script executed:
curl -s "https://raw.githubusercontent.com/frappe/erpnext/v15.101.0/erpnext/public/js/controllers/taxes_and_totals.js" | grep -A 50 "get_current_tax_amount"Repository: ruknsoftware/Round-Tax-Amount-Row-wise
Length of output: 4066
Fix the net amount returned for inclusive taxes.
When tax.included_in_print_rate is true (lines 30–32), you calculate current_tax_amount from a derived net_amount, but return current_net_amount as item.net_amount. On ERPNext v15.101+, the caller accumulates tax.net_amount += current_net_amount;, so reporting a different base than the one used to calculate the tax causes a mismatch. With multiple inclusive-tax rows, the sum of reported net amounts won't reflect the sum of the actual bases used for each tax calculation. Either return the derived net_amount as current_net_amount in the inclusive branch, or use the upstream formula current_tax_amount = (tax_rate / 100.0) * item.net_amount for v15.101+ compatibility.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@round_tax_amount_row_wise/public/js/taxes_and_totals_override.js` around
lines 27 - 34, The inclusive-tax branch computes a derived net_amount but leaves
current_net_amount as item.net_amount, causing mismatch; in the block guarded by
tax.included_in_print_rate set current_net_amount to the derived net_amount (the
local variable net_amount computed from item.amount and tax_rate) so that
current_tax_amount and the returned/accumulated current_net_amount are
consistent (alternatively, replace the inclusive calculation with
current_tax_amount = (tax_rate / 100.0) * item.net_amount if you prefer the
upstream formula), updating the logic around tax.included_in_print_rate,
current_net_amount, current_tax_amount, net_amount, item.amount and
item.net_amount.
https://tasko.rukn.sh/tasko/task/TASK-2026-00354
frappe/erpnext@717c5b2
#14
Summary by CodeRabbit
Chores
Bug Fixes