Merge branch 'develop'

This commit is contained in:
Pratik Vyas 2014-01-07 13:47:44 +05:30
commit 63d71d7f2f
6 changed files with 81 additions and 60 deletions

View File

@ -9,11 +9,13 @@ from accounts.report.accounts_receivable.accounts_receivable import get_ageing_d
def execute(filters=None): def execute(filters=None):
if not filters: filters = {} 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) entries = get_gl_entries(filters)
account_supplier = dict(webnotes.conn.sql("""select account.name, supplier.supplier_name account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select acc.name,
from `tabAccount` account, `tabSupplier` supplier supp.supplier_name, supp.name as supplier
where account.master_type="Supplier" and supplier.name=account.master_name""")) 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] entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
for gle in get_gl_entries(filters, before_report_date=False)] for gle in get_gl_entries(filters, before_report_date=False)]
@ -37,9 +39,7 @@ def execute(filters=None):
if abs(flt(outstanding_amount)) > 0.01: if abs(flt(outstanding_amount)) > 0.01:
paid_amount = invoiced_amount - outstanding_amount paid_amount = invoiced_amount - outstanding_amount
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""), row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
gle.voucher_type, gle.voucher_no, gle.remarks,
account_supplier_type_map.get(gle.account),
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""), voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
voucher_details.get("bill_date", ""), invoiced_amount, voucher_details.get("bill_date", ""), invoiced_amount,
paid_amount, outstanding_amount] paid_amount, outstanding_amount]
@ -50,21 +50,38 @@ def execute(filters=None):
else: else:
ageing_based_on_date = gle.posting_date 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) 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 return columns, data
def get_columns(): def get_columns(supplier_naming_by):
return [ columns = [
"Posting Date:Date:80", "Account:Link/Account:150", "Supplier::150", "Voucher Type::110", "Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110",
"Voucher No::120", "Remarks::150", "Supplier Type:Link/Supplier Type:120", "Voucher No::120", "::30", "Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
"Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
"Invoiced Amount:Currency:100", "Paid Amount:Currency:100", "Invoiced Amount:Currency:100", "Paid Amount:Currency:100",
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30: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): def get_gl_entries(filters, before_report_date=True):
conditions, supplier_accounts = get_conditions(filters, before_report_date) conditions, supplier_accounts = get_conditions(filters, before_report_date)
gl_entries = [] gl_entries = []
@ -102,8 +119,8 @@ def get_conditions(filters, before_report_date=True):
def get_account_supplier_type_map(): def get_account_supplier_type_map():
account_supplier_type_map = {} account_supplier_type_map = {}
for each in webnotes.conn.sql("""select t2.name, t1.supplier_type from `tabSupplier` t1, for each in webnotes.conn.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
`tabAccount` t2 where t1.name = t2.master_name group by t2.name"""): `tabAccount` acc where supp.name = acc.master_name group by acc.name"""):
account_supplier_type_map[each[0]] = each[1] account_supplier_type_map[each[0]] = each[1]
return account_supplier_type_map return account_supplier_type_map

View File

@ -12,7 +12,8 @@ def execute(filters=None):
item_list = get_items(filters) item_list = get_items(filters)
aii_account_map = get_aii_accounts() aii_account_map = get_aii_accounts()
item_tax, tax_accounts = get_tax_accounts(item_list, columns) if item_list:
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
data = [] data = []
for d in item_list: for d in item_list:

View File

@ -11,7 +11,8 @@ def execute(filters=None):
last_col = len(columns) last_col = len(columns)
item_list = get_items(filters) item_list = get_items(filters)
item_tax, tax_accounts = get_tax_accounts(item_list, columns) if item_list:
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
data = [] data = []
for d in item_list: for d in item_list:
@ -39,7 +40,6 @@ def get_columns():
"Qty:Float:120", "Rate:Currency:120", "Amount:Currency:120" "Qty:Float:120", "Rate:Currency:120", "Amount:Currency:120"
] ]
def get_conditions(filters): def get_conditions(filters):
conditions = "" conditions = ""

View File

@ -1,6 +1,6 @@
{ {
"app_name": "ERPNext", "app_name": "ERPNext",
"app_version": "3.4.7", "app_version": "3.4.8",
"base_template": "app/portal/templates/base.html", "base_template": "app/portal/templates/base.html",
"modules": { "modules": {
"Accounts": { "Accounts": {
@ -74,5 +74,5 @@
"type": "module" "type": "module"
} }
}, },
"requires_framework_version": "==3.4.3" "requires_framework_version": "==3.4.4"
} }

View File

@ -387,35 +387,38 @@ class AccountsController(TransactionBase):
for item in self.doclist.get({"parentfield": "entries"}): for item in self.doclist.get({"parentfield": "entries"}):
if item.fields.get(item_ref_dn): if item.fields.get(item_ref_dn):
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
where %s=%s and docstatus=1 and parent != %s""" %
(based_on, self.tname, item_ref_dn, '%s', '%s'),
(item.fields[item_ref_dn], self.doc.name), debug=1)[0][0]
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
self.precision(based_on, item))
ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item", ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
item.fields[item_ref_dn], based_on), self.precision(based_on, item)) item.fields[item_ref_dn], based_on), self.precision(based_on, item))
if not ref_amt:
webnotes.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
ref_dt + _(" is zero, system will not check for over-billed"))
else:
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
where %s=%s and docstatus=1 and parent != %s""" %
(based_on, self.tname, item_ref_dn, '%s', '%s'),
(item.fields[item_ref_dn], self.doc.name))[0][0]
tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code, total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
item_tolerance, global_tolerance) self.precision(based_on, item))
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100) tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code,
item_tolerance, global_tolerance)
if total_billed_amt - max_allowed_amt > 0.01: max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
reduce_by = total_billed_amt - max_allowed_amt
webnotes.throw(_("Row #") + cstr(item.idx) + ": " + if total_billed_amt - max_allowed_amt > 0.01:
_(" Max amount allowed for Item ") + cstr(item.item_code) + reduce_by = total_billed_amt - max_allowed_amt
_(" against ") + ref_dt + " " +
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") + webnotes.throw(_("Row #") + cstr(item.idx) + ": " +
cstr(max_allowed_amt) + ". \n" + _(" Max amount allowed for Item ") + cstr(item.item_code) +
_("""If you want to increase your overflow tolerance, please increase \ _(" against ") + ref_dt + " " +
tolerance % in Global Defaults or Item master. cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") +
Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" + cstr(max_allowed_amt) + ". \n" +
_("""Also, please check if the order item has already been billed \ _("""If you want to increase your overflow tolerance, please increase \
in the Sales Order""")) tolerance % in Global Defaults or Item master.
Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" +
_("""Also, please check if the order item has already been billed \
in the Sales Order"""))
def get_company_default(self, fieldname): def get_company_default(self, fieldname):
from accounts.utils import get_company_default from accounts.utils import get_company_default

View File

@ -19,7 +19,7 @@ requirements = [
"jinja2", "jinja2",
"markdown2", "markdown2",
"markupsafe", "markupsafe",
"mysql-python", "mysql-python==1.2.4",
"pygeoip", "pygeoip",
"python-dateutil", "python-dateutil",
"python-memcached", "python-memcached",
@ -148,13 +148,13 @@ def install_python_modules():
print "Installing Python Modules: (This may take some time)" print "Installing Python Modules: (This may take some time)"
print "-"*80 print "-"*80
if not exec_in_shell("which pip"): if not exec_in_shell("which pip-2.7"):
exec_in_shell("easy_install pip") exec_in_shell("easy_install-2.7 pip")
exec_in_shell("pip install --upgrade pip") exec_in_shell("pip-2.7 install --upgrade pip")
exec_in_shell("pip install --upgrade setuptools") exec_in_shell("pip-2.7 install --upgrade setuptools")
exec_in_shell("pip install --upgrade virtualenv") exec_in_shell("pip-2.7 install --upgrade virtualenv")
exec_in_shell("pip install {}".format(' '.join(requirements))) exec_in_shell("pip-2.7 install {}".format(' '.join(requirements)))
def install_erpnext(install_path): def install_erpnext(install_path):
print print
@ -200,7 +200,7 @@ def setup_folders(install_path):
app = os.path.join(install_path, "app") app = os.path.join(install_path, "app")
if not os.path.exists(app): if not os.path.exists(app):
print "Cloning erpnext" print "Cloning erpnext"
exec_in_shell("cd %s && git clone https://github.com/webnotes/erpnext.git app" % install_path) exec_in_shell("cd %s && git clone --branch master https://github.com/webnotes/erpnext.git app" % install_path)
exec_in_shell("cd app && git config core.filemode false") exec_in_shell("cd app && git config core.filemode false")
if not os.path.exists(app): if not os.path.exists(app):
raise Exception, "Couldn't clone erpnext repository" raise Exception, "Couldn't clone erpnext repository"
@ -208,7 +208,7 @@ def setup_folders(install_path):
lib = os.path.join(install_path, "lib") lib = os.path.join(install_path, "lib")
if not os.path.exists(lib): if not os.path.exists(lib):
print "Cloning wnframework" print "Cloning wnframework"
exec_in_shell("cd %s && git clone https://github.com/webnotes/wnframework.git lib" % install_path) exec_in_shell("cd %s && git clone --branch master https://github.com/webnotes/wnframework.git lib" % install_path)
exec_in_shell("cd lib && git config core.filemode false") exec_in_shell("cd lib && git config core.filemode false")
if not os.path.exists(lib): if not os.path.exists(lib):
raise Exception, "Couldn't clone wnframework repository" raise Exception, "Couldn't clone wnframework repository"