mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
Merge pull request #45814 from frappe/mergify/bp/version-15-hotfix/pr-45762
refactor: set received and paid amount based on each other, if unset (backport #45762)
This commit is contained in:
@@ -812,27 +812,41 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
|
|
||||||
paid_amount: function (frm) {
|
paid_amount: function (frm) {
|
||||||
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));
|
||||||
|
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
|
||||||
|
if (!frm.doc.received_amount) {
|
||||||
|
if (frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
|
||||||
|
frm.set_value("received_amount", frm.doc.paid_amount);
|
||||||
|
} else if (company_currency == frm.doc.paid_to_account_currency) {
|
||||||
|
frm.set_value("received_amount", frm.doc.base_paid_amount);
|
||||||
|
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
frm.trigger("reset_received_amount");
|
frm.trigger("reset_received_amount");
|
||||||
frm.events.hide_unhide_fields(frm);
|
frm.events.hide_unhide_fields(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
received_amount: function (frm) {
|
received_amount: function (frm) {
|
||||||
|
let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
|
||||||
frm.set_paid_amount_based_on_received_amount = true;
|
frm.set_paid_amount_based_on_received_amount = true;
|
||||||
|
|
||||||
if (!frm.doc.paid_amount && frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
|
|
||||||
frm.set_value("paid_amount", frm.doc.received_amount);
|
|
||||||
|
|
||||||
if (frm.doc.target_exchange_rate) {
|
|
||||||
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
|
|
||||||
}
|
|
||||||
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
frm.set_value(
|
frm.set_value(
|
||||||
"base_received_amount",
|
"base_received_amount",
|
||||||
flt(frm.doc.received_amount) * flt(frm.doc.target_exchange_rate)
|
flt(frm.doc.received_amount) * flt(frm.doc.target_exchange_rate)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!frm.doc.paid_amount) {
|
||||||
|
if (frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
|
||||||
|
frm.set_value("paid_amount", frm.doc.received_amount);
|
||||||
|
if (frm.doc.target_exchange_rate) {
|
||||||
|
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
|
||||||
|
}
|
||||||
|
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
|
||||||
|
} else if (company_currency == frm.doc.paid_from_account_currency) {
|
||||||
|
frm.set_value("paid_amount", frm.doc.base_received_amount);
|
||||||
|
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (frm.doc.payment_type == "Pay")
|
if (frm.doc.payment_type == "Pay")
|
||||||
frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount, true);
|
frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount, true);
|
||||||
else frm.events.set_unallocated_amount(frm);
|
else frm.events.set_unallocated_amount(frm);
|
||||||
|
|||||||
Reference in New Issue
Block a user