Demo data for fixed asset depreciation
diff --git a/erpnext/demo/data/asset.json b/erpnext/demo/data/asset.json
new file mode 100644
index 0000000..b158218
--- /dev/null
+++ b/erpnext/demo/data/asset.json
@@ -0,0 +1,37 @@
+[
+ {
+ "asset_name": "Macbook Pro - 1",
+ "item_code": "Computer",
+ "gross_purchase_amount": 100000
+ },
+ {
+ "asset_name": "Macbook Air - 1",
+ "item_code": "Computer",
+ "gross_purchase_amount": 60000
+ },
+ {
+ "asset_name": "Conferrence Table",
+ "item_code": "Table",
+ "gross_purchase_amount": 30000
+ },
+ {
+ "asset_name": "Lunch Table",
+ "item_code": "Table",
+ "gross_purchase_amount": 20000
+ },
+ {
+ "asset_name": "ERPNext",
+ "item_code": "ERP",
+ "gross_purchase_amount": 100000
+ },
+ {
+ "asset_name": "Chair 1",
+ "item_code": "Chair",
+ "gross_purchase_amount": 10000
+ },
+ {
+ "asset_name": "Chair 2",
+ "item_code": "Chair",
+ "gross_purchase_amount": 10000
+ }
+]
\ No newline at end of file
diff --git a/erpnext/demo/data/asset_category.json b/erpnext/demo/data/asset_category.json
new file mode 100644
index 0000000..54f779d
--- /dev/null
+++ b/erpnext/demo/data/asset_category.json
@@ -0,0 +1,38 @@
+[
+ {
+ "asset_category_name": "Furnitures",
+ "depreciation_method": "Straight Line",
+ "total_number_of_depreciations": 5,
+ "frequency_of_depreciation": 12,
+ "accounts": [{
+ "company_name": "Wind Power LLC",
+ "fixed_asset_account": "Furnitures and Fixtures - WPL",
+ "accumulated_depreciation_account": "Accumulated Depreciation - WPL",
+ "depreciation_expense_account": "Depreciation - WPL"
+ }]
+ },
+ {
+ "asset_category_name": "Electronic Equipments",
+ "depreciation_method": "Double Declining Balance",
+ "total_number_of_depreciations": 10,
+ "frequency_of_depreciation": 6,
+ "accounts": [{
+ "company_name": "Wind Power LLC",
+ "fixed_asset_account": "Electronic Equipments - WPL",
+ "accumulated_depreciation_account": "Accumulated Depreciation - WPL",
+ "depreciation_expense_account": "Depreciation - WPL"
+ }]
+ },
+ {
+ "asset_category_name": "Softwares",
+ "depreciation_method": "Straight Line",
+ "total_number_of_depreciations": 10,
+ "frequency_of_depreciation": 12,
+ "accounts": [{
+ "company_name": "Wind Power LLC",
+ "fixed_asset_account": "Softwares - WPL",
+ "accumulated_depreciation_account": "Accumulated Depreciation - WPL",
+ "depreciation_expense_account": "Depreciation - WPL"
+ }]
+ }
+]
\ No newline at end of file
diff --git a/erpnext/demo/data/item.json b/erpnext/demo/data/item.json
index d8d4584..e208522 100644
--- a/erpnext/demo/data/item.json
+++ b/erpnext/demo/data/item.json
@@ -221,5 +221,59 @@
"item_code": "Base Plate Un Painted",
"item_group": "Raw Material",
"item_name": "Base Plate Un Painted"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Furnitures",
+ "is_stock_item": 0,
+ "description": "Table",
+ "item_code": "Table",
+ "item_name": "Table",
+ "item_group": "Products"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Furnitures",
+ "is_stock_item": 0,
+ "description": "Chair",
+ "item_code": "Chair",
+ "item_name": "Chair",
+ "item_group": "Products"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Electronic Equipments",
+ "is_stock_item": 0,
+ "description": "Computer",
+ "item_code": "Computer",
+ "item_name": "Computer",
+ "item_group": "Products"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Electronic Equipments",
+ "is_stock_item": 0,
+ "description": "Mobile",
+ "item_code": "Mobile",
+ "item_name": "Mobile",
+ "item_group": "Products"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Softwares",
+ "is_stock_item": 0,
+ "description": "ERP",
+ "item_code": "ERP",
+ "item_name": "ERP",
+ "item_group": "All Item Groups"
+ },
+ {
+ "is_fixed_asset": 1,
+ "asset_category": "Softwares",
+ "is_stock_item": 0,
+ "description": "Autocad",
+ "item_code": "Autocad",
+ "item_name": "Autocad",
+ "item_group": "All Item Groups"
}
]
\ No newline at end of file
diff --git a/erpnext/demo/demo.py b/erpnext/demo/demo.py
index 4188432..2435029 100644
--- a/erpnext/demo/demo.py
+++ b/erpnext/demo/demo.py
@@ -4,7 +4,7 @@
import erpnext
import frappe.utils
from erpnext.demo.setup_data import setup_data
-from erpnext.demo.user import hr, sales, purchase, manufacturing, stock, accounts, projects
+from erpnext.demo.user import hr, sales, purchase, manufacturing, stock, accounts, projects, fixed_asset
"""
Make a demo
@@ -53,6 +53,8 @@
if not runs_for:
runs_for = frappe.utils.date_diff(frappe.utils.nowdate(), current_date)
# runs_for = 100
+
+ fixed_asset.work()
for i in xrange(runs_for):
sys.stdout.write("\rSimulating {0}".format(current_date.strftime("%Y-%m-%d")))
diff --git a/erpnext/demo/setup_data.py b/erpnext/demo/setup_data.py
index 0903482..98892d4 100644
--- a/erpnext/demo/setup_data.py
+++ b/erpnext/demo/setup_data.py
@@ -3,7 +3,7 @@
import random, json
from erpnext.demo.domains import data
import frappe, erpnext
-from frappe.utils import cint, flt, now_datetime, cstr
+from frappe.utils import flt, now_datetime, cstr, nowdate, add_days
from frappe import _
def setup_data():
@@ -14,8 +14,10 @@
setup_holiday_list()
setup_customer()
setup_supplier()
+ import_json("Asset Category")
setup_item()
setup_warehouse()
+ setup_asset()
import_json('Address')
import_json('Contact')
setup_workstation()
@@ -158,6 +160,20 @@
w = frappe.new_doc('Warehouse')
w.warehouse_name = 'Supplier'
w.insert()
+
+def setup_asset():
+ assets = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', 'asset.json')).read())
+ for d in assets:
+ asset = frappe.new_doc('Asset')
+ asset.update(d)
+ asset.purchase_date = add_days(nowdate(), -random.randint(20, 1500))
+ asset.next_depreciation_date = add_days(asset.purchase_date, 30)
+ asset.warehouse = "Stores - WPL"
+ asset.set_missing_values()
+ asset.make_depreciation_schedule()
+ asset.flags.ignore_validate = True
+ asset.save()
+ asset.submit()
def setup_currency_exchange():
frappe.get_doc({
diff --git a/erpnext/demo/user/fixed_asset.py b/erpnext/demo/user/fixed_asset.py
new file mode 100644
index 0000000..bf3199e
--- /dev/null
+++ b/erpnext/demo/user/fixed_asset.py
@@ -0,0 +1,59 @@
+
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+from frappe.utils.make_random import get_random
+from erpnext.accounts.doctype.asset.asset import make_purchase_invoice, make_sales_invoice
+from erpnext.accounts.doctype.asset.depreciation import post_depreciation_entries, scrap_asset
+
+def work():
+ frappe.set_user(frappe.db.get_global('demo_accounts_user'))
+
+ asset_list = make_asset_purchase_entry()
+
+ if not asset_list:
+ # fixed_asset.work() already run
+ return
+
+ # post depreciation entries as on today
+ post_depreciation_entries()
+
+ # scrap a random asset
+ frappe.db.set_value("Company", "Wind Power LLC", "disposal_account", "Gain/Loss on Asset Disposal - WPL")
+
+ asset = get_random_asset()
+ scrap_asset(asset.name)
+
+ # Sell a random asset
+ sell_an_asset()
+
+def make_asset_purchase_entry():
+ asset_list = frappe.get_all("Asset", filters={"purchase_invoice": ["in", ("", None)]},
+ fields=["name", "item_code", "gross_purchase_amount", "company", "purchase_date"])
+
+ # make purchase invoice
+ for asset in asset_list:
+ pi = make_purchase_invoice(asset.name, asset.item_code, asset.gross_purchase_amount,
+ asset.company, asset.purchase_date)
+ pi.supplier = get_random("Supplier")
+ pi.save()
+ pi.submit()
+
+ return asset_list
+
+def sell_an_asset():
+ asset = get_random_asset()
+ si = make_sales_invoice(asset.name, asset.item_code, "Wind Power LLC")
+ si.customer = get_random("Customer")
+ si.get("items")[0].rate = asset.value_after_depreciation * 0.8 \
+ if asset.value_after_depreciation else asset.gross_purchase_amount * 0.9
+ si.save()
+ si.submit()
+
+def get_random_asset():
+ return frappe.db.sql(""" select name, item_code, value_after_depreciation, gross_purchase_amount
+ from `tabAsset`
+ where docstatus=1 and status not in ("Scrapped", "Sold") order by rand() limit 1""", as_dict=1)[0]
diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py
index bd86507..50f15bb 100644
--- a/erpnext/demo/user/hr.py
+++ b/erpnext/demo/user/hr.py
@@ -124,4 +124,4 @@
def get_random_item():
return frappe.db.sql_list(""" select name from `tabItem` where
- has_variants = 0 order by rand() limit 1""")[0]
+ has_variants=0 and is_stock_item=0 and is_fixed_asset=0 order by rand() limit 1""")[0]