fix(expense claim): fetch outstanding documents based on party account type
This commit is contained in:
parent
3f854fce2e
commit
9db9edca2c
@ -630,7 +630,7 @@ def get_held_invoices(party_type, party):
|
|||||||
'select name from `tabPurchase Invoice` where release_date IS NOT NULL and release_date > CURDATE()',
|
'select name from `tabPurchase Invoice` where release_date IS NOT NULL and release_date > CURDATE()',
|
||||||
as_dict=1
|
as_dict=1
|
||||||
)
|
)
|
||||||
held_invoices = [d['name'] for d in held_invoices]
|
held_invoices = set([d['name'] for d in held_invoices])
|
||||||
|
|
||||||
return held_invoices
|
return held_invoices
|
||||||
|
|
||||||
@ -639,14 +639,19 @@ def get_outstanding_invoices(party_type, party, account, condition=None, filters
|
|||||||
outstanding_invoices = []
|
outstanding_invoices = []
|
||||||
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
|
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
|
||||||
|
|
||||||
if erpnext.get_party_account_type(party_type) == 'Receivable':
|
if account:
|
||||||
|
root_type = frappe.get_cached_value("Account", account, "root_type")
|
||||||
|
party_account_type = "Receivable" if root_type == "Asset" else "Payable"
|
||||||
|
else:
|
||||||
|
party_account_type = erpnext.get_party_account_type(party_type)
|
||||||
|
|
||||||
|
if party_account_type == 'Receivable':
|
||||||
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
||||||
payment_dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
payment_dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
||||||
else:
|
else:
|
||||||
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
|
||||||
payment_dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
payment_dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
invoice_list = frappe.db.sql("""
|
invoice_list = frappe.db.sql("""
|
||||||
@ -665,7 +670,6 @@ def get_outstanding_invoices(party_type, party, account, condition=None, filters
|
|||||||
group by voucher_type, voucher_no
|
group by voucher_type, voucher_no
|
||||||
order by posting_date, name""".format(
|
order by posting_date, name""".format(
|
||||||
dr_or_cr=dr_or_cr,
|
dr_or_cr=dr_or_cr,
|
||||||
invoice = invoice,
|
|
||||||
condition=condition or ""
|
condition=condition or ""
|
||||||
), {
|
), {
|
||||||
"party_type": party_type,
|
"party_type": party_type,
|
||||||
|
@ -140,32 +140,6 @@ class ExpenseClaim(AccountsController):
|
|||||||
"against": ",".join([d.default_account for d in self.expenses]),
|
"against": ",".join([d.default_account for d in self.expenses]),
|
||||||
"party_type": "Employee",
|
"party_type": "Employee",
|
||||||
"party": self.employee,
|
"party": self.employee,
|
||||||
"against_voucher_type": self.doctype,
|
|
||||||
"against_voucher": self.name
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
gl_entry.append(
|
|
||||||
self.get_gl_dict({
|
|
||||||
"account": data.advance_account,
|
|
||||||
"debit": data.allocated_amount,
|
|
||||||
"debit_in_account_currency": data.allocated_amount,
|
|
||||||
"against": self.payable_account,
|
|
||||||
"party_type": "Employee",
|
|
||||||
"party": self.employee,
|
|
||||||
"against_voucher_type": self.doctype,
|
|
||||||
"against_voucher": self.name
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
gl_entry.append(
|
|
||||||
self.get_gl_dict({
|
|
||||||
"account": self.payable_account,
|
|
||||||
"credit": data.allocated_amount,
|
|
||||||
"credit_in_account_currency": data.allocated_amount,
|
|
||||||
"against": data.advance_account,
|
|
||||||
"party_type": "Employee",
|
|
||||||
"party": self.employee,
|
|
||||||
"against_voucher_type": "Employee Advance",
|
"against_voucher_type": "Employee Advance",
|
||||||
"against_voucher": data.employee_advance
|
"against_voucher": data.employee_advance
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user