From 8a4111fe0eca17c786c4eb6ea5ad6cd03ea2fa6c Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 17 Jan 2014 18:50:44 +0530 Subject: [PATCH 01/15] decimal places fixed in item prices report --- stock/report/item_prices/item_prices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py index e744cc73e4..18228ff64b 100644 --- a/stock/report/item_prices/item_prices.py +++ b/stock/report/item_prices/item_prices.py @@ -15,8 +15,8 @@ def execute(filters=None): bom_rate = get_item_bom_rate() val_rate_map = get_valuation_rate() - precision = get_currency_precision or 2 - + precision = get_currency_precision() or 2 + data = [] for item in sorted(item_map): data.append([item, item_map[item]["item_name"], From 529709e08b08ba51479d6a69a55662107361cc17 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 20 Jan 2014 16:39:03 +0530 Subject: [PATCH 02/15] patch for enabling all price list --- patches/1401/enable_all_price_list.py | 9 +++++++++ patches/patch_list.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 patches/1401/enable_all_price_list.py diff --git a/patches/1401/enable_all_price_list.py b/patches/1401/enable_all_price_list.py new file mode 100644 index 0000000000..9cf141fe67 --- /dev/null +++ b/patches/1401/enable_all_price_list.py @@ -0,0 +1,9 @@ +# Copyright (c) 2014, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.reload_doc("stock", "doctype", "price_list") + webnotes.conn.sql("""update `tabPrice List` set enabled=1""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 5bf730af0b..89e33091bf 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -266,5 +266,5 @@ patch_list = [ "patches.1401.p01_move_related_property_setters_to_custom_field", "patches.1401.p01_make_buying_selling_as_check_box_in_price_list", "patches.1401.update_billing_status_for_zero_value_order", - "execute:webnotes.reload_doc('stock', 'doctype', 'price_list') #2014-01-20", + "patches.1401.enable_all_price_list", ] \ No newline at end of file From afe93d633ca0320d5e57fbb4b2049be71bbc5524 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 Jan 2014 18:28:48 +0530 Subject: [PATCH 03/15] Increased remarks width in general ledger --- accounts/report/general_ledger/general_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index 2f5716ece3..4b1a63b8b3 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -34,7 +34,7 @@ def validate_filters(filters, account_details): def get_columns(): return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100", "Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20", - "Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::200"] + "Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::400"] def get_result(filters, account_details): gl_entries = get_gl_entries(filters) From 872e4d1f3d660355ceec220967983aa4ee19e7f2 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 20 Jan 2014 19:51:25 +0600 Subject: [PATCH 04/15] bumped to version 3.6.4 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 450e2bca6d..5a916c569b 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.6.3", + "app_version": "3.6.4", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.7.3" + "requires_framework_version": "==3.7.4" } \ No newline at end of file From b2f2df4c64609fcc3dc6fe0d049886baaf2b688d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Jan 2014 11:58:17 +0530 Subject: [PATCH 05/15] General ledger: opening balance issue fixed --- accounts/report/general_ledger/general_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index 4b1a63b8b3..02e970b39c 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -138,7 +138,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map): for gle in gl_entries: amount = flt(gle.debit) - flt(gle.credit) if filters.get("account") and (gle.posting_date < filters.from_date - or cstr(gle.is_advance) == "Yes"): + or cstr(gle.is_opening) == "Yes"): gle_map[gle.account].opening += amount opening += amount elif gle.posting_date <= filters.to_date: From f3aba2e536a58427b477c4064847ce38ea06a753 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 21 Jan 2014 12:39:31 +0600 Subject: [PATCH 06/15] bumped to version 3.6.5 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 5a916c569b..d45459417f 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.6.4", + "app_version": "3.6.5", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 13a9e27320b18883e59f3a69175c064d69ad12ed Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 21 Jan 2014 20:57:39 +0530 Subject: [PATCH 07/15] Fixes in warehouse merge function --- stock/doctype/warehouse/warehouse.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index e1b0ef3cc9..0b2fa840c5 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -92,23 +92,19 @@ class DocType: exists for this warehouse.""")) def before_rename(self, olddn, newdn, merge=False): - # Add company abbr if not provided - from setup.doctype.company.company import get_name_with_abbr - new_warehouse = get_name_with_abbr(newdn, self.doc.company) - if merge: if not webnotes.conn.exists("Warehouse", newdn): webnotes.throw(_("Warehouse ") + newdn +_(" does not exists")) - if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"): + if self.doc.company != webnotes.conn.get_value("Warehouse", newdn, "company"): webnotes.throw(_("Both Warehouse must belong to same Company")) webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn) from accounts.utils import rename_account_for - rename_account_for("Warehouse", olddn, new_warehouse, merge) + rename_account_for("Warehouse", olddn, newdn, merge) - return new_warehouse + return newdn def after_rename(self, olddn, newdn, merge=False): if merge: From 423932fab2f266efe7a5b443a39fed08289e0449 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 22 Jan 2014 11:52:54 +0530 Subject: [PATCH 08/15] Fixes in general ledger opening --- accounts/report/general_ledger/general_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index 02e970b39c..af6a87ca97 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -51,7 +51,7 @@ def get_gl_entries(filters): gl_entries = webnotes.conn.sql("""select posting_date, account, sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit, - voucher_type, voucher_no, cost_center, remarks, is_advance, against + voucher_type, voucher_no, cost_center, remarks, is_opening, against from `tabGL Entry` where company=%(company)s {conditions} {group_by_condition} From c7676797e1f6a847a69d05e5fec88b37c3dd5322 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 22 Jan 2014 15:36:44 +0530 Subject: [PATCH 09/15] Dont display old fraction outstanding in AR report --- .../report/accounts_receivable/accounts_receivable.py | 5 ++++- accounts/utils.py | 11 ++++++++++- stock/report/item_prices/item_prices.py | 9 +-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index de96abb7d7..c826fcbd13 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -37,12 +37,15 @@ class AccountsReceivableReport(object): return columns def get_data(self, customer_naming_by): + from accounts.utils import get_currency_precision + currency_precision = get_currency_precision() or 2 + data = [] future_vouchers = self.get_entries_after(self.filters.report_date) for gle in self.get_entries_till(self.filters.report_date): if self.is_receivable(gle, future_vouchers): outstanding_amount = self.get_outstanding_amount(gle, self.filters.report_date) - if abs(outstanding_amount) > 0.0: + if abs(outstanding_amount) > 0.1/10**currency_precision: due_date = self.get_due_date(gle) invoiced_amount = gle.debit if (gle.debit > 0) else 0 payment_received = invoiced_amount - outstanding_amount diff --git a/accounts/utils.py b/accounts/utils.py index fdd57b35c2..a3557aed09 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -378,4 +378,13 @@ def get_account_for(account_for_doctype, account_for): account_for_field = "account_type" return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype, - "master_name": account_for}) \ No newline at end of file + "master_name": account_for}) + +def get_currency_precision(currency=None): + if not currency: + currency = webnotes.conn.get_value("Company", + webnotes.conn.get_default("company"), "default_currency") + currency_format = webnotes.conn.get_value("Currency", currency, "number_format") + + from webnotes.utils import get_number_format_info + return get_number_format_info(currency_format)[2] \ No newline at end of file diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py index c9efd69829..50c923bad4 100644 --- a/stock/report/item_prices/item_prices.py +++ b/stock/report/item_prices/item_prices.py @@ -15,6 +15,7 @@ def execute(filters=None): bom_rate = get_item_bom_rate() val_rate_map = get_valuation_rate() + from accounts.utils import get_currency_precision precision = get_currency_precision() or 2 data = [] for item in sorted(item_map): @@ -29,14 +30,6 @@ def execute(filters=None): ]) return columns, data - -def get_currency_precision(): - company_currency = webnotes.conn.get_value("Company", - webnotes.conn.get_default("company"), "default_currency") - currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format") - - from webnotes.utils import get_number_format_info - return get_number_format_info(currency_format)[2] def get_columns(filters): """return columns based on filters""" From 7395dc996942a9da58660396ae4e85d75649ab5d Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Wed, 22 Jan 2014 16:33:07 +0600 Subject: [PATCH 10/15] bumped to version 3.6.6 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index d45459417f..f71ed9b572 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.6.5", + "app_version": "3.6.6", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.7.4" + "requires_framework_version": "==3.7.5" } \ No newline at end of file From 82a21beba04bde8ec5b1ee6402c2812b7cef2ecf Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 22 Jan 2014 16:55:32 +0530 Subject: [PATCH 11/15] Item List refresh when price list changed in POS --- accounts/doctype/sales_invoice/pos.js | 52 +++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index b71b45e55b..21ccd01eaa 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -109,6 +109,7 @@ erpnext.POS = Class.extend({ this.party = party; this.price_list = (party == "Customer" ? this.frm.doc.selling_price_list : this.frm.doc.buying_price_list); + this.price_list_field = (party == "Customer" ? "selling_price_list" : "buying_price_list"); this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase"); this.net_total = "net_total_" + export_or_import; this.grand_total = "grand_total_" + export_or_import; @@ -324,10 +325,12 @@ erpnext.POS = Class.extend({ } } }); - me.refresh(); + this.refresh(); }, refresh: function() { var me = this; + + this.refresh_item_list(); this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]); this.barcode.set_input(""); @@ -350,6 +353,14 @@ erpnext.POS = Class.extend({ this.make_party(); } }, + refresh_item_list: function() { + var me = this; + // refresh item list on change of price list + if (this.frm.doc[this.price_list_field] != this.price_list) { + this.price_list = this.frm.doc[this.price_list_field]; + this.make_item_list(); + } + }, show_items_in_item_cart: function() { var me = this; var $items = this.wrapper.find("#cart tbody").empty(); @@ -383,9 +394,8 @@ erpnext.POS = Class.extend({ )).appendTo($items); }); - this.wrapper.find(".increase-qty, .decrease-qty").on("click", function() { - var item_code = $(this).closest("tr").attr("id"); - me.selected_item_qty_operation(item_code, $(this).attr("class")); + this.wrapper.find("input.qty").on("focus", function() { + $(this).select(); }); }, show_taxes: function() { @@ -422,10 +432,16 @@ erpnext.POS = Class.extend({ // append quantity to the respective item after change from input box $(this.wrapper).find("input.qty").on("change", function() { - var item_code = $(this).closest("tr")[0].id; + var item_code = $(this).closest("tr").attr("id"); me.update_qty(item_code, $(this).val()); }); + // increase/decrease qty on plus/minus button + $(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() { + var tr = $(this).closest("tr"); + me.increase_decrease_qty(tr, $(this).attr("class")); + }); + // on td click toggle the highlighting of row $(this.wrapper).find("#cart tbody tr td").on("click", function() { var row = $(this).closest("tr"); @@ -443,6 +459,15 @@ erpnext.POS = Class.extend({ me.refresh_delete_btn(); this.barcode.$input.focus(); }, + increase_decrease_qty: function(tr, operation) { + var item_code = tr.attr("id"); + var item_qty = cint(tr.find("input.qty").val()); + + if (operation == "increase-qty") + this.update_qty(item_code, item_qty + 1); + else if (operation == "decrease-qty" && item_qty != 1) + this.update_qty(item_code, item_qty - 1); + }, disable_text_box_and_button: function() { var me = this; // if form is submitted & cancelled then disable all input box & buttons @@ -518,23 +543,6 @@ erpnext.POS = Class.extend({ this.frm.script_manager.trigger("calculate_taxes_and_totals"); this.refresh(); }, - selected_item_qty_operation: function(item_code, operation) { - var me = this; - var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, - this.frm.cscript.fname, this.frm.doctype); - - $.each(child, function(i, d) { - if (d.item_code == item_code) { - if (operation == "increase-qty") - d.qty += 1; - else if (operation == "decrease-qty") - d.qty != 1 ? d.qty -= 1 : d.qty = 1; - - me.frm.script_manager.trigger("qty", d.doctype, d.name); - me.refresh(); - } - }); - }, make_payment: function() { var me = this; var no_of_items = $(this.wrapper).find("#cart tbody tr").length; From 8589b1db2208ea0472480b41614a23066835d178 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 22 Jan 2014 19:25:51 +0530 Subject: [PATCH 12/15] Use model set_value for updating values from POS --- accounts/doctype/sales_invoice/pos.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 21ccd01eaa..a594f7f941 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -270,22 +270,17 @@ erpnext.POS = Class.extend({ this.frm.cscript.fname, this.frm.doctype), function(i, d) { if (d.item_code == item_code) { caught = true; - if (serial_no) { - d.serial_no += '\n' + serial_no; - me.frm.script_manager.trigger("serial_no", d.doctype, d.name); - } - else { - d.qty += 1; - me.frm.script_manager.trigger("qty", d.doctype, d.name); - } + if (serial_no) + wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no); + else + wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1); } }); } // if item not found then add new item - if (!caught) { + if (!caught) this.add_new_item_to_grid(item_code, serial_no); - } this.refresh(); this.refresh_search_box(); @@ -320,8 +315,7 @@ erpnext.POS = Class.extend({ wn.model.clear_doc(d.doctype, d.name); me.refresh_grid(); } else { - d.qty = qty; - me.frm.script_manager.trigger("qty", d.doctype, d.name); + wn.model.set_value(d.doctype, d.name, "qty", qty); } } }); @@ -539,6 +533,7 @@ erpnext.POS = Class.extend({ this.refresh_grid(); }, refresh_grid: function() { + this.frm.dirty(); this.frm.fields_dict[this.frm.cscript.fname].grid.refresh(); this.frm.script_manager.trigger("calculate_taxes_and_totals"); this.refresh(); From 557abdebe09af858b21d2473af51bf113b0876cd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 23 Jan 2014 13:25:26 +0530 Subject: [PATCH 13/15] order preview through customer login --- portal/templates/sale.html | 4 ++-- portal/utils.py | 12 +++++++----- selling/doctype/sales_order/templates/pages/order.py | 11 ++++++----- selling/utils/cart.py | 5 +++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 5dc72c793b..c0996cc4f1 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -10,9 +10,9 @@
  • {{ doc.name }}
  • {{ doc.name }}

    - {% if doc.name == "Not Allowed" -%} + {% if session_user == "Guest" -%} - {% else %} + {% elif doc.name != "Not Allowed"%}
    diff --git a/portal/utils.py b/portal/utils.py index 89800f3e1d..e210f1a020 100644 --- a/portal/utils.py +++ b/portal/utils.py @@ -41,21 +41,23 @@ def get_currency_context(): } def get_transaction_context(doctype, name): + context = {"session_user": webnotes.session.user} + customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer") bean = webnotes.bean(doctype, name) if bean.doc.customer != customer: - return { - "doc": {"name": "Not Allowed"} - } + context.update({"doc": {"name": "Not Allowed"}}) else: - return { + context.update({ "doc": bean.doc, "doclist": bean.doclist, "webnotes": webnotes, "utils": webnotes.utils - } + }) + + return context @webnotes.whitelist(allow_guest=True) def send_message(subject="Website Query", message="", sender="", status="Open"): diff --git a/selling/doctype/sales_order/templates/pages/order.py b/selling/doctype/sales_order/templates/pages/order.py index d53a8b0f6f..9b4a83ce21 100644 --- a/selling/doctype/sales_order/templates/pages/order.py +++ b/selling/doctype/sales_order/templates/pages/order.py @@ -10,11 +10,12 @@ no_cache = True def get_context(): from portal.utils import get_transaction_context context = get_transaction_context("Sales Order", webnotes.form_dict.name) - modify_status(context.get("doc")) - context.update({ - "parent_link": "orders", - "parent_title": "My Orders" - }) + if context.get("doc").get("name") != "Not Allowed": + modify_status(context.get("doc")) + context.update({ + "parent_link": "orders", + "parent_title": "My Orders" + }) return context def modify_status(doc): diff --git a/selling/utils/cart.py b/selling/utils/cart.py index 3cd7b3c9f1..79046270a9 100644 --- a/selling/utils/cart.py +++ b/selling/utils/cart.py @@ -282,7 +282,7 @@ def apply_cart_settings(party=None, quotation=None): party = get_lead_or_customer() if not quotation: quotation = _get_cart_quotation(party) - + cart_settings = webnotes.get_obj("Shopping Cart Settings") billing_territory = get_address_territory(quotation.doc.customer_address) or \ @@ -310,7 +310,8 @@ def set_price_list_and_rate(quotation, cart_settings, billing_territory): quotation.run_method("set_price_list_and_item_details") # set it in cookies for using in product page - webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list) + if quotation.doc.selling_price_list: + webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list) def set_taxes(quotation, cart_settings, billing_territory): """set taxes based on billing territory""" From d9ba544e09e6ed87216d7a0a3e585d1a31ec2cb0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 24 Jan 2014 15:59:05 +0530 Subject: [PATCH 14/15] Fix in Item Test Case --- stock/doctype/item/test_item.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py index b8f6f9e246..47541749db 100644 --- a/stock/doctype/item/test_item.py +++ b/stock/doctype/item/test_item.py @@ -36,6 +36,7 @@ test_records = [ "stock_uom": "_Test UOM", "default_income_account": "Sales - _TC", "default_warehouse": "_Test Warehouse - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC" }, { "doctype": "Item Reorder", "parentfield": "item_reorder", @@ -64,6 +65,7 @@ test_records = [ "stock_uom": "_Test UOM", "default_income_account": "Sales - _TC", "default_warehouse": "_Test Warehouse - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC" }], [{ "doctype": "Item", @@ -73,6 +75,7 @@ test_records = [ "item_group": "_Test Item Group Desktops", "default_warehouse": "_Test Warehouse - _TC", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_stock_item": "Yes", "is_asset_item": "No", "has_batch_no": "No", @@ -99,6 +102,7 @@ test_records = [ "item_group": "_Test Item Group Desktops", "default_warehouse": "_Test Warehouse - _TC", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_stock_item": "Yes", "is_asset_item": "No", "has_batch_no": "No", @@ -119,6 +123,7 @@ test_records = [ "description": "_Test Sales BOM Item", "item_group": "_Test Item Group Desktops", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_stock_item": "No", "is_asset_item": "No", "has_batch_no": "No", @@ -140,6 +145,7 @@ test_records = [ "is_stock_item": "Yes", "default_warehouse": "_Test Warehouse - _TC", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_asset_item": "No", "has_batch_no": "No", "has_serial_no": "No", @@ -216,6 +222,7 @@ test_records = [ "item_group": "_Test Item Group Desktops", "default_warehouse": "_Test Warehouse - _TC", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_stock_item": "Yes", "is_asset_item": "No", "has_batch_no": "No", @@ -238,6 +245,7 @@ test_records = [ "is_stock_item": "Yes", "default_warehouse": "_Test Warehouse - _TC", "default_income_account": "Sales - _TC", + "purchase_account": "_Test Account Cost for Goods Sold - _TC", "is_asset_item": "No", "has_batch_no": "No", "has_serial_no": "No", From fc13b87fd56c6b9fa8ac8b8e9fcbf88f62c8749b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 24 Jan 2014 18:54:50 +0530 Subject: [PATCH 15/15] Fixes in Make Demo --- accounts/doctype/sales_invoice/sales_invoice.py | 7 ++----- .../requested_items_to_be_ordered.txt | 4 ++-- utilities/demo/demo_docs/Fiscal_Year.csv | 3 ++- utilities/demo/make_demo.py | 15 +++++++++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index a39702b3fc..1768b9b02f 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -320,12 +320,9 @@ class DocType(SellingController): item = webnotes.conn.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code) acc = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account) if not acc: - msgprint("Account: "+d.income_account+" does not exist in the system") - raise Exception + msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True) elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account': - msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code) - raise Exception - + msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code, raise_exception=True) def validate_with_previous_doc(self): super(DocType, self).validate_with_previous_doc(self.tname, { diff --git a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt index 49c747854a..4d3558ca68 100644 --- a/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt +++ b/buying/report/requested_items_to_be_ordered/requested_items_to_be_ordered.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-13 16:10:02", "docstatus": 0, - "modified": "2013-05-13 16:21:07", + "modified": "2014-01-24 18:19:11", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,7 +11,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc", + "query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc", "ref_doctype": "Purchase Order", "report_name": "Requested Items To Be Ordered", "report_type": "Query Report" diff --git a/utilities/demo/demo_docs/Fiscal_Year.csv b/utilities/demo/demo_docs/Fiscal_Year.csv index d56b1b9b94..1a06e872b8 100644 --- a/utilities/demo/demo_docs/Fiscal_Year.csv +++ b/utilities/demo/demo_docs/Fiscal_Year.csv @@ -20,4 +20,5 @@ Info:,,,,,"One of: No, Yes" Start entering data below this line,,,, ,,2009,01-01-2009,31-12-2009,No ,,2010,01-01-2010,31-12-2010,No -,,2011,01-01-2011,31-12-2011,No \ No newline at end of file +,,2011,01-01-2011,31-12-2011,No +,,2012,01-01-2012,31-12-2012,No \ No newline at end of file diff --git a/utilities/demo/make_demo.py b/utilities/demo/make_demo.py index b98fd7ac9c..99c3e8b7e8 100644 --- a/utilities/demo/make_demo.py +++ b/utilities/demo/make_demo.py @@ -19,7 +19,7 @@ company_abbr = "WP" country = "United States" currency = "USD" time_zone = "America/New_York" -start_date = '2013-01-01' +start_date = '2014-01-01' bank_name = "Citibank" runs_for = None prob = { @@ -105,6 +105,10 @@ def run_accounts(current_date): for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]: si = webnotes.bean(make_sales_invoice(so)) si.doc.posting_date = current_date + for d in si.doclist.get({"parentfield": "entries"}): + if not d.income_account: + d.income_account = "Sales - {}".format(company_abbr) + si.insert() si.submit() webnotes.conn.commit() @@ -170,6 +174,9 @@ def run_stock(current_date): dn = webnotes.bean(make_delivery_note(so)) dn.doc.posting_date = current_date dn.doc.fiscal_year = current_date.year + for d in dn.doclist.get({"parentfield": "delivery_note_details"}): + d.expense_account = "Cost of Goods Sold - {}".format(company_abbr) + dn.insert() try: dn.submit() @@ -236,7 +243,7 @@ def run_manufacturing(current_date): ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool") ppt.doc.company = company ppt.doc.use_multi_level_bom = 1 - ppt.doc.purchase_request_for_warehouse = "Stores - WP" + ppt.doc.purchase_request_for_warehouse = "Stores - {}".format(company_abbr) ppt.run_method("get_open_sales_orders") ppt.run_method("get_items_from_so") ppt.run_method("raise_production_order") @@ -380,8 +387,8 @@ def complete_setup(): setup_account({ "first_name": "Test", "last_name": "User", - "fy_start_date": "2013-01-01", - "fy_end_date": "2013-12-31", + "fy_start_date": "2014-01-01", + "fy_end_date": "2014-12-31", "industry": "Manufacturing", "company_name": company, "company_abbr": company_abbr,