Merge pull request #4047 from nabinhait/payment_reco
[fix] Get outstanding invoices in Payment Reconciliation and Payment Tool
This commit is contained in:
commit
aa95a1b1ef
@ -70,7 +70,7 @@ class PaymentReconciliation(Document):
|
|||||||
non_reconciled_invoices = []
|
non_reconciled_invoices = []
|
||||||
dr_or_cr = "debit" if self.party_type == "Customer" else "credit"
|
dr_or_cr = "debit" if self.party_type == "Customer" else "credit"
|
||||||
cond = self.check_condition(dr_or_cr)
|
cond = self.check_condition(dr_or_cr)
|
||||||
|
|
||||||
invoice_list = frappe.db.sql("""
|
invoice_list = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
voucher_no, voucher_type, posting_date,
|
voucher_no, voucher_type, posting_date,
|
||||||
@ -79,8 +79,12 @@ class PaymentReconciliation(Document):
|
|||||||
`tabGL Entry`
|
`tabGL Entry`
|
||||||
where
|
where
|
||||||
party_type = %(party_type)s and party = %(party)s
|
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 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
|
group by voucher_type, voucher_no
|
||||||
""".format(**{
|
""".format(**{
|
||||||
"cond": cond,
|
"cond": cond,
|
||||||
|
@ -71,7 +71,7 @@ def get_outstanding_vouchers(args):
|
|||||||
|
|
||||||
# Get all outstanding sales /purchase invoices
|
# Get all outstanding sales /purchase invoices
|
||||||
outstanding_invoices = get_outstanding_invoices(amount_query, args.get("party_account"),
|
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
|
# 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"),
|
orders_to_be_billed = get_orders_to_be_billed(args.get("party_type"), args.get("party"),
|
||||||
|
@ -397,7 +397,7 @@ def get_stock_rbnb_difference(posting_date, company):
|
|||||||
# Amount should be credited
|
# Amount should be credited
|
||||||
return flt(stock_rbnb) + flt(sys_bal)
|
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 = []
|
all_outstanding_vouchers = []
|
||||||
outstanding_voucher_list = frappe.db.sql("""
|
outstanding_voucher_list = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
@ -407,6 +407,11 @@ def get_outstanding_invoices(amount_query, account, party_type, party, with_jour
|
|||||||
`tabGL Entry`
|
`tabGL Entry`
|
||||||
where
|
where
|
||||||
account = %s and party_type=%s and party=%s and {amount_query} > 0
|
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
|
group by voucher_type, voucher_no
|
||||||
""".format(amount_query = amount_query), (account, party_type, party), as_dict = True)
|
""".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
|
payment_amount = -1*payment_amount[0][0] if payment_amount else 0
|
||||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
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:
|
if d.invoice_amount > payment_amount:
|
||||||
|
|
||||||
all_outstanding_vouchers.append({
|
all_outstanding_vouchers.append({
|
||||||
|
Loading…
Reference in New Issue
Block a user