From 4af2dbf84da08513bff53b9b259fee0cb200cb70 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 12 Aug 2013 12:24:08 +0530 Subject: [PATCH] [perpetual accounting] [minor] patch for intial setup --- accounts/utils.py | 8 +++--- .../p01_perpetual_accounting_patch.py | 7 +++-- patches/march_2013/p08_create_aii_accounts.py | 22 +-------------- public/js/complete_setup.js | 2 +- setup/doctype/company/company.py | 28 ++++++++++--------- 5 files changed, 26 insertions(+), 41 deletions(-) diff --git a/accounts/utils.py b/accounts/utils.py index e3c0691b33e..e49d4b1d347 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -269,7 +269,7 @@ def create_stock_in_hand_jv(reverse=False): "posting_date": today, "fiscal_year": fiscal_year, "voucher_type": "Journal Entry", - "user_remark": (_("Auto Inventory Accounting") + ": " + + "user_remark": (_("Perpetual Accounting") + ": " + (_("Disabled") if reverse else _("Enabled")) + ". " + _("Journal Entry for inventory that is received but not yet invoiced")) }, @@ -297,14 +297,14 @@ def create_stock_in_hand_jv(reverse=False): 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. + as a required step to use Perpetual 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""")) + Perpetual Accounting""")) - webnotes.msgprint("""Please refresh the system to get effect of Auto Inventory Accounting""") + webnotes.msgprint("""Please refresh the system to get effect of Perpetual Accounting""") def get_stock_rbnb_value(company): diff --git a/patches/august_2013/p01_perpetual_accounting_patch.py b/patches/august_2013/p01_perpetual_accounting_patch.py index de231a15f5c..b3c993dd6ec 100644 --- a/patches/august_2013/p01_perpetual_accounting_patch.py +++ b/patches/august_2013/p01_perpetual_accounting_patch.py @@ -2,8 +2,12 @@ import webnotes from webnotes.utils import cint def execute(): + import patches.march_2013.p08_create_aii_accounts + patches.march_2013.p08_create_aii_accounts.execute() + copy_perpetual_accounting_settings() set_missing_cost_center() + def set_missing_cost_center(): reload_docs = [ @@ -17,8 +21,7 @@ def set_missing_cost_center(): if cint(webnotes.defaults.get_global_default("perpetual_accounting")): for dt in ["Serial No", "Stock Reconciliation", "Stock Entry"]: webnotes.conn.sql("""update `tab%s` t1, tabCompany t2 - set t1.cost_center=t2.stock_adjustment_cost_center - where t1.company = t2.name""" % dt) + set t1.cost_center=t2.cost_center where t1.company = t2.name""" % dt) def copy_perpetual_accounting_settings(): webnotes.reload_doc("accounts", "doctype", "accounts_settings") diff --git a/patches/march_2013/p08_create_aii_accounts.py b/patches/march_2013/p08_create_aii_accounts.py index 03ba36ca7e5..8f4fa4ac74c 100644 --- a/patches/march_2013/p08_create_aii_accounts.py +++ b/patches/march_2013/p08_create_aii_accounts.py @@ -8,7 +8,6 @@ def execute(): create_chart_of_accounts_if_not_exists() add_group_accounts() add_ledger_accounts() - add_aii_cost_center() set_default_accounts() def set_default_accounts(): @@ -79,26 +78,7 @@ def add_accounts(accounts_to_add, check_fn=None): "company": company }) account.insert() - -def add_aii_cost_center(): - for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""): - if not webnotes.conn.sql("""select name from `tabCost Center` where cost_center_name = - 'Auto Inventory Accounting' and company = %s""", company): - parent_cost_center = webnotes.conn.get_value("Cost Center", - {"parent_cost_center['']": '', "company": company}) - - if not parent_cost_center: - webnotes.errprint("Company " + company + "does not have a root cost center") - continue - - cc = webnotes.bean({ - "doctype": "Cost Center", - "cost_center_name": "Auto Inventory Accounting", - "parent_cost_center": parent_cost_center, - "group_or_ledger": "Ledger", - "company": company - }) - cc.insert() + def create_chart_of_accounts_if_not_exists(): for company in webnotes.conn.sql("select name from `tabCompany`"): diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js index b661e025d06..e565621a2ae 100644 --- a/public/js/complete_setup.js +++ b/public/js/complete_setup.js @@ -122,5 +122,5 @@ $.extend(erpnext.complete_setup, { fy_start_list: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'], - domains: ['', "Manufacturing", "Retail", "Distribution", "Services"], + domains: ['', "Manufacturing", "Retail", "Distribution", "Services", "Other"], }); \ No newline at end of file diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 66c83d69338..8b8e71e0fd1 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import webnotes from webnotes import _, msgprint -from webnotes.utils import cstr +from webnotes.utils import cstr, cint from webnotes.model.doc import Document from webnotes.model.code import get_obj import webnotes.defaults @@ -58,11 +58,15 @@ class DocType: def create_default_warehouses(self): for whname in ("Stores", "Work In Progress", "Finished Goods"): - webnotes.bean({ + wh = { "doctype":"Warehouse", "warehouse_name": whname, "company": self.doc.name - }).insert() + } + if cint(webnotes.defaults.get_global_default("perpetual_accounting")): + wh.update({"account": "Stock In Hand - " + self.doc.abbr}) + + webnotes.bean(wh).insert() def create_default_web_page(self): if not webnotes.conn.get_value("Website Settings", None, "home_page"): @@ -242,8 +246,8 @@ class DocType: "default_expense_account": "Cost of Goods Sold", "receivables_group": "Accounts Receivable", "payables_group": "Accounts Payable", + "default_cash_account": "Cash", "stock_received_but_not_billed": "Stock Received But Not Billed", - "stock_in_hand_account": "Stock In Hand", "stock_adjustment_account": "Stock Adjustment", "expenses_included_in_valuation": "Expenses Included In Valuation" } @@ -253,9 +257,6 @@ class DocType: if not self.doc.fields.get(a) and webnotes.conn.exists("Account", account_name): webnotes.conn.set(self.doc, a, account_name) - if not self.doc.stock_adjustment_cost_center: - webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center) - def create_default_cost_center(self): cc_list = [ { @@ -272,14 +273,15 @@ class DocType: }, ] for cc in cc_list: - cc.update({"doctype": "Cost Center"}) - cc_bean = webnotes.bean(cc) - cc_bean.ignore_permissions = True + if webnotes.conn.exists("Cost Center", cc.cost_center_name + ' - ' + self.doc.abbr): + cc.update({"doctype": "Cost Center"}) + cc_bean = webnotes.bean(cc) + cc_bean.ignore_permissions = True - if cc.get("cost_center_name") == self.doc.name: - cc_bean.ignore_mandatory = True + if cc.get("cost_center_name") == self.doc.name: + cc_bean.ignore_mandatory = True - cc_bean.insert() + cc_bean.insert() webnotes.conn.set(self.doc, "cost_center", "Main - " + self.doc.abbr)