package com.prolog.upcloud.base.wh.operate.utils;

import cn.hutool.core.lang.Assert;
import lombok.extern.slf4j.Slf4j;

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

@Slf4j
public class StockHelper {

    /**
     * 计算库存数量（[0]=件数；[1]=零散数
     *
     * @param qty      数量
     * @param packSize 包大小
     * @return {@link BigDecimal[]}
     */
    public static BigDecimal[] countStock(@NotNull BigDecimal qty, @NotNull BigDecimal packSize) {
        log.info("qty={},packSize={}", qty, packSize);
        Assert.notNull(qty, "库存数量不能为空");
        Assert.notNull(packSize, "包装数量不能为空");
        return qty.divideAndRemainder(packSize);
    }
}
