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: validate advance amount in company currency #44693

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions erpnext/controllers/taxes_and_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,21 +786,11 @@ def calculate_total_advance(self):

self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))

grand_total = self.doc.rounded_total or self.doc.grand_total
grand_total = self.doc.base_rounded_total or self.doc.base_grand_total

if self.doc.party_account_currency == self.doc.currency:
invoice_total = flt(
grand_total - flt(self.doc.write_off_amount), self.doc.precision("grand_total")
)
else:
base_write_off_amount = flt(
flt(self.doc.write_off_amount) * self.doc.conversion_rate,
self.doc.precision("base_write_off_amount"),
)
invoice_total = (
flt(grand_total * self.doc.conversion_rate, self.doc.precision("grand_total"))
- base_write_off_amount
)
invoice_total = flt(
grand_total - flt(self.doc.base_write_off_amount), self.doc.precision("grand_total")
)

if invoice_total > 0 and self.doc.total_advance > invoice_total:
frappe.throw(
Expand Down
Loading