[tests] creation of asset and asset category
diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py
index 83516da..4580d02 100644
--- a/erpnext/accounts/doctype/account/test_account.py
+++ b/erpnext/accounts/doctype/account/test_account.py
@@ -35,7 +35,12 @@
# related to Account Inventory Integration
["_Test Account Stock In Hand", "Current Assets", 0, None, None],
- ["_Test Account Fixed Assets", "Current Assets", 0, None, None],
+
+ # fixed asset depreciation
+ ["_Test Fixed Asset", "Current Assets", 0, "Fixed Asset", None],
+ ["_Test Accumulated Depreciations", "Current Assets", 0, None, None],
+ ["_Test Depreciations", "Expenses", 0, None, None],
+ ["_Test Gain/Loss on Asset Disposal", "Expenses", 0, None, None],
# Receivable / Payable Account
["_Test Receivable", "Current Assets", 0, "Receivable", None],
diff --git a/erpnext/accounts/doctype/asset/asset.py b/erpnext/accounts/doctype/asset/asset.py
index fb1502e..488ba6a 100644
--- a/erpnext/accounts/doctype/asset/asset.py
+++ b/erpnext/accounts/doctype/asset/asset.py
@@ -30,6 +30,9 @@
if flt(self.expected_value_after_useful_life) >= flt(self.gross_purchase_amount):
frappe.throw(_("Expected Value After Useful Life must be less than Gross Purchase Amount"))
+ if not flt(self.gross_purchase_amount):
+ frappe.throw(_("Gross Purchase Amount is mandatory"), frappe.MandatoryError)
+
if not self.current_value:
self.current_value = flt(self.gross_purchase_amount)
else:
diff --git a/erpnext/accounts/doctype/asset/test_asset.py b/erpnext/accounts/doctype/asset/test_asset.py
index cada250..031fcc2 100644
--- a/erpnext/accounts/doctype/asset/test_asset.py
+++ b/erpnext/accounts/doctype/asset/test_asset.py
@@ -6,7 +6,71 @@
import frappe
import unittest
-# test_records = frappe.get_test_records('Asset')
-
class TestAsset(unittest.TestCase):
- pass
+ def setUp(self):
+ create_asset()
+
+ def test_fixed_asset_must_be_non_stock_item(self):
+ item = frappe.get_doc("Item", "Macbook Pro")
+ item.is_stock_item = 1
+ self.assertRaises(frappe.ValidationError, item.save)
+
+ def test_asset_purchase(self):
+ asset = create_asset()
+
+ self.assertEqual(asset.current_value, 100000)
+
+
+def create_asset():
+ if not frappe.db.exists("Asset Category", "Computers"):
+ create_asset_category()
+
+ if not frappe.db.exists("Item", "Macbook Pro"):
+ create_fixed_asset_item()
+
+ asset = frappe.get_doc({
+ "doctype": "Asset",
+ "asset_name": "Macbook Pro 1",
+ "asset_category": "Computers",
+ "item_code": "Macbook Pro",
+ "purchase_date": "2015-01-01",
+ "next_depreciation_date": "2015-12-31",
+ "gross_purchase_amount": 100000,
+ "expected_value_after_useful_life": 10000
+ })
+ try:
+ asset.save()
+ except frappe.DuplicateEntryError:
+ pass
+
+ return asset
+
+def create_asset_category():
+ asset_category = frappe.new_doc("Asset Category")
+ asset_category.asset_category_name = "Computers"
+ asset_category.number_of_depreciations = 5
+ asset_category.number_of_months_in_a_period = 12
+ asset_category.append("accounts", {
+ "company": "_Test Company",
+ "fixed_asset_account": "_Test Fixed Asset - _TC",
+ "accumulated_depreciation_account": "_Test Accumulated Depreciations - _TC",
+ "depreciation_expense_account": "_Test Depreciations - _TC"
+ })
+ asset_category.insert()
+
+def create_fixed_asset_item():
+ try:
+ frappe.get_doc({
+ "doctype": "Item",
+ "item_code": "Macbook Pro",
+ "item_name": "Macbook Pro",
+ "description": "Macbook Pro Retina Display",
+ "item_group": "All Item Groups",
+ "stock_uom": "Nos",
+ "is_fixed_asset": 1,
+ "is_stock_item": 0
+ }).insert()
+ except frappe.DuplicateEntryError:
+ pass
+
+
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/asset_category/asset_category.py b/erpnext/accounts/doctype/asset_category/asset_category.py
index f139499..7acd883 100644
--- a/erpnext/accounts/doctype/asset_category/asset_category.py
+++ b/erpnext/accounts/doctype/asset_category/asset_category.py
@@ -12,4 +12,4 @@
for field in ("depreciation_method", "number_of_depreciations",
"number_of_months_in_a_period", "accounts"):
if not self.get(field):
- frappe.throw(_("{0} is mandatory").format(self.meta.get_label(field)))
\ No newline at end of file
+ frappe.throw(_("{0} is mandatory").format(self.meta.get_label(field)), frappe.MandatoryError)
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/asset_category/test_asset_category.py b/erpnext/accounts/doctype/asset_category/test_asset_category.py
index a85fe3d..1fe4aae 100644
--- a/erpnext/accounts/doctype/asset_category/test_asset_category.py
+++ b/erpnext/accounts/doctype/asset_category/test_asset_category.py
@@ -6,7 +6,24 @@
import frappe
import unittest
-# test_records = frappe.get_test_records('Asset Category')
-
class TestAssetCategory(unittest.TestCase):
- pass
+ def test_mandatory_fields(self):
+ asset_category = frappe.new_doc("Asset Category")
+ asset_category.asset_category_name = "Computers"
+
+ self.assertRaises(frappe.MandatoryError, asset_category.insert)
+
+ asset_category.number_of_depreciations = 5
+ asset_category.number_of_months_in_a_period = 12
+ asset_category.append("accounts", {
+ "company": "_Test Company",
+ "fixed_asset_account": "_Test Fixed Asset - _TC",
+ "accumulated_depreciation_account": "_Test Accoumulated Depreciations - _TC",
+ "depreciation_expense_account": "_Test Depreciations - _TC"
+ })
+
+ try:
+ asset_category.insert()
+ except frappe.DuplicateEntryError:
+ pass
+
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json
index 95b17c4..be63aac 100644
--- a/erpnext/setup/doctype/company/company.json
+++ b/erpnext/setup/doctype/company/company.json
@@ -257,7 +257,7 @@
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
- "reqd": 1,
+ "reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index c3bd452..28a07f3 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -49,7 +49,9 @@
"company_tagline" :"Testing",
"email" :"test@erpnext.com",
"password" :"test",
- "chart_of_accounts" : "Standard"
+ "chart_of_accounts" : "Standard",
+ "domain" : "Manufacturing",
+
})
frappe.db.sql("delete from `tabLeave Allocation`")