计算直线下降
calculate straight line declining
我今年有价值1000的资产(比如车辆)...
var assetCurrentBookValue = 1000
车辆将在5年内贬值...这意味着未来5年价值将变为0...
var assetLife = 5
年折旧变为...
var assetYearlyDepreciation = assetCurrentBookValue / assetLife
我需要像这样计算年度折旧后的年度价值...
year assetYearlyDepreciation assetBookVaue
2016 200 1000
2017 200 800
2018 200 600
2019 200 400
2020 200 200
2021 200 0
我需要像这样转换成数组...
[
[2016,1000],
[2017,800],
[2018,600],
[2019,400],
[2020,200],
[2021,0]
]
这是我的解决方法...
var index = Array.from(Array(assetLife).keys());
var thisYear = new Date().getFullYear()
var assetYearlyBookValue = [[thisYear,assetCurrentBookValue]]
index.forEach((o) => {
assetYearlyBookValue.push([o + thisYear + 1, assetCurrentBookValue - assetYearlyDepreciation])
});
但我得到了..
[
[2016,1000],
[2017,800],
[2018,800],
[2019,800],
[2020,800],
[2021,800]
]
如有任何帮助,我们将不胜感激...谢谢 Youu..
修改 assetCurrentBookValue - assetYearlyDepreciation
和 new Date().getFullYear()
的结果并将它们存储到变量中,以便您可以获得不断变化的结果:
var index = Array.from(Array(assetEconomicLife).keys());
var thisYear = new Date().getFullYear()
var assetYearlyBookValue = [[thisYear,assetCurrentBookValue]]
var lastRes = assetCurrentBookValue
index.forEach((o) => {
lastRes -= assetYearlyDepreciation
assetYearlyBookValue.push([o + (++thisYear), lastRes])
});
我今年有价值1000的资产(比如车辆)...
var assetCurrentBookValue = 1000
车辆将在5年内贬值...这意味着未来5年价值将变为0...
var assetLife = 5
年折旧变为...
var assetYearlyDepreciation = assetCurrentBookValue / assetLife
我需要像这样计算年度折旧后的年度价值...
year assetYearlyDepreciation assetBookVaue
2016 200 1000
2017 200 800
2018 200 600
2019 200 400
2020 200 200
2021 200 0
我需要像这样转换成数组...
[
[2016,1000],
[2017,800],
[2018,600],
[2019,400],
[2020,200],
[2021,0]
]
这是我的解决方法...
var index = Array.from(Array(assetLife).keys());
var thisYear = new Date().getFullYear()
var assetYearlyBookValue = [[thisYear,assetCurrentBookValue]]
index.forEach((o) => {
assetYearlyBookValue.push([o + thisYear + 1, assetCurrentBookValue - assetYearlyDepreciation])
});
但我得到了..
[
[2016,1000],
[2017,800],
[2018,800],
[2019,800],
[2020,800],
[2021,800]
]
如有任何帮助,我们将不胜感激...谢谢 Youu..
修改 assetCurrentBookValue - assetYearlyDepreciation
和 new Date().getFullYear()
的结果并将它们存储到变量中,以便您可以获得不断变化的结果:
var index = Array.from(Array(assetEconomicLife).keys());
var thisYear = new Date().getFullYear()
var assetYearlyBookValue = [[thisYear,assetCurrentBookValue]]
var lastRes = assetCurrentBookValue
index.forEach((o) => {
lastRes -= assetYearlyDepreciation
assetYearlyBookValue.push([o + (++thisYear), lastRes])
});