asset-depreciation-calculator
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -18,7 +18,16 @@ "use strict"; | ||
const depreciationAmount = toFixedTwo((purchaseAmount / totalDepreciationYears / MONTHS_IN_YEAR) * monthsLeft); | ||
const percentage = toFixedTwo((depreciationAmount / purchaseAmount) * 100); | ||
const newEndAmount = toFixedTwo(previousEndAmount - depreciationAmount); | ||
// Because of the rounding, even if the calculation is correct, sometimes there is €0.01 left over. | ||
// For example, if total is 3.1, divided by 3 it would be 1.33 / 1.33 / 1.33. | ||
if (newEndAmount === 0.01) { | ||
return { | ||
depreciationAmount: previousEndAmount, | ||
percentage: toFixedTwo((previousEndAmount / purchaseAmount) * 100), | ||
startAmount: previousEndAmount, | ||
endAmount: 0, | ||
}; | ||
} | ||
return { | ||
depreciationAmount, | ||
percentage, | ||
percentage: toFixedTwo((depreciationAmount / purchaseAmount) * 100), | ||
startAmount: previousEndAmount, | ||
@@ -25,0 +34,0 @@ endAmount: newEndAmount, |
{ | ||
"name": "asset-depreciation-calculator", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Asset Depreciation Calculator", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10332
93