fix: Multiple fixes in payment entry
This commit is contained in:
parent
035ce304fe
commit
a57d13e1e9
@ -533,8 +533,8 @@ frappe.ui.form.on('Payment Entry', {
|
|||||||
source_exchange_rate: function(frm) {
|
source_exchange_rate: function(frm) {
|
||||||
if (frm.doc.paid_amount) {
|
if (frm.doc.paid_amount) {
|
||||||
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
|
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
|
||||||
if(!frm.set_paid_amount_based_on_received_amount &&
|
// target exchange rate should always be same as source if both account currencies is same
|
||||||
(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) {
|
if(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
|
||||||
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
|
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
|
||||||
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
|
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,9 @@ class PaymentEntry(AccountsController):
|
|||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_reference_documents()
|
self.validate_reference_documents()
|
||||||
self.set_tax_withholding()
|
self.set_tax_withholding()
|
||||||
self.apply_taxes()
|
|
||||||
self.set_amounts()
|
self.set_amounts()
|
||||||
|
self.validate_amounts()
|
||||||
|
self.apply_taxes()
|
||||||
self.clear_unallocated_reference_document_rows()
|
self.clear_unallocated_reference_document_rows()
|
||||||
self.validate_payment_against_negative_invoice()
|
self.validate_payment_against_negative_invoice()
|
||||||
self.validate_transaction_reference()
|
self.validate_transaction_reference()
|
||||||
@ -236,7 +237,9 @@ class PaymentEntry(AccountsController):
|
|||||||
self.company_currency, self.posting_date)
|
self.company_currency, self.posting_date)
|
||||||
|
|
||||||
def set_target_exchange_rate(self, ref_doc=None):
|
def set_target_exchange_rate(self, ref_doc=None):
|
||||||
if self.paid_to and not self.target_exchange_rate:
|
if self.paid_from_account_currency == self.paid_to_account_currency:
|
||||||
|
self.target_exchange_rate = self.source_exchange_rate
|
||||||
|
elif self.paid_to and not self.target_exchange_rate:
|
||||||
if ref_doc:
|
if ref_doc:
|
||||||
if self.paid_to_account_currency == ref_doc.currency:
|
if self.paid_to_account_currency == ref_doc.currency:
|
||||||
self.target_exchange_rate = ref_doc.get("exchange_rate")
|
self.target_exchange_rate = ref_doc.get("exchange_rate")
|
||||||
@ -473,6 +476,14 @@ class PaymentEntry(AccountsController):
|
|||||||
self.set_unallocated_amount()
|
self.set_unallocated_amount()
|
||||||
self.set_difference_amount()
|
self.set_difference_amount()
|
||||||
|
|
||||||
|
def validate_amounts(self):
|
||||||
|
self.validate_received_amount()
|
||||||
|
|
||||||
|
def validate_received_amount(self):
|
||||||
|
if self.paid_from_account_currency == self.paid_to_account_currency:
|
||||||
|
if self.paid_amount != self.received_amount:
|
||||||
|
frappe.throw(_("Received Amount cannot be greater than Paid Amount"))
|
||||||
|
|
||||||
def set_received_amount(self):
|
def set_received_amount(self):
|
||||||
self.base_received_amount = self.base_paid_amount
|
self.base_received_amount = self.base_paid_amount
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user