CurrentPeriodBo.java 1.64 KB
Newer Older
1 2 3 4 5 6
package pwc.taxtech.atms.dto.vatdto;

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

7 8 9 10 11
    public CurrentPeriodBo(int curYear, int curPeriod) {
        this.curYear = curYear;
        this.curPeriod = curPeriod;
    }

12 13 14 15 16
    public CurrentPeriodBo(int period) {
        this.curPeriod = period;
    }

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

21
    public static CurrentPeriodBo getPeriod(int parameterPeriod, int periodContent) {
22 23 24 25
        int yearOffset = 0;
        if (parameterPeriod == -99) {
            return new CurrentPeriodBo(parameterPeriod);
        } else if (parameterPeriod <= -1) {
26
            Integer period = parameterPeriod + periodContent;
27 28 29 30 31 32 33 34 35 36 37 38 39
            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);
        }
    }
40

eddie.woo's avatar
eddie.woo committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    public int getCurYear() {
        return this.curYear;
    }

    public void setCurYear(int curYear) {
        this.curYear = curYear;
    }

    public int getCurPeriod() {
        return this.curPeriod;
    }

    public void setCurPeriod(int curPeriod) {
        this.curPeriod = curPeriod;
    }

57 58 59 60 61 62 63
    @Override
    public String toString() {
        return "CurrentPeriodBo{" +
                "curYear=" + curYear +
                ", curPeriod=" + curPeriod +
                '}';
    }
64
}