fixed accounts receivable for customer name

This commit is contained in:
Akhilesh Darjee 2014-01-03 12:44:00 +05:30
parent 5fbb757c2c
commit b0a9581e59

View File

@ -18,16 +18,23 @@ class AccountsReceivableReport(object):
return self.get_columns(), self.get_data()
def get_columns(self):
return [
columns = [
"Posting Date:Date:80", "Account:Link/Account:150",
"Voucher Type::110", "Voucher No::120", "::30",
"Due Date:Date:80",
"Invoiced Amount:Currency:100", "Payment Received:Currency:100",
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100",
"Customer:Link/Customer:200", "Territory:Link/Territory:80", "Remarks::200"
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
naming_by = self.get_selling_settings()
if naming_by[0].value == "Naming Series":
columns += ["Customer:Link/Customer:200"]
columns += ["Customer Name::110", "Territory:Link/Territory:80", "Remarks::200"]
return columns
def get_data(self):
data = []
future_vouchers = self.get_entries_after(self.filters.report_date)
@ -42,10 +49,15 @@ class AccountsReceivableReport(object):
gle.voucher_type, gle.voucher_no, due_date,
invoiced_amount, payment_received,
outstanding_amount]
entry_date = due_date if self.filters.ageing_based_on=="Due Date" \
entry_date = due_date if self.filters.ageing_based_on == "Due Date" \
else gle.posting_date
row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount)
row += [self.get_customer(gle.account), self.get_territory(gle.account), gle.remarks]
naming_by = self.get_selling_settings()
if naming_by[0].value == "Naming Series":
row += [self.get_customer(gle.account)]
row += [self.get_customer_name(gle.account), self.get_territory(gle.account), gle.remarks]
data.append(row)
for i in range(0,len(data)):
@ -53,7 +65,11 @@ class AccountsReceivableReport(object):
% ("/".join(["#Form", data[i][2], data[i][3]]),))
return data
def get_selling_settings(self):
return webnotes.conn.sql("""select value from `tabSingles` where
doctype='Selling Settings' and field='cust_master_name'""", as_dict=1)
def get_entries_after(self, report_date):
# returns a distinct list
return list(set([(e.voucher_type, e.voucher_no) for e in self.get_gl_entries()
@ -77,18 +93,21 @@ class AccountsReceivableReport(object):
return flt(gle.debit) - flt(gle.credit) - payment_received
def get_customer(self, account):
return self.get_account_map().get(account).get("customer") or ""
def get_customer_name(self, account):
return self.get_account_map().get(account).get("customer_name") or ""
def get_territory(self, account):
return self.get_account_map().get(account).get("territory") or ""
def get_account_map(self):
if not hasattr(self, "account_map"):
self.account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select
account.name, customer.name as customer_name, customer.territory
from `tabAccount` account, `tabCustomer` customer
where account.master_type="Customer"
and customer.name=account.master_name""", as_dict=True)))
acc.name, cust.name as customer, cust.customer_name, cust.territory
from `tabAccount` acc, `tabCustomer` cust
where acc.master_type="Customer"
and cust.name=acc.master_name""", as_dict=True)))
return self.account_map
@ -164,4 +183,4 @@ def get_ageing_data(age_as_on, entry_date, outstanding_amount):
if index is None: index = 3
outstanding_range[index] = outstanding_amount
return [age] + outstanding_range
return [age] + outstanding_range