Skip to content

Commit

Permalink
Merge pull request #43770 from frappe/revert-43703-update-depreciatio…
Browse files Browse the repository at this point in the history
…n-checkbox-to-select

chore: revert use selectbox instead of checkbox
  • Loading branch information
khushi8112 authored Oct 22, 2024
2 parents 18bc82f + d47ab78 commit bd0c605
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
19 changes: 9 additions & 10 deletions erpnext/accounts/doctype/accounts_settings/accounts_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"post_change_gl_entries",
"assets_tab",
"asset_settings_section",
"calculate_daily_depreciation_using",
"calculate_depr_using_total_days",
"column_break_gjcc",
"book_asset_depreciation_entry_automatically",
"closing_settings_tab",
Expand Down Expand Up @@ -471,6 +471,13 @@
"fieldname": "column_break_gjcc",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "Enable this option to calculate daily depreciation by considering the total number of days in the entire depreciation period, (including leap years) while using daily pro-rata based depreciation",
"fieldname": "calculate_depr_using_total_days",
"fieldtype": "Check",
"label": "Calculate daily depreciation using total days in depreciation period"
},
{
"description": "Payment Request created from Sales Order or Purchase Order will be in Draft status. When disabled document will be in unsaved state.",
"fieldname": "payment_request_settings",
Expand All @@ -482,22 +489,14 @@
"fieldname": "create_pr_in_draft_status",
"fieldtype": "Check",
"label": "Create in Draft Status"
},
{
"default": "Total years in depreciation period",
"description": "This field lets you select your preferred method for calculating pro rata depreciation. Each approach has different implication. For detailed explanations, please refer to the <a href=\"https://docs.erpnext.com/docs/user/manual/en/pro-rata-based-depreciation-for-slm\" target=\"_blank\"><u>Documentation</u></a>.",
"fieldname": "calculate_daily_depreciation_using",
"fieldtype": "Select",
"label": "Calculate Daily Pro-rata Depreciation Using",
"options": "Total days in depreciation period\nTotal years in depreciation period"
}
],
"icon": "icon-cog",
"idx": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-10-21 04:29:02.556355",
"modified": "2024-07-26 06:48:52.714630",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class AccountsSettings(Document):
book_deferred_entries_based_on: DF.Literal["Days", "Months"]
book_deferred_entries_via_journal_entry: DF.Check
book_tax_discount_loss: DF.Check
calculate_daily_depreciation_using: DF.Literal[
"Total days in depreciation period", "Total years in depreciation period"
]
calculate_depr_using_total_days: DF.Check
check_supplier_invoice_uniqueness: DF.Check
create_pr_in_draft_status: DF.Check
credit_controller: DF.Link | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,7 @@ def get_daily_prorata_based_straight_line_depr(


def get_daily_depr_amount(asset, row, schedule_idx, amount):
if (
frappe.db.get_single_value("Accounts Settings", "calculate_daily_depreciation_using")
== "Total days in depreciation period"
):
if cint(frappe.db.get_single_value("Accounts Settings", "calculate_depr_using_total_days")):
total_days = (
date_diff(
get_last_day(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def test_daily_prorata_based_depr_on_sl_method(self):
self.assertEqual(schedules, expected_schedules)

def test_schedule_for_slm_for_existing_asset_daily_pro_rata_enabled(self):
frappe.db.set_single_value(
"Accounts Settings", "calculate_daily_depreciation_using", "Total days in depreciation period"
)
frappe.db.set_single_value("Accounts Settings", "calculate_depr_using_total_days", 1)
asset = create_asset(
calculate_depreciation=1,
depreciation_method="Straight Line",
Expand Down Expand Up @@ -125,9 +123,7 @@ def test_schedule_for_slm_for_existing_asset_daily_pro_rata_enabled(self):
for d in get_depr_schedule(asset.name, "Draft")
]
self.assertEqual(schedules, expected_schedules)
frappe.db.set_single_value(
"Accounts Settings", "calculate_daily_depreciation_using", "Total years in depreciation period"
)
frappe.db.set_single_value("Accounts Settings", "calculate_depr_using_total_days", 0)

def test_schedule_for_slm_for_existing_asset(self):
asset = create_asset(
Expand Down Expand Up @@ -200,9 +196,7 @@ def test_schedule_sl_method_for_existing_asset_with_frequency_of_3_months(self):

# Enable Checkbox to Calculate depreciation using total days in depreciation period
def test_daily_prorata_based_depr_after_enabling_configuration(self):
frappe.db.set_single_value(
"Accounts Settings", "calculate_daily_depreciation_using", "Total days in depreciation period"
)
frappe.db.set_single_value("Accounts Settings", "calculate_depr_using_total_days", 1)

asset = create_asset(
calculate_depreciation=1,
Expand Down Expand Up @@ -260,9 +254,7 @@ def test_daily_prorata_based_depr_after_enabling_configuration(self):
for d in get_depr_schedule(asset.name, "Draft")
]
self.assertEqual(schedules, expected_schedule)
frappe.db.set_single_value(
"Accounts Settings", "calculate_daily_depreciation_using", "Total years in depreciation period"
)
frappe.db.set_single_value("Accounts Settings", "calculate_depr_using_total_days", 0)

# Test for Written Down Value Method
# Frequency of deprciation = 3
Expand Down

0 comments on commit bd0c605

Please sign in to comment.