Multiple fixes

This commit is contained in:
Nabin Hait 2015-01-10 16:03:49 +05:30
parent d49a123fd0
commit e8500ad4e6
15 changed files with 603 additions and 624 deletions

View File

@ -65,6 +65,22 @@
"reqd": 1,
"search_index": 1
},
{
"fieldname": "root_type",
"fieldtype": "Select",
"label": "Root Type",
"options": "\nAsset\nLiability\nIncome\nExpense\nEquity",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "report_type",
"fieldtype": "Select",
"label": "Report Type",
"options": "\nBalance Sheet\nProfit and Loss",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
@ -130,22 +146,6 @@
"options": "\nDebit\nCredit",
"permlevel": 0
},
{
"fieldname": "root_type",
"fieldtype": "Select",
"label": "Root Type",
"options": "\nAsset\nLiability\nIncome\nExpense\nEquity",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "report_type",
"fieldtype": "Select",
"label": "Report Type",
"options": "\nBalance Sheet\nProfit and Loss",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "lft",
"fieldtype": "Int",
@ -177,7 +177,7 @@
"icon": "icon-money",
"idx": 1,
"in_create": 0,
"modified": "2015-01-01 15:36:43.219662",
"modified": "2015-01-05 11:03:07.861934",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Account",

View File

@ -22,7 +22,9 @@ coa = {
},
"account_type": "Cash"
},
_("Loans and Advances (Assets)"): {},
_("Loans and Advances (Assets)"): {
"group_or_ledger": "Group"
},
_("Securities and Deposits"): {
_("Earnest Money"): {}
},

View File

@ -12,7 +12,7 @@ from erpnext.controllers.trends import get_period_date_ranges, get_period_month_
def execute(filters=None):
if not filters: filters = {}
columns = get_columns(filters)
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
cam_map = get_costcenter_account_month_map(filters)
@ -37,7 +37,7 @@ def execute(filters=None):
data.append(row)
return columns, sorted(data, key=lambda x: (x[0], x[1]))
def get_columns(filters):
for fieldname in ["fiscal_year", "period", "company"]:
if not filters.get(fieldname):
@ -55,45 +55,45 @@ def get_columns(filters):
label = label % (formatdate(from_date, format_string="MMM") + " - " + formatdate(from_date, format_string="MMM"))
else:
label = label % formatdate(from_date, format_string="MMM")
columns.append(label+":Float:120")
return columns + [_("Total Target") + ":Float:120", _("Total Actual") + ":Float:120",
return columns + [_("Total Target") + ":Float:120", _("Total Actual") + ":Float:120",
_("Total Variance") + ":Float:120"]
#Get cost center & target details
def get_costcenter_target_details(filters):
return frappe.db.sql("""select cc.name, cc.distribution_id,
cc.parent_cost_center, bd.account, bd.budget_allocated
from `tabCost Center` cc, `tabBudget Detail` bd
where bd.parent=cc.name and bd.fiscal_year=%s and
cc.company=%s order by cc.name""" % ('%s', '%s'),
return frappe.db.sql("""select cc.name, cc.distribution_id,
cc.parent_cost_center, bd.account, bd.budget_allocated
from `tabCost Center` cc, `tabBudget Detail` bd
where bd.parent=cc.name and bd.fiscal_year=%s and
cc.company=%s order by cc.name""" % ('%s', '%s'),
(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
#Get target distribution details of accounts of cost center
def get_target_distribution_details(filters):
target_details = {}
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
where mdp.parent=md.name and md.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
return target_details
#Get actual details from gl entry
def get_actual_details(filters):
ac_details = frappe.db.sql("""select gl.account, gl.debit, gl.credit,
gl.cost_center, MONTHNAME(gl.posting_date) as month_name
from `tabGL Entry` gl, `tabBudget Detail` bd
ac_details = frappe.db.sql("""select gl.account, gl.debit, gl.credit,
gl.cost_center, MONTHNAME(gl.posting_date) as month_name
from `tabGL Entry` gl, `tabBudget Detail` bd
where gl.fiscal_year=%s and company=%s
and bd.account=gl.account and bd.parent=gl.cost_center""" % ('%s', '%s'),
and bd.account=gl.account and bd.parent=gl.cost_center""" % ('%s', '%s'),
(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
cc_actual_details = {}
for d in ac_details:
cc_actual_details.setdefault(d.cost_center, {}).setdefault(d.account, []).append(d)
return cc_actual_details
def get_costcenter_account_month_map(filters):
@ -107,7 +107,7 @@ def get_costcenter_account_month_map(filters):
for ccd in costcenter_target_details:
for month_id in range(1, 13):
month = datetime.date(2013, month_id, 1).strftime('%B')
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, frappe._dict({
"target": 0.0, "actual": 0.0
@ -117,11 +117,11 @@ def get_costcenter_account_month_map(filters):
month_percentage = tdd.get(ccd.distribution_id, {}).get(month, 0) \
if ccd.distribution_id else 100.0/12
tav_dict.target = flt(ccd.budget_allocated) * month_percentage / 100
for ad in actual_details.get(ccd.name, {}).get(ccd.account, []):
if ad.month_name == month:
tav_dict.actual += flt(ad.debit) - flt(ad.credit)
return cam_map

View File

@ -309,9 +309,9 @@ def validate_expense_against_budget(args):
def get_allocated_budget(distribution_id, posting_date, fiscal_year, yearly_budget):
if distribution_id:
distribution = {}
for d in frappe.db.sql("""select bdd.month, bdd.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
where bdd.parent=bd.name and bd.fiscal_year=%s""", fiscal_year, as_dict=1):
for d in frappe.db.sql("""select mdp.month, mdp.percentage_allocation
from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
where mdp.parent=md.name and md.fiscal_year=%s""", fiscal_year, as_dict=1):
distribution.setdefault(d.month, d.percentage_allocation)
dt = frappe.db.get_value("Fiscal Year", fiscal_year, "year_start_date")
@ -413,8 +413,8 @@ def get_outstanding_invoices(amount_query, account, party_type, party):
})
return all_outstanding_vouchers
@frappe.whitelist()
def get_letter_head(company):
return frappe.db.get_value("Company",company,"default_letter_head")

View File

@ -1,257 +1,244 @@
{
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2013-01-10 16:34:11",
"description": "Supplier of Goods or Services.",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2013-01-10 16:34:11",
"description": "Supplier of Goods or Services.",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"fields": [
{
"fieldname": "basic_info",
"fieldtype": "Section Break",
"label": "Basic Info",
"oldfieldtype": "Section Break",
"options": "icon-user",
"fieldname": "basic_info",
"fieldtype": "Section Break",
"label": "Basic Info",
"oldfieldtype": "Section Break",
"options": "icon-user",
"permlevel": 0
},
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "SUPP-",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "SUPP-",
"permlevel": 0
},
},
{
"fieldname": "supplier_name",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Supplier Name",
"no_copy": 1,
"oldfieldname": "supplier_name",
"oldfieldtype": "Data",
"permlevel": 0,
"fieldname": "supplier_name",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Supplier Name",
"no_copy": 1,
"oldfieldname": "supplier_name",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 1
},
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"permlevel": 0,
"fieldname": "column_break0",
"fieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
},
{
"fieldname": "supplier_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Supplier Type",
"oldfieldname": "supplier_type",
"oldfieldtype": "Link",
"options": "Supplier Type",
"permlevel": 0,
"fieldname": "supplier_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Supplier Type",
"oldfieldname": "supplier_type",
"oldfieldtype": "Link",
"options": "Supplier Type",
"permlevel": 0,
"reqd": 1
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
"fieldtype": "Section Break",
"label": "Address & Contacts",
"oldfieldtype": "Column Break",
"options": "icon-map-marker",
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
"fieldtype": "Section Break",
"label": "Address & Contacts",
"oldfieldtype": "Column Break",
"options": "icon-map-marker",
"permlevel": 0
},
},
{
"fieldname": "address_html",
"fieldtype": "HTML",
"label": "Address HTML",
"permlevel": 0,
"fieldname": "address_html",
"fieldtype": "HTML",
"label": "Address HTML",
"permlevel": 0,
"read_only": 1
},
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0,
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
},
{
"fieldname": "contact_html",
"fieldtype": "HTML",
"label": "Contact HTML",
"permlevel": 0,
"fieldname": "contact_html",
"fieldtype": "HTML",
"label": "Contact HTML",
"permlevel": 0,
"read_only": 1
},
},
{
"fieldname": "default_payable_accounts",
"fieldtype": "Section Break",
"label": "Default Payable Accounts",
"fieldname": "default_payable_accounts",
"fieldtype": "Section Break",
"label": "Default Payable Accounts",
"permlevel": 0
},
},
{
"fieldname": "accounts",
"fieldtype": "Table",
"label": "Accounts",
"options": "Party Account",
"fieldname": "accounts",
"fieldtype": "Table",
"label": "Accounts",
"options": "Party Account",
"permlevel": 0
},
},
{
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"options": "icon-file-text",
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"options": "icon-file-text",
"permlevel": 0
},
},
{
"description": "Enter the company name under which Account Head will be created for this Supplier",
"fieldname": "company",
"fieldtype": "Link",
"in_filter": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"permlevel": 0,
"reqd": 1,
"search_index": 0
},
{
"fieldname": "default_currency",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Currency",
"no_copy": 1,
"options": "Currency",
"fieldname": "default_currency",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Currency",
"no_copy": 1,
"options": "Currency",
"permlevel": 0
},
},
{
"fieldname": "default_price_list",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Price List",
"options": "Price List",
"fieldname": "default_price_list",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Price List",
"options": "Price List",
"permlevel": 0
},
},
{
"fieldname": "default_taxes_and_charges",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Taxes and Charges",
"options": "Purchase Taxes and Charges Master",
"fieldname": "default_taxes_and_charges",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Taxes and Charges",
"options": "Purchase Taxes and Charges Master",
"permlevel": 0
},
},
{
"fieldname": "credit_days",
"fieldtype": "Int",
"label": "Credit Days",
"fieldname": "credit_days",
"fieldtype": "Int",
"label": "Credit Days",
"permlevel": 0
},
},
{
"fieldname": "column_break2",
"fieldtype": "Column Break",
"permlevel": 0,
"fieldname": "column_break2",
"fieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
},
{
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"oldfieldname": "website",
"oldfieldtype": "Data",
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"oldfieldname": "website",
"oldfieldtype": "Data",
"permlevel": 0
},
},
{
"description": "Statutory info and other general information about your Supplier",
"fieldname": "supplier_details",
"fieldtype": "Text",
"label": "Supplier Details",
"oldfieldname": "supplier_details",
"oldfieldtype": "Code",
"description": "Statutory info and other general information about your Supplier",
"fieldname": "supplier_details",
"fieldtype": "Text",
"label": "Supplier Details",
"oldfieldname": "supplier_details",
"oldfieldtype": "Code",
"permlevel": 0
},
},
{
"fieldname": "communications",
"fieldtype": "Table",
"hidden": 1,
"label": "Communications",
"options": "Communication",
"permlevel": 0,
"fieldname": "communications",
"fieldtype": "Table",
"hidden": 1,
"label": "Communications",
"options": "Communication",
"permlevel": 0,
"print_hide": 1
}
],
"icon": "icon-user",
"idx": 1,
"modified": "2015-01-06 17:32:39.936580",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
"owner": "Administrator",
],
"icon": "icon-user",
"idx": 1,
"modified": "2015-01-06 17:32:39.936580",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
"owner": "Administrator",
"permissions": [
{
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase User"
},
},
{
"amend": 0,
"create": 0,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Manager",
"submit": 0,
"amend": 0,
"create": 0,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Manager",
"submit": 0,
"write": 0
},
},
{
"amend": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Master Manager",
"submit": 0,
"amend": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Master Manager",
"submit": 0,
"write": 1
},
},
{
"apply_user_permissions": 1,
"permlevel": 0,
"read": 1,
"apply_user_permissions": 1,
"permlevel": 0,
"read": 1,
"role": "Material User"
},
},
{
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Material Manager"
},
},
{
"apply_user_permissions": 1,
"permlevel": 0,
"read": 1,
"apply_user_permissions": 1,
"permlevel": 0,
"read": 1,
"role": "Accounts User"
},
},
{
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager"
}
],
"search_fields": "supplier_name,supplier_type",
],
"search_fields": "supplier_name,supplier_type",
"title_field": "supplier_name"
}
}

View File

@ -139,7 +139,7 @@ def get_data():
{
"type":"doctype",
"name": "Monthly Distribution",
"description": _("Seasonality for setting budgets.")
"description": _("Seasonality for setting budgets, targets etc.")
},
{
"type": "doctype",

View File

@ -220,6 +220,9 @@ rename_map = {
],
"Journal Entry": [
["entries", "accounts"]
],
"Monthly Distribution": [
["budget_distribution_details", "percentages"]
]
}

View File

@ -71,9 +71,9 @@ def get_salesperson_details(filters):
def get_target_distribution_details(filters):
target_details = {}
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` mdp
where mdp.parent=md.name and md.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
return target_details

View File

@ -11,11 +11,11 @@ from erpnext.controllers.trends import get_period_date_ranges, get_period_month_
def execute(filters=None):
if not filters: filters = {}
columns = get_columns(filters)
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
tim_map = get_territory_item_month_map(filters)
data = []
for territory, territory_items in tim_map.items():
for item_group, monthwise_data in territory_items.items():
@ -36,7 +36,7 @@ def execute(filters=None):
data.append(row)
return columns, sorted(data, key=lambda x: (x[0], x[1]))
def get_columns(filters):
for fieldname in ["fiscal_year", "period", "target_on"]:
if not filters.get(fieldname):
@ -55,24 +55,24 @@ def get_columns(filters):
label = label % _(from_date.strftime("%b"))
columns.append(label+":Float:120")
return columns + [_("Total Target") + ":Float:120", _("Total Achieved") + ":Float:120",
return columns + [_("Total Target") + ":Float:120", _("Total Achieved") + ":Float:120",
_("Total Variance") + ":Float:120"]
#Get territory & item group details
def get_territory_details(filters):
return frappe.db.sql("""select t.name, td.item_group, td.target_qty,
td.target_amount, t.distribution_id
from `tabTerritory` t, `tabTarget Detail` td
where td.parent=t.name and td.fiscal_year=%s order by t.name""",
return frappe.db.sql("""select t.name, td.item_group, td.target_qty,
td.target_amount, t.distribution_id
from `tabTerritory` t, `tabTarget Detail` td
where td.parent=t.name and td.fiscal_year=%s order by t.name""",
(filters["fiscal_year"]), as_dict=1)
#Get target distribution details of item group
def get_target_distribution_details(filters):
target_details = {}
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
where mdp.parent=md.name and md.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
return target_details
@ -81,11 +81,11 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
so.territory, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
so.transaction_date<=%s""" % ('%s', '%s'),
item_details = frappe.db.sql("""select soi.item_code, soi.qty, soi.base_amount, so.transaction_date,
so.territory, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
so.transaction_date<=%s""" % ('%s', '%s'),
(start_date, end_date), as_dict=1)
item_actual_details = {}
@ -106,7 +106,7 @@ def get_territory_item_month_map(filters):
for td in territory_details:
for month_id in range(1, 13):
month = datetime.date(2013, month_id, 1).strftime('%B')
tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\
.setdefault(month, frappe._dict({
"target": 0.0, "achieved": 0.0
@ -130,4 +130,4 @@ def get_territory_item_month_map(filters):
return tim_map
def get_item_group(item_name):
return frappe.db.get_value("Item", item_name, "item_group")
return frappe.db.get_value("Item", item_name, "item_group")

View File

@ -1,404 +1,407 @@
{
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:company_name",
"creation": "2013-04-10 08:35:39",
"description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:company_name",
"creation": "2013-04-10 08:35:39",
"description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"fields": [
{
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Company Details",
"oldfieldtype": "Section Break",
"permlevel": 0,
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Company Details",
"oldfieldtype": "Section Break",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "company_name",
"fieldtype": "Data",
"label": "Company",
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"fieldname": "company_name",
"fieldtype": "Data",
"label": "Company",
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
},
{
"description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.",
"fieldname": "abbr",
"fieldtype": "Data",
"label": "Abbr",
"no_copy": 0,
"oldfieldname": "abbr",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.",
"fieldname": "abbr",
"fieldtype": "Data",
"label": "Abbr",
"no_copy": 0,
"oldfieldname": "abbr",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
},
{
"depends_on": "eval:!doc.__islocal && in_list(user_roles, \"System Manager\")",
"fieldname": "change_abbr",
"fieldtype": "Button",
"label": "Change Abbreviation",
"depends_on": "eval:!doc.__islocal && in_list(user_roles, \"System Manager\")",
"fieldname": "change_abbr",
"fieldtype": "Button",
"label": "Change Abbreviation",
"permlevel": 0
},
},
{
"fieldname": "cb0",
"fieldtype": "Column Break",
"permlevel": 0,
"fieldname": "cb0",
"fieldtype": "Column Break",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "domain",
"fieldtype": "Select",
"label": "Domain",
"options": "Distribution\nManufacturing\nRetail\nServices",
"permlevel": 0,
"fieldname": "domain",
"fieldtype": "Select",
"label": "Domain",
"options": "Distribution\nManufacturing\nRetail\nServices",
"permlevel": 0,
"reqd": 0
},
},
{
"fieldname": "charts_section",
"fieldtype": "Section Break",
"hidden": 0,
"label": "Chart of Accounts",
"fieldname": "charts_section",
"fieldtype": "Section Break",
"hidden": 0,
"label": "Chart of Accounts",
"permlevel": 0
},
},
{
"fieldname": "country",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Country",
"options": "Country",
"permlevel": 0,
"fieldname": "country",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Country",
"options": "Country",
"permlevel": 0,
"reqd": 1
},
},
{
"fieldname": "chart_of_accounts",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 1,
"label": "Chart of Accounts",
"options": "",
"fieldname": "chart_of_accounts",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 1,
"label": "Chart of Accounts",
"options": "",
"permlevel": 0
},
},
{
"fieldname": "default_settings",
"fieldtype": "Section Break",
"label": "Default Settings",
"oldfieldtype": "Section Break",
"permlevel": 0,
"fieldname": "default_settings",
"fieldtype": "Section Break",
"label": "Default Settings",
"oldfieldtype": "Section Break",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_bank_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Bank Account",
"no_copy": 1,
"oldfieldname": "default_bank_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_bank_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Bank Account",
"no_copy": 1,
"oldfieldname": "default_bank_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "default_cash_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Cash Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_cash_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Cash Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_receivable_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Receivable Account",
"no_copy": 1,
"oldfieldname": "receivables_group",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_receivable_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Receivable Account",
"no_copy": 1,
"oldfieldname": "receivables_group",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_payable_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Payable Account",
"no_copy": 1,
"oldfieldname": "payables_group",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_payable_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Payable Account",
"no_copy": 1,
"oldfieldname": "payables_group",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "default_expense_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Expense Account",
"no_copy": 1,
"options": "Account",
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_expense_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Expense Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0
},
},
{
"fieldname": "default_income_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Income Account",
"no_copy": 1,
"options": "Account",
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_income_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Income Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0
},
},
{
"fieldname": "default_holiday_list",
"fieldtype": "Link",
"label": "Default Holiday List",
"options": "Holiday List",
"permlevel": 0,
"fieldname": "default_holiday_list",
"fieldtype": "Link",
"label": "Default Holiday List",
"options": "Holiday List",
"permlevel": 0,
"precision": ""
},
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
},
{
"fieldname": "default_currency",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Currency",
"options": "Currency",
"permlevel": 0,
"read_only": 0,
"fieldname": "default_currency",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Currency",
"options": "Currency",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
},
{
"fieldname": "default_letter_head",
"fieldtype": "Link",
"label": "Default Letter Head",
"options": "Letter Head",
"permlevel": 0,
"fieldname": "default_letter_head",
"fieldtype": "Link",
"label": "Default Letter Head",
"options": "Letter Head",
"permlevel": 0,
"precision": ""
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "cost_center",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center",
"depends_on": "eval:!doc.__islocal",
"fieldname": "cost_center",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center",
"permlevel": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "credit_days",
"fieldtype": "Int",
"label": "Credit Days",
"oldfieldname": "credit_days",
"oldfieldtype": "Int",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "credit_days",
"fieldtype": "Int",
"label": "Credit Days",
"oldfieldname": "credit_days",
"oldfieldtype": "Int",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "credit_limit",
"fieldtype": "Currency",
"label": "Credit Limit",
"oldfieldname": "credit_limit",
"oldfieldtype": "Currency",
"options": "default_currency",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "credit_limit",
"fieldtype": "Currency",
"label": "Credit Limit",
"oldfieldname": "credit_limit",
"oldfieldtype": "Currency",
"options": "default_currency",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "yearly_bgt_flag",
"fieldtype": "Select",
"label": "If Yearly Budget Exceeded",
"oldfieldname": "yearly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "yearly_bgt_flag",
"fieldtype": "Select",
"label": "If Yearly Budget Exceeded",
"oldfieldname": "yearly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "monthly_bgt_flag",
"fieldtype": "Select",
"label": "If Monthly Budget Exceeded",
"oldfieldname": "monthly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "monthly_bgt_flag",
"fieldtype": "Select",
"label": "If Monthly Budget Exceeded",
"oldfieldname": "monthly_bgt_flag",
"oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop",
"permlevel": 0,
"read_only": 0
},
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "auto_accounting_for_stock_settings",
"fieldtype": "Section Break",
"label": "Auto Accounting For Stock Settings",
"permlevel": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "auto_accounting_for_stock_settings",
"fieldtype": "Section Break",
"label": "Auto Accounting For Stock Settings",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "stock_received_but_not_billed",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Stock Received But Not Billed",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"fieldname": "stock_received_but_not_billed",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Stock Received But Not Billed",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "stock_adjustment_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Stock Adjustment Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"fieldname": "stock_adjustment_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Stock Adjustment Account",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "expenses_included_in_valuation",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Expenses Included In Valuation",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"fieldname": "expenses_included_in_valuation",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Expenses Included In Valuation",
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"read_only": 0
},
},
{
"description": "For reference only.",
"fieldname": "company_info",
"fieldtype": "Section Break",
"label": "Company Info",
"permlevel": 0,
"description": "For reference only.",
"fieldname": "company_info",
"fieldtype": "Section Break",
"label": "Company Info",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "address",
"fieldtype": "Small Text",
"label": "Address",
"oldfieldname": "address",
"oldfieldtype": "Small Text",
"permlevel": 0,
"fieldname": "address",
"fieldtype": "Small Text",
"label": "Address",
"oldfieldname": "address",
"oldfieldtype": "Small Text",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
},
{
"fieldname": "phone_no",
"fieldtype": "Data",
"label": "Phone No",
"oldfieldname": "phone_no",
"oldfieldtype": "Data",
"options": "Phone",
"permlevel": 0,
"fieldname": "phone_no",
"fieldtype": "Data",
"label": "Phone No",
"oldfieldname": "phone_no",
"oldfieldtype": "Data",
"options": "Phone",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "fax",
"fieldtype": "Data",
"label": "Fax",
"oldfieldname": "fax",
"oldfieldtype": "Data",
"options": "Phone",
"permlevel": 0,
"fieldname": "fax",
"fieldtype": "Data",
"label": "Fax",
"oldfieldname": "fax",
"oldfieldtype": "Data",
"options": "Phone",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "email",
"fieldtype": "Data",
"label": "Email",
"oldfieldname": "email",
"oldfieldtype": "Data",
"options": "Email",
"permlevel": 0,
"fieldname": "email",
"fieldtype": "Data",
"label": "Email",
"oldfieldname": "email",
"oldfieldtype": "Data",
"options": "Email",
"permlevel": 0,
"read_only": 0
},
},
{
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"oldfieldname": "website",
"oldfieldtype": "Data",
"permlevel": 0,
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"oldfieldname": "website",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0
},
},
{
"description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.",
"fieldname": "registration_info",
"fieldtype": "Section Break",
"label": "Registration Info",
"oldfieldtype": "Section Break",
"permlevel": 0,
"read_only": 0,
"description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.",
"fieldname": "registration_info",
"fieldtype": "Section Break",
"label": "Registration Info",
"oldfieldtype": "Section Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
},
{
"description": "Company registration numbers for your reference. Tax numbers etc.",
"fieldname": "registration_details",
"fieldtype": "Code",
"label": "Registration Details",
"oldfieldname": "registration_details",
"oldfieldtype": "Code",
"permlevel": 0,
"description": "Company registration numbers for your reference. Tax numbers etc.",
"fieldname": "registration_details",
"fieldtype": "Code",
"label": "Registration Details",
"oldfieldname": "registration_details",
"oldfieldtype": "Code",
"permlevel": 0,
"read_only": 0
}
],
"icon": "icon-building",
"idx": 1,
"modified": "2014-12-15 11:14:12.090020",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
"owner": "Administrator",
],
"icon": "icon-building",
"idx": 1,
"modified": "2015-01-05 11:30:45.716971",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"submit": 0,
"amend": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"submit": 0,
"write": 1
},
},
{
"apply_user_permissions": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"apply_user_permissions": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"role": "All"
}
]
}
}

View File

@ -168,6 +168,12 @@ class Company(Document):
#delete cost center
frappe.db.sql("delete from `tabCost Center` WHERE company = %s order by lft desc, rgt desc", self.name)
# delete account from customer and supplier
frappe.db.sql("delete from `tabParty Account` where company=%s", self.name)
# delete email digest
frappe.db.sql("delete from `tabEmail Digest` where company=%s", 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

@ -314,10 +314,10 @@ def create_items(args):
is_stock_item = item_group!=_("Services")
default_warehouse = ""
if is_stock_item:
if is_sales_item:
default_warehouse = _("Finished Goods") + " - " + args.get("company_abbr")
else:
default_warehouse = _("Stores") + " - " + args.get("company_abbr")
default_warehouse = frappe.db.get_value("Warehouse", filters={
"warehouse_name": _("Finished Goods") if is_sales_item else _("Stores"),
"company": args.get("company_name").strip()
})
frappe.get_doc({
"doctype":"Item",

View File

@ -79,7 +79,7 @@ class Item(WebsiteGenerator):
return context
def check_warehouse_is_set_for_stock_item(self):
if self.is_stock_item=="Yes" and not self.default_warehouse:
if self.is_stock_item=="Yes" and not self.default_warehouse and frappe.get_all("Warehouse"):
frappe.msgprint(_("Default Warehouse is mandatory for stock Item."),
raise_exception=WarehouseNotSet)

View File

@ -18,17 +18,6 @@
"permlevel": 0,
"width": "50%"
},
{
"fieldname": "account",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Account",
"options": "Account",
"permlevel": 0,
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "amount",
"fieldtype": "Currency",
@ -40,7 +29,7 @@
}
],
"istable": 1,
"modified": "2014-08-08 13:12:02.594698",
"modified": "2015-01-10 11:32:46.466371",
"modified_by": "Administrator",
"module": "Stock",
"name": "Landed Cost Taxes and Charges",

View File

@ -5,10 +5,10 @@
frappe.provide("erpnext.stock");
frappe.require("assets/erpnext/js/controllers/stock_controller.js");
erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
setup: function() {
var me = this;
this.frm.fields_dict.purchase_receipts.grid.get_field('purchase_receipt').get_query =
this.frm.fields_dict.purchase_receipts.grid.get_field('purchase_receipt').get_query =
function() {
if(!me.frm.doc.company) msgprint(__("Please enter company first"));
return {
@ -18,24 +18,13 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
]
}
};
this.frm.fields_dict.taxes.grid.get_field('account').get_query = function() {
if(!me.frm.doc.company) msgprint(__("Please enter company first"));
return {
filters:[
['Account', 'group_or_ledger', '=', 'Ledger'],
['Account', 'account_type', 'in', ['Tax', 'Chargeable', 'Expense Account']],
['Account', 'company', '=', me.frm.doc.company]
]
}
};
this.frm.add_fetch("purchase_receipt", "supplier", "supplier");
this.frm.add_fetch("purchase_receipt", "posting_date", "posting_date");
this.frm.add_fetch("purchase_receipt", "grand_total", "grand_total");
},
},
refresh: function() {
var help_content = ['<table class="table table-bordered" style="background-color: #f9f9f9;">',
'<tr><td>',
@ -64,7 +53,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
set_field_options("landed_cost_help", help_content);
},
get_items_from_purchase_receipts: function() {
var me = this;
if(!this.frm.doc.purchase_receipts.length) {
@ -75,13 +64,13 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
method: "get_items_from_purchase_receipts"
});
}
},
},
amount: function() {
this.set_total_taxes_and_charges();
this.set_applicable_charges_for_item();
},
set_total_taxes_and_charges: function() {
total_taxes_and_charges = 0.0;
$.each(this.frm.doc.taxes, function(i, d) {
@ -89,7 +78,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
});
cur_frm.set_value("total_taxes_and_charges", total_taxes_and_charges);
},
set_applicable_charges_for_item: function() {
var me = this;
if(this.frm.doc.taxes.length) {
@ -97,14 +86,14 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
$.each(this.frm.doc.items, function(i, d) {
total_item_cost += flt(d.amount)
});
$.each(this.frm.doc.items, function(i, item) {
item.applicable_charges = flt(item.amount) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)
});
refresh_field("items");
}
}
});
cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher);
cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher);