Skip to content

Commit

Permalink
Merge pull request #32366 from frappe/mergify/bp/version-13-hotfix/pr…
Browse files Browse the repository at this point in the history
…-32339

fix: opening entry causing discrepancy between stock and trial balance (backport #32339)
  • Loading branch information
rohitwaghchaure authored Sep 27, 2022
2 parents 8f961ab + 70c68f0 commit ddf5565
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions erpnext/accounts/report/general_ledger/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ def get_conditions(filters):
or filters.get("party")
or filters.get("group_by") in ["Group by Account", "Group by Party"]
):
conditions.append("posting_date >=%(from_date)s")
conditions.append("(posting_date >=%(from_date)s or is_opening = 'Yes')")

conditions.append("(posting_date <=%(to_date)s or is_opening = 'Yes')")
conditions.append("(posting_date <=%(to_date)s)")

if filters.get("project"):
conditions.append("project in %(project)s")
Expand Down
3 changes: 2 additions & 1 deletion erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def get_rootwise_opening_balances(filters, report_type):
query_filters = {
"company": filters.company,
"from_date": filters.from_date,
"to_date": filters.to_date,
"report_type": report_type,
"year_start_date": filters.year_start_date,
"project": filters.project,
Expand Down Expand Up @@ -200,7 +201,7 @@ def get_rootwise_opening_balances(filters, report_type):
where
company=%(company)s
{additional_conditions}
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
and (posting_date < %(from_date)s or (ifnull(is_opening, 'No') = 'Yes' and posting_date <= %(to_date)s))
and account in (select name from `tabAccount` where report_type=%(report_type)s)
and is_cancelled = 0
group by account""".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,17 @@ def get_opening_balances(filters):
where company=%(company)s
and is_cancelled=0
and ifnull(party_type, '') = %(party_type)s and ifnull(party, '') != ''
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
and (posting_date < %(from_date)s or (ifnull(is_opening, 'No') = 'Yes' and posting_date <= %(to_date)s))
{account_filter}
group by party""".format(
account_filter=account_filter
),
{"company": filters.company, "from_date": filters.from_date, "party_type": filters.party_type},
{
"company": filters.company,
"from_date": filters.from_date,
"to_date": filters.to_date,
"party_type": filters.party_type,
},
as_dict=True,
)

Expand Down

0 comments on commit ddf5565

Please sign in to comment.