package com.yuchen.saas.park.api.dto.property;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkunion.park.service.common.utils.AmtUtil;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class PropertyBillSplitDto {

    @NotNull(message = "账单id不能为空")
    private Long billId;

    @NotNull(message = "拆分账单列表")
    @Size(min = 2,message = "拆分账单不能小于2笔")
    private List<SplitBill> splitBillList = new ArrayList<>();

    @Data
    public static class SplitBill {
        /**
         * 开始日期
         */
        @NotNull(message = "开始日期不能为空")
        @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
        private Date startDate;
        /**
         * 结束日期
         */
        @NotNull(message = "结束日期不能为空")
        @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
        private Date endDate;
        /**
         * 应收金额
         */
        @NotNull(message = "应收金额不能为空")
        private BigDecimal receivableAmt;
        @JsonIgnore
        private long receivableAmtFen;
        public long getReceivableAmtFen() {
            return AmtUtil.yuanToFen(this.receivableAmt);
        }
        /**
         * 调整金额
         */
        @NotNull(message = "调整金额不能为空")
        private BigDecimal readjustAmt;
        @JsonIgnore
        private long readjustAmtFen;
        public long getReadjustAmtFen() {
            return AmtUtil.yuanToFen(this.readjustAmt);
        }

        /**
         * 直接减免金额
         */
        @NotNull(message = "直接减免金额不能为空")
        private BigDecimal directReductionAmt;
        @JsonIgnore
        private long directReductionAmtFen;
        public long getDirectReductionAmtFen() {
            return AmtUtil.yuanToFen(this.directReductionAmt);
        }

        /**
         * 滞纳金
         */
        @NotNull(message = "滞纳金不能为空")
        private BigDecimal breachAmt;
        @JsonIgnore
        private long breachAmtFen;
        public long getBreachAmtFen() {
            return AmtUtil.yuanToFen(this.breachAmt);
        }

        /**
         * 调整滞纳金
         */
        @NotNull(message = "调整滞纳金不能为空")
        private BigDecimal reductionBreachAmt;
        @JsonIgnore
        private long reductionBreachAmtFen;
        public long getReductionBreachAmtFen() {
            return AmtUtil.yuanToFen(this.reductionBreachAmt);
        }

        /**
         * 应收日期
         */
        @NotNull(message = "应收日期不能为空")
        @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
        private Date receivableDate;

        /**
         * 实际应收
         */
        @NotNull(message = "实际应收不能为空")
        private BigDecimal noPayAmt;
        @JsonIgnore
        private long noPayAmtFen;
        public long getNoPayAmtFen() {
            return AmtUtil.yuanToFen(this.noPayAmt);
        }

    }

}
