From 181df2fe632f2c5e71115982a0967e2295a422b4 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 4 Nov 2022 15:49:37 +0530 Subject: [PATCH] fix: Auto advance allocation against partial invoices --- erpnext/controllers/accounts_controller.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 22291a3544..5059f48cc1 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -804,15 +804,12 @@ class AccountsController(TransactionBase): self.set("advances", []) advance_allocated = 0 for d in res: - if d.against_order: - allocated_amount = flt(d.amount) + if self.get("party_account_currency") == self.company_currency: + amount = self.get("base_rounded_total") or self.base_grand_total else: - if self.get("party_account_currency") == self.company_currency: - amount = self.get("base_rounded_total") or self.base_grand_total - else: - amount = self.get("rounded_total") or self.grand_total + amount = self.get("rounded_total") or self.grand_total - allocated_amount = min(amount - advance_allocated, d.amount) + allocated_amount = min(amount - advance_allocated, d.amount) advance_allocated += flt(allocated_amount) advance_row = {