Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Asset Repair #25798

Merged
merged 111 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
ed79b22
fix(Asset): Group buttons under 'Action'
GangaManoj May 10, 2021
322975a
feat(Asset): Add 'Create > Asset Repair' button
GangaManoj May 10, 2021
3e0e3f0
fix(Asset Repair): Replace 'Item Name' and 'Item Code' with 'Asset Name'
GangaManoj May 10, 2021
bbbd61d
fix(Asset): Group all buttons under 'Manage'
GangaManoj May 10, 2021
1c26b27
fix(Asset Repair): Display 'Completion Date' and 'Repair Status' only…
GangaManoj May 10, 2021
30c4a56
feat(Asset Repair): Change Asset's status according to repair_status
GangaManoj May 11, 2021
deadcd9
feat(Asset Repair): Add payable_account field
GangaManoj May 11, 2021
88ac9b2
fix(Company): Rename 'Fixed Asset Depreciation Settings' to 'Fixed As…
GangaManoj May 11, 2021
11594f8
fix(Company): Add 'Repair and Maintenance Account' field
GangaManoj May 11, 2021
1b2a5d1
feat(Asset Repair): Add 'Capitalize Repair Cost' checkbox
GangaManoj May 11, 2021
194a08e
fix(Asset Repair): Hide 'Accounting Details' section till doc gets saved
GangaManoj May 11, 2021
6d1cf76
feat(Asset): Add 'Asset Value' field
GangaManoj May 11, 2021
258c238
feat(Asset Repair): Add repair_cost to asset_value
GangaManoj May 11, 2021
c62890b
feat: Create 'Stock Item' child table
GangaManoj May 11, 2021
d2d31fd
feat(Asset Repair): Add 'Stock Items' table
GangaManoj May 11, 2021
0739d4b
feat(Asset Repair): Add value of consumed stock items to asset value
GangaManoj May 11, 2021
e5ab5d8
feat(Asset Repair): Create GL Entries
GangaManoj May 12, 2021
f5a2ea9
feat(Asset Repair): Add 'Accounting Dimensions' section
GangaManoj May 12, 2021
d554267
feat(Asset Repair): Add 'Cost Center' to GL Entries
GangaManoj May 12, 2021
234b473
feat(Asset Repair): Remove 'Assign To'
GangaManoj May 12, 2021
7ad74cf
feat(Asset Repair): Add stock_consumption checkbox
GangaManoj May 12, 2021
c2b0102
feat(Asset Repair): Add 'View General Ledger' button
GangaManoj May 12, 2021
385ca80
feat(Asset Repair): Add total_repair_cost field
GangaManoj May 12, 2021
8d05eca
feat(Asset Repair): Create GL Entries to capitalise repair cost
GangaManoj May 12, 2021
f2fe55c
feat(Asset Repair): Check for Cost Center and Payable Account
GangaManoj May 12, 2021
c8cb96a
feat(Asset Repair): Add Warehouse field
GangaManoj May 12, 2021
1ac1ced
feat(Asset Repair): Decrease stock quantity if consumed during Asset …
GangaManoj May 12, 2021
ec72f89
fix(Asset Repair): Revert to asset's previous status if repair is com…
GangaManoj May 12, 2021
68b7837
fix(Asset): Make Manage button white
GangaManoj May 12, 2021
f7eebf0
feat(Asset Repair): Add 'Increase In Asset Life' field
GangaManoj May 12, 2021
2874d08
fix(Asset Repair): Rearrange fields
GangaManoj May 12, 2021
568369a
feat(Asset Maintenance): Add stock_consumption checkbox
GangaManoj May 12, 2021
04a909b
feat(Asset Maintenance): Add 'Stock Consumption Details' section
GangaManoj May 12, 2021
d1f5217
feat(Asset Maintenance): Check if Warehouse and Stock Items were entered
GangaManoj May 13, 2021
70bad47
feat(Asset Maintenance): Increase Asset value if Stock Items were con…
GangaManoj May 13, 2021
a7bbaac
fix(Asset Repair): Always add value of consumed Stock Items to Asset …
GangaManoj May 13, 2021
15294d5
feat(Asset Maintenance): Decrease stock quantity if consumed during A…
GangaManoj May 13, 2021
d5d7cac
fix(Asset Repair): Improve code
GangaManoj May 13, 2021
3ab852d
fix(Asset Repair): Fetch 'Asset Name' when 'Asset' is selected
GangaManoj May 13, 2021
a8037c1
fix(Asset Repair): Add Purchase Invoice
GangaManoj May 13, 2021
66e6f01
fix(Asset Repair): Make Purchase Invoice mandatory if capitalize_repa…
GangaManoj May 13, 2021
8a41f63
fix(Asset Repair): Remove 'Payable Account' field
GangaManoj May 13, 2021
6bb920f
fix(Asset Repair): Only create GL entries if repair cost is capitalised
GangaManoj May 13, 2021
30fdeba
feat(Asset): Modify depreciation schedule
GangaManoj May 21, 2021
4277877
feat(Asset Repair): Change visibilty of sections
GangaManoj May 21, 2021
4b543de
feat(Asset Repair): Modify depreciation schedule when increase_in_ass…
GangaManoj May 21, 2021
28ca383
feat(Asset): Edit value_after_depreciation
GangaManoj May 21, 2021
1d7dda2
fix(Asset): Fix depreciation_amount calculation
GangaManoj May 22, 2021
03a6977
fix: Sider issues
GangaManoj May 22, 2021
960840d
fix(Asset Repair): Set completion_date
GangaManoj Jun 2, 2021
2ceeb81
fix(Asset Repair): Set company when creating Stock Entry
GangaManoj Jun 2, 2021
9fb4779
fix(Asset Repair): Only modify depreciation schedule if calculate_dep…
GangaManoj Jun 2, 2021
034f7bd
fix(Asset Repair): Remove unnecessary condition
GangaManoj Jun 3, 2021
aa9bbe5
fix(Asset Repair): Add Company in GL Entries
GangaManoj Jun 3, 2021
b55649f
fix(Asset): Add depreciation schedule details in create_asset()
GangaManoj Jun 3, 2021
12d9e3b
fix(Asset Repair): Add tests
GangaManoj Jun 3, 2021
6eeaf9b
Merge branch 'version-13-hotfix' into asset-repair-refactor
nextchamp-saqib Jun 8, 2021
d4acf87
fix(Asset Repair): Make Accounting Dimensions section collapsible
GangaManoj Jun 15, 2021
285bc60
fix(Asset Repair): Set asset_name as title
GangaManoj Jun 15, 2021
14ea9eb
fix(Asset Repair): Display fields according to the state of the doc
GangaManoj Jun 16, 2021
695cd70
fix(Asset Repair): Add title to error messages
GangaManoj Jun 16, 2021
bf52f55
fix(Asset Repair): Make Stock Items and Warehouse mandatory if stock_…
GangaManoj Jun 16, 2021
9e07b7d
fix(Asset Repair): Add Company field
GangaManoj Jun 16, 2021
71c60f7
fix(Asset Repair): Filter Cost Center and Project by Company
GangaManoj Jun 16, 2021
94ac52c
fix(Asset Repair): Add mandatory_depends_on condition for Purchase In…
GangaManoj Jun 16, 2021
c61bbc5
fix(Asset Repair): Use existing function from asset.py for fetching f…
GangaManoj Jun 16, 2021
abb0c76
fix(Asset Repair): Uncheck allow_on_submit for all fields
GangaManoj Jun 16, 2021
a33e751
fix(Asset Repair): Make Cost Center non-mandatory
GangaManoj Jun 16, 2021
491763f
fix(Asset Repair): Fix Sider issues
GangaManoj Jun 16, 2021
6d6aee2
fix(Asset Repair): Fix GL Entry creation
GangaManoj Jun 16, 2021
3499778
fix(Asset Repair): Filter Warehouse by Company
GangaManoj Jun 16, 2021
66d4e2b
fix(Asset Repair): Display value_after_depreciation in Finance Books
GangaManoj Jun 17, 2021
05c70ac
fix(Asset): Replace asset_value with value_after_depreciation in Fina…
GangaManoj Jun 17, 2021
3541161
fix(Asset Repair): Create GL Entries for each item in Stock Items
GangaManoj Jun 18, 2021
94dfd0e
fix(Asset): Add function to clear old depreciation schedule
GangaManoj Jun 18, 2021
93b9752
fix: Add comments
GangaManoj Jun 19, 2021
2b93e54
fix(Asset Repair): Fix depreciation_amount calculation
GangaManoj Jun 19, 2021
da8da9f
fix: Replace edit_dates with flags.increase_in_asset_life
GangaManoj Jun 19, 2021
09ba6f6
fix(Asset Repair): Move Total Repair Cost to the Stock Consumption De…
GangaManoj Jun 19, 2021
7db7988
fix(Asset Repair): Add Stock Entry field
GangaManoj Jun 19, 2021
012b9ea
fix(Asset Repair): Make Error Description non-mandatory
GangaManoj Jun 19, 2021
23876c0
fix(Asset Repair): Prevent some fields from being copied on duplicati…
GangaManoj Jun 19, 2021
740df95
fix(Asset Repair): Set completion_date on changing repair_status to '…
GangaManoj Jun 20, 2021
b081d79
fix(Asset Repair): Fix tests
GangaManoj Jun 21, 2021
a34bf5e
fix: Rename 'Stock Item' to 'Asset Repair Consumed Item'
GangaManoj Jun 21, 2021
f88a13b
fix(Asset Repair): Compute total_value instantly
GangaManoj Jun 21, 2021
91a99e0
fix(Asset Repair): Increase stock quantity and decrease asset value o…
GangaManoj Jun 21, 2021
5776a96
fix(Asset Repair): Return Depreciation Schedule to original state on …
GangaManoj Jun 21, 2021
4b4eb99
Merge branch 'develop' into asset-repair-refactor
nextchamp-saqib Jun 22, 2021
3b0eac7
fix(Asset Repair): Compute total_value
GangaManoj Jun 22, 2021
3a44d88
fix(Asset): Fix tests for Asset Repair
GangaManoj Jun 22, 2021
2ea325c
fix(Asset Repair): Revert Stock Entry on cancellation
GangaManoj Jun 22, 2021
859c8c9
fix: Remove changes made to Asset Maintenance
GangaManoj Jun 22, 2021
2e45965
fix(Asset Repair): Fix Sider issues
GangaManoj Jun 22, 2021
8039980
fix(Asset Repair): Replace asset_value with value_after_depreciation …
GangaManoj Jun 23, 2021
2f5f9d8
fix(Asset): Fix value_after_depreciation calculation
GangaManoj Jun 23, 2021
dce2113
fix(Asset Repair): Remove test that's no longer necessary
GangaManoj Jun 23, 2021
60a44ae
fix(Asset): Fix test
GangaManoj Jun 24, 2021
550fe8a
fix(Asset): Remove redundant code
GangaManoj Jun 24, 2021
2fdb923
fix(Asset Repair): Change controller hooks
GangaManoj Jun 24, 2021
e21d44c
fix(Asset): Remove to_date field
GangaManoj Jun 24, 2021
f4e8e7d
fix(Asset): Remove extra tabs
GangaManoj Jun 24, 2021
289b449
fix(Asset): Add comment
GangaManoj Jun 24, 2021
b44e412
fix(Asset Repair): Move filters for cost_center, warehouse and projec…
GangaManoj Jun 24, 2021
c73e137
fix(Asset Repair): Edit description for total_repair_cost
GangaManoj Jun 24, 2021
dcb8a28
fix(Asset Repair): Simplify code for Asset Repair creation in tests
GangaManoj Jun 24, 2021
ca2dbce
fix(Asset Repair): Rearrange fields
GangaManoj Jun 25, 2021
4b69563
Merge branch 'develop' into asset-repair-refactor
nextchamp-saqib Jun 28, 2021
40c90d0
fix(Asset Repair): cancellation
nextchamp-saqib Jun 28, 2021
49ef260
Merge branch 'develop' into asset-repair-refactor
nextchamp-saqib Jul 1, 2021
f9c5893
Merge branch 'develop' into asset-repair-refactor
nextchamp-saqib Jul 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 41 additions & 23 deletions erpnext/assets/doctype/asset/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,52 +82,56 @@ frappe.ui.form.on('Asset', {
if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) {
frm.add_custom_button("Transfer Asset", function() {
erpnext.asset.transfer_asset(frm);
});
}, __("Manage"));

frm.add_custom_button("Scrap Asset", function() {
erpnext.asset.scrap_asset(frm);
});
}, __("Manage"));

frm.add_custom_button("Sell Asset", function() {
frm.trigger("make_sales_invoice");
});
}, __("Manage"));

} else if (frm.doc.status=='Scrapped') {
frm.add_custom_button("Restore Asset", function() {
erpnext.asset.restore_asset(frm);
});
}

if (frm.doc.purchase_receipt || !frm.doc.is_existing_asset) {
frm.add_custom_button("General Ledger", function() {
frappe.route_options = {
"voucher_no": frm.doc.name,
"from_date": frm.doc.available_for_use_date,
"to_date": frm.doc.available_for_use_date,
"company": frm.doc.company
};
frappe.set_route("query-report", "General Ledger");
});
}, __("Manage"));
}

if (frm.doc.maintenance_required && !frm.doc.maintenance_schedule) {
frm.add_custom_button(__("Asset Maintenance"), function() {
frm.add_custom_button(__("Maintain Asset"), function() {
frm.trigger("create_asset_maintenance");
}, __('Create'));
}, __("Manage"));
}

frm.add_custom_button(__("Repair Asset"), function() {
frm.trigger("create_asset_repair");
}, __("Manage"));

if (frm.doc.status != 'Fully Depreciated') {
frm.add_custom_button(__("Asset Value Adjustment"), function() {
frm.add_custom_button(__("Adjust Asset Value"), function() {
frm.trigger("create_asset_adjustment");
}, __('Create'));
}, __("Manage"));
}

if (!frm.doc.calculate_depreciation) {
frm.add_custom_button(__("Depreciation Entry"), function() {
frm.add_custom_button(__("Create Depreciation Entry"), function() {
frm.trigger("make_journal_entry");
}, __('Create'));
}, __("Manage"));
}

if (frm.doc.purchase_receipt || !frm.doc.is_existing_asset) {
frm.add_custom_button("View General Ledger", function() {
frappe.route_options = {
"voucher_no": frm.doc.name,
"from_date": frm.doc.available_for_use_date,
"to_date": frm.doc.available_for_use_date,
"company": frm.doc.company
};
frappe.set_route("query-report", "General Ledger");
}, __("Manage"));
}

frm.page.set_inner_btn_group_as_primary(__('Create'));
frm.trigger("setup_chart");
}

Expand Down Expand Up @@ -304,6 +308,20 @@ frappe.ui.form.on('Asset', {
})
},

create_asset_repair: function(frm) {
frappe.call({
args: {
"asset": frm.doc.name,
"asset_name": frm.doc.asset_name
},
method: "erpnext.assets.doctype.asset.asset.create_asset_repair",
callback: function(r) {
var doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
});
},

create_asset_adjustment: function(frm) {
frappe.call({
args: {
Expand Down
2 changes: 1 addition & 1 deletion erpnext/assets/doctype/asset/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
"link_fieldname": "asset"
}
],
"modified": "2021-01-22 12:38:59.091510",
"modified": "2021-06-24 14:58:51.097908",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
Expand Down
65 changes: 52 additions & 13 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,24 @@ def set_depreciation_rate(self):
d.precision("rate_of_depreciation"))

def make_depreciation_schedule(self):
if 'Manual' not in [d.depreciation_method for d in self.finance_books]:
if 'Manual' not in [d.depreciation_method for d in self.finance_books] and not self.schedules:
self.schedules = []

if self.get("schedules") or not self.available_for_use_date:
if not self.available_for_use_date:
return

for d in self.get('finance_books'):
self.validate_asset_finance_books(d)

start = self.clear_depreciation_schedule()

value_after_depreciation = (flt(self.gross_purchase_amount) -
flt(self.opening_accumulated_depreciation))
# value_after_depreciation - current Asset value
if d.value_after_depreciation:
value_after_depreciation = (flt(d.value_after_depreciation) -
flt(self.opening_accumulated_depreciation))
else:
value_after_depreciation = (flt(self.gross_purchase_amount) -
flt(self.opening_accumulated_depreciation))

d.value_after_depreciation = value_after_depreciation

Expand All @@ -191,7 +198,7 @@ def make_depreciation_schedule(self):
number_of_pending_depreciations += 1

skip_row = False
for n in range(number_of_pending_depreciations):
for n in range(start, number_of_pending_depreciations):
# If depreciation is already completed (for double declining balance)
if skip_row: continue

Expand All @@ -216,11 +223,13 @@ def make_depreciation_schedule(self):

# For last row
elif has_pro_rata and n == cint(number_of_pending_depreciations) - 1:
to_date = add_months(self.available_for_use_date,
n * cint(d.frequency_of_depreciation))
if not self.flags.increase_in_asset_life:
# In case of increase_in_asset_life, the self.to_date is already set on asset_repair submission
self.to_date = add_months(self.available_for_use_date,
n * cint(d.frequency_of_depreciation))

depreciation_amount, days, months = self.get_pro_rata_amt(d,
depreciation_amount, schedule_date, to_date)
depreciation_amount, schedule_date, self.to_date)

monthly_schedule_date = add_months(schedule_date, 1)

Expand Down Expand Up @@ -284,10 +293,23 @@ def make_depreciation_schedule(self):
"finance_book_id": d.idx
})

# used when depreciation schedule needs to be modified due to increase in asset life
def clear_depreciation_schedule(self):
start = 0
for n in range(len(self.schedules)):
if not self.schedules[n].journal_entry:
del self.schedules[n:]
start = n
break
return start


# if it returns True, depreciation_amount will not be equal for the first and last rows
def check_is_pro_rata(self, row):
has_pro_rata = False

days = date_diff(row.depreciation_start_date, self.available_for_use_date) + 1

# if frequency_of_depreciation is 12 months, total_days = 365
total_days = get_total_days(row.depreciation_start_date, row.frequency_of_depreciation)

if days < total_days:
Expand Down Expand Up @@ -346,11 +368,12 @@ def set_accumulated_depreciation(self, ignore_booked_entry = False):
if d.finance_book_id not in finance_books:
accumulated_depreciation = flt(self.opening_accumulated_depreciation)
value_after_depreciation = flt(self.get_value_after_depreciation(d.finance_book_id))
finance_books.append(d.finance_book_id)
finance_books.append(int(d.finance_book_id))

depreciation_amount = flt(d.depreciation_amount, d.precision("depreciation_amount"))
value_after_depreciation -= flt(depreciation_amount)

# for the last row, if depreciation method = Straight Line
if straight_line_idx and i == max(straight_line_idx) - 1:
book = self.get('finance_books')[cint(d.finance_book_id) - 1]
depreciation_amount += flt(value_after_depreciation -
Expand Down Expand Up @@ -625,9 +648,18 @@ def create_asset_maintenance(asset, item_code, item_name, asset_category, compan
})
return asset_maintenance

@frappe.whitelist()
def create_asset_repair(asset, asset_name):
asset_repair = frappe.new_doc("Asset Repair")
asset_repair.update({
"asset": asset,
"asset_name": asset_name
})
return asset_repair

@frappe.whitelist()
def create_asset_adjustment(asset, asset_category, company):
asset_maintenance = frappe.new_doc("Asset Value Adjustment")
asset_maintenance = frappe.get_doc("Asset Value Adjustment")
asset_maintenance.update({
"asset": asset,
"company": company,
Expand Down Expand Up @@ -757,8 +789,15 @@ def get_depreciation_amount(asset, depreciable_value, row):
depreciation_left = flt(row.total_number_of_depreciations) - flt(asset.number_of_depreciations_booked)

if row.depreciation_method in ("Straight Line", "Manual"):
depreciation_amount = (flt(row.value_after_depreciation) -
flt(row.expected_value_after_useful_life)) / depreciation_left
# if the Depreciation Schedule is being prepared for the first time
if not asset.flags.increase_in_asset_life:
depreciation_amount = (flt(row.value_after_depreciation) -
flt(row.expected_value_after_useful_life)) / depreciation_left

# if the Depreciation Schedule is being modified after Asset Repair
else:
depreciation_amount = (flt(row.value_after_depreciation) -
flt(row.expected_value_after_useful_life)) / (date_diff(asset.to_date, asset.available_for_use_date) / 365)
else:
nextchamp-saqib marked this conversation as resolved.
Show resolved Hide resolved
depreciation_amount = flt(depreciable_value * (flt(row.rate_of_depreciation) / 100))

Expand Down
24 changes: 12 additions & 12 deletions erpnext/assets/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_schedule_for_straight_line_method_for_existing_asset(self):
"frequency_of_depreciation": 12,
"depreciation_start_date": "2030-12-31"
})
asset.insert()
self.assertEqual(asset.status, "Draft")
asset.save()
expected_schedules = [
Expand Down Expand Up @@ -154,9 +153,8 @@ def test_schedule_for_double_declining_method(self):
"frequency_of_depreciation": 12,
"depreciation_start_date": '2030-12-31'
})
asset.insert()
self.assertEqual(asset.status, "Draft")
asset.save()
self.assertEqual(asset.status, "Draft")

expected_schedules = [
['2030-12-31', 66667.00, 66667.00],
Expand Down Expand Up @@ -185,7 +183,7 @@ def test_schedule_for_double_declining_method_for_existing_asset(self):
"frequency_of_depreciation": 12,
"depreciation_start_date": "2030-12-31"
})
asset.insert()
asset.save()
self.assertEqual(asset.status, "Draft")

expected_schedules = [
Expand Down Expand Up @@ -216,7 +214,6 @@ def test_schedule_for_prorated_straight_line_method(self):
"depreciation_start_date": "2030-12-31"
})

asset.insert()
asset.save()

expected_schedules = [
Expand Down Expand Up @@ -247,7 +244,6 @@ def test_depreciation(self):
"frequency_of_depreciation": 10,
"depreciation_start_date": "2020-12-31"
})
asset.insert()
asset.submit()
asset.load_from_db()
self.assertEqual(asset.status, "Submitted")
Expand Down Expand Up @@ -350,7 +346,6 @@ def test_depreciation_entry_cancellation(self):
"frequency_of_depreciation": 10,
"depreciation_start_date": "2020-12-31"
})
asset.insert()
asset.submit()
post_depreciation_entries(date="2021-01-01")

Expand Down Expand Up @@ -380,7 +375,6 @@ def test_scrap_asset(self):
"total_number_of_depreciations": 10,
"frequency_of_depreciation": 1
})
asset.insert()
asset.submit()

post_depreciation_entries(date=add_months('2020-01-01', 4))
Expand Down Expand Up @@ -424,7 +418,6 @@ def test_asset_sale(self):
"frequency_of_depreciation": 10,
"depreciation_start_date": "2020-12-31"
})
asset.insert()
asset.submit()
post_depreciation_entries(date="2021-01-01")

Expand Down Expand Up @@ -468,7 +461,7 @@ def test_asset_expected_value_after_useful_life(self):
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 10
})
asset.insert()
asset.save()
accumulated_depreciation_after_full_schedule = \
max(d.accumulated_depreciation_amount for d in asset.get("schedules"))

Expand Down Expand Up @@ -699,17 +692,24 @@ def create_asset(**args):
"item_code": args.item_code or "Macbook Pro",
"company": args.company or"_Test Company",
"purchase_date": "2015-01-01",
"calculate_depreciation": 0,
"calculate_depreciation": args.calculate_depreciation or 0,
"gross_purchase_amount": 100000,
"purchase_receipt_amount": 100000,
"expected_value_after_useful_life": 10000,
"warehouse": args.warehouse or "_Test Warehouse - _TC",
"available_for_use_date": "2020-06-06",
"location": "Test Location",
"asset_owner": "Company",
"is_existing_asset": args.is_existing_asset or 0
"is_existing_asset": 1
})

if asset.calculate_depreciation:
asset.append("finance_books", {
"depreciation_method": "Straight Line",
"frequency_of_depreciation": 12,
"total_number_of_depreciations": 5
})

try:
asset.save()
except frappe.DuplicateEntryError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
{
"fieldname": "value_after_depreciation",
"fieldtype": "Currency",
"hidden": 1,
"label": "Value After Depreciation",
"no_copy": 1,
"options": "Company:company:default_currency",
Expand All @@ -85,7 +84,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2020-11-05 16:30:09.213479",
"modified": "2021-06-17 12:59:05.743683",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Finance Book",
Expand Down
Loading