-
Notifications
You must be signed in to change notification settings - Fork 11.1k
fix: adjust outstanding amount calculation in purchase and sales registers #54597
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,17 +141,31 @@ def _execute(filters, additional_table_columns=None): | |
|
|
||
| # total tax, grand total, outstanding amount & rounded total | ||
|
|
||
| outstanding_precision = ( | ||
| get_field_precision( | ||
| frappe.get_meta("Sales Invoice").get_field("outstanding_amount"), | ||
| currency=company_currency, | ||
| ) | ||
| or 2 | ||
| ) | ||
| row.update( | ||
| { | ||
| "tax_total": total_tax, | ||
| "grand_total": inv.base_grand_total, | ||
| "rounded_total": inv.base_rounded_total, | ||
| "outstanding_amount": inv.outstanding_amount, | ||
| } | ||
| ) | ||
|
|
||
| if inv.doctype == "Sales Invoice": | ||
| row.update({"debit": inv.base_grand_total, "credit": 0.0}) | ||
| row.update( | ||
| { | ||
| "debit": inv.base_grand_total, | ||
| "credit": 0.0, | ||
| "outstanding_amount": flt( | ||
| (inv.outstanding_amount * (inv.conversion_rate or 1)), outstanding_precision | ||
| ), | ||
| } | ||
| ) | ||
|
Comment on lines
+160
to
+168
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add regression tests for multi-currency outstanding conversion in Sales Register. This changes financial output semantics ( If useful, I can draft a focused test matrix and expected values for these scenarios. 🤖 Prompt for AI Agents |
||
| else: | ||
| row.update({"debit": 0.0, "credit": inv.base_grand_total}) | ||
| data.append(row) | ||
|
|
@@ -437,6 +451,7 @@ def get_invoices(filters, additional_query_columns): | |
| si.is_internal_customer, | ||
| si.represents_company, | ||
| si.company, | ||
| si.conversion_rate, | ||
| ) | ||
| .where(si.docstatus == 1) | ||
| ) | ||
|
|
||
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.
Please add regression tests for Purchase Register outstanding conversion.
Line 150-Line 152 changes monetary behavior (conversion + rounding). Add coverage for foreign-currency invoices and precision expectations to prevent regressions.
I can help draft concrete fixtures/assertions if you want.
🤖 Prompt for AI Agents