package com.zfire.mall.manager.bean.engin.info;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

@Data
@ApiModel
public class EnginInfoOrderItemBean {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "工程明细id")
    private String id;

    @ApiModelProperty(value = "工程信息id")
    private String parentId;

    @ApiModelProperty(value = "工程信息编号")
    private String enginInfoNo;

    @NotBlank(message = "销售类型不能为空")
    @ApiModelProperty(value = "销售类型id")
    private String saleTypeId;

    @NotBlank(message = "销售类型编码不能为空")
    @ApiModelProperty(value = "销售名称")
    private String saleTypeCode;

    @NotBlank(message = "销售类型名称不能为空")
    @ApiModelProperty(value = "销售名称")
    private String saleTypeName;

    @NotBlank(message = "产品不能为空")
    @ApiModelProperty(value = "金蝶物料id")
    private String materialId;

    @ApiModelProperty(value = "金蝶物料编码")
    private String materialNumber;

    @ApiModelProperty(value = "金蝶物料名称")
    private String materialName;

    @ApiModelProperty(value = "金蝶物料旧编码")
    private String materialOldNumber;

    @ApiModelProperty(value = "规格型号")
    private String specification;

    @ApiModelProperty(value = "基本单位编码")
    private String unit;

    @NotNull(message = "单价不能为空")
    @Min(message = "单价不能少于0", value = 0)
    @ApiModelProperty(value = "单价", required = true)
    private BigDecimal price = new BigDecimal("0");

    @NotNull(message = "数量不能为空")
    @Min(message = "数量不能少于0", value = 0)
    @ApiModelProperty(value = "数量", required = true)
    private Integer qty = 0;

    @ApiModelProperty(value = "已订数量", required = true)
    private Integer hasOrderQty = 0;

    @ApiModelProperty(value = "已发货数量", required = true)
    private Integer hasDeliverQty = 0;

    @ApiModelProperty(value = "总金额")
    private BigDecimal totalAmount = new BigDecimal("0");

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "税率")
    private BigDecimal taxRate;

    public BigDecimal getTotalAmount() {
        return new BigDecimal(this.qty.toString()).multiply(this.price).setScale(2, BigDecimal.ROUND_HALF_UP);
    }

}
