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

feat: update depreciation #147

Merged
merged 15 commits into from
Jan 6, 2025
Merged

feat: update depreciation #147

merged 15 commits into from
Jan 6, 2025

Conversation

zz-hh-aa
Copy link
Collaborator

@zz-hh-aa zz-hh-aa commented Nov 22, 2024

What does this PR do?

constants.ts

  • Creates new types for calculating depreciation
    • componentBreakdownType breaks each component down into the percentage of the house it makes up, how much of its original value it depreciates each year, and what percentage of yearly maintenance spend it accounts for
    • houseBreakdownType is an object with a component breakdown object per-component
  • HOUSE_BREAKDOWN_PERCENTAGES is exported as a constant for use in calculateDepreciatedBuildPrice()

Property.ts

  • New calculateComponentValue() method (separated this out for ease of testing)
  • Updates calculateDepreciatedBuildPrice()
    • Loops through each object in HOUSE_BREAKDOWN_PERCENTAGES and runs calculateComponentValue() to calculate depreciated value per-component
    • Sums each value

Property.test.ts

  • Creates tests for newbuild, depreciated building, component breakdowns

Tests now pass! I ended up opting for a different method where stuff gets calculated again in the test file. Felt a bit more meaningful than just passing the resultant number as the expected value.

Closes #154

Copy link

vercel bot commented Nov 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fairhold-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 11:22am

@zz-hh-aa zz-hh-aa marked this pull request as ready for review November 29, 2024 17:16
Copy link
Collaborator

@gabrielegranello gabrielegranello left a comment

Choose a reason for hiding this comment

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

That looks good to me @zz-hh-aa , great work.

@zz-hh-aa zz-hh-aa changed the title wip: feat: update depreciation feat: update depreciation Dec 11, 2024
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

@zz-hh-aa Really sorry for the holdup here! All looking good :)

@zz-hh-aa zz-hh-aa force-pushed the oz/depreciation-update branch from 27fffba to db7c2d9 Compare January 6, 2025 11:21
@zz-hh-aa zz-hh-aa merged commit bb63983 into main Jan 6, 2025
5 checks passed
@zz-hh-aa zz-hh-aa deleted the oz/depreciation-update branch January 6, 2025 11:23
@zz-hh-aa zz-hh-aa restored the oz/depreciation-update branch January 6, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calculate depreciating house value
3 participants