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

Added Depreciation Percentage as an option #15100

Merged
merged 10 commits into from
Aug 12, 2024

Conversation

Godmartinz
Copy link
Collaborator

@Godmartinz Godmartinz commented Jul 16, 2024

Description

This adds the ability to calculate depreciations by percentage. which takes the purchase cost and grabs the percentage and substitutes it in for the amount. the current formula has not changed. this just adds a private method calculateDepreciation() to handle this math.

A percentage option has been added to Depreciations:
image

Floor Value as an amount or percentage:
image

Error if you go outside of 0-100%:
image

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • PHP version:
  • MySQL version
  • Webserver version
  • OS version

Checklist:

Copy link

what-the-diff bot commented Jul 16, 2024

PR Summary

  • Addition of 'Depreciation Type' Column
    A new column called depreciation_type has been added to the depreciations table.

  • Updates in Depreciations Controller
    The DepreciationsController.php file has been updated to include the depreciation_type field. This includes operations where a new depreciation record is created (store method) and instances where a depreciation record is updated (update method). It also includes adding validation rules for depreciation_min and depreciation_type fields.

  • Validation of 'Depreciation Type' field
    New validation rules have been set for the depreciation_type field. It can only accept the values 'amount' or 'percent'.

  • Updates in Depreciation Transformer
    The transformer class DepreciationsTransformer.php has been updated to handle the transform operation related to depreciation_min.

  • Modification in Depreciable Model
    The Depreciable.php model file has a new method calculateDepreciation() that calculates depreciation based on the minimum depreciation and the depreciation type. This new method is now used in the getLinearDepreciatedValue and getMonthlyDepreciation methods.

  • Updates in API Depreciation Controller
    The Api/DepreciationsController.php file now allows 'depreciation_type' in the list of fields ($allowed_columns) and hence it is included in the select query.

  • Updates in View File
    A select input field for depreciation_type has been added to the depreciations/edit.blade.php view file.

Copy link
Owner

@snipe snipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - can you add in a test or two here as well?

Copy link
Collaborator

@akemidx akemidx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Math seems solid and the now() variable seems to be fine for what we wanna do.

@Godmartinz
Copy link
Collaborator Author

@snipe added a test for amount and percentage 👍

@Godmartinz Godmartinz requested a review from snipe July 23, 2024 18:54
@Godmartinz Godmartinz requested a review from snipe August 1, 2024 17:51
@snipe snipe merged commit ce5be8a into snipe:develop Aug 12, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants