mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
[report] Accounts Receivable / Payable in multi currency
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from frappe.utils import getdate, nowdate, flt, cint
|
from frappe.utils import getdate, nowdate, flt, cint, cstr
|
||||||
|
|
||||||
class ReceivablePayableReport(object):
|
class ReceivablePayableReport(object):
|
||||||
def __init__(self, filters=None):
|
def __init__(self, filters=None):
|
||||||
@@ -30,19 +30,37 @@ class ReceivablePayableReport(object):
|
|||||||
if args.get("party_type") == "Supplier":
|
if args.get("party_type") == "Supplier":
|
||||||
columns += [_("Bill No") + "::80", _("Bill Date") + ":Date:80"]
|
columns += [_("Bill No") + "::80", _("Bill Date") + ":Date:80"]
|
||||||
|
|
||||||
columns += [_("Invoiced Amount") + ":Currency:100", _("Paid Amount") + ":Currency:100",
|
for label in ("Invoiced Amount", "Paid Amount", "Outstanding Amount"):
|
||||||
_("Outstanding Amount") + ":Currency:100", _("Age") + ":Int:50",
|
columns.append({
|
||||||
"0-" + str(self.filters.range1) + ":Currency:100",
|
"label": label,
|
||||||
str(self.filters.range1) + "-" + str(self.filters.range2) + ":Currency:100",
|
"fieldtype": "Currency",
|
||||||
str(self.filters.range2) + "-" + str(self.filters.range3) + ":Currency:100",
|
"options": "currency",
|
||||||
str(self.filters.range3) + _("-Above") + ":Currency:100"
|
"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":
|
if args.get("party_type") == "Customer":
|
||||||
columns += [_("Territory") + ":Link/Territory:80"]
|
columns += [_("Territory") + ":Link/Territory:80"]
|
||||||
if args.get("party_type") == "Supplier":
|
if args.get("party_type") == "Supplier":
|
||||||
columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
|
columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
|
||||||
columns += [_("Remarks") + "::200"]
|
columns += [{
|
||||||
|
"fieldname": "currency",
|
||||||
|
"label": _("Currency"),
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 100,
|
||||||
|
}, _("Remarks") + "::200"]
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
@@ -91,10 +109,11 @@ class ReceivablePayableReport(object):
|
|||||||
|
|
||||||
# customer territory / supplier type
|
# customer territory / supplier type
|
||||||
if args.get("party_type") == "Customer":
|
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":
|
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)
|
data.append(row)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@@ -171,10 +190,17 @@ class ReceivablePayableReport(object):
|
|||||||
def get_gl_entries(self, party_type):
|
def get_gl_entries(self, party_type):
|
||||||
if not hasattr(self, "gl_entries"):
|
if not hasattr(self, "gl_entries"):
|
||||||
conditions, values = self.prepare_conditions(party_type)
|
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`
|
if self.filters.get(scrub(party_type)):
|
||||||
where docstatus < 2 and party_type=%s {0} order by posting_date, party"""
|
select_fields = ", debit_in_account_currency as debit, credit_in_account_currency as credit"
|
||||||
.format(conditions), values, as_dict=True)
|
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
|
return self.gl_entries
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user