Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2013-05-02 14:47:10 +05:30
commit 88f6acdbe4
22 changed files with 424 additions and 60 deletions

View File

@ -187,6 +187,11 @@ wn.module_page["Accounts"] = [
right: true,
icon: "icon-list",
items: [
{
"label":wn._("Bank Reconciliation Statement"),
route: "query-report/Bank Reconciliation Statement",
doctype: "Journal Voucher"
},
{
"label":wn._("Delivered Items To Be Billed"),
route: "query-report/Delivered Items To Be Billed",
@ -197,6 +202,16 @@ wn.module_page["Accounts"] = [
route: "query-report/Ordered Items To Be Billed",
doctype: "Sales Invoice"
},
{
"label":wn._("Bank Clearance Summary"),
route: "query-report/Bank Clearance Summary",
doctype: "Journal Voucher"
},
{
"label":wn._("Payment Collection With Ageing"),
route: "query-report/Payment Collection With Ageing",
doctype: "Journal Voucher"
},
]
}
]

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, nowdate, flt, cstr
from accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
@ -67,8 +68,7 @@ def get_gl_entries(filters, before_report_date=True):
gl_entries = []
gl_entries = webnotes.conn.sql("""select * from `tabGL Entry`
where ifnull(is_cancelled, 'No') = 'No' %s order by posting_date, account""" %
(conditions) % (", ".join(['%s']*len(supplier_accounts))),
tuple(supplier_accounts), as_dict=1)
(conditions), tuple(supplier_accounts), as_dict=1)
return gl_entries
def get_conditions(filters, before_report_date=True):
@ -85,7 +85,7 @@ def get_conditions(filters, before_report_date=True):
conditions, filters)
if supplier_accounts:
conditions += " and account in (%s)"
conditions += " and account in (%s)" % (", ".join(['%s']*len(supplier_accounts)))
if filters.get("report_date"):
if before_report_date:
@ -125,20 +125,4 @@ def get_paid_amount(gle, report_date, entries_after_report_date):
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
return flt(paid_amount)
def get_ageing_data(ageing_based_on_date, age_on, outstanding_amount):
val1 = val2 = val3 = val4 = diff = 0
diff = age_on and ageing_based_on_date \
and (getdate(age_on) - getdate(ageing_based_on_date)).days or 0
if diff <= 30:
val1 = outstanding_amount
elif 30 < diff <= 60:
val2 = outstanding_amount
elif 60 < diff <= 90:
val3 = outstanding_amount
elif diff > 90:
val4 = outstanding_amount
return [diff, val1, val2, val3, val4]
return flt(paid_amount)

View File

@ -58,8 +58,7 @@ def get_gl_entries(filters, upto_report_date=True):
conditions, customer_accounts = get_conditions(filters, upto_report_date)
return webnotes.conn.sql("""select * from `tabGL Entry`
where ifnull(is_cancelled, 'No') = 'No' %s order by posting_date, account""" %
(conditions) % (", ".join(['%s']*len(customer_accounts))),
tuple(customer_accounts), as_dict=1)
(conditions), tuple(customer_accounts), as_dict=1)
def get_conditions(filters, upto_report_date=True):
conditions = ""
@ -75,7 +74,7 @@ def get_conditions(filters, upto_report_date=True):
conditions, filters)
if customer_accounts:
conditions += " and account in (%s)"
conditions += " and account in (%s)" % (", ".join(['%s']*len(customer_accounts)))
if filters.get("report_date"):
if upto_report_date:
@ -96,7 +95,7 @@ def get_account_territory_map():
def get_si_due_date_map():
""" get due_date from sales invoice """
si_due_date_map = {}
for t in webnotes.conn.sql("""select name, due_date from `tabSales Invoice` group by name"""):
for t in webnotes.conn.sql("""select name, due_date from `tabSales Invoice`"""):
si_due_date_map[t[0]] = t[1]
return si_due_date_map

View File

@ -0,0 +1,32 @@
wn.query_reports["Bank Clearance Summary"] = {
"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": "Bank Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
}
}
},
]
}

View File

@ -0,0 +1,54 @@
# 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 import _, msgprint
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
data = get_entries(filters)
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Account:Link/Account:140",
"Posting Date:Date:100", "Clearance Date:Date:110", "Against Account:Link/Account:200",
"Debit:Currency:120", "Credit:Currency:120"
]
def get_conditions(filters):
conditions = ""
if not filters.get("account"):
msgprint(_("Please select Bank Account"), raise_exception=1)
else:
conditions += " and jvd.account = %(account)s"
if filters.get("from_date"): conditions += " and jv.posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and jv.posting_date<=%(to_date)s"
return conditions
def get_entries(filters):
conditions = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 %s
order by jv.name DESC""" % conditions, filters, as_list=1)
return entries

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-05-01 12:13:25",
"docstatus": 0,
"modified": "2013-05-01 12:13:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Bank Clearance Summary",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Bank Clearance Summary"
}
]

View File

@ -0,0 +1,25 @@
wn.query_reports["Bank Reconciliation Statement"] = {
"filters": [
{
"fieldname":"account",
"label": "Bank Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
}
}
},
{
"fieldname":"report_date",
"label": "Date",
"fieldtype": "Date",
"default": get_today()
},
]
}

View File

@ -0,0 +1,79 @@
# 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 import _, msgprint
from webnotes.utils import flt
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
data = get_entries(filters)
from accounts.utils import get_balance_on
balance_as_per_company = get_balance_on(filters["account"], filters["report_date"])
total_debit, total_credit = 0,0
for d in data:
total_debit += flt(d[4])
total_credit += flt(d[5])
if webnotes.conn.get_value("Account", filters["account"], "debit_or_credit") == 'Debit':
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
else:
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
data += [
["", "", "", "Balance as per company books", balance_as_per_company, ""],
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
["", "", "", "Balance as per bank", bank_bal, ""]
]
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100",
"Clearance Date:Date:110", "Against Account:Link/Account:200",
"Debit:Currency:120", "Credit:Currency:120"
]
def get_conditions(filters):
conditions = ""
if not filters.get("account"):
msgprint(_("Please select Bank Account"), raise_exception=1)
else:
conditions += " and jvd.account = %(account)s"
if not filters.get("report_date"):
msgprint(_("Please select Date on which you want to run the report"), raise_exception=1)
else:
conditions += """ and jv.posting_date <= %(report_date)s
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s"""
return conditions
def get_entries(filters):
conditions = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jv.posting_date, jv.clearance_date,
jvd.against_account, jvd.debit, jvd.credit
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= '' %s
order by jv.name DESC""" % conditions, filters, as_list=1)
return entries

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-30 18:30:21",
"docstatus": 0,
"modified": "2013-05-01 10:53:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 0,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Bank Reconciliation Statement",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Bank Reconciliation Statement"
}
]

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 17:55:23",
"creation": "2013-02-25 10:38:57",
"docstatus": 0,
"modified": "2013-02-23 14:35:28",
"modified": "2013-05-01 11:56:43",
"modified_by": "Administrator",
"owner": "Administrator"
},

View File

@ -0,0 +1,42 @@
wn.query_reports["Payment Collection With Ageing"] = {
"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": "Customer 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": "Debit",
"company": company,
"master_type": "Customer"
}
}
}
},
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
},
]
}

View File

@ -0,0 +1,86 @@
# 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 accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_entries(filters)
si_posting_date_map = get_si_posting_date_map()
data = []
for d in entries:
against_invoice_date = d.against_invoice and si_posting_date_map[d.against_invoice] or ""
row = [d.name, d.account, d.posting_date, d.against_invoice, against_invoice_date,
d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark]
if d.against_invoice:
row += get_ageing_data(against_invoice_date, d.posting_date, d.credit or -1*d.debit)
else:
row += ["", "", "", "", ""]
data.append(row)
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Account:Link/Account:140",
"Posting Date:Date:100", "Against Invoice:Link/Sales Invoice:130",
"Against Invoice Posting Date:Date:130", "Debit:Currency:120", "Credit:Currency:120",
"Reference No::100", "Reference Date:Date:100", "Remarks::150", "Age:Int:40",
"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
def get_conditions(filters):
conditions = ""
customer_accounts = []
if filters.get("account"):
customer_accounts = [filters["account"]]
elif filters.get("company"):
customer_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
where ifnull(master_type, '') = 'Customer' and docstatus < 2
and company = %s""", filters["company"])
if customer_accounts:
conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(customer_accounts)))
if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
return conditions, customer_accounts
def get_entries(filters):
conditions, customer_accounts = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
jvd.against_invoice, jvd.debit, jvd.credit, jv.cheque_no, jv.cheque_date, jv.remark
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 %s order by jv.name DESC""" %
(conditions), tuple(customer_accounts), as_dict=1)
return entries
def get_si_posting_date_map():
si_posting_date_map = {}
for t in webnotes.conn.sql("""select name, posting_date from `tabSales Invoice`"""):
si_posting_date_map[t[0]] = t[1]
return si_posting_date_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-05-02 12:09:51",
"docstatus": 0,
"modified": "2013-05-02 12:09:51",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Payment Collection With Ageing",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Payment Collection With Ageing"
}
]

View File

@ -141,7 +141,6 @@ def get_account_details(invoice_list):
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

View File

@ -145,7 +145,6 @@ def get_customer_deatils(invoice_list):
customers = list(set([inv.customer for inv in invoice_list]))
for cust in webnotes.conn.sql("""select name, territory from `tabCustomer`
where name in (%s)""" % ", ".join(["%s"]*len(customers)), tuple(customers), as_dict=1):
customer_map.setdefault(cust.name, "")
customer_map[cust.name] = cust.territory
return customer_map
@ -155,7 +154,6 @@ def get_account_details(invoice_list):
accounts = list(set([inv.debit_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

View File

@ -1,12 +1,13 @@
[
{
"creation": "2013-01-10 16:34:13",
"creation": "2013-01-22 16:50:30",
"docstatus": 0,
"modified": "2013-01-22 14:25:38",
"modified": "2013-05-02 11:22:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_rename": 1,
"autoname": "field:deduction_name",
"doctype": "DocType",
"document_type": "Master",

View File

@ -1,12 +1,13 @@
[
{
"creation": "2013-01-10 16:34:13",
"creation": "2013-01-24 11:03:32",
"docstatus": 0,
"modified": "2013-01-23 16:32:07",
"modified": "2013-05-02 11:22:48",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_rename": 1,
"autoname": "field:earning_name",
"doctype": "DocType",
"document_type": "Master",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-01 19:09:43",
"creation": "2013-03-05 14:50:38",
"docstatus": 0,
"modified": "2013-03-01 08:22:16",
"modified": "2013-05-01 15:49:47",
"modified_by": "Administrator",
"owner": "harshada@webnotestech.com"
},
@ -24,14 +24,19 @@
"permlevel": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Batch",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"role": "Material Master Manager",
"submit": 0
"submit": 0,
"write": 1
},
{
"doctype": "DocType",
@ -94,28 +99,6 @@
"oldfieldtype": "Date"
},
{
"doctype": "DocField",
"fieldname": "trash_reason",
"fieldtype": "Small Text",
"label": "Trash Reason",
"oldfieldname": "trash_reason",
"oldfieldtype": "Small Text",
"read_only": 1
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1
"doctype": "DocPerm"
}
]

View File

@ -114,7 +114,8 @@ class DocType:
def update_serial_purchase_details(self, obj, d, serial_no, is_submit, purpose = '', rejected=None):
exists = webnotes.conn.sql("select name, status, docstatus from `tabSerial No` where name = '%s'" % (serial_no))
if is_submit:
if exists and exists[0][2] != 2 and purpose not in ['Material Transfer', 'Sales Return']:
if exists and exists[0][2] != 2 and \
purpose not in ['Material Transfer', "Material Receipt", 'Sales Return']:
msgprint("Serial No: %s already %s" % (serial_no, exists and exists[0][1]), raise_exception = 1)
elif exists:
s = Document('Serial No', exists and exists[0][0])