fix for fields names at sales invoice return payments and verifying the payment amount (#15245)
* fix for payments field names in sales invoice return * add verification for payment amount at sales invoice return adding verification to be sure the payment amount is negative at sales invoice return * correction for precision field name
This commit is contained in:
parent
0cd5313c69
commit
8d7c1868d6
@ -112,6 +112,11 @@ class SalesInvoice(SellingController):
|
||||
self.set_status()
|
||||
if self.is_pos and not self.is_return:
|
||||
self.verify_payment_amount_is_positive()
|
||||
|
||||
#validate amount in mode of payments for returned invoices for pos must be negative
|
||||
if self.is_pos and self.is_return:
|
||||
self.verify_payment_amount_is_negative()
|
||||
|
||||
if self.redeem_loyalty_points and self.loyalty_program and self.loyalty_points:
|
||||
validate_loyalty_points(self, self.loyalty_points)
|
||||
|
||||
@ -971,6 +976,11 @@ class SalesInvoice(SellingController):
|
||||
if entry.amount < 0:
|
||||
frappe.throw(_("Row #{0} (Payment Table): Amount must be positive").format(entry.idx))
|
||||
|
||||
def verify_payment_amount_is_negative(self):
|
||||
for entry in self.payments:
|
||||
if entry.amount > 0:
|
||||
frappe.throw(_("Row #{0} (Payment Table): Amount must be negative").format(entry.idx))
|
||||
|
||||
# collection of the loyalty points, create the ledger entry for that.
|
||||
def make_loyalty_point_entry(self):
|
||||
returned_amount = self.get_returned_amount()
|
||||
|
@ -232,8 +232,8 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
||||
doc.append('payments', {
|
||||
'mode_of_payment': data.mode_of_payment,
|
||||
'type': data.type,
|
||||
'paid_amount': -1 * paid_amount,
|
||||
'base_paid_amount': -1 * base_paid_amount
|
||||
'amount': -1 * paid_amount,
|
||||
'base_amount': -1 * base_paid_amount
|
||||
})
|
||||
elif doc.doctype == 'Purchase Invoice':
|
||||
doc.paid_amount = -1 * source.paid_amount
|
||||
|
Loading…
x
Reference in New Issue
Block a user