CurrentPeriodBo.java 1.24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
package pwc.taxtech.atms.dto.vatdto;

import lombok.Getter;

@Getter
public class CurrentPeriodBo {
    int curYear = 0;
    int curPeriod;

    public CurrentPeriodBo(int period) {
        this.curPeriod = period;
    }

    public CurrentPeriodBo fixedCurYear(int curYear) {
15
        this.curYear = +curYear;
16 17 18
        return this;
    }

19
    public static CurrentPeriodBo getPeriod(int parameterPeriod, int periodContent) {
20 21 22 23
        int yearOffset = 0;
        if (parameterPeriod == -99) {
            return new CurrentPeriodBo(parameterPeriod);
        } else if (parameterPeriod <= -1) {
24
            Integer period = parameterPeriod + periodContent;
25 26 27 28 29 30 31 32 33 34 35 36 37
            while (period <= 0) {
                yearOffset--;
                period += 12;
                //throw new NotImplementedException();
            }

            return new CurrentPeriodBo(period).fixedCurYear(yearOffset);
        } else if (parameterPeriod == 0) {
            return new CurrentPeriodBo(periodContent);
        } else {
            return new CurrentPeriodBo(parameterPeriod);
        }
    }
38 39 40 41 42 43 44 45

    @Override
    public String toString() {
        return "CurrentPeriodBo{" +
                "curYear=" + curYear +
                ", curPeriod=" + curPeriod +
                '}';
    }
46
}