[report] Accounts Receivable / Payable in multi currency
This commit is contained in:
parent
06b15bfd63
commit
699751c531
@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _, scrub
|
||||
from frappe.utils import getdate, nowdate, flt, cint
|
||||
from frappe.utils import getdate, nowdate, flt, cint, cstr
|
||||
|
||||
class ReceivablePayableReport(object):
|
||||
def __init__(self, filters=None):
|
||||
@ -30,19 +30,37 @@ class ReceivablePayableReport(object):
|
||||
if args.get("party_type") == "Supplier":
|
||||
columns += [_("Bill No") + "::80", _("Bill Date") + ":Date:80"]
|
||||
|
||||
columns += [_("Invoiced Amount") + ":Currency:100", _("Paid Amount") + ":Currency:100",
|
||||
_("Outstanding Amount") + ":Currency:100", _("Age") + ":Int:50",
|
||||
"0-" + str(self.filters.range1) + ":Currency:100",
|
||||
str(self.filters.range1) + "-" + str(self.filters.range2) + ":Currency:100",
|
||||
str(self.filters.range2) + "-" + str(self.filters.range3) + ":Currency:100",
|
||||
str(self.filters.range3) + _("-Above") + ":Currency:100"
|
||||
]
|
||||
for label in ("Invoiced Amount", "Paid Amount", "Outstanding Amount"):
|
||||
columns.append({
|
||||
"label": label,
|
||||
"fieldtype": "Currency",
|
||||
"options": "currency",
|
||||
"width": 120
|
||||
})
|
||||
|
||||
columns += [_("Age (Days)") + "::80"]
|
||||
|
||||
for label in ("0-" + cstr(self.filters.range1),
|
||||
cstr(self.filters.range1) + "-" + cstr(self.filters.range2),
|
||||
cstr(self.filters.range2) + "-" +cstr(self.filters.range3),
|
||||
cstr(self.filters.range3) + _("-Above")):
|
||||
columns.append({
|
||||
"label": label,
|
||||
"fieldtype": "Currency",
|
||||
"options": "currency",
|
||||
"width": 120
|
||||
})
|
||||
|
||||
if args.get("party_type") == "Customer":
|
||||
columns += [_("Territory") + ":Link/Territory:80"]
|
||||
if args.get("party_type") == "Supplier":
|
||||
columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
|
||||
columns += [_("Remarks") + "::200"]
|
||||
columns += [{
|
||||
"fieldname": "currency",
|
||||
"label": _("Currency"),
|
||||
"fieldtype": "Data",
|
||||
"width": 100,
|
||||
}, _("Remarks") + "::200"]
|
||||
|
||||
return columns
|
||||
|
||||
@ -91,10 +109,11 @@ class ReceivablePayableReport(object):
|
||||
|
||||
# customer territory / supplier type
|
||||
if args.get("party_type") == "Customer":
|
||||
row += [self.get_territory(gle.party), gle.remarks]
|
||||
row += [self.get_territory(gle.party)]
|
||||
if args.get("party_type") == "Supplier":
|
||||
row += [self.get_supplier_type(gle.party), gle.remarks]
|
||||
row += [self.get_supplier_type(gle.party)]
|
||||
|
||||
row += [gle.account_currency, gle.remarks]
|
||||
data.append(row)
|
||||
|
||||
return data
|
||||
@ -171,10 +190,17 @@ class ReceivablePayableReport(object):
|
||||
def get_gl_entries(self, party_type):
|
||||
if not hasattr(self, "gl_entries"):
|
||||
conditions, values = self.prepare_conditions(party_type)
|
||||
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party, debit, credit,
|
||||
voucher_type, voucher_no, against_voucher_type, against_voucher from `tabGL Entry`
|
||||
where docstatus < 2 and party_type=%s {0} order by posting_date, party"""
|
||||
.format(conditions), values, as_dict=True)
|
||||
|
||||
if self.filters.get(scrub(party_type)):
|
||||
select_fields = ", debit_in_account_currency as debit, credit_in_account_currency as credit"
|
||||
else:
|
||||
select_fields = ", debit, credit"
|
||||
|
||||
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
|
||||
voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks {0}
|
||||
from `tabGL Entry`
|
||||
where docstatus < 2 and party_type=%s {1} order by posting_date, party"""
|
||||
.format(select_fields, conditions), values, as_dict=True)
|
||||
|
||||
return self.gl_entries
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user