From 80f78aab51e35a2e00479d2f16c0e599f0bb42da Mon Sep 17 00:00:00 2001 From: vishakhdesai Date: Thu, 27 Feb 2025 18:18:49 +0530 Subject: [PATCH] fix: payment entry exchange gain loss issue (cherry picked from commit 2dbef23244ed40871561489dccbe78e5d795affe) # Conflicts: # erpnext/accounts/doctype/payment_entry/payment_entry.js --- .../doctype/payment_entry/payment_entry.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index f4819aaea59..5864d5c1635 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -214,6 +214,10 @@ frappe.ui.form.on('Payment Entry', { frappe.flags.allocate_payment_amount = true; }, + validate: async function (frm) { + await frm.events.set_exchange_gain_loss_deduction(frm); + }, + validate_company: (frm) => { if (!frm.doc.company){ frappe.throw({message:__("Please select a Company first."), title: __("Mandatory")}); @@ -1551,3 +1555,54 @@ function set_default_party_type(frm) { if (party_type) frm.set_value("party_type", party_type); } +<<<<<<< HEAD +======= + +function get_included_taxes(frm) { + let included_taxes = 0; + for (const tax of frm.doc.taxes) { + if (!tax.included_in_paid_amount) continue; + + if (tax.add_deduct_tax == "Add") { + included_taxes += tax.base_tax_amount; + } else { + included_taxes -= tax.base_tax_amount; + } + } + + return included_taxes; +} + +function get_company_defaults(company) { + return frappe.call({ + method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_company_defaults", + args: { + company: company, + }, + }); +} + +function prompt_for_missing_account(frm, account) { + return new Promise((resolve) => { + const dialog = frappe.prompt( + { + label: __(frappe.unscrub(account)), + fieldname: account, + fieldtype: "Link", + options: "Account", + get_query: () => ({ + filters: { + company: frm.doc.company, + }, + }), + }, + (values) => resolve(values?.[account]), + __("Please Specify Account") + ); + }); +} + +function get_deduction_amount_precision() { + return frappe.meta.get_field_precision(frappe.meta.get_field("Payment Entry Deduction", "amount")); +} +>>>>>>> 2dbef23244 (fix: payment entry exchange gain loss issue)