Merge pull request #530 from akhileshdarjee/master
[Report] Added rounded_total & outstanding_amount to Sales & Purchase Register
This commit is contained in:
commit
329a3df260
@ -38,11 +38,12 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for inv in invoice_list:
|
for inv in invoice_list:
|
||||||
# invoice details
|
# invoice details
|
||||||
purchase_order = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", []))
|
purchase_order = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", [])))
|
||||||
purchase_receipt = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))
|
purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", [])))
|
||||||
|
|
||||||
row = [inv.name, inv.posting_date, inv.supplier, inv.credit_to,
|
row = [inv.name, inv.posting_date, inv.supplier, inv.credit_to,
|
||||||
account_map.get(inv.credit_to), inv.project_name, inv.bill_no, inv.bill_date,
|
account_map.get(inv.credit_to), inv.project_name, inv.bill_no, inv.bill_date,
|
||||||
inv.remarks, purchase_order, purchase_receipt]
|
inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)]
|
||||||
|
|
||||||
# map expense values
|
# map expense values
|
||||||
for expense_acc in expense_accounts:
|
for expense_acc in expense_accounts:
|
||||||
@ -55,8 +56,9 @@ def execute(filters=None):
|
|||||||
for tax_acc in tax_accounts:
|
for tax_acc in tax_accounts:
|
||||||
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
|
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
|
||||||
|
|
||||||
# total tax, grand total
|
# total tax, grand total, outstanding amount & rounded total
|
||||||
row += [inv.total_tax, inv.grand_total]
|
row += [inv.other_charges_total, inv.grand_total, flt(inv.grand_total, 2), \
|
||||||
|
inv.outstanding_amount]
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
@ -85,7 +87,8 @@ def get_columns(invoice_list):
|
|||||||
|
|
||||||
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
|
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
|
||||||
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
||||||
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
|
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
|
||||||
|
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
|
||||||
|
|
||||||
return columns, expense_accounts, tax_accounts
|
return columns, expense_accounts, tax_accounts
|
||||||
|
|
||||||
@ -102,9 +105,11 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_invoices(filters):
|
def get_invoices(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return webnotes.conn.sql("""select name, posting_date, credit_to, project_name, supplier,
|
return webnotes.conn.sql("""select pi.name, pi.posting_date, pi.credit_to,
|
||||||
bill_no, bill_date, remarks, net_total, total_tax, grand_total
|
pii.project_name, pi.supplier, pi.bill_no, pi.bill_date, pi.remarks, pi.net_total,
|
||||||
from `tabPurchase Invoice` where docstatus = 1 %s
|
pi.total_tax, pi.grand_total, pi.outstanding_amount
|
||||||
|
from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii
|
||||||
|
where pii.parent = pi.name and pi.docstatus = 1 %s
|
||||||
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for inv in invoice_list:
|
for inv in invoice_list:
|
||||||
# invoice details
|
# invoice details
|
||||||
sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", []))
|
sales_order = list(set(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])))
|
||||||
delivery_note = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", []))
|
delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])))
|
||||||
|
|
||||||
row = [inv.name, inv.posting_date, inv.customer, inv.debit_to,
|
row = [inv.name, inv.posting_date, inv.customer, inv.debit_to,
|
||||||
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
|
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
|
||||||
inv.remarks, sales_order, delivery_note]
|
inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
|
||||||
|
|
||||||
# map income values
|
# map income values
|
||||||
for income_acc in income_accounts:
|
for income_acc in income_accounts:
|
||||||
@ -57,8 +57,8 @@ def execute(filters=None):
|
|||||||
for tax_acc in tax_accounts:
|
for tax_acc in tax_accounts:
|
||||||
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
|
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
|
||||||
|
|
||||||
# total tax, grand total
|
# total tax, grand total, outstanding amount & rounded total
|
||||||
row += [inv.other_charges_total, inv.grand_total]
|
row += [inv.other_charges_total, inv.grand_total, inv.rounded_total, inv.outstanding_amount]
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
@ -88,7 +88,8 @@ def get_columns(invoice_list):
|
|||||||
|
|
||||||
columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
|
columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
|
||||||
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
||||||
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
|
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
|
||||||
|
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
|
||||||
|
|
||||||
return columns, income_accounts, tax_accounts
|
return columns, income_accounts, tax_accounts
|
||||||
|
|
||||||
@ -106,7 +107,8 @@ def get_conditions(filters):
|
|||||||
def get_invoices(filters):
|
def get_invoices(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
|
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
|
||||||
remarks, net_total, other_charges_total, grand_total from `tabSales Invoice`
|
remarks, net_total, other_charges_total, grand_total, rounded_total,
|
||||||
|
outstanding_amount from `tabSales Invoice`
|
||||||
where docstatus = 1 %s order by posting_date desc, name desc""" %
|
where docstatus = 1 %s order by posting_date desc, name desc""" %
|
||||||
conditions, filters, as_dict=1)
|
conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user