Demo data for fixed asset depreciation
This commit is contained in:
parent
649e2538e5
commit
3edefb19b9
37
erpnext/demo/data/asset.json
Normal file
37
erpnext/demo/data/asset.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
]
|
38
erpnext/demo/data/asset_category.json
Normal file
38
erpnext/demo/data/asset_category.json
Normal file
@ -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"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
@ -221,5 +221,59 @@
|
|||||||
"item_code": "Base Plate Un Painted",
|
"item_code": "Base Plate Un Painted",
|
||||||
"item_group": "Raw Material",
|
"item_group": "Raw Material",
|
||||||
"item_name": "Base Plate Un Painted"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -4,7 +4,7 @@ import frappe, sys
|
|||||||
import erpnext
|
import erpnext
|
||||||
import frappe.utils
|
import frappe.utils
|
||||||
from erpnext.demo.setup_data import setup_data
|
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
|
Make a demo
|
||||||
@ -54,6 +54,8 @@ def simulate():
|
|||||||
runs_for = frappe.utils.date_diff(frappe.utils.nowdate(), current_date)
|
runs_for = frappe.utils.date_diff(frappe.utils.nowdate(), current_date)
|
||||||
# runs_for = 100
|
# runs_for = 100
|
||||||
|
|
||||||
|
fixed_asset.work()
|
||||||
|
|
||||||
for i in xrange(runs_for):
|
for i in xrange(runs_for):
|
||||||
sys.stdout.write("\rSimulating {0}".format(current_date.strftime("%Y-%m-%d")))
|
sys.stdout.write("\rSimulating {0}".format(current_date.strftime("%Y-%m-%d")))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import random, json
|
import random, json
|
||||||
from erpnext.demo.domains import data
|
from erpnext.demo.domains import data
|
||||||
import frappe, erpnext
|
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 _
|
from frappe import _
|
||||||
|
|
||||||
def setup_data():
|
def setup_data():
|
||||||
@ -14,8 +14,10 @@ def setup_data():
|
|||||||
setup_holiday_list()
|
setup_holiday_list()
|
||||||
setup_customer()
|
setup_customer()
|
||||||
setup_supplier()
|
setup_supplier()
|
||||||
|
import_json("Asset Category")
|
||||||
setup_item()
|
setup_item()
|
||||||
setup_warehouse()
|
setup_warehouse()
|
||||||
|
setup_asset()
|
||||||
import_json('Address')
|
import_json('Address')
|
||||||
import_json('Contact')
|
import_json('Contact')
|
||||||
setup_workstation()
|
setup_workstation()
|
||||||
@ -159,6 +161,20 @@ def setup_warehouse():
|
|||||||
w.warehouse_name = 'Supplier'
|
w.warehouse_name = 'Supplier'
|
||||||
w.insert()
|
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():
|
def setup_currency_exchange():
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
'doctype': 'Currency Exchange',
|
'doctype': 'Currency Exchange',
|
||||||
|
59
erpnext/demo/user/fixed_asset.py
Normal file
59
erpnext/demo/user/fixed_asset.py
Normal file
@ -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]
|
@ -124,4 +124,4 @@ def make_sales_invoice_for_timesheet(name):
|
|||||||
|
|
||||||
def get_random_item():
|
def get_random_item():
|
||||||
return frappe.db.sql_list(""" select name from `tabItem` where
|
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]
|
||||||
|
@ -344,10 +344,9 @@ class update_entries_after(object):
|
|||||||
def raise_exceptions(self):
|
def raise_exceptions(self):
|
||||||
deficiency = min(e["diff"] for e in self.exceptions)
|
deficiency = min(e["diff"] for e in self.exceptions)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((self.exceptions[0]["voucher_type"], self.exceptions[0]["voucher_no"]) in
|
if ((self.exceptions[0]["voucher_type"], self.exceptions[0]["voucher_no"]) in
|
||||||
frappe.local.flags.currently_saving):
|
frappe.local.flags.currently_saving):
|
||||||
|
|
||||||
msg = _("{0} units of {1} needed in {2} to complete this transaction.").format(
|
msg = _("{0} units of {1} needed in {2} to complete this transaction.").format(
|
||||||
abs(deficiency), frappe.get_desk_link('Item', self.item_code),
|
abs(deficiency), frappe.get_desk_link('Item', self.item_code),
|
||||||
frappe.get_desk_link('Warehouse', self.warehouse))
|
frappe.get_desk_link('Warehouse', self.warehouse))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user