mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
Merge pull request #50560 from frappe/mergify/copy/develop/pr-49788
feat: (Multi-Currency in Employee Advance, Expense Claim) update exchange rate of payment entry in gl entry & added exchange rate, base amount field in Advance Payment Ledger Entry (copy #49788)
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
// Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
// frappe.ui.form.on("Advance Payment Ledger Entry", {
|
frappe.ui.form.on("Advance Payment Ledger Entry", {
|
||||||
// refresh(frm) {
|
refresh(frm) {
|
||||||
|
frm.set_currency_labels(["amount"], frm.doc.currency);
|
||||||
// },
|
frm.set_currency_labels(["base_amount"], erpnext.get_currency(frm.doc.company));
|
||||||
// });
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -10,8 +10,10 @@
|
|||||||
"voucher_no",
|
"voucher_no",
|
||||||
"against_voucher_type",
|
"against_voucher_type",
|
||||||
"against_voucher_no",
|
"against_voucher_no",
|
||||||
"amount",
|
|
||||||
"currency",
|
"currency",
|
||||||
|
"exchange_rate",
|
||||||
|
"amount",
|
||||||
|
"base_amount",
|
||||||
"event",
|
"event",
|
||||||
"delinked"
|
"delinked"
|
||||||
],
|
],
|
||||||
@@ -76,13 +78,29 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "DeLinked",
|
"label": "DeLinked",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "base_amount",
|
||||||
|
"fieldname": "base_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Amount (Company Currency)",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "exchange_rate",
|
||||||
|
"fieldname": "exchange_rate",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Exchange Rate",
|
||||||
|
"precision": "9",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grid_page_length": 50,
|
"grid_page_length": 50,
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-10-13 15:11:58.300836",
|
"modified": "2025-11-13 12:45:03.014555",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Advance Payment Ledger Entry",
|
"name": "Advance Payment Ledger Entry",
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ class AdvancePaymentLedgerEntry(Document):
|
|||||||
against_voucher_no: DF.DynamicLink | None
|
against_voucher_no: DF.DynamicLink | None
|
||||||
against_voucher_type: DF.Link | None
|
against_voucher_type: DF.Link | None
|
||||||
amount: DF.Currency
|
amount: DF.Currency
|
||||||
|
base_amount: DF.Currency
|
||||||
company: DF.Link | None
|
company: DF.Link | None
|
||||||
currency: DF.Link | None
|
currency: DF.Link | None
|
||||||
delinked: DF.Check
|
delinked: DF.Check
|
||||||
event: DF.Data | None
|
event: DF.Data | None
|
||||||
|
exchange_rate: DF.Float
|
||||||
voucher_no: DF.DynamicLink | None
|
voucher_no: DF.DynamicLink | None
|
||||||
voucher_type: DF.Link | None
|
voucher_type: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ frappe.ui.form.on("Journal Entry", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.accounts.unreconcile_payment.add_unreconcile_btn(frm);
|
erpnext.accounts.unreconcile_payment.add_unreconcile_btn(frm);
|
||||||
|
|
||||||
|
$.each(frm.doc.accounts || [], function (i, row) {
|
||||||
|
erpnext.journal_entry.set_exchange_rate(frm, row.doctype, row.name);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
before_save: function (frm) {
|
before_save: function (frm) {
|
||||||
if (frm.doc.docstatus == 0 && !frm.doc.is_system_generated) {
|
if (frm.doc.docstatus == 0 && !frm.doc.is_system_generated) {
|
||||||
|
|||||||
@@ -1774,7 +1774,7 @@ def get_exchange_rate(
|
|||||||
|
|
||||||
# The date used to retreive the exchange rate here is the date passed
|
# The date used to retreive the exchange rate here is the date passed
|
||||||
# in as an argument to this function.
|
# in as an argument to this function.
|
||||||
elif (not exchange_rate or flt(exchange_rate) == 1) and account_currency and posting_date:
|
elif (not flt(exchange_rate) or flt(exchange_rate) == 1) and account_currency and posting_date:
|
||||||
exchange_rate = get_exchange_rate(account_currency, company_currency, posting_date)
|
exchange_rate = get_exchange_rate(account_currency, company_currency, posting_date)
|
||||||
else:
|
else:
|
||||||
exchange_rate = 1
|
exchange_rate = 1
|
||||||
|
|||||||
@@ -1437,6 +1437,7 @@ class PaymentEntry(AccountsController):
|
|||||||
else allocated_amount_in_company_currency / self.transaction_exchange_rate,
|
else allocated_amount_in_company_currency / self.transaction_exchange_rate,
|
||||||
"advance_voucher_type": d.advance_voucher_type,
|
"advance_voucher_type": d.advance_voucher_type,
|
||||||
"advance_voucher_no": d.advance_voucher_no,
|
"advance_voucher_no": d.advance_voucher_no,
|
||||||
|
"transaction_exchange_rate": self.target_exchange_rate,
|
||||||
},
|
},
|
||||||
item=self,
|
item=self,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -594,7 +594,11 @@ def check_if_advance_entry_modified(args):
|
|||||||
q.inner_join(payment_ref)
|
q.inner_join(payment_ref)
|
||||||
.on(payment_entry.name == payment_ref.parent)
|
.on(payment_entry.name == payment_ref.parent)
|
||||||
.where(payment_ref.name == args.get("voucher_detail_no"))
|
.where(payment_ref.name == args.get("voucher_detail_no"))
|
||||||
.where(payment_ref.reference_doctype.isin(("", "Sales Order", "Purchase Order")))
|
.where(
|
||||||
|
payment_ref.reference_doctype.isin(
|
||||||
|
("", "Sales Order", "Purchase Order", "Employee Advance")
|
||||||
|
)
|
||||||
|
)
|
||||||
.where(payment_ref.allocated_amount == args.get("unreconciled_amount"))
|
.where(payment_ref.allocated_amount == args.get("unreconciled_amount"))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -1920,8 +1924,19 @@ def get_payment_ledger_entries(gl_entries, cancel=0):
|
|||||||
|
|
||||||
if gle.advance_voucher_no:
|
if gle.advance_voucher_no:
|
||||||
# create advance entry
|
# create advance entry
|
||||||
|
base_amount, exchange_rate = (
|
||||||
|
(dr_or_cr, gle.transaction_exchange_rate)
|
||||||
|
if gle.advance_voucher_type == "Employee Advance"
|
||||||
|
else (None, None)
|
||||||
|
)
|
||||||
adv = get_advance_ledger_entry(
|
adv = get_advance_ledger_entry(
|
||||||
gle, against_voucher_type, against_voucher_no, dr_or_cr_account_currency, cancel
|
gle,
|
||||||
|
against_voucher_type,
|
||||||
|
against_voucher_no,
|
||||||
|
dr_or_cr_account_currency,
|
||||||
|
cancel,
|
||||||
|
base_amount,
|
||||||
|
exchange_rate,
|
||||||
)
|
)
|
||||||
|
|
||||||
ple_map.append(adv)
|
ple_map.append(adv)
|
||||||
@@ -1931,13 +1946,15 @@ def get_payment_ledger_entries(gl_entries, cancel=0):
|
|||||||
return ple_map
|
return ple_map
|
||||||
|
|
||||||
|
|
||||||
def get_advance_ledger_entry(gle, against_voucher_type, against_voucher_no, amount, cancel):
|
def get_advance_ledger_entry(
|
||||||
|
gle, against_voucher_type, against_voucher_no, amount, cancel, base_amount=None, exchange_rate=None
|
||||||
|
):
|
||||||
event = (
|
event = (
|
||||||
"Submit"
|
"Submit"
|
||||||
if (against_voucher_type == gle.voucher_type and against_voucher_no == gle.voucher_no)
|
if (against_voucher_type == gle.voucher_type and against_voucher_no == gle.voucher_no)
|
||||||
else "Adjustment"
|
else "Adjustment"
|
||||||
)
|
)
|
||||||
return frappe._dict(
|
aple = frappe._dict(
|
||||||
doctype="Advance Payment Ledger Entry",
|
doctype="Advance Payment Ledger Entry",
|
||||||
company=gle.company,
|
company=gle.company,
|
||||||
voucher_type=gle.voucher_type,
|
voucher_type=gle.voucher_type,
|
||||||
@@ -1951,6 +1968,12 @@ def get_advance_ledger_entry(gle, against_voucher_type, against_voucher_no, amou
|
|||||||
delinked=cancel,
|
delinked=cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if base_amount is not None:
|
||||||
|
aple.base_amount = base_amount
|
||||||
|
if exchange_rate is not None:
|
||||||
|
aple.exchange_rate = exchange_rate
|
||||||
|
return aple
|
||||||
|
|
||||||
|
|
||||||
def create_payment_ledger_entry(
|
def create_payment_ledger_entry(
|
||||||
gl_entries, cancel=0, adv_adj=0, update_outstanding="Yes", from_repost=0, partial_cancel=False
|
gl_entries, cancel=0, adv_adj=0, update_outstanding="Yes", from_repost=0, partial_cancel=False
|
||||||
|
|||||||
@@ -1291,7 +1291,10 @@ class AccountsController(TransactionBase):
|
|||||||
"Payment Entry",
|
"Payment Entry",
|
||||||
]:
|
]:
|
||||||
set_balance_in_account_currency(
|
set_balance_in_account_currency(
|
||||||
gl_dict, account_currency, self.get("conversion_rate"), self.company_currency
|
gl_dict,
|
||||||
|
account_currency,
|
||||||
|
args.get("transaction_exchange_rate") or self.get("conversion_rate"),
|
||||||
|
self.company_currency,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update details in transaction currency
|
# Update details in transaction currency
|
||||||
@@ -1299,7 +1302,8 @@ class AccountsController(TransactionBase):
|
|||||||
gl_dict.update(
|
gl_dict.update(
|
||||||
{
|
{
|
||||||
"transaction_currency": self.get("currency") or self.company_currency,
|
"transaction_currency": self.get("currency") or self.company_currency,
|
||||||
"transaction_exchange_rate": self.get("conversion_rate", 1),
|
"transaction_exchange_rate": args.get("transaction_exchange_rate")
|
||||||
|
or self.get("conversion_rate", 1),
|
||||||
"debit_in_transaction_currency": self.get_value_in_transaction_currency(
|
"debit_in_transaction_currency": self.get_value_in_transaction_currency(
|
||||||
account_currency, gl_dict, "debit"
|
account_currency, gl_dict, "debit"
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user