Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 6871b1e..ab44247 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -351,7 +351,7 @@
if ret.get("warehouse"):
ret["actual_qty"] = flt(webnotes.conn.get_value("Bin",
- {"item_code": args.get("item_code"), "warehouse": args.get("warehouse")},
+ {"item_code": args.get("item_code"), "warehouse": ret.get("warehouse")},
"actual_qty"))
return ret
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index c3d4cf1..25ee92c 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -198,11 +198,21 @@
doctype: "Sales Invoice"
},
{
+ "label":wn._("Received Items To Be Billed"),
+ route: "query-report/Received Items To Be Billed",
+ doctype: "Purchase Invoice"
+ },
+ {
"label":wn._("Ordered Items To Be Billed"),
route: "query-report/Ordered Items To Be Billed",
doctype: "Sales Invoice"
},
{
+ "label":wn._("Purchase Order Items To Be Billed"),
+ route: "query-report/Purchase Order Items To Be Billed",
+ doctype: "Purchase Invoice"
+ },
+ {
"label":wn._("Bank Clearance Summary"),
route: "query-report/Bank Clearance Summary",
doctype: "Journal Voucher"
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py
index 6648ee6..7634e5b 100644
--- a/accounts/page/voucher_import_tool/voucher_import_tool.py
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
-from webnotes.utils import flt, comma_and
+from webnotes.utils import flt, comma_and, cstr
import webnotes.defaults
@webnotes.whitelist()
@@ -31,13 +31,12 @@
"3. Naming Series Options: %(naming_options)s"
"4. Voucher Type Options: %(voucher_type)s"%(extra_note)s
"-------Common Values-----------"
-"Company:","%(default_company)s"
+"Company:",
"--------Data----------"
%(columns)s
''' % {
"template_type": template_type,
"user_fmt": webnotes.defaults.get_global_default('date_format'),
- "default_company": webnotes.conn.get_default("company"),
"naming_options": naming_options.replace("\n", ", "),
"voucher_type": voucher_type.replace("\n", ", "),
"extra_note": extra_note,
@@ -49,14 +48,29 @@
@webnotes.whitelist()
def upload():
- from webnotes.utils.datautils import read_csv_content_from_uploaded_file
- rows = read_csv_content_from_uploaded_file()
-
- common_values = get_common_values(rows)
- company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
- data, start_idx = get_data(rows, company_abbr)
+ messages = []
+ try:
+ from webnotes.utils.datautils import read_csv_content_from_uploaded_file
+ rows = read_csv_content_from_uploaded_file()
+ common_values = get_common_values(rows)
+ company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
+
+ if not company_abbr:
+ webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1)
+
+ data, start_idx = get_data(rows, company_abbr)
+ except Exception, e:
+ err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
+ messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
+ webnotes.errprint(webnotes.getTraceback())
+ webnotes.message_log = []
+ return messages
+
return import_vouchers(common_values, data, start_idx, rows[0][0])
+
+
+
def map_fields(field_list, source, target):
for f in field_list:
@@ -70,9 +84,8 @@
from webnotes.model.bean import Bean
from accounts.utils import get_fiscal_year
from webnotes.utils.dateutils import parse_date
-
messages = []
-
+
def get_account_details(account):
acc_details = webnotes.conn.sql("""select is_pl_account,
master_name from tabAccount where name=%s""", account, as_dict=1)
@@ -113,8 +126,9 @@
if d.ref_number:
if not d.ref_date:
- raise webnotes.ValidationError, \
- """Ref Date is Mandatory if Ref Number is specified"""
+ webnotes.msgprint(_("Ref Date is Mandatory if Ref Number is specified"),
+ raise_exception=1)
+
d.ref_date = parse_date(d.ref_date)
d.company = common_values.company
@@ -176,7 +190,7 @@
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
- err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or unicode(e)
+ err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
messages.append("""<p style='color: red'>[row #%s] %s failed: %s</p>"""
% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
messages.append("<p style='color: red'>All transactions rolled back</p>")
@@ -240,16 +254,20 @@
raise Exception, """Column No(s). %s %s empty. \
Please remove them and try again.""" % (comma_and(empty_columns),
len(empty_columns)==1 and "is" or "are")
-
+
columns = [c.replace(" ", "_").lower() for c in rows[i+1]
if not c.endswith(" - " + company_abbr)]
accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]
-
+
+ if not accounts:
+ webnotes.msgprint(_("""No Account found in csv file,
+ May be company abbreviation is not correct"""), raise_exception=1)
+
if accounts and (len(columns) != rows[i+1].index(accounts[0])):
- raise Exception, _("""All account columns should be after \
+ webnotes.msgprint(_("""All account columns should be after \
standard columns and on the right.
If you entered it properly, next probable reason \
could be wrong account name.
- Please rectify it in the file and try again.""")
+ Please rectify it in the file and try again."""), raise_exception=1)
return data, start_row_idx
\ No newline at end of file
diff --git a/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt b/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
index 53a1d7a..554e0f0 100644
--- a/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
+++ b/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-28 15:57:59",
"docstatus": 0,
- "modified": "2013-05-28 16:02:06",
+ "modified": "2013-05-28 17:34:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -11,7 +11,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
- "query": "select \n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Receipt Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Receipt Item`.qty - ifnull(`tabPurchase Receipt Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_qty, 0) < ifnull(`tabPurchase Receipt Item`.qty, 0)\norder by `tabPurchase Receipt`.transaction_date asc",
+ "query": "select \n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Receipt Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Receipt Item`.qty - ifnull(`tabPurchase Receipt Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_qty, 0) < ifnull(`tabPurchase Receipt Item`.qty, 0)\norder by `tabPurchase Receipt`.posting_date asc",
"ref_doctype": "Purchase Invoice",
"report_name": "Received Items To Be Billed",
"report_type": "Query Report"
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index 78f8422..549128f 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -132,6 +132,7 @@
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now()
or end_of_life = '0000-00-00') and (is_sales_item = 'Yes'
or is_service_item = 'Yes')""", args['item_code'], as_dict=1)
+
tax = webnotes.conn.sql("""select tax_type, tax_rate from `tabItem Tax`
where parent = %s""", args['item_code'])
t = {}
@@ -167,8 +168,9 @@
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
ret['base_ref_rate'] = flt(base_ref_rate)
ret['basic_rate'] = flt(base_ref_rate)
-
+
if ret['warehouse'] or ret['reserved_warehouse']:
+
av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
ret.update(av_qty)
@@ -179,7 +181,7 @@
(args['item_code'], obj.doc.customer))
if customer_item_code_row and customer_item_code_row[0][0]:
ret['customer_item_code'] = customer_item_code_row[0][0]
-
+
return ret