Redesigned budgets

This commit is contained in:
Nabin Hait
2016-05-18 12:22:42 +05:30
parent b9bc7d6df3
commit ca90963d5b
29 changed files with 501 additions and 745 deletions

View File

@@ -3,6 +3,7 @@
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:company_name",
"beta": 0,
"creation": "2013-04-10 08:35:39",
"custom": 0,
"description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.",
@@ -661,7 +662,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Cost Center",
"label": "Deafult Cost Center",
"length": 0,
"no_copy": 1,
"options": "Cost Center",
@@ -675,59 +676,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "credit_days_based_on",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Credit Days Based On",
"length": 0,
"no_copy": 0,
"options": "\nFixed Days\nLast Day of the Next Month",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:(!doc.__islocal && doc.credit_days_based_on=='Fixed Days')",
"fieldname": "credit_days",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Credit Days",
"length": 0,
"no_copy": 0,
"oldfieldname": "credit_days",
"oldfieldtype": "Int",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -784,21 +732,19 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "yearly_bgt_flag",
"fieldname": "credit_days_based_on",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "If Yearly Budget Exceeded (for expense account)",
"label": "Credit Days Based On",
"length": 0,
"no_copy": 0,
"oldfieldname": "yearly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"options": "\nFixed Days\nLast Day of the Next Month",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -812,20 +758,19 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "monthly_bgt_flag",
"fieldtype": "Select",
"depends_on": "eval:(!doc.__islocal && doc.credit_days_based_on=='Fixed Days')",
"fieldname": "credit_days",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "If Monthly Budget Exceeded (for expense account)",
"label": "Credit Days",
"length": 0,
"no_copy": 0,
"oldfieldname": "monthly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"oldfieldname": "credit_days",
"oldfieldtype": "Int",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -1387,7 +1332,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-03-10 04:34:43.440914",
"modified": "2016-05-16 15:24:47.178826",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
@@ -1534,7 +1479,9 @@
"write": 0
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC"
"sort_order": "ASC",
"track_seen": 0
}

View File

@@ -194,17 +194,11 @@ class Company(Document):
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
if not rec:
# delete Account
frappe.db.sql("delete from `tabAccount` where company = %s", self.name)
# delete cost center child table - budget detail
frappe.db.sql("""delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc
where bd.parent = cc.name and cc.company = %s""", self.name)
#delete cost center
frappe.db.sql("delete from `tabCost Center` WHERE company = %s", self.name)
# delete account from customer and supplier
frappe.db.sql("delete from `tabParty Account` where company=%s", self.name)
frappe.db.sql("""delete from `tabBudget Account` b
where exists(select name from tabBudget where name=b.parent and company = %s)""", self.name)
for doctype in ["Account", "Cost Center", "Budget", "Party Account"]:
frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)
if not frappe.db.get_value("Stock Ledger Entry", {"company": self.name}):
frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.name)

View File

@@ -14,7 +14,8 @@ def delete_company_transactions(company_name):
doc = frappe.get_doc("Company", company_name)
if frappe.session.user != doc.owner:
frappe.throw(_("Transactions can only be deleted by the creator of the Company"), frappe.PermissionError)
frappe.throw(_("Transactions can only be deleted by the creator of the Company"),
frappe.PermissionError)
delete_bins(company_name)
delete_time_logs(company_name)
@@ -22,7 +23,7 @@ def delete_company_transactions(company_name):
for doctype in frappe.db.sql_list("""select parent from
tabDocField where fieldtype='Link' and options='Company'"""):
if doctype not in ("Account", "Cost Center", "Warehouse", "Budget Detail",
if doctype not in ("Account", "Cost Center", "Warehouse", "Budget",
"Party Account", "Employee", "Sales Taxes and Charges Template",
"Purchase Taxes and Charges Template", "POS Profile", 'BOM'):
delete_for_doctype(doctype, company_name)