Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
672cb0c02b
@ -154,6 +154,11 @@ wn.module_page["Accounts"] = [
|
|||||||
route: "query-report/Sales Register",
|
route: "query-report/Sales Register",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label":wn._("Purchase Register"),
|
||||||
|
route: "query-report/Purchase Register",
|
||||||
|
doctype: "Purchase Invoice"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,6 @@ def execute(filters=None):
|
|||||||
and nowdate() or filters.get("report_date")
|
and nowdate() or filters.get("report_date")
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
total_invoiced_amount = total_paid = total_outstanding = 0
|
|
||||||
for gle in entries:
|
for gle in entries:
|
||||||
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
||||||
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
||||||
@ -47,16 +46,9 @@ def execute(filters=None):
|
|||||||
ageing_based_on_date = due_date
|
ageing_based_on_date = due_date
|
||||||
else:
|
else:
|
||||||
ageing_based_on_date = gle.posting_date
|
ageing_based_on_date = gle.posting_date
|
||||||
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
|
|
||||||
|
|
||||||
# Add to total
|
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
|
||||||
total_invoiced_amount += flt(invoiced_amount)
|
|
||||||
total_paid += flt(paid_amount)
|
|
||||||
total_outstanding += flt(outstanding_amount)
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
if data:
|
|
||||||
data.append(["", "", "", "", "", "", "", "Total", "", total_invoiced_amount, total_paid,
|
|
||||||
total_outstanding, "", "", "", ""])
|
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-04-22 16:16:03",
|
"creation": "2013-04-22 16:16:03",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-04-23 14:54:27",
|
"modified": "2013-04-30 17:55:54",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"add_total_row": 1,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
|
@ -18,7 +18,6 @@ def execute(filters=None):
|
|||||||
and nowdate() or filters.get("report_date")
|
and nowdate() or filters.get("report_date")
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
total_invoiced_amount = total_payment = total_outstanding = 0
|
|
||||||
for gle in entries:
|
for gle in entries:
|
||||||
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
||||||
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
||||||
@ -42,15 +41,7 @@ def execute(filters=None):
|
|||||||
ageing_based_on_date = gle.posting_date
|
ageing_based_on_date = gle.posting_date
|
||||||
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
|
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
|
||||||
|
|
||||||
# Add to total
|
|
||||||
total_invoiced_amount += flt(invoiced_amount)
|
|
||||||
total_payment += flt(payment_amount)
|
|
||||||
total_outstanding += flt(outstanding_amount)
|
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
if data:
|
|
||||||
data.append(["", "", "", "", "", "", "Total", total_invoiced_amount, total_payment,
|
|
||||||
total_outstanding, "", "", "", ""])
|
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-04-16 11:31:13",
|
"creation": "2013-04-16 11:31:13",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-04-16 11:31:13",
|
"modified": "2013-04-30 17:54:47",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"add_total_row": 1,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
|
0
accounts/report/purchase_register/__init__.py
Normal file
0
accounts/report/purchase_register/__init__.py
Normal file
42
accounts/report/purchase_register/purchase_register.js
Normal file
42
accounts/report/purchase_register/purchase_register.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
wn.query_reports["Purchase Register"] = {
|
||||||
|
"filters": [
|
||||||
|
{
|
||||||
|
"fieldname":"from_date",
|
||||||
|
"label": "From Date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"default": wn.defaults.get_user_default("year_start_date"),
|
||||||
|
"width": "80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"to_date",
|
||||||
|
"label": "To Date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"default": get_today()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"account",
|
||||||
|
"label": "Account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"get_query": function() {
|
||||||
|
var company = wn.query_report.filters_by_name.company.get_value();
|
||||||
|
return {
|
||||||
|
"query": "accounts.utils.get_account_list",
|
||||||
|
"filters": {
|
||||||
|
"is_pl_account": "No",
|
||||||
|
"debit_or_credit": "Credit",
|
||||||
|
"company": company,
|
||||||
|
"master_type": "Supplier"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"company",
|
||||||
|
"label": "Company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"default": sys_defaults.company
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
147
accounts/report/purchase_register/purchase_register.py
Normal file
147
accounts/report/purchase_register/purchase_register.py
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
# ERPNext - web based ERP (http://erpnext.com)
|
||||||
|
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
from webnotes.utils import flt
|
||||||
|
|
||||||
|
def execute(filters=None):
|
||||||
|
if not filters: filters = {}
|
||||||
|
columns, expense_accounts, tax_accounts = get_columns()
|
||||||
|
|
||||||
|
invoice_list = get_invoices(filters)
|
||||||
|
invoice_expense_map = get_invoice_expense_map(invoice_list)
|
||||||
|
invoice_tax_map = get_invoice_tax_map(invoice_list)
|
||||||
|
invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
|
||||||
|
account_map = get_account_details(invoice_list)
|
||||||
|
|
||||||
|
data = []
|
||||||
|
for inv in invoice_list:
|
||||||
|
# invoice details
|
||||||
|
purchase_order = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", []))
|
||||||
|
purchase_receipt = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))
|
||||||
|
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,
|
||||||
|
inv.remarks, purchase_order, purchase_receipt]
|
||||||
|
|
||||||
|
# map expense values
|
||||||
|
for expense_acc in expense_accounts:
|
||||||
|
row.append(invoice_expense_map.get(inv.name, {}).get(expense_acc))
|
||||||
|
|
||||||
|
# net total
|
||||||
|
row.append(inv.net_total)
|
||||||
|
|
||||||
|
# tax account
|
||||||
|
for tax_acc in tax_accounts:
|
||||||
|
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
|
||||||
|
|
||||||
|
# total tax, grand total
|
||||||
|
row += [inv.total_tax, inv.grand_total]
|
||||||
|
data.append(row)
|
||||||
|
|
||||||
|
return columns, data
|
||||||
|
|
||||||
|
|
||||||
|
def get_columns():
|
||||||
|
"""return columns based on filters"""
|
||||||
|
columns = [
|
||||||
|
"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier:Link/Supplier:120",
|
||||||
|
"Supplier Account:Link/Account:120", "Account Group:LInk/Account:120",
|
||||||
|
"Project:Link/Project:80", "Bill No::120", "Bill Date:Date:80", "Remarks::150",
|
||||||
|
"Purchase Order:Link/Purchase Order:100", "Purchase Receipt:Link/Purchase Receipt:100"
|
||||||
|
]
|
||||||
|
|
||||||
|
expense_accounts = webnotes.conn.sql_list("""select distinct expense_head
|
||||||
|
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != ''
|
||||||
|
order by expense_head""")
|
||||||
|
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
|
||||||
|
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||||
|
and docstatus = 1 and ifnull(account_head, '') != '' order by account_head""")
|
||||||
|
|
||||||
|
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
|
||||||
|
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
|
||||||
|
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
|
||||||
|
|
||||||
|
return columns, expense_accounts, tax_accounts
|
||||||
|
|
||||||
|
def get_conditions(filters):
|
||||||
|
conditions = ""
|
||||||
|
|
||||||
|
if filters.get("company"): conditions += " and company=%(company)s"
|
||||||
|
if filters.get("account"): conditions += " and account = %(account)s"
|
||||||
|
|
||||||
|
if filters.get("from_date"): conditions += " and posting_date>=%(from_date)s"
|
||||||
|
if filters.get("to_date"): conditions += " and posting_date<=%(to_date)s"
|
||||||
|
|
||||||
|
return conditions
|
||||||
|
|
||||||
|
def get_invoices(filters):
|
||||||
|
conditions = get_conditions(filters)
|
||||||
|
return webnotes.conn.sql("""select name, posting_date, credit_to, project_name, supplier,
|
||||||
|
bill_no, bill_date, remarks, net_total, total_tax, grand_total
|
||||||
|
from `tabPurchase Invoice` where docstatus = 1 %s
|
||||||
|
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
def get_invoice_expense_map(invoice_list):
|
||||||
|
expense_details = webnotes.conn.sql("""select parent, expense_head, sum(amount) as amount
|
||||||
|
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_head""" %
|
||||||
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
|
invoice_expense_map = {}
|
||||||
|
for d in expense_details:
|
||||||
|
invoice_expense_map.setdefault(d.parent, webnotes._dict()).setdefault(d.expense_head, [])
|
||||||
|
invoice_expense_map[d.parent][d.expense_head] = flt(d.amount)
|
||||||
|
|
||||||
|
return invoice_expense_map
|
||||||
|
|
||||||
|
def get_invoice_tax_map(invoice_list):
|
||||||
|
tax_details = webnotes.conn.sql("""select parent, account_head, sum(tax_amount) as tax_amount
|
||||||
|
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||||
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
|
invoice_tax_map = {}
|
||||||
|
for d in tax_details:
|
||||||
|
invoice_tax_map.setdefault(d.parent, webnotes._dict()).setdefault(d.account_head, [])
|
||||||
|
invoice_tax_map[d.parent][d.account_head] = flt(d.tax_amount)
|
||||||
|
|
||||||
|
return invoice_tax_map
|
||||||
|
|
||||||
|
def get_invoice_po_pr_map(invoice_list):
|
||||||
|
pi_items = webnotes.conn.sql("""select parent, purchase_order, purchase_receipt
|
||||||
|
from `tabPurchase Invoice Item` where parent in (%s)
|
||||||
|
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
|
||||||
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
|
invoice_po_pr_map = {}
|
||||||
|
for d in pi_items:
|
||||||
|
if d.purchase_order:
|
||||||
|
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
|
||||||
|
"purchase_order", []).append(d.purchase_order)
|
||||||
|
if d.purchase_receipt:
|
||||||
|
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
|
||||||
|
"purchase_receipt", []).append(d.purchase_receipt)
|
||||||
|
|
||||||
|
return invoice_po_pr_map
|
||||||
|
|
||||||
|
def get_account_details(invoice_list):
|
||||||
|
account_map = {}
|
||||||
|
accounts = list(set([inv.credit_to for inv in invoice_list]))
|
||||||
|
for acc in webnotes.conn.sql("""select name, parent_account from tabAccount
|
||||||
|
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
|
||||||
|
account_map.setdefault(acc.name, "")
|
||||||
|
account_map[acc.name] = acc.parent_account
|
||||||
|
|
||||||
|
return account_map
|
22
accounts/report/purchase_register/purchase_register.txt
Normal file
22
accounts/report/purchase_register/purchase_register.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"creation": "2013-04-29 16:13:11",
|
||||||
|
"docstatus": 0,
|
||||||
|
"modified": "2013-04-30 17:51:19",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"owner": "Administrator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"add_total_row": 1,
|
||||||
|
"doctype": "Report",
|
||||||
|
"is_standard": "Yes",
|
||||||
|
"name": "__common__",
|
||||||
|
"ref_doctype": "Purchase Invoice",
|
||||||
|
"report_name": "Purchase Register",
|
||||||
|
"report_type": "Script Report"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Report",
|
||||||
|
"name": "Purchase Register"
|
||||||
|
}
|
||||||
|
]
|
@ -94,8 +94,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, territory, debit_to, territory,
|
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
|
||||||
project_name, customer, remarks, net_total, other_charges_total, grand_total
|
remarks, net_total, other_charges_total, grand_total
|
||||||
from `tabSales Invoice` where docstatus = 1 %s
|
from `tabSales Invoice` where 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)
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-04-23 18:15:29",
|
"creation": "2013-04-23 18:15:29",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-04-23 18:15:29",
|
"modified": "2013-04-30 17:53:10",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"add_total_row": 1,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
|
@ -1,29 +1,32 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"owner": "Administrator",
|
"creation": "2012-05-14 18:05:41",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"creation": "2012-04-03 12:49:50",
|
"modified": "2013-04-30 14:49:06",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"modified": "2012-04-03 12:49:50"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Bank Clearance report",
|
"columns": "Journal Voucher\u0001ID,Journal Voucher Detail\u0001Account,Journal Voucher Detail\u0001Debit,Journal Voucher Detail\u0001Credit,Journal Voucher\u0001Clearance Date,Journal Voucher\u0001Cheque No,Journal Voucher\u0001Cheque Date,Journal Voucher\u0001Voucher Date,Journal Voucher\u0001Posting Date,Journal Voucher Detail\u0001Against Payable,Journal Voucher Detail\u0001Against Receivable",
|
||||||
"parent_doc_type": "Journal Voucher",
|
|
||||||
"module": "Accounts",
|
|
||||||
"standard": "Yes",
|
|
||||||
"sort_order": "DESC",
|
|
||||||
"filters": "{'Journal Voucher\u0001Submitted':1,'Journal Voucher\u0001Voucher Type':'','Journal Voucher\u0001Is Opening':'','Journal Voucher\u0001Fiscal Year':'','Journal Voucher\u0001Company':'','Journal Voucher\u0001TDS Applicable':'','Journal Voucher\u0001TDS Category':''}",
|
|
||||||
"dis_filters": "fiscal_year",
|
|
||||||
"doc_type": "Journal Voucher Detail",
|
|
||||||
"name": "__common__",
|
|
||||||
"doctype": "Search Criteria",
|
|
||||||
"sort_by": "ID",
|
|
||||||
"page_len": 50,
|
|
||||||
"criteria_name": "Bank Clearance report",
|
"criteria_name": "Bank Clearance report",
|
||||||
"columns": "Journal Voucher\u0001ID,Journal Voucher Detail\u0001Account,Journal Voucher Detail\u0001Debit,Journal Voucher Detail\u0001Credit,Journal Voucher\u0001Clearance Date,Journal Voucher\u0001Cheque No,Journal Voucher\u0001Cheque Date,Journal Voucher\u0001Voucher Date,Journal Voucher\u0001Posting Date,Journal Voucher Detail\u0001Against Payable,Journal Voucher Detail\u0001Against Receivable"
|
"custom_query": "",
|
||||||
|
"description": "Bank Clearance report",
|
||||||
|
"dis_filters": "fiscal_year",
|
||||||
|
"disabled": 0,
|
||||||
|
"doc_type": "Journal Voucher Detail",
|
||||||
|
"doctype": "Search Criteria",
|
||||||
|
"filters": "{'Journal Voucher\u0001Submitted':1,'Journal Voucher\u0001Voucher Type':'','Journal Voucher\u0001Is Opening':'','Journal Voucher\u0001Fiscal Year':'','Journal Voucher\u0001Company':'','Journal Voucher\u0001TDS Applicable':'','Journal Voucher\u0001TDS Category':''}",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "__common__",
|
||||||
|
"page_len": 50,
|
||||||
|
"parent_doc_type": "Journal Voucher",
|
||||||
|
"report_script": null,
|
||||||
|
"sort_by": "ID",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"standard": "Yes"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bank_clearance_report",
|
"doctype": "Search Criteria",
|
||||||
"doctype": "Search Criteria"
|
"name": "bank_clearance_report"
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
x
Reference in New Issue
Block a user