From 77a2ee01e27223b4b6f20aee53b5d9f3b68bb628 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 11:56:48 +0530 Subject: [PATCH 01/12] [rename][fixes] do not update customer name of renaming of customer --- selling/doctype/customer/customer.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 6f54ef9641..72e12b7942 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -219,27 +219,8 @@ class DocType(TransactionBase): def on_rename(self, new, old, merge=False): #update customer_name if not naming series if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': - update_fields = [ - ('Customer', 'name'), - ('Address', 'customer'), - ('Contact', 'customer'), - ('Customer Issue', 'customer'), - ('Delivery Note', 'customer'), - ('Opportunity', 'customer'), - ('Installation Note', 'customer'), - ('Maintenance Schedule', 'customer'), - ('Maintenance Visit', 'customer'), - ('Project', 'customer'), - ('Quotation', 'customer'), - ('Sales Invoice', 'customer'), - ('Sales Order', 'customer'), - ('Serial No', 'customer'), - ('Shipping Address', 'customer'), - ('Stock Entry', 'customer'), - ('Support Ticket', 'customer')] - for rec in update_fields: - sql("""update `tab%s` set customer_name = %s - where `%s` = %s""" % (rec[0], "%s" ,rec[1], "%s"), (new, old)) + webnotes.conn.sql("""update `tabCustomer` set customer_name = %s where name = %s""", + (new, old)) for account in webnotes.conn.sql("""select name, account_name from tabAccount where master_name=%s and master_type='Customer'""", old, as_dict=1): From 34d1b1415e6ccb1221f8122506cb6b8623a81457 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 12:32:21 +0530 Subject: [PATCH 02/12] [report] filter added base on territory in sales personwise transaction summary --- accounts/report/accounts_receivable/accounts_receivable.txt | 2 +- .../item_wise_sales_history/item_wise_sales_history.txt | 5 +++-- .../sales_person_wise_transaction_summary.js | 6 ++++++ .../sales_person_wise_transaction_summary.py | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.txt b/accounts/report/accounts_receivable/accounts_receivable.txt index 7eb344fc08..d01bef23d3 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.txt +++ b/accounts/report/accounts_receivable/accounts_receivable.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-16 11:31:13", "docstatus": 0, - "modified": "2013-04-30 17:54:47", + "modified": "2013-05-24 12:02:52", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/selling/report/item_wise_sales_history/item_wise_sales_history.txt b/selling/report/item_wise_sales_history/item_wise_sales_history.txt index 6fee050e0d..adbfe69254 100644 --- a/selling/report/item_wise_sales_history/item_wise_sales_history.txt +++ b/selling/report/item_wise_sales_history/item_wise_sales_history.txt @@ -1,13 +1,14 @@ [ { - "creation": "2013-05-03 14:38:34", + "creation": "2013-05-23 17:42:24", "docstatus": 0, - "modified": "2013-05-07 11:19:40", + "modified": "2013-05-24 12:20:17", "modified_by": "Administrator", "owner": "Administrator" }, { "add_total_row": 1, + "disabled": 0, "doctype": "Report", "is_standard": "Yes", "name": "__common__", diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js index 4a8e6787ff..2e1996e9a2 100644 --- a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.js @@ -50,5 +50,11 @@ wn.query_reports["Sales Person-wise Transaction Summary"] = { fieldtype: "Link", options: "Customer", }, + { + fieldname:"territory", + label: "Territory", + fieldtype: "Link", + options: "Territory", + }, ] } \ No newline at end of file diff --git a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py index 23e8819242..8ec3a1826e 100644 --- a/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py +++ b/selling/report/sales_person_wise_transaction_summary/sales_person_wise_transaction_summary.py @@ -54,6 +54,7 @@ def get_conditions(filters, date_field): conditions = "" if filters.get("company"): conditions += " and dt.company = '%s'" % filters["company"] if filters.get("customer"): conditions += " and dt.customer = '%s'" % filters["customer"] + if filters.get("territory"): conditions += " and dt.territory = '%s'" % filters["territory"] if filters.get("from_date"): conditions += " and dt.%s >= '%s'" % \ (date_field, filters["from_date"]) From eca0531068e8ec75c58d9c11764798612b7a9c84 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 16:07:03 +0530 Subject: [PATCH 03/12] [report] purchase order/ received items to be billed --- .../__init__.py | 0 .../purchase_order_items_to_be_billed.txt | 23 +++++++++++++++++++ .../received_items_to_be_billed/__init__.py | 0 .../received_items_to_be_billed.txt | 23 +++++++++++++++++++ .../purchase_order_items_to_be_received.txt | 4 ++-- 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 accounts/report/purchase_order_items_to_be_billed/__init__.py create mode 100644 accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt create mode 100644 accounts/report/received_items_to_be_billed/__init__.py create mode 100644 accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt diff --git a/accounts/report/purchase_order_items_to_be_billed/__init__.py b/accounts/report/purchase_order_items_to_be_billed/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt b/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt new file mode 100644 index 0000000000..7a9ec367b1 --- /dev/null +++ b/accounts/report/purchase_order_items_to_be_billed/purchase_order_items_to_be_billed.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-28 15:54:16", + "docstatus": 0, + "modified": "2013-05-28 16:02:57", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", + "ref_doctype": "Purchase Invoice", + "report_name": "Purchase Order Items To Be Billed", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Purchase Order Items To Be Billed" + } +] \ No newline at end of file diff --git a/accounts/report/received_items_to_be_billed/__init__.py b/accounts/report/received_items_to_be_billed/__init__.py new file mode 100644 index 0000000000..e69de29bb2 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 new file mode 100644 index 0000000000..53a1d7a7f5 --- /dev/null +++ b/accounts/report/received_items_to_be_billed/received_items_to_be_billed.txt @@ -0,0 +1,23 @@ +[ + { + "creation": "2013-05-28 15:57:59", + "docstatus": 0, + "modified": "2013-05-28 16:02:06", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "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", + "ref_doctype": "Purchase Invoice", + "report_name": "Received Items To Be Billed", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Received Items To Be Billed" + } +] \ No newline at end of file diff --git a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt index 7a2f6365bf..c588dde3f7 100644 --- a/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt +++ b/stock/report/purchase_order_items_to_be_received/purchase_order_items_to_be_received.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 18:01:55", "docstatus": 0, - "modified": "2013-05-13 16:11:27", + "modified": "2013-05-28 16:03:15", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", + "query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n\t`tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.received_qty as \"Received Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.received_qty, 0)) as \"Qty to Receive:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.received_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc", "ref_doctype": "Purchase Receipt", "report_name": "Purchase Order Items To Be Received", "report_type": "Query Report" From 8b509f56b7b900c1508c27d13aa5095b4c6185ea Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 16:52:30 +0530 Subject: [PATCH 04/12] [utility function] fix total debit/credit due to floating point issue --- accounts/utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/accounts/utils.py b/accounts/utils.py index 755546c0e1..382a33762b 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -322,3 +322,20 @@ def get_stock_rbnb_value(company): and exists(select name from `tabPurchase Invoice` where name = pi_item.parent and company = %s)""", company) return flt(total_received_amount[0][0]) - flt(total_billed_amount[0][0]) + + +def fix_total_debit_credit(): + vouchers = webnotes.conn.sql("""select voucher_type, voucher_no, + sum(debit) - sum(credit) as diff + from `tabGL Entry` + group by voucher_type, voucher_no + having sum(ifnull(debit, 0)) != sum(ifnull(credit, 0))""", as_dict=1) + + for d in vouchers: + if abs(d.diff) > 0: + dr_or_cr = d.voucher_type == "Sales Invoice" and "credit" or "debit" + + webnotes.conn.sql("""update `tabGL Entry` set %s = %s + %s + where voucher_type = %s and voucher_no = %s and %s > 0 limit 1""" % + (dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr), + (d.diff, d.voucher_type, d.voucher_no), debug=1) \ No newline at end of file From 9fce94ff96d575a32abdf8d3759a16778bbe4b81 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 17:12:15 +0530 Subject: [PATCH 05/12] [report] reports link added into accounts home page --- accounts/page/accounts_home/accounts_home.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index c3d4cf18ce..25ee92c397 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -197,11 +197,21 @@ wn.module_page["Accounts"] = [ route: "query-report/Delivered Items To Be Billed", 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", From 7742e2baed55ace102048cdd7e5642bbe8470a4d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 17:58:36 +0530 Subject: [PATCH 06/12] [report][fix] --- .../received_items_to_be_billed.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 53a1d7a7f5..554e0f0c79 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" From 58c3348ca6b8281d5feca79029b9a73f9fc89196 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 18:06:20 +0530 Subject: [PATCH 07/12] [voucher import tool][fix] fixes for handling exception --- .../voucher_import_tool.py | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 6648ee6f8e..3c920ce04e 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 @@ def get_template(): "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,28 @@ def get_template(): @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) + if not common_values.company: + webnotes.msgprint(_("Company is missing in csv file"), raise_exception=1) + + company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr") + data, start_idx = get_data(rows, company_abbr) + except Exception, e: + err_msg = webnotes.message_log and "
".join(webnotes.message_log) or cstr(e) + messages.append("""

%s

""" % (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 +83,8 @@ def import_vouchers(common_values, data, start_idx, import_type): 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 +125,9 @@ def import_vouchers(common_values, data, start_idx, import_type): 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 +189,7 @@ def import_vouchers(common_values, data, start_idx, import_type): webnotes.conn.commit() except Exception, e: webnotes.conn.rollback() - err_msg = webnotes.message_log and "
".join(webnotes.message_log) or unicode(e) + err_msg = webnotes.message_log and "
".join(webnotes.message_log) or cstr(e) messages.append("""

[row #%s] %s failed: %s

""" % ((start_idx + 1) + i, jv.name or "", err_msg or "No message")) messages.append("

All transactions rolled back

") @@ -240,16 +253,20 @@ def get_data(rows, company_abbr): 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 From 0dbd62f163e236f5661b9985770c8327af6bab58 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 May 2013 18:16:44 +0530 Subject: [PATCH 08/12] [voucher import tool][fix] fixes for handling exception --- accounts/page/voucher_import_tool/voucher_import_tool.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 3c920ce04e..7634e5bf84 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -54,10 +54,11 @@ def upload(): rows = read_csv_content_from_uploaded_file() common_values = get_common_values(rows) - if not common_values.company: - webnotes.msgprint(_("Company is missing in csv file"), raise_exception=1) - 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 "
".join(webnotes.message_log) or cstr(e) From df3353228080a510811c541e43f62112995dd7ba Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 May 2013 11:03:11 +0530 Subject: [PATCH 09/12] [fixes] pulling available qty on selection of item in case of pos --- selling/doctype/sales_common/sales_common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 78f842291d..549128f1ea 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -132,6 +132,7 @@ class DocType(TransactionBase): 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 @@ class DocType(TransactionBase): 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 @@ class DocType(TransactionBase): (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 From f6911fb51c4f8efcd6baa3403f0fc58835511400 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 May 2013 11:06:17 +0530 Subject: [PATCH 10/12] Update sales_invoice.py [fixes] pulling available qty on selection of item in case of pos --- accounts/doctype/sales_invoice/sales_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 6871b1e90f..ab44247d5c 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -351,7 +351,7 @@ class DocType(SellingController): 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 From a3773396f37359eaf020829a3f9cece2e5ff910c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 29 May 2013 11:41:13 +0530 Subject: [PATCH 11/12] [naming series] [fix] added Date in make autoname --- setup/doctype/naming_series/naming_series.py | 13 +++---------- setup/page/setup/setup.js | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/setup/doctype/naming_series/naming_series.py b/setup/doctype/naming_series/naming_series.py index 3a6b36d1ff..eb293f256b 100644 --- a/setup/doctype/naming_series/naming_series.py +++ b/setup/doctype/naming_series/naming_series.py @@ -123,16 +123,9 @@ class DocType: def validate_series_name(self, n): import re - if "." in n: - parts = n.split(".") - if len(parts) > 2: - msgprint("Only one dot (.) allowed in " + n, raise_exception=1) - if not re.match("#+$", parts[-1]): - msgprint("Numbering series must be in hashes (e.g. ####)", raise_exception=1) - n = n[0] - if not re.match("^[a-zA-Z0-9-/]*$", n): - msgprint('Special Characters except "-" and "/" not allowed in naming series') - raise Exception + if not re.match("^[a-zA-Z0-9-/.#]*$", n): + msgprint('Special Characters except "-" and "/" not allowed in naming series', + raise_exception=True) def get_options(self, arg=''): sr = webnotes.model.doctype.get_property(self.doc.select_doc_for_series, diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js index 1ebd7307a6..788021a42a 100644 --- a/setup/page/setup/setup.js +++ b/setup/page/setup/setup.js @@ -73,7 +73,7 @@ wn.module_page["Setup"] = [ { "route":"Form/Naming Series/Naming Series", doctype: "Naming Series", - label: wn._("Manage numbering series"), + label: wn._("Manage Numbering Series"), "description":wn._("Set multiple numbering series for transactions") }, { From 72edc3d955d7755623e3fa286fd060b07a509f34 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 29 May 2013 12:13:16 +0530 Subject: [PATCH 12/12] [accounts] [auto inventory accounting] changed naming series and message of journal vouchers created for Auto Inventory Accounting --- accounts/utils.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/accounts/utils.py b/accounts/utils.py index 382a33762b..31e622166e 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -273,36 +273,45 @@ def create_stock_in_hand_jv(reverse=False): jv = webnotes.bean([ { "doctype": "Journal Voucher", - "naming_series": "_PATCH-", + "naming_series": "JV-AUTO-", "company": company, "posting_date": today, "fiscal_year": fiscal_year, "voucher_type": "Journal Entry", - "user_remark": "Accounting Entry for Stock: \ - Initial booking of stock received but not billed account" + "user_remark": (_("Auto Inventory Accounting") + ": " + + (_("Disabled") if reverse else _("Enabled")) + ". " + + _("Journal Entry for inventory that is received but not yet invoiced")) }, { "doctype": "Journal Voucher Detail", "parentfield": "entries", "account": get_company_default(company, "stock_received_but_not_billed"), - (stock_rbnb_value > 0 and "credit" or "debit"): abs(stock_rbnb_value) + (stock_rbnb_value > 0 and "credit" or "debit"): abs(stock_rbnb_value) }, { "doctype": "Journal Voucher Detail", "parentfield": "entries", "account": get_company_default(company, "stock_adjustment_account"), - (stock_rbnb_value > 0 and "debit" or "credit"): abs(stock_rbnb_value), + (stock_rbnb_value > 0 and "debit" or "credit"): abs(stock_rbnb_value), "cost_center": get_company_default(company, "stock_adjustment_cost_center") }, ]) jv.insert() - jv.submit() jv_list.append(jv.doc.name) if jv_list: - webnotes.msgprint("""Folowing Journal Vouchers has been created automatically: - %s""" % '\n'.join(jv_list)) + msgprint(_("Following Journal Vouchers have been created automatically") + \ + ":\n%s" % ("\n".join([("%s" % (jv, jv)) for jv in jv_list]),)) + + msgprint(_("""These adjustment vouchers book the difference between \ + the total value of received items and the total value of invoiced items, \ + as a required step to use Auto Inventory Accounting. + This is an approximation to get you started. + You will need to submit these vouchers after checking if the values are correct. + For more details, read: \ + \ + Auto Inventory Accounting""")) webnotes.msgprint("""Please refresh the system to get effect of Auto Inventory Accounting""")