mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 06:28:29 +00:00
fix: Limit conditions while fetching payment entries
This commit is contained in:
@@ -13,20 +13,20 @@ class PaymentReconciliation(Document):
|
|||||||
def get_unreconciled_entries(self):
|
def get_unreconciled_entries(self):
|
||||||
self.get_nonreconciled_payment_entries()
|
self.get_nonreconciled_payment_entries()
|
||||||
self.get_invoice_entries()
|
self.get_invoice_entries()
|
||||||
|
|
||||||
def get_nonreconciled_payment_entries(self):
|
def get_nonreconciled_payment_entries(self):
|
||||||
self.check_mandatory_to_fetch()
|
self.check_mandatory_to_fetch()
|
||||||
|
|
||||||
payment_entries = self.get_payment_entries()
|
payment_entries = self.get_payment_entries()
|
||||||
journal_entries = self.get_jv_entries()
|
journal_entries = self.get_jv_entries()
|
||||||
|
|
||||||
self.add_payment_entries(payment_entries + journal_entries)
|
self.add_payment_entries(payment_entries + journal_entries)
|
||||||
|
|
||||||
def get_payment_entries(self):
|
def get_payment_entries(self):
|
||||||
order_doctype = "Sales Order" if self.party_type=="Customer" else "Purchase Order"
|
order_doctype = "Sales Order" if self.party_type=="Customer" else "Purchase Order"
|
||||||
payment_entries = get_advance_payment_entries(self.party_type, self.party,
|
payment_entries = get_advance_payment_entries(self.party_type, self.party,
|
||||||
self.receivable_payable_account, order_doctype, against_all_orders=True, limit=self.limit)
|
self.receivable_payable_account, order_doctype, against_all_orders=True, limit=self.limit)
|
||||||
|
|
||||||
return payment_entries
|
return payment_entries
|
||||||
|
|
||||||
def get_jv_entries(self):
|
def get_jv_entries(self):
|
||||||
@@ -36,12 +36,12 @@ 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
|
||||||
"Journal Entry" as reference_type, t1.name as reference_name,
|
"Journal Entry" as reference_type, t1.name as reference_name,
|
||||||
t1.posting_date, t1.remark as remarks, t2.name as reference_row,
|
t1.posting_date, t1.remark as remarks, t2.name as reference_row,
|
||||||
{dr_or_cr} as amount, t2.is_advance
|
{dr_or_cr} as amount, t2.is_advance
|
||||||
from
|
from
|
||||||
`tabJournal Entry` t1, `tabJournal Entry Account` t2
|
`tabJournal Entry` t1, `tabJournal Entry Account` t2
|
||||||
@@ -49,8 +49,8 @@ class PaymentReconciliation(Document):
|
|||||||
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
t1.name = t2.parent and t1.docstatus = 1 and t2.docstatus = 1
|
||||||
and t2.party_type = %(party_type)s and t2.party = %(party)s
|
and t2.party_type = %(party_type)s and t2.party = %(party)s
|
||||||
and t2.account = %(account)s and {dr_or_cr} > 0
|
and t2.account = %(account)s and {dr_or_cr} > 0
|
||||||
and (t2.reference_type is null or t2.reference_type = '' or
|
and (t2.reference_type is null or t2.reference_type = '' or
|
||||||
(t2.reference_type in ('Sales Order', 'Purchase Order')
|
(t2.reference_type in ('Sales Order', 'Purchase Order')
|
||||||
and t2.reference_name is not null and t2.reference_name != ''))
|
and t2.reference_name is not null and t2.reference_name != ''))
|
||||||
and (CASE
|
and (CASE
|
||||||
WHEN t1.voucher_type in ('Debit Note', 'Credit Note')
|
WHEN t1.voucher_type in ('Debit Note', 'Credit Note')
|
||||||
@@ -109,7 +109,7 @@ class PaymentReconciliation(Document):
|
|||||||
self.validate_invoice()
|
self.validate_invoice()
|
||||||
dr_or_cr = ("credit_in_account_currency"
|
dr_or_cr = ("credit_in_account_currency"
|
||||||
if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency")
|
if erpnext.get_party_account_type(self.party_type) == 'Receivable' else "debit_in_account_currency")
|
||||||
|
|
||||||
lst = []
|
lst = []
|
||||||
for e in self.get('payments'):
|
for e in self.get('payments'):
|
||||||
if e.invoice_number and e.allocated_amount:
|
if e.invoice_number and e.allocated_amount:
|
||||||
@@ -127,11 +127,11 @@ class PaymentReconciliation(Document):
|
|||||||
'unadjusted_amount' : flt(e.amount),
|
'unadjusted_amount' : flt(e.amount),
|
||||||
'allocated_amount' : flt(e.allocated_amount)
|
'allocated_amount' : flt(e.allocated_amount)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if lst:
|
if lst:
|
||||||
from erpnext.accounts.utils import reconcile_against_document
|
from erpnext.accounts.utils import reconcile_against_document
|
||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst)
|
||||||
|
|
||||||
msgprint(_("Successfully Reconciled"))
|
msgprint(_("Successfully Reconciled"))
|
||||||
self.get_unreconciled_entries()
|
self.get_unreconciled_entries()
|
||||||
|
|
||||||
|
|||||||
@@ -959,11 +959,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