mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
Allowed paid amount against debit/credit note
This commit is contained in:
@@ -588,6 +588,10 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
allocate_party_amount_against_ref_docs: function(frm, paid_amount) {
|
allocate_party_amount_against_ref_docs: function(frm, paid_amount) {
|
||||||
var total_positive_outstanding_including_order = 0;
|
var total_positive_outstanding_including_order = 0;
|
||||||
var total_negative_outstanding = 0;
|
var total_negative_outstanding = 0;
|
||||||
|
var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
|
||||||
|
function(d) { return flt(d.amount) }));
|
||||||
|
|
||||||
|
paid_amount -= total_deductions;
|
||||||
|
|
||||||
$.each(frm.doc.references || [], function(i, row) {
|
$.each(frm.doc.references || [], function(i, row) {
|
||||||
if(flt(row.outstanding_amount) > 0)
|
if(flt(row.outstanding_amount) > 0)
|
||||||
|
|||||||
@@ -337,14 +337,15 @@ class PaymentEntry(AccountsController):
|
|||||||
total_negative_outstanding = sum([abs(flt(d.outstanding_amount))
|
total_negative_outstanding = sum([abs(flt(d.outstanding_amount))
|
||||||
for d in self.get("references") if flt(d.outstanding_amount) < 0])
|
for d in self.get("references") if flt(d.outstanding_amount) < 0])
|
||||||
|
|
||||||
party_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount
|
paid_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount
|
||||||
|
additional_charges = sum([flt(d.amount) for d in self.deductions])
|
||||||
|
|
||||||
if not total_negative_outstanding:
|
if not total_negative_outstanding:
|
||||||
frappe.throw(_("Cannot {0} {1} {2} without any negative outstanding invoice")
|
frappe.throw(_("Cannot {0} {1} {2} without any negative outstanding invoice")
|
||||||
.format(self.payment_type, ("to" if self.party_type=="Customer" else "from"),
|
.format(self.payment_type, ("to" if self.party_type=="Customer" else "from"),
|
||||||
self.party_type), InvalidPaymentEntry)
|
self.party_type), InvalidPaymentEntry)
|
||||||
|
|
||||||
elif party_amount > total_negative_outstanding:
|
elif paid_amount - additional_charges > total_negative_outstanding:
|
||||||
frappe.throw(_("Paid Amount cannot be greater than total negative outstanding amount {0}")
|
frappe.throw(_("Paid Amount cannot be greater than total negative outstanding amount {0}")
|
||||||
.format(total_negative_outstanding), InvalidPaymentEntry)
|
.format(total_negative_outstanding), InvalidPaymentEntry)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user