fix(purchase-invoice): Update paid amount on creation of debit note (#18830)
* fix(purchase-invoice): set paid amount for purchase return * fix(purchase-invoice): remove payment schedule on creation of debit note
This commit is contained in:
committed by
Nabin Hait
parent
bb736248a2
commit
7bcb24efbf
@@ -89,7 +89,7 @@ class AccountsController(TransactionBase):
|
||||
self.validate_currency()
|
||||
|
||||
if self.doctype == 'Purchase Invoice':
|
||||
self.validate_paid_amount()
|
||||
self.calculate_paid_amount()
|
||||
|
||||
if self.doctype in ['Purchase Invoice', 'Sales Invoice']:
|
||||
pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid"
|
||||
@@ -135,22 +135,23 @@ class AccountsController(TransactionBase):
|
||||
else:
|
||||
df.set("print_hide", 1)
|
||||
|
||||
def validate_paid_amount(self):
|
||||
def calculate_paid_amount(self):
|
||||
if hasattr(self, "is_pos") or hasattr(self, "is_paid"):
|
||||
is_paid = self.get("is_pos") or self.get("is_paid")
|
||||
if cint(is_paid) == 1:
|
||||
if flt(self.paid_amount) == 0 and flt(self.outstanding_amount) > 0:
|
||||
if self.cash_bank_account:
|
||||
self.paid_amount = flt(flt(self.outstanding_amount), self.precision("paid_amount"))
|
||||
self.base_paid_amount = flt(self.paid_amount * self.conversion_rate,
|
||||
self.precision("base_paid_amount"))
|
||||
else:
|
||||
# show message that the amount is not paid
|
||||
self.paid_amount = 0
|
||||
frappe.throw(
|
||||
_("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified"))
|
||||
else:
|
||||
frappe.db.set(self, 'paid_amount', 0)
|
||||
|
||||
if is_paid:
|
||||
if not self.cash_bank_account:
|
||||
# show message that the amount is not paid
|
||||
frappe.throw(_("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified"))
|
||||
|
||||
if cint(self.is_return) and self.grand_total > self.paid_amount:
|
||||
self.paid_amount = flt(flt(self.grand_total), self.precision("paid_amount"))
|
||||
|
||||
elif not flt(self.paid_amount) and flt(self.outstanding_amount) > 0:
|
||||
self.paid_amount = flt(flt(self.outstanding_amount), self.precision("paid_amount"))
|
||||
|
||||
self.base_paid_amount = flt(self.paid_amount * self.conversion_rate,
|
||||
self.precision("base_paid_amount"))
|
||||
|
||||
def set_missing_values(self, for_validate=False):
|
||||
if frappe.flags.in_test:
|
||||
|
||||
Reference in New Issue
Block a user