Merge pull request #4047 from nabinhait/payment_reco

[fix] Get outstanding invoices in Payment Reconciliation and Payment Tool
This commit is contained in:
Anand Doshi 2015-09-22 12:55:27 +05:30
commit aa95a1b1ef
3 changed files with 13 additions and 7 deletions

View File

@ -70,7 +70,7 @@ class PaymentReconciliation(Document):
non_reconciled_invoices = []
dr_or_cr = "debit" if self.party_type == "Customer" else "credit"
cond = self.check_condition(dr_or_cr)
invoice_list = frappe.db.sql("""
select
voucher_no, voucher_type, posting_date,
@ -79,8 +79,12 @@ class PaymentReconciliation(Document):
`tabGL Entry`
where
party_type = %(party_type)s and party = %(party)s
and voucher_type != "Journal Entry"
and account = %(account)s and {dr_or_cr} > 0 {cond}
and (CASE
WHEN voucher_type = 'Journal Entry'
THEN ifnull(against_voucher, '') = ''
ELSE 1=1
END)
group by voucher_type, voucher_no
""".format(**{
"cond": cond,

View File

@ -71,7 +71,7 @@ def get_outstanding_vouchers(args):
# Get all outstanding sales /purchase invoices
outstanding_invoices = get_outstanding_invoices(amount_query, args.get("party_account"),
args.get("party_type"), args.get("party"), with_journal_entry=False)
args.get("party_type"), args.get("party"))
# Get all SO / PO which are not fully billed or aginst which full advance not paid
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"),

View File

@ -397,7 +397,7 @@ def get_stock_rbnb_difference(posting_date, company):
# Amount should be credited
return flt(stock_rbnb) + flt(sys_bal)
def get_outstanding_invoices(amount_query, account, party_type, party, with_journal_entry=True):
def get_outstanding_invoices(amount_query, account, party_type, party):
all_outstanding_vouchers = []
outstanding_voucher_list = frappe.db.sql("""
select
@ -407,6 +407,11 @@ def get_outstanding_invoices(amount_query, account, party_type, party, with_jour
`tabGL Entry`
where
account = %s and party_type=%s and party=%s and {amount_query} > 0
and (CASE
WHEN voucher_type = 'Journal Entry'
THEN ifnull(against_voucher, '') = ''
ELSE 1=1
END)
group by voucher_type, voucher_no
""".format(amount_query = amount_query), (account, party_type, party), as_dict = True)
@ -425,9 +430,6 @@ def get_outstanding_invoices(amount_query, account, party_type, party, with_jour
payment_amount = -1*payment_amount[0][0] if payment_amount else 0
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
if not with_journal_entry and d.voucher_type=="Journal Entry":
continue
if d.invoice_amount > payment_amount:
all_outstanding_vouchers.append({