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, "reqd": 1,
"search_index": 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", "fieldname": "column_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
@@ -130,22 +146,6 @@
"options": "\nDebit\nCredit", "options": "\nDebit\nCredit",
"permlevel": 0 "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", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
@@ -177,7 +177,7 @@
"icon": "icon-money", "icon": "icon-money",
"idx": 1, "idx": 1,
"in_create": 0, "in_create": 0,
"modified": "2015-01-01 15:36:43.219662", "modified": "2015-01-05 11:03:07.861934",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Account", "name": "Account",

View File

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

View File

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

View File

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

View File

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

View File

@@ -220,6 +220,9 @@ rename_map = {
], ],
"Journal Entry": [ "Journal Entry": [
["entries", "accounts"] ["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): def get_target_distribution_details(filters):
target_details = {} target_details = {}
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` mdp
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1): 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)) target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
return target_details 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): def execute(filters=None):
if not filters: filters = {} if not filters: filters = {}
columns = get_columns(filters) columns = get_columns(filters)
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"]) period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
tim_map = get_territory_item_month_map(filters) tim_map = get_territory_item_month_map(filters)
data = [] data = []
for territory, territory_items in tim_map.items(): for territory, territory_items in tim_map.items():
for item_group, monthwise_data in territory_items.items(): for item_group, monthwise_data in territory_items.items():
@@ -36,7 +36,7 @@ def execute(filters=None):
data.append(row) data.append(row)
return columns, sorted(data, key=lambda x: (x[0], x[1])) return columns, sorted(data, key=lambda x: (x[0], x[1]))
def get_columns(filters): def get_columns(filters):
for fieldname in ["fiscal_year", "period", "target_on"]: for fieldname in ["fiscal_year", "period", "target_on"]:
if not filters.get(fieldname): if not filters.get(fieldname):
@@ -55,24 +55,24 @@ def get_columns(filters):
label = label % _(from_date.strftime("%b")) label = label % _(from_date.strftime("%b"))
columns.append(label+":Float:120") 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"] _("Total Variance") + ":Float:120"]
#Get territory & item group details #Get territory & item group details
def get_territory_details(filters): def get_territory_details(filters):
return frappe.db.sql("""select t.name, td.item_group, td.target_qty, return frappe.db.sql("""select t.name, td.item_group, td.target_qty,
td.target_amount, t.distribution_id td.target_amount, t.distribution_id
from `tabTerritory` t, `tabTarget Detail` td from `tabTerritory` t, `tabTarget Detail` td
where td.parent=t.name and td.fiscal_year=%s order by t.name""", where td.parent=t.name and td.fiscal_year=%s order by t.name""",
(filters["fiscal_year"]), as_dict=1) (filters["fiscal_year"]), as_dict=1)
#Get target distribution details of item group #Get target distribution details of item group
def get_target_distribution_details(filters): def get_target_distribution_details(filters):
target_details = {} target_details = {}
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation for d in frappe.db.sql("""select md.name, mdp.month, mdp.percentage_allocation
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1): 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)) target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
return target_details return target_details
@@ -81,11 +81,11 @@ def get_target_distribution_details(filters):
def get_achieved_details(filters): def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:] 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, 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 so.territory, MONTHNAME(so.transaction_date) as month_name
from `tabSales Order Item` soi, `tabSales Order` so from `tabSales Order Item` soi, `tabSales Order` so
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
so.transaction_date<=%s""" % ('%s', '%s'), so.transaction_date<=%s""" % ('%s', '%s'),
(start_date, end_date), as_dict=1) (start_date, end_date), as_dict=1)
item_actual_details = {} item_actual_details = {}
@@ -106,7 +106,7 @@ def get_territory_item_month_map(filters):
for td in territory_details: for td in territory_details:
for month_id in range(1, 13): for month_id in range(1, 13):
month = datetime.date(2013, month_id, 1).strftime('%B') month = datetime.date(2013, month_id, 1).strftime('%B')
tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\ tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\
.setdefault(month, frappe._dict({ .setdefault(month, frappe._dict({
"target": 0.0, "achieved": 0.0 "target": 0.0, "achieved": 0.0
@@ -130,4 +130,4 @@ def get_territory_item_month_map(filters):
return tim_map return tim_map
def get_item_group(item_name): 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_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:company_name", "autoname": "field:company_name",
"creation": "2013-04-10 08:35:39", "creation": "2013-04-10 08:35:39",
"description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.", "description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Master", "document_type": "Master",
"fields": [ "fields": [
{ {
"fieldname": "details", "fieldname": "details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Company Details", "label": "Company Details",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "company_name", "fieldname": "company_name",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Company", "label": "Company",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "company_name", "oldfieldname": "company_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.", "description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.",
"fieldname": "abbr", "fieldname": "abbr",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Abbr", "label": "Abbr",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "abbr", "oldfieldname": "abbr",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"depends_on": "eval:!doc.__islocal && in_list(user_roles, \"System Manager\")", "depends_on": "eval:!doc.__islocal && in_list(user_roles, \"System Manager\")",
"fieldname": "change_abbr", "fieldname": "change_abbr",
"fieldtype": "Button", "fieldtype": "Button",
"label": "Change Abbreviation", "label": "Change Abbreviation",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "cb0", "fieldname": "cb0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "domain", "fieldname": "domain",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Domain", "label": "Domain",
"options": "Distribution\nManufacturing\nRetail\nServices", "options": "Distribution\nManufacturing\nRetail\nServices",
"permlevel": 0, "permlevel": 0,
"reqd": 0 "reqd": 0
}, },
{ {
"fieldname": "charts_section", "fieldname": "charts_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
"label": "Chart of Accounts", "label": "Chart of Accounts",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "country", "fieldname": "country",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "Country", "label": "Country",
"options": "Country", "options": "Country",
"permlevel": 0, "permlevel": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname": "chart_of_accounts", "fieldname": "chart_of_accounts",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Chart of Accounts", "label": "Chart of Accounts",
"options": "", "options": "",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "default_settings", "fieldname": "default_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Default Settings", "label": "Default Settings",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "default_bank_account", "fieldname": "default_bank_account",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Default Bank Account", "label": "Default Bank Account",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "default_bank_account", "oldfieldname": "default_bank_account",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "default_cash_account", "depends_on": "eval:!doc.__islocal",
"fieldtype": "Link", "fieldname": "default_cash_account",
"ignore_user_permissions": 1, "fieldtype": "Link",
"label": "Default Cash Account", "ignore_user_permissions": 1,
"no_copy": 1, "label": "Default Cash Account",
"options": "Account", "no_copy": 1,
"permlevel": 0, "options": "Account",
"permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "default_receivable_account", "fieldname": "default_receivable_account",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Default Receivable Account", "label": "Default Receivable Account",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "receivables_group", "oldfieldname": "receivables_group",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "default_payable_account", "fieldname": "default_payable_account",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Default Payable Account", "label": "Default Payable Account",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "payables_group", "oldfieldname": "payables_group",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "default_expense_account", "depends_on": "eval:!doc.__islocal",
"fieldtype": "Link", "fieldname": "default_expense_account",
"ignore_user_permissions": 1, "fieldtype": "Link",
"label": "Default Expense Account", "ignore_user_permissions": 1,
"no_copy": 1, "label": "Default Expense Account",
"options": "Account", "no_copy": 1,
"options": "Account",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "default_income_account", "depends_on": "eval:!doc.__islocal",
"fieldtype": "Link", "fieldname": "default_income_account",
"ignore_user_permissions": 1, "fieldtype": "Link",
"label": "Default Income Account", "ignore_user_permissions": 1,
"no_copy": 1, "label": "Default Income Account",
"options": "Account", "no_copy": 1,
"options": "Account",
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "default_holiday_list", "fieldname": "default_holiday_list",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Default Holiday List", "label": "Default Holiday List",
"options": "Holiday List", "options": "Holiday List",
"permlevel": 0, "permlevel": 0,
"precision": "" "precision": ""
}, },
{ {
"fieldname": "column_break0", "fieldname": "column_break0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
"fieldname": "default_currency", "fieldname": "default_currency",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Default Currency", "label": "Default Currency",
"options": "Currency", "options": "Currency",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname": "default_letter_head", "fieldname": "default_letter_head",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Default Letter Head", "label": "Default Letter Head",
"options": "Letter Head", "options": "Letter Head",
"permlevel": 0, "permlevel": 0,
"precision": "" "precision": ""
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Cost Center", "label": "Cost Center",
"no_copy": 1, "no_copy": 1,
"options": "Cost Center", "options": "Cost Center",
"permlevel": 0 "permlevel": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "credit_days", "fieldname": "credit_days",
"fieldtype": "Int", "fieldtype": "Int",
"label": "Credit Days", "label": "Credit Days",
"oldfieldname": "credit_days", "oldfieldname": "credit_days",
"oldfieldtype": "Int", "oldfieldtype": "Int",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "credit_limit", "fieldname": "credit_limit",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Credit Limit", "label": "Credit Limit",
"oldfieldname": "credit_limit", "oldfieldname": "credit_limit",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "default_currency", "options": "default_currency",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "yearly_bgt_flag", "fieldname": "yearly_bgt_flag",
"fieldtype": "Select", "fieldtype": "Select",
"label": "If Yearly Budget Exceeded", "label": "If Yearly Budget Exceeded",
"oldfieldname": "yearly_bgt_flag", "oldfieldname": "yearly_bgt_flag",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop", "options": "\nWarn\nIgnore\nStop",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "monthly_bgt_flag", "fieldname": "monthly_bgt_flag",
"fieldtype": "Select", "fieldtype": "Select",
"label": "If Monthly Budget Exceeded", "label": "If Monthly Budget Exceeded",
"oldfieldname": "monthly_bgt_flag", "oldfieldname": "monthly_bgt_flag",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "\nWarn\nIgnore\nStop", "options": "\nWarn\nIgnore\nStop",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:!doc.__islocal", "depends_on": "eval:!doc.__islocal",
"fieldname": "auto_accounting_for_stock_settings", "fieldname": "auto_accounting_for_stock_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Auto Accounting For Stock Settings", "label": "Auto Accounting For Stock Settings",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "stock_received_but_not_billed", "fieldname": "stock_received_but_not_billed",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Stock Received But Not Billed", "label": "Stock Received But Not Billed",
"no_copy": 1, "no_copy": 1,
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "stock_adjustment_account", "fieldname": "stock_adjustment_account",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Stock Adjustment Account", "label": "Stock Adjustment Account",
"no_copy": 1, "no_copy": 1,
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "expenses_included_in_valuation", "fieldname": "expenses_included_in_valuation",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"label": "Expenses Included In Valuation", "label": "Expenses Included In Valuation",
"no_copy": 1, "no_copy": 1,
"options": "Account", "options": "Account",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"description": "For reference only.", "description": "For reference only.",
"fieldname": "company_info", "fieldname": "company_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Company Info", "label": "Company Info",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "address", "fieldname": "address",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"label": "Address", "label": "Address",
"oldfieldname": "address", "oldfieldname": "address",
"oldfieldtype": "Small Text", "oldfieldtype": "Small Text",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "column_break1", "fieldname": "column_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"oldfieldtype": "Column Break", "oldfieldtype": "Column Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
"fieldname": "phone_no", "fieldname": "phone_no",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Phone No", "label": "Phone No",
"oldfieldname": "phone_no", "oldfieldname": "phone_no",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "Phone", "options": "Phone",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "fax", "fieldname": "fax",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Fax", "label": "Fax",
"oldfieldname": "fax", "oldfieldname": "fax",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "Phone", "options": "Phone",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "email", "fieldname": "email",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Email", "label": "Email",
"oldfieldname": "email", "oldfieldname": "email",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"options": "Email", "options": "Email",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"fieldname": "website", "fieldname": "website",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Website", "label": "Website",
"oldfieldname": "website", "oldfieldname": "website",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{ {
"description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.", "description": "Company registration numbers for your reference. Example: VAT Registration Numbers etc.",
"fieldname": "registration_info", "fieldname": "registration_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Registration Info", "label": "Registration Info",
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{ {
"description": "Company registration numbers for your reference. Tax numbers etc.", "description": "Company registration numbers for your reference. Tax numbers etc.",
"fieldname": "registration_details", "fieldname": "registration_details",
"fieldtype": "Code", "fieldtype": "Code",
"label": "Registration Details", "label": "Registration Details",
"oldfieldname": "registration_details", "oldfieldname": "registration_details",
"oldfieldtype": "Code", "oldfieldtype": "Code",
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
} }
], ],
"icon": "icon-building", "icon": "icon-building",
"idx": 1, "idx": 1,
"modified": "2014-12-15 11:14:12.090020", "modified": "2015-01-05 11:30:45.716971",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Company", "name": "Company",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0, "amend": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "System Manager", "role": "System Manager",
"submit": 0, "submit": 0,
"write": 1 "write": 1
}, },
{ {
"apply_user_permissions": 1, "apply_user_permissions": 1,
"delete": 0, "delete": 0,
"email": 1, "email": 1,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"role": "All" "role": "All"
} }
] ]
} }

View File

@@ -168,6 +168,12 @@ class Company(Document):
#delete cost center #delete cost center
frappe.db.sql("delete from `tabCost Center` WHERE company = %s order by lft desc, rgt desc", self.name) 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}): if not frappe.db.get_value("Stock Ledger Entry", {"company": self.name}):
frappe.db.sql("""delete from `tabWarehouse` where company=%s""", 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") is_stock_item = item_group!=_("Services")
default_warehouse = "" default_warehouse = ""
if is_stock_item: if is_stock_item:
if is_sales_item: default_warehouse = frappe.db.get_value("Warehouse", filters={
default_warehouse = _("Finished Goods") + " - " + args.get("company_abbr") "warehouse_name": _("Finished Goods") if is_sales_item else _("Stores"),
else: "company": args.get("company_name").strip()
default_warehouse = _("Stores") + " - " + args.get("company_abbr") })
frappe.get_doc({ frappe.get_doc({
"doctype":"Item", "doctype":"Item",

View File

@@ -79,7 +79,7 @@ class Item(WebsiteGenerator):
return context return context
def check_warehouse_is_set_for_stock_item(self): 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."), frappe.msgprint(_("Default Warehouse is mandatory for stock Item."),
raise_exception=WarehouseNotSet) raise_exception=WarehouseNotSet)

View File

@@ -18,17 +18,6 @@
"permlevel": 0, "permlevel": 0,
"width": "50%" "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", "fieldname": "amount",
"fieldtype": "Currency", "fieldtype": "Currency",
@@ -40,7 +29,7 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2014-08-08 13:12:02.594698", "modified": "2015-01-10 11:32:46.466371",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Landed Cost Taxes and Charges", "name": "Landed Cost Taxes and Charges",

View File

@@ -5,10 +5,10 @@
frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock");
frappe.require("assets/erpnext/js/controllers/stock_controller.js"); 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() { setup: function() {
var me = this; 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() { function() {
if(!me.frm.doc.company) msgprint(__("Please enter company first")); if(!me.frm.doc.company) msgprint(__("Please enter company first"));
return { 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", "supplier", "supplier");
this.frm.add_fetch("purchase_receipt", "posting_date", "posting_date"); this.frm.add_fetch("purchase_receipt", "posting_date", "posting_date");
this.frm.add_fetch("purchase_receipt", "grand_total", "grand_total"); this.frm.add_fetch("purchase_receipt", "grand_total", "grand_total");
}, },
refresh: function() { refresh: function() {
var help_content = ['<table class="table table-bordered" style="background-color: #f9f9f9;">', var help_content = ['<table class="table table-bordered" style="background-color: #f9f9f9;">',
'<tr><td>', '<tr><td>',
@@ -64,7 +53,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
set_field_options("landed_cost_help", help_content); set_field_options("landed_cost_help", help_content);
}, },
get_items_from_purchase_receipts: function() { get_items_from_purchase_receipts: function() {
var me = this; var me = this;
if(!this.frm.doc.purchase_receipts.length) { if(!this.frm.doc.purchase_receipts.length) {
@@ -75,13 +64,13 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
method: "get_items_from_purchase_receipts" method: "get_items_from_purchase_receipts"
}); });
} }
}, },
amount: function() { amount: function() {
this.set_total_taxes_and_charges(); this.set_total_taxes_and_charges();
this.set_applicable_charges_for_item(); this.set_applicable_charges_for_item();
}, },
set_total_taxes_and_charges: function() { set_total_taxes_and_charges: function() {
total_taxes_and_charges = 0.0; total_taxes_and_charges = 0.0;
$.each(this.frm.doc.taxes, function(i, d) { $.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); cur_frm.set_value("total_taxes_and_charges", total_taxes_and_charges);
}, },
set_applicable_charges_for_item: function() { set_applicable_charges_for_item: function() {
var me = this; var me = this;
if(this.frm.doc.taxes.length) { 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) { $.each(this.frm.doc.items, function(i, d) {
total_item_cost += flt(d.amount) total_item_cost += flt(d.amount)
}); });
$.each(this.frm.doc.items, function(i, item) { $.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) item.applicable_charges = flt(item.amount) * flt(me.frm.doc.total_taxes_and_charges) / flt(total_item_cost)
}); });
refresh_field("items"); refresh_field("items");
} }
} }
}); });
cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher); cur_frm.script_manager.make(erpnext.stock.LandedCostVoucher);