mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 13:24:47 +00:00
Fix in unallocated amount calc in payment entry (#13288)
This commit is contained in:
@@ -676,30 +676,17 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
function(d) { return flt(d.amount) }));
|
function(d) { return flt(d.amount) }));
|
||||||
|
|
||||||
if(frm.doc.party) {
|
if(frm.doc.party) {
|
||||||
var party_amount = frm.doc.payment_type=="Receive" ?
|
if(frm.doc.payment_type == "Receive"
|
||||||
frm.doc.paid_amount : frm.doc.received_amount;
|
&& frm.doc.base_total_allocated_amount < frm.doc.base_received_amount + total_deductions
|
||||||
var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";
|
&& frm.doc.total_allocated_amount < frm.doc.paid_amount + (total_deductions / frm.doc.source_exchange_rate)) {
|
||||||
|
unallocated_amount = (frm.doc.base_received_amount + total_deductions
|
||||||
if (frm.doc.party_account_currency == company_currency) {
|
- frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate;
|
||||||
if(frm.doc.payment_type == "Receive" && frm.doc.total_allocated_amount <= party_amount + total_deductions) {
|
} else if (frm.doc.payment_type == "Pay"
|
||||||
unallocated_amount = party_amount - (frm.doc.total_allocated_amount - total_deductions);
|
&& frm.doc.base_total_allocated_amount < frm.doc.base_paid_amount - total_deductions
|
||||||
} else if (frm.doc.payment_type == "Pay" && frm.doc.total_allocated_amount <= party_amount - total_deductions) {
|
&& frm.doc.total_allocated_amount < frm.doc.received_amount + (total_deductions / frm.doc.target_exchange_rate)) {
|
||||||
unallocated_amount = party_amount - (frm.doc.total_allocated_amount + total_deductions);
|
unallocated_amount = (frm.doc.base_paid_amount - (total_deductions
|
||||||
}
|
+ frm.doc.base_total_allocated_amount)) / frm.doc.target_exchange_rate;
|
||||||
} else {
|
|
||||||
if(frm.doc.payment_type == "Receive"
|
|
||||||
&& frm.doc.base_total_allocated_amount <= frm.doc.base_received_amount + total_deductions
|
|
||||||
&& frm.doc.total_allocated_amount < frm.doc.paid_amount) {
|
|
||||||
unallocated_amount = (frm.doc.base_received_amount + total_deductions
|
|
||||||
- frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate;
|
|
||||||
} else if (frm.doc.payment_type == "Pay"
|
|
||||||
&& frm.doc.base_total_allocated_amount < frm.doc.base_paid_amount - total_deductions
|
|
||||||
&& frm.doc.total_allocated_amount < frm.doc.received_amount) {
|
|
||||||
unallocated_amount = (frm.doc.base_paid_amount - (total_deductions
|
|
||||||
+ frm.doc.base_total_allocated_amount)) / frm.doc.target_exchange_rate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
frm.set_value("unallocated_amount", unallocated_amount);
|
frm.set_value("unallocated_amount", unallocated_amount);
|
||||||
frm.trigger("set_difference_amount");
|
frm.trigger("set_difference_amount");
|
||||||
|
|||||||
@@ -292,30 +292,18 @@ class PaymentEntry(AccountsController):
|
|||||||
|
|
||||||
def set_unallocated_amount(self):
|
def set_unallocated_amount(self):
|
||||||
self.unallocated_amount = 0
|
self.unallocated_amount = 0
|
||||||
|
|
||||||
if self.party:
|
if self.party:
|
||||||
total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
|
total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
|
||||||
|
if self.payment_type == "Receive" \
|
||||||
if self.party_account_currency == self.company_currency:
|
and self.base_total_allocated_amount < self.base_received_amount + total_deductions \
|
||||||
if self.payment_type == "Receive" \
|
and self.total_allocated_amount < self.paid_amount + (total_deductions / self.source_exchange_rate):
|
||||||
and self.total_allocated_amount <= self.paid_amount + total_deductions:
|
self.unallocated_amount = (self.base_received_amount + total_deductions -
|
||||||
self.unallocated_amount = self.paid_amount - \
|
self.base_total_allocated_amount) / self.source_exchange_rate
|
||||||
(self.total_allocated_amount - total_deductions)
|
elif self.payment_type == "Pay" \
|
||||||
elif self.payment_type == "Pay" \
|
and self.base_total_allocated_amount < (self.base_paid_amount - total_deductions) \
|
||||||
and self.total_allocated_amount <= self.received_amount - total_deductions:
|
and self.total_allocated_amount < self.received_amount + (total_deductions / self.target_exchange_rate):
|
||||||
self.unallocated_amount = self.received_amount - \
|
self.unallocated_amount = (self.base_paid_amount - (total_deductions +
|
||||||
(self.total_allocated_amount + total_deductions)
|
self.base_total_allocated_amount)) / self.target_exchange_rate
|
||||||
else:
|
|
||||||
if self.payment_type == "Receive" \
|
|
||||||
and self.base_total_allocated_amount <= self.base_received_amount + total_deductions \
|
|
||||||
and self.total_allocated_amount < self.paid_amount:
|
|
||||||
self.unallocated_amount = (self.base_received_amount + total_deductions -
|
|
||||||
self.base_total_allocated_amount) / self.source_exchange_rate
|
|
||||||
elif self.payment_type == "Pay" \
|
|
||||||
and self.base_total_allocated_amount < (self.base_paid_amount - total_deductions) \
|
|
||||||
and self.total_allocated_amount < self.received_amount:
|
|
||||||
self.unallocated_amount = (self.base_paid_amount - (total_deductions +
|
|
||||||
self.base_total_allocated_amount)) / self.target_exchange_rate
|
|
||||||
|
|
||||||
def set_difference_amount(self):
|
def set_difference_amount(self):
|
||||||
base_unallocated_amount = flt(self.unallocated_amount) * (flt(self.source_exchange_rate)
|
base_unallocated_amount = flt(self.unallocated_amount) * (flt(self.source_exchange_rate)
|
||||||
|
|||||||
Reference in New Issue
Block a user