mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
Fixed merge conflict
This commit is contained in:
@@ -571,11 +571,12 @@ def get_stock_rbnb_difference(posting_date, company):
|
||||
# Amount should be credited
|
||||
return flt(stock_rbnb) + flt(sys_bal)
|
||||
|
||||
|
||||
def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
outstanding_invoices = []
|
||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
|
||||
|
||||
if party_type=="Customer":
|
||||
if party_type == "Customer":
|
||||
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
||||
payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
|
||||
else:
|
||||
@@ -585,12 +586,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
invoice = 'Sales Invoice' if party_type == 'Customer' else 'Purchase Invoice'
|
||||
invoice_list = frappe.db.sql("""
|
||||
select
|
||||
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount,
|
||||
(
|
||||
case when (voucher_type = 'Sales Invoice' or voucher_type = 'Purchase Invoice')
|
||||
then (select due_date from `tab{invoice}` where name = voucher_no)
|
||||
else posting_date end
|
||||
) as due_date,
|
||||
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount, due_date,
|
||||
(
|
||||
select ifnull(sum({payment_dr_or_cr}), 0)
|
||||
from `tabGL Entry` payment_gl_entry
|
||||
@@ -601,6 +597,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
and payment_gl_entry.party_type = invoice_gl_entry.party_type
|
||||
and payment_gl_entry.party = invoice_gl_entry.party
|
||||
and payment_gl_entry.account = invoice_gl_entry.account
|
||||
and payment_gl_entry.due_date = invoice_gl_entry.due_date
|
||||
and {payment_dr_or_cr} > 0
|
||||
) as payment_amount
|
||||
from
|
||||
@@ -612,13 +609,13 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
and ((voucher_type = 'Journal Entry'
|
||||
and (against_voucher = '' or against_voucher is null))
|
||||
or (voucher_type not in ('Journal Entry', 'Payment Entry')))
|
||||
group by voucher_type, voucher_no
|
||||
group by voucher_type, voucher_no, due_date
|
||||
having (invoice_amount - payment_amount) > 0.005
|
||||
order by posting_date, name""".format(
|
||||
dr_or_cr = dr_or_cr,
|
||||
invoice = invoice,
|
||||
payment_dr_or_cr = payment_dr_or_cr,
|
||||
condition = condition or ""
|
||||
order by posting_date, name, due_date""".format(
|
||||
dr_or_cr=dr_or_cr,
|
||||
invoice=invoice,
|
||||
payment_dr_or_cr=payment_dr_or_cr,
|
||||
condition=condition or ""
|
||||
), {
|
||||
"party_type": party_type,
|
||||
"party": party,
|
||||
@@ -626,17 +623,24 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
}, as_dict=True)
|
||||
|
||||
for d in invoice_list:
|
||||
outstanding_invoices.append(frappe._dict({
|
||||
'voucher_no': d.voucher_no,
|
||||
'voucher_type': d.voucher_type,
|
||||
'due_date': d.due_date,
|
||||
'posting_date': d.posting_date,
|
||||
'invoice_amount': flt(d.invoice_amount),
|
||||
'payment_amount': flt(d.payment_amount),
|
||||
'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision),
|
||||
'due_date': frappe.db.get_value(d.voucher_type, d.voucher_no,
|
||||
"posting_date" if party_type=="Employee" else "due_date"),
|
||||
}))
|
||||
due_date = d.due_date or (
|
||||
frappe.db.get_value(
|
||||
d.voucher_type, d.voucher_no,
|
||||
"posting_date" if party_type == "Employee" else "due_date"
|
||||
)
|
||||
)
|
||||
|
||||
outstanding_invoices.append(
|
||||
frappe._dict({
|
||||
'voucher_no': d.voucher_no,
|
||||
'voucher_type': d.voucher_type,
|
||||
'posting_date': d.posting_date,
|
||||
'invoice_amount': flt(d.invoice_amount),
|
||||
'payment_amount': flt(d.payment_amount),
|
||||
'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision),
|
||||
'due_date': due_date
|
||||
})
|
||||
)
|
||||
|
||||
outstanding_invoices = sorted(outstanding_invoices, key=lambda k: k['due_date'] or getdate(nowdate()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user