accounts payable fixed
This commit is contained in:
parent
bd4030bf85
commit
7e79f300a1
@ -9,18 +9,20 @@ from accounts.report.accounts_receivable.accounts_receivable import get_ageing_d
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
columns = get_columns()
|
||||
supplier_naming_by = webnotes.conn.get_value("Buying Settings", None, "supp_master_name")
|
||||
columns = get_columns(supplier_naming_by)
|
||||
entries = get_gl_entries(filters)
|
||||
account_supplier = dict(webnotes.conn.sql("""select account.name, supplier.supplier_name
|
||||
from `tabAccount` account, `tabSupplier` supplier
|
||||
where account.master_type="Supplier" and supplier.name=account.master_name"""))
|
||||
|
||||
account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select acc.name,
|
||||
supp.supplier_name, supp.name as supplier
|
||||
from `tabAccount` acc, `tabSupplier` supp
|
||||
where acc.master_type="Supplier" and supp.name=acc.master_name""", as_dict=1)))
|
||||
|
||||
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
|
||||
for gle in get_gl_entries(filters, before_report_date=False)]
|
||||
|
||||
|
||||
account_supplier_type_map = get_account_supplier_type_map()
|
||||
voucher_detail_map = get_voucher_details()
|
||||
|
||||
|
||||
# Age of the invoice on this date
|
||||
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
|
||||
and nowdate() or filters.get("report_date")
|
||||
@ -37,9 +39,7 @@ def execute(filters=None):
|
||||
|
||||
if abs(flt(outstanding_amount)) > 0.01:
|
||||
paid_amount = invoiced_amount - outstanding_amount
|
||||
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""),
|
||||
gle.voucher_type, gle.voucher_no, gle.remarks,
|
||||
account_supplier_type_map.get(gle.account),
|
||||
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
||||
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
|
||||
voucher_details.get("bill_date", ""), invoiced_amount,
|
||||
paid_amount, outstanding_amount]
|
||||
@ -50,21 +50,38 @@ def execute(filters=None):
|
||||
else:
|
||||
ageing_based_on_date = gle.posting_date
|
||||
|
||||
row += get_ageing_data(age_on, ageing_based_on_date, outstanding_amount)
|
||||
row += get_ageing_data(age_on, ageing_based_on_date, outstanding_amount) + \
|
||||
[account_map.get(gle.account).get("supplier") or ""]
|
||||
|
||||
if supplier_naming_by == "Naming Series":
|
||||
row += [account_map.get(gle.account).get("supplier_name") or ""]
|
||||
|
||||
row += [account_supplier_type_map.get(gle.account), gle.remarks]
|
||||
data.append(row)
|
||||
|
||||
|
||||
for i in range(0, len(data)):
|
||||
data[i].insert(4, """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
|
||||
% ("/".join(["#Form", data[i][2], data[i][3]]),))
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
"Posting Date:Date:80", "Account:Link/Account:150", "Supplier::150", "Voucher Type::110",
|
||||
"Voucher No::120", "Remarks::150", "Supplier Type:Link/Supplier Type:120",
|
||||
"Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
|
||||
def get_columns(supplier_naming_by):
|
||||
columns = [
|
||||
"Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110",
|
||||
"Voucher No::120", "::30", "Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
|
||||
"Invoiced Amount:Currency:100", "Paid Amount: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"
|
||||
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100",
|
||||
"Supplier:Link/Supplier:150"
|
||||
]
|
||||
|
||||
|
||||
if supplier_naming_by == "Naming Series":
|
||||
columns += ["Supplier Name::110"]
|
||||
|
||||
columns += ["Supplier Type:Link/Supplier Type:120", "Remarks::150"]
|
||||
|
||||
return columns
|
||||
|
||||
def get_gl_entries(filters, before_report_date=True):
|
||||
conditions, supplier_accounts = get_conditions(filters, before_report_date)
|
||||
gl_entries = []
|
||||
@ -102,10 +119,10 @@ def get_conditions(filters, before_report_date=True):
|
||||
|
||||
def get_account_supplier_type_map():
|
||||
account_supplier_type_map = {}
|
||||
for each in webnotes.conn.sql("""select t2.name, t1.supplier_type from `tabSupplier` t1,
|
||||
`tabAccount` t2 where t1.name = t2.master_name group by t2.name"""):
|
||||
for each in webnotes.conn.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
|
||||
`tabAccount` acc where supp.name = acc.master_name group by acc.name"""):
|
||||
account_supplier_type_map[each[0]] = each[1]
|
||||
|
||||
|
||||
return account_supplier_type_map
|
||||
|
||||
def get_voucher_details():
|
||||
|
Loading…
Reference in New Issue
Block a user