mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 07:02:54 +00:00
fix(accounts): Get balance for Profit and Loss accounts, only including valid transactions (not cancelled)
Fixed #25572 Period Closing Voucher incorrect journal entry amount for Income/Expenses Accounts containing canceled transactions.
This commit is contained in:
@@ -102,14 +102,14 @@ class PeriodClosingVoucher(AccountsController):
|
|||||||
make_gl_entries(gl_entries)
|
make_gl_entries(gl_entries)
|
||||||
|
|
||||||
def get_pl_balances(self, dimension_fields):
|
def get_pl_balances(self, dimension_fields):
|
||||||
"""Get balance for pl accounts"""
|
"""Get balance for Profit and Loss accounts, only including valid transactions (not cancelled)"""
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select
|
select
|
||||||
t1.account, t2.account_currency, {dimension_fields},
|
t1.account, t2.account_currency, {dimension_fields},
|
||||||
sum(t1.debit_in_account_currency) - sum(t1.credit_in_account_currency) as balance_in_account_currency,
|
sum(t1.debit_in_account_currency) - sum(t1.credit_in_account_currency) as balance_in_account_currency,
|
||||||
sum(t1.debit) - sum(t1.credit) as balance_in_company_currency
|
sum(t1.debit) - sum(t1.credit) as balance_in_company_currency
|
||||||
from `tabGL Entry` t1, `tabAccount` t2
|
from `tabGL Entry` t1, `tabAccount` t2
|
||||||
where t1.account = t2.name and t2.report_type = 'Profit and Loss'
|
where t1.is_cancelled = 0 and t1.account = t2.name and t2.report_type = 'Profit and Loss'
|
||||||
and t2.docstatus < 2 and t2.company = %s
|
and t2.docstatus < 2 and t2.company = %s
|
||||||
and t1.posting_date between %s and %s
|
and t1.posting_date between %s and %s
|
||||||
group by t1.account, {dimension_fields}
|
group by t1.account, {dimension_fields}
|
||||||
|
|||||||
Reference in New Issue
Block a user