feat: Transaction currency columns in GL report
This commit is contained in:
parent
924911e743
commit
35be3ac5a1
@ -32,7 +32,11 @@
|
||||
"finance_book",
|
||||
"to_rename",
|
||||
"due_date",
|
||||
"is_cancelled"
|
||||
"is_cancelled",
|
||||
"transaction_currency",
|
||||
"debit_in_transaction_currency",
|
||||
"credit_in_transaction_currency",
|
||||
"transaction_exchange_rate"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -253,15 +257,40 @@
|
||||
"fieldname": "is_cancelled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Cancelled"
|
||||
},
|
||||
{
|
||||
"fieldname": "transaction_currency",
|
||||
"fieldtype": "Link",
|
||||
"label": "Transaction Currency",
|
||||
"options": "Currency"
|
||||
},
|
||||
{
|
||||
"fieldname": "transaction_exchange_rate",
|
||||
"fieldtype": "Float",
|
||||
"label": "Transaction Exchange Rate"
|
||||
},
|
||||
{
|
||||
"fieldname": "debit_in_transaction_currency",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Debit Amount in Transaction Currency",
|
||||
"options": "transaction_currency"
|
||||
},
|
||||
{
|
||||
"fieldname": "credit_in_transaction_currency",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Credit Amount in Transaction Currency",
|
||||
"options": "transaction_currency"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-list",
|
||||
"idx": 1,
|
||||
"in_create": 1,
|
||||
"modified": "2020-04-07 16:22:33.766994",
|
||||
"links": [],
|
||||
"modified": "2023-08-16 21:38:44.072267",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "GL Entry",
|
||||
"naming_rule": "Expression (old style)",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
@ -290,5 +319,6 @@
|
||||
"quick_entry": 1,
|
||||
"search_fields": "voucher_no,account,posting_date,against_voucher",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
@ -188,6 +188,11 @@ frappe.query_reports["General Ledger"] = {
|
||||
"fieldname": "show_net_values_in_party_account",
|
||||
"label": __("Show Net Values in Party Account"),
|
||||
"fieldtype": "Check"
|
||||
},
|
||||
{
|
||||
"fieldname": "add_values_in_transaction_currency",
|
||||
"label": __("Add Columns in Transaction Currency"),
|
||||
"fieldtype": "Check"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -182,12 +182,18 @@ def get_gl_entries(filters, accounting_dimensions):
|
||||
if accounting_dimensions:
|
||||
dimension_fields = ", ".join(accounting_dimensions) + ","
|
||||
|
||||
transaction_currency_fields = ""
|
||||
if filters.get("add_values_in_transaction_currency"):
|
||||
transaction_currency_fields = (
|
||||
"debit_in_transaction_currency, credit_in_transaction_currency, transaction_currency,"
|
||||
)
|
||||
|
||||
gl_entries = frappe.db.sql(
|
||||
"""
|
||||
select
|
||||
name as gl_entry, posting_date, account, party_type, party,
|
||||
voucher_type, voucher_no, {dimension_fields}
|
||||
cost_center, project,
|
||||
cost_center, project, {transaction_currency_fields}
|
||||
against_voucher_type, against_voucher, account_currency,
|
||||
remarks, against, is_opening, creation {select_fields}
|
||||
from `tabGL Entry`
|
||||
@ -195,6 +201,7 @@ def get_gl_entries(filters, accounting_dimensions):
|
||||
{order_by_statement}
|
||||
""".format(
|
||||
dimension_fields=dimension_fields,
|
||||
transaction_currency_fields=transaction_currency_fields,
|
||||
select_fields=select_fields,
|
||||
conditions=get_conditions(filters),
|
||||
order_by_statement=order_by_statement,
|
||||
@ -562,6 +569,34 @@ def get_columns(filters):
|
||||
"fieldtype": "Float",
|
||||
"width": 130,
|
||||
},
|
||||
]
|
||||
|
||||
if filters.get("add_values_in_transaction_currency"):
|
||||
columns += [
|
||||
{
|
||||
"label": _("Debit (Transaction)"),
|
||||
"fieldname": "debit_in_transaction_currency",
|
||||
"fieldtype": "Currency",
|
||||
"width": 130,
|
||||
"options": "transaction_currency",
|
||||
},
|
||||
{
|
||||
"label": _("Credit (Transaction)"),
|
||||
"fieldname": "credit_in_transaction_currency",
|
||||
"fieldtype": "Currency",
|
||||
"width": 130,
|
||||
"options": "transaction_currency",
|
||||
},
|
||||
{
|
||||
"label": "Transaction Currency",
|
||||
"fieldname": "transaction_currency",
|
||||
"fieldtype": "Link",
|
||||
"options": "Currency",
|
||||
"width": 70,
|
||||
},
|
||||
]
|
||||
|
||||
columns += [
|
||||
{"label": _("Voucher Type"), "fieldname": "voucher_type", "width": 120},
|
||||
{
|
||||
"label": _("Voucher No"),
|
||||
|
@ -803,8 +803,28 @@ class AccountsController(TransactionBase):
|
||||
gl_dict, account_currency, self.get("conversion_rate"), self.company_currency
|
||||
)
|
||||
|
||||
# Update details in transaction currency
|
||||
gl_dict.update(
|
||||
{
|
||||
"transaction_currency": self.get("currency") or self.company_currency,
|
||||
"transaction_exchange_rate": self.get("conversion_rate", 1),
|
||||
"debit_in_transaction_currency": self.get_value_in_transaction_currency(
|
||||
account_currency, args, "debit"
|
||||
),
|
||||
"credit_in_transaction_currency": self.get_value_in_transaction_currency(
|
||||
account_currency, args, "credit"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
return gl_dict
|
||||
|
||||
def get_value_in_transaction_currency(self, account_currency, args, field):
|
||||
if account_currency == self.get("currency"):
|
||||
return args.get(field + "_in_account_currency")
|
||||
else:
|
||||
return flt(args.get(field, 0) / self.get("conversion_rate", 1))
|
||||
|
||||
def validate_qty_is_not_zero(self):
|
||||
if self.doctype != "Purchase Receipt":
|
||||
for item in self.items:
|
||||
|
Loading…
x
Reference in New Issue
Block a user