mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
feat: dr/cr amounts in reporting_currency on gl entries
This commit is contained in:
@@ -29,14 +29,17 @@
|
|||||||
"against_voucher",
|
"against_voucher",
|
||||||
"voucher_detail_no",
|
"voucher_detail_no",
|
||||||
"transaction_exchange_rate",
|
"transaction_exchange_rate",
|
||||||
|
"reporting_currency_exchange_rate",
|
||||||
"amounts_section",
|
"amounts_section",
|
||||||
"debit_in_account_currency",
|
"debit_in_account_currency",
|
||||||
"debit",
|
"debit",
|
||||||
"debit_in_transaction_currency",
|
"debit_in_transaction_currency",
|
||||||
|
"debit_in_reporting_currency",
|
||||||
"column_break_bm1w",
|
"column_break_bm1w",
|
||||||
"credit_in_account_currency",
|
"credit_in_account_currency",
|
||||||
"credit",
|
"credit",
|
||||||
"credit_in_transaction_currency",
|
"credit_in_transaction_currency",
|
||||||
|
"credit_in_reporting_currency",
|
||||||
"dimensions_section",
|
"dimensions_section",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
"column_break_lmnm",
|
"column_break_lmnm",
|
||||||
@@ -353,13 +356,31 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_8abq",
|
"fieldname": "column_break_8abq",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "debit_in_reporting_currency",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Debit Amount in Reporting Currency",
|
||||||
|
"options": "Company:company:reporting_currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit_in_reporting_currency",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Credit Amount in Reporting Currency",
|
||||||
|
"options": "Company:company:reporting_currency"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reporting_currency_exchange_rate",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Reporting Currency Exchange Rate",
|
||||||
|
"precision": "9"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-list",
|
"icon": "fa fa-list",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-03-21 15:29:11.221890",
|
"modified": "2025-08-22 12:57:17.750252",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "GL Entry",
|
"name": "GL Entry",
|
||||||
@@ -390,8 +411,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
|
"row_format": "Dynamic",
|
||||||
"search_fields": "voucher_no,account,posting_date,against_voucher",
|
"search_fields": "voucher_no,account,posting_date,against_voucher",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": []
|
"states": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ from erpnext.accounts.party import (
|
|||||||
validate_party_gle_currency,
|
validate_party_gle_currency,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.utils import OUTSTANDING_DOCTYPES, get_account_currency, get_fiscal_year
|
from erpnext.accounts.utils import OUTSTANDING_DOCTYPES, get_account_currency, get_fiscal_year
|
||||||
from erpnext.exceptions import InvalidAccountCurrency
|
from erpnext.exceptions import InvalidAccountCurrency, ReportingCurrencyExchangeNotFoundError
|
||||||
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
|
|
||||||
exclude_from_linked_with = True
|
exclude_from_linked_with = True
|
||||||
|
|
||||||
@@ -42,9 +43,11 @@ class GLEntry(Document):
|
|||||||
cost_center: DF.Link | None
|
cost_center: DF.Link | None
|
||||||
credit: DF.Currency
|
credit: DF.Currency
|
||||||
credit_in_account_currency: DF.Currency
|
credit_in_account_currency: DF.Currency
|
||||||
|
credit_in_reporting_currency: DF.Currency
|
||||||
credit_in_transaction_currency: DF.Currency
|
credit_in_transaction_currency: DF.Currency
|
||||||
debit: DF.Currency
|
debit: DF.Currency
|
||||||
debit_in_account_currency: DF.Currency
|
debit_in_account_currency: DF.Currency
|
||||||
|
debit_in_reporting_currency: DF.Currency
|
||||||
debit_in_transaction_currency: DF.Currency
|
debit_in_transaction_currency: DF.Currency
|
||||||
due_date: DF.Date | None
|
due_date: DF.Date | None
|
||||||
finance_book: DF.Link | None
|
finance_book: DF.Link | None
|
||||||
@@ -57,6 +60,7 @@ class GLEntry(Document):
|
|||||||
posting_date: DF.Date | None
|
posting_date: DF.Date | None
|
||||||
project: DF.Link | None
|
project: DF.Link | None
|
||||||
remarks: DF.Text | None
|
remarks: DF.Text | None
|
||||||
|
reporting_currency_exchange_rate: DF.Float
|
||||||
to_rename: DF.Check
|
to_rename: DF.Check
|
||||||
transaction_currency: DF.Link | None
|
transaction_currency: DF.Link | None
|
||||||
transaction_date: DF.Date | None
|
transaction_date: DF.Date | None
|
||||||
@@ -88,6 +92,8 @@ class GLEntry(Document):
|
|||||||
self.validate_party()
|
self.validate_party()
|
||||||
self.validate_currency()
|
self.validate_currency()
|
||||||
|
|
||||||
|
self.set_amount_in_reporting_currency()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
adv_adj = self.flags.adv_adj
|
adv_adj = self.flags.adv_adj
|
||||||
if not self.flags.from_repost and self.voucher_type != "Period Closing Voucher":
|
if not self.flags.from_repost and self.voucher_type != "Period Closing Voucher":
|
||||||
@@ -292,6 +298,25 @@ class GLEntry(Document):
|
|||||||
if self.party_type and self.party:
|
if self.party_type and self.party:
|
||||||
validate_party_gle_currency(self.party_type, self.party, self.company, self.account_currency)
|
validate_party_gle_currency(self.party_type, self.party, self.company, self.account_currency)
|
||||||
|
|
||||||
|
def set_amount_in_reporting_currency(self):
|
||||||
|
default_currency, reporting_currency = frappe.get_cached_value(
|
||||||
|
"Company", self.company, ["default_currency", "reporting_currency"]
|
||||||
|
)
|
||||||
|
transaction_date = self.transaction_date or self.posting_date
|
||||||
|
self.reporting_currency_exchange_rate = get_exchange_rate(
|
||||||
|
default_currency, reporting_currency, transaction_date
|
||||||
|
)
|
||||||
|
if not self.reporting_currency_exchange_rate:
|
||||||
|
frappe.throw(
|
||||||
|
title=_("Reporting Currency Exchange Not Found"),
|
||||||
|
msg=_(
|
||||||
|
"Unable to find exchange rate for {0} to {1} for key date {2}. Please create a Currency Exchange record manually."
|
||||||
|
).format(default_currency, reporting_currency, transaction_date),
|
||||||
|
exc=ReportingCurrencyExchangeNotFoundError,
|
||||||
|
)
|
||||||
|
self.debit_in_reporting_currency = flt(self.debit * self.reporting_currency_exchange_rate)
|
||||||
|
self.credit_in_reporting_currency = flt(self.credit * self.reporting_currency_exchange_rate)
|
||||||
|
|
||||||
def validate_and_set_fiscal_year(self):
|
def validate_and_set_fiscal_year(self):
|
||||||
if not self.fiscal_year:
|
if not self.fiscal_year:
|
||||||
self.fiscal_year = get_fiscal_year(self.posting_date, company=self.company)[0]
|
self.fiscal_year = get_fiscal_year(self.posting_date, company=self.company)[0]
|
||||||
|
|||||||
@@ -24,3 +24,7 @@ class InvalidAccountDimensionError(frappe.ValidationError):
|
|||||||
|
|
||||||
class MandatoryAccountDimensionError(frappe.ValidationError):
|
class MandatoryAccountDimensionError(frappe.ValidationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ReportingCurrencyExchangeNotFoundError(frappe.ValidationError):
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user