Skip to content

Commit

Permalink
Merge pull request #226 from 8848digital/223-get_payment_entries_issue
Browse files Browse the repository at this point in the history
fix: get_payment_entries_issue
  • Loading branch information
tinadn authored Oct 10, 2024
2 parents e793be7 + 2b0babb commit acebb16
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def get_payment_entries_for_bank_clearance(

condition = ""
if not include_reconciled_entries:
condition = "and (clearance_date IS NULL or clearance_date='0000-00-00')"
condition = "and (clearance_date IS NULL or to_char(clearance_date, 'YYYY-MM-DD') = '0000-00-00')"

journal_entries = frappe.db.sql(
f"""
select
"Journal Entry" as payment_document, t1.name as payment_entry,
'Journal Entry' as payment_document, t1.name as payment_entry,
t1.cheque_no as cheque_number, t1.cheque_date,
sum(t2.debit_in_account_currency) as debit, sum(t2.credit_in_account_currency) as credit,
t1.posting_date, t2.against_account, t1.clearance_date, t2.account_currency
Expand All @@ -142,7 +142,7 @@ def get_payment_entries_for_bank_clearance(
t2.parent = t1.name and t2.account = %(account)s and t1.docstatus=1
and t1.posting_date >= %(from)s and t1.posting_date <= %(to)s
and ifnull(t1.is_opening, 'No') = 'No' {condition}
group by t2.account, t1.name
group by t2.account, t1.name , t2.against_account, t2.account_currency
order by t1.posting_date ASC, t1.name DESC
""",
{"account": account, "from": from_date, "to": to_date},
Expand All @@ -155,12 +155,12 @@ def get_payment_entries_for_bank_clearance(
payment_entries = frappe.db.sql(
f"""
select
"Payment Entry" as payment_document, name as payment_entry,
'Payment Entry' as payment_document, name as payment_entry,
reference_no as cheque_number, reference_date as cheque_date,
if(paid_from=%(account)s, paid_amount + total_taxes_and_charges, 0) as credit,
if(paid_from=%(account)s, 0, received_amount) as debit,
posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
case when paid_from=%(account)s then paid_amount + total_taxes_and_charges else 0 end as credit,
case when paid_from=%(account)s then 0 else received_amount end as debit,
posting_date,coalesce(party, case when paid_from=%(account)s then paid_to else paid_from end) as against_account, clearance_date,
case when paid_to=%(account)s then paid_to_account_currency else paid_from_account_currency end as account_currency
from `tabPayment Entry`
where
(paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
Expand Down

0 comments on commit acebb16

Please sign in to comment.