Merge pull request #16752 from nabinhait/limit-cond-fix
fix: Limit conditions while fetching payment entries
This commit is contained in:
@@ -36,7 +36,7 @@ class PaymentReconciliation(Document):
|
|||||||
bank_account_condition = "t2.against_account like %(bank_cash_account)s" \
|
bank_account_condition = "t2.against_account like %(bank_cash_account)s" \
|
||||||
if self.bank_cash_account else "1=1"
|
if self.bank_cash_account else "1=1"
|
||||||
|
|
||||||
limit_cond = "limit %s" % (self.limit or 1000)
|
limit_cond = "limit %s" % self.limit if self.limit else ""
|
||||||
|
|
||||||
journal_entries = frappe.db.sql("""
|
journal_entries = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
@@ -83,7 +83,10 @@ class PaymentReconciliation(Document):
|
|||||||
condition = self.check_condition()
|
condition = self.check_condition()
|
||||||
|
|
||||||
non_reconciled_invoices = get_outstanding_invoices(self.party_type, self.party,
|
non_reconciled_invoices = get_outstanding_invoices(self.party_type, self.party,
|
||||||
self.receivable_payable_account, condition=condition, limit=self.limit)
|
self.receivable_payable_account, condition=condition)
|
||||||
|
|
||||||
|
if self.limit:
|
||||||
|
non_reconciled_invoices = non_reconciled_invoices[:self.limit]
|
||||||
|
|
||||||
self.add_invoice_entries(non_reconciled_invoices)
|
self.add_invoice_entries(non_reconciled_invoices)
|
||||||
|
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ def get_held_invoices(party_type, party):
|
|||||||
return held_invoices
|
return held_invoices
|
||||||
|
|
||||||
|
|
||||||
def get_outstanding_invoices(party_type, party, account, condition=None, limit=None):
|
def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||||
outstanding_invoices = []
|
outstanding_invoices = []
|
||||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
|
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
|
||||||
|
|
||||||
@@ -628,7 +628,6 @@ def get_outstanding_invoices(party_type, party, account, condition=None, limit=N
|
|||||||
|
|
||||||
invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice'
|
invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice'
|
||||||
held_invoices = get_held_invoices(party_type, party)
|
held_invoices = get_held_invoices(party_type, party)
|
||||||
limit_cond = "limit %s" % limit if limit else ""
|
|
||||||
|
|
||||||
invoice_list = frappe.db.sql("""
|
invoice_list = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
@@ -643,11 +642,10 @@ def get_outstanding_invoices(party_type, party, account, condition=None, limit=N
|
|||||||
and (against_voucher = '' or against_voucher is null))
|
and (against_voucher = '' or against_voucher is null))
|
||||||
or (voucher_type not in ('Journal Entry', 'Payment Entry')))
|
or (voucher_type not in ('Journal Entry', 'Payment Entry')))
|
||||||
group by voucher_type, voucher_no
|
group by voucher_type, voucher_no
|
||||||
order by posting_date, name {limit_cond}""".format(
|
order by posting_date, name""".format(
|
||||||
dr_or_cr=dr_or_cr,
|
dr_or_cr=dr_or_cr,
|
||||||
invoice = invoice,
|
invoice = invoice,
|
||||||
condition=condition or "",
|
condition=condition or ""
|
||||||
limit_cond = limit_cond
|
|
||||||
), {
|
), {
|
||||||
"party_type": party_type,
|
"party_type": party_type,
|
||||||
"party": party,
|
"party": party,
|
||||||
|
|||||||
@@ -960,11 +960,11 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field,
|
|||||||
|
|
||||||
|
|
||||||
def get_advance_payment_entries(party_type, party, party_account, order_doctype,
|
def get_advance_payment_entries(party_type, party, party_account, order_doctype,
|
||||||
order_list=None, include_unallocated=True, against_all_orders=False, limit=1000):
|
order_list=None, include_unallocated=True, against_all_orders=False, limit=None):
|
||||||
party_account_field = "paid_from" if party_type == "Customer" else "paid_to"
|
party_account_field = "paid_from" if party_type == "Customer" else "paid_to"
|
||||||
payment_type = "Receive" if party_type == "Customer" else "Pay"
|
payment_type = "Receive" if party_type == "Customer" else "Pay"
|
||||||
payment_entries_against_order, unallocated_payment_entries = [], []
|
payment_entries_against_order, unallocated_payment_entries = [], []
|
||||||
limit_cond = "limit %s" % (limit or 1000)
|
limit_cond = "limit %s" % limit if limit else ""
|
||||||
|
|
||||||
if order_list or against_all_orders:
|
if order_list or against_all_orders:
|
||||||
if order_list:
|
if order_list:
|
||||||
|
|||||||
Reference in New Issue
Block a user