fix: Mandatory bank account error fix (#20733)
* fix: Mandatory bank account error fix * fix: SQL condition
This commit is contained in:
parent
55078faec4
commit
fe18b92b61
@ -13,9 +13,11 @@ form_grid_templates = {
|
|||||||
|
|
||||||
class BankReconciliation(Document):
|
class BankReconciliation(Document):
|
||||||
def get_payment_entries(self):
|
def get_payment_entries(self):
|
||||||
if not (self.bank_account and self.from_date and self.to_date):
|
if not (self.from_date and self.to_date):
|
||||||
msgprint(_("Bank Account, From Date and To Date are Mandatory"))
|
frappe.throw(_("From Date and To Date are Mandatory"))
|
||||||
return
|
|
||||||
|
if not self.account:
|
||||||
|
frappe.throw(_("Account is mandatory to get payment entries"))
|
||||||
|
|
||||||
condition = ""
|
condition = ""
|
||||||
if not self.include_reconciled_entries:
|
if not self.include_reconciled_entries:
|
||||||
@ -37,6 +39,11 @@ class BankReconciliation(Document):
|
|||||||
order by t1.posting_date ASC, t1.name DESC
|
order by t1.posting_date ASC, t1.name DESC
|
||||||
""", {"condition":condition, "account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1)
|
""", {"condition":condition, "account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1)
|
||||||
|
|
||||||
|
condition = ''
|
||||||
|
|
||||||
|
if self.bank_account:
|
||||||
|
condition += 'and bank_account = %(bank_account)s'
|
||||||
|
|
||||||
payment_entries = frappe.db.sql("""
|
payment_entries = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
"Payment Entry" as payment_document, name as payment_entry,
|
"Payment Entry" as payment_document, name as payment_entry,
|
||||||
@ -49,10 +56,10 @@ class BankReconciliation(Document):
|
|||||||
where
|
where
|
||||||
(paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
|
(paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
|
||||||
and posting_date >= %(from)s and posting_date <= %(to)s
|
and posting_date >= %(from)s and posting_date <= %(to)s
|
||||||
and bank_account = %(bank_account)s
|
{condition}
|
||||||
order by
|
order by
|
||||||
posting_date ASC, name DESC
|
posting_date ASC, name DESC
|
||||||
""", {"account": self.account, "from":self.from_date,
|
""".format(condition=condition), {"account": self.account, "from":self.from_date,
|
||||||
"to": self.to_date, "bank_account": self.bank_account}, as_dict=1)
|
"to": self.to_date, "bank_account": self.bank_account}, as_dict=1)
|
||||||
|
|
||||||
pos_entries = []
|
pos_entries = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user