zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.changhong.epc.parsing.service.asset.formula;
 
import com.changhong.epc.bean.form.Asset;
import com.changhong.epc.bean.tenant.asset.FixedAsset;
import com.changhong.epc.constter.parsing.asset.AssetStatic;
import lombok.extern.slf4j.Slf4j;
 
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
 
@Slf4j
public class DepreciationFactory {
 
    public static final Map<String, Depreciation> DEPRECIATION_MAP;
 
    static {
        Map<String, Depreciation> depreciation = new HashMap<>();
        depreciation.put(AssetStatic.DUBLEdDECLININGBALANCEMETHODCODE, new DoubleMoney());
        depreciation.put(AssetStatic.AVERAGELIFEMETHODCODE, new AvgYear());
        depreciation.put(AssetStatic.SUMOFYEARSMETHODCODE, new YearSum());
        DEPRECIATION_MAP = Collections.unmodifiableMap(depreciation);
    }
 
    public static FixedAsset count(Asset money, String type){
        FixedAsset fixedAsset = DEPRECIATION_MAP.get(type).doCount(money);
        log.debug("月折旧率\t:{}", fixedAsset.getDepreciationRate());
        log.debug("本期折旧额\t:{}", fixedAsset.getCurrentDepreciation());
        log.debug("累计折旧额\t:{}", fixedAsset.getCumulativeDepreciation());
        log.debug("净值\t\t:{}", fixedAsset.getNetMoney());
        return fixedAsset;
    }
 
    public static FixedAsset count(Asset money){
        return count(money, money.getDepreciationMethod());
    }
 
}