Added default asset accounts in COA, CWIP account in asset category
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py
index 5452040..6e16371 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py
@@ -63,7 +63,10 @@
},
_("Accumulated Depreciation"): {
"account_type": "Accumulated Depreciation"
- }
+ },
+ _("CWIP Account"): {
+ "account_type": "Capital Work in Progress",
+ }
},
_("Investments"): {
"is_group": 1
@@ -81,6 +84,9 @@
_("Cost of Goods Sold"): {
"account_type": "Cost of Goods Sold"
},
+ _("Expenses Included In Asset Valuation"): {
+ "account_type": "Expenses Included In Asset Valuation"
+ },
_("Expenses Included In Valuation"): {
"account_type": "Expenses Included In Valuation"
},
@@ -146,6 +152,9 @@
_("Stock Received But Not Billed"): {
"account_type": "Stock Received But Not Billed"
},
+ _("Asset Received But Not Billed"): {
+ "account_type": "Asset Received But Not Billed"
+ }
},
_("Duties and Taxes"): {
"account_type": "Tax",
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py
index bad8453..5ed3e45 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts_with_account_number.py
@@ -85,6 +85,10 @@
"account_type": "Accumulated Depreciation",
"account_number": "1780"
},
+ _("CWIP Account"): {
+ "account_type": "Capital Work in Progress",
+ "account_number": "1790"
+ },
"account_number": "1700"
},
_("Investments"): {
@@ -108,6 +112,10 @@
"account_type": "Cost of Goods Sold",
"account_number": "5111"
},
+ _("Expenses Included In Asset Valuation"): {
+ "account_type": "Expenses Included In Asset Valuation",
+ "account_number": "5112"
+ },
_("Expenses Included In Valuation"): {
"account_type": "Expenses Included In Valuation",
"account_number": "5118"
@@ -228,6 +236,10 @@
"account_type": "Stock Received But Not Billed",
"account_number": "2210"
},
+ _("Asset Received But Not Billed"): {
+ "account_type": "Asset Received But Not Billed",
+ "account_number": "2211"
+ },
"account_number": "2200"
},
_("Duties and Taxes"): {
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index fea1269..fd0054a 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -19,6 +19,7 @@
from frappe.model.mapper import get_mapped_doc
from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_invoice,\
unlink_inter_company_invoice
+from erpnext.assets.doctype.asset_category.asset_category import get_cwip_account
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -423,7 +424,7 @@
"credit": flt(item.rm_supp_cost)
}, warehouse_account[self.supplier_warehouse]["account_currency"]))
- elif item.is_fixed_asset and not self.update_stock:
+ elif item.is_fixed_asset:
asset_accounts = self.get_company_default(["asset_received_but_not_billed",
"expenses_included_in_asset_valuation", "capital_work_in_progress_account"])
@@ -432,7 +433,6 @@
if not self.update_stock:
asset_rbnb_currency = get_account_currency(asset_accounts[0])
-
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[0],
"against": self.supplier,
@@ -442,10 +442,10 @@
if asset_rbnb_currency == self.company_currency else asset_amount)
}))
else:
- cwip_account_currency = get_account_currency(asset_accounts[2])
-
+ cwip_account = get_cwip_account(item.item_code, self.company) or asset_accounts[2]
+ cwip_account_currency = get_account_currency(cwip_account)
gl_entries.append(self.get_gl_dict({
- "account": asset_accounts[2],
+ "account": cwip_account,
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": base_asset_amount,
@@ -453,18 +453,18 @@
if cwip_account_currency == self.company_currency else asset_amount)
}))
- asset_eiiav_currency = get_account_currency(asset_accounts[0])
- gl_entries.append(self.get_gl_dict({
- "account": asset_accounts[1],
- "against": self.supplier,
- "remarks": self.get("remarks") or _("Accounting Entry for Asset"),
- "cost_center": item.cost_center,
- "credit": item.item_tax_amount,
- "credit_in_account_currency": (item.item_tax_amount
- if asset_eiiav_currency == self.company_currency else
- item.item_tax_amount / self.conversion_rate)
- }))
-
+ if item.item_tax_amount:
+ asset_eiiav_currency = get_account_currency(asset_accounts[0])
+ gl_entries.append(self.get_gl_dict({
+ "account": asset_accounts[1],
+ "against": self.supplier,
+ "remarks": self.get("remarks") or _("Accounting Entry for Asset"),
+ "cost_center": item.cost_center,
+ "credit": item.item_tax_amount,
+ "credit_in_account_currency": (item.item_tax_amount
+ if asset_eiiav_currency == self.company_currency else
+ item.item_tax_amount / self.conversion_rate)
+ }))
else:
gl_entries.append(
self.get_gl_dict({
diff --git a/erpnext/assets/doctype/asset_category/asset_category.js b/erpnext/assets/doctype/asset_category/asset_category.js
index aafe8a6..6f0c428 100644
--- a/erpnext/assets/doctype/asset_category/asset_category.js
+++ b/erpnext/assets/doctype/asset_category/asset_category.js
@@ -40,5 +40,16 @@
};
});
+ frm.set_query('capital_work_in_progress_account', 'accounts', function(doc, cdt, cdn) {
+ var d = locals[cdt][cdn];
+ return {
+ "filters": {
+ "account_type": "Capital Work in Progress",
+ "is_group": 0,
+ "company": d.company_name
+ }
+ };
+ });
+
}
});
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset_category/asset_category.py b/erpnext/assets/doctype/asset_category/asset_category.py
index 542bd12..4ffd20b 100644
--- a/erpnext/assets/doctype/asset_category/asset_category.py
+++ b/erpnext/assets/doctype/asset_category/asset_category.py
@@ -13,3 +13,10 @@
for field in ("total_number_of_depreciations", "frequency_of_depreciation"):
if cint(self.get(field))<1:
frappe.throw(_("{0} must be greater than 0").format(self.meta.get_label(field)), frappe.MandatoryError)
+
+def get_cwip_account(item_code, company):
+ asset_category = frappe.db.get_value('Item', item_code, 'asset_category')
+ cwip_account = frappe.db.get_value('Asset Category Account',
+ {'parent': asset_category, 'company_name': company}, 'capital_work_in_progress_account')
+
+ return cwip_account or None
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset_category_account/asset_category_account.json b/erpnext/assets/doctype/asset_category_account/asset_category_account.json
index 679cc52..3cace59 100644
--- a/erpnext/assets/doctype/asset_category_account/asset_category_account.json
+++ b/erpnext/assets/doctype/asset_category_account/asset_category_account.json
@@ -41,6 +41,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -72,6 +73,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -103,6 +105,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
@@ -134,6 +137,39 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "capital_work_in_progress_account",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Capital Work In Progress Account",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -147,7 +183,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-11-28 16:54:12.252271",
+ "modified": "2018-05-08 11:41:09.678234",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Category Account",
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 1b68b8a..9040bb7 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -168,6 +168,9 @@
self._set_default_account("round_off_account", "Round Off")
self._set_default_account("accumulated_depreciation_account", "Accumulated Depreciation")
self._set_default_account("depreciation_expense_account", "Depreciation")
+ self._set_default_account("capital_work_in_progress_account", "Capital Work in Progress")
+ self._set_default_account("asset_received_but_not_billed", "Asset Received But Not Billed")
+ self._set_default_account("expenses_included_in_asset_valuation", "Expenses Included In Asset Valuation")
if self.enable_perpetual_inventory:
self._set_default_account("stock_received_but_not_billed", "Stock Received But Not Billed")
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 984bf33..ab86c76 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -13,6 +13,7 @@
from erpnext.accounts.utils import get_account_currency
from frappe.desk.notifications import clear_doctype_notifications
from erpnext.buying.utils import check_for_closed_status
+from erpnext.assets.doctype.asset_category.asset_category import get_cwip_account
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -258,12 +259,14 @@
"asset_received_but_not_billed"])
# CWIP entry
+ cwip_account = get_cwip_account(d.item_code, self.company) or asset_accounts[0]
+
asset_amount = flt(d.net_amount) + flt(d.item_tax_amount/self.conversion_rate)
base_asset_amount = flt(d.base_net_amount + d.item_tax_amount)
- cwip_account_currency = get_account_currency(asset_accounts[0])
+ cwip_account_currency = get_account_currency(cwip_account)
gl_entries.append(self.get_gl_dict({
- "account": asset_accounts[0],
+ "account": cwip_account,
"against": asset_accounts[1],
"cost_center": d.cost_center,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),