package com.sy.coinage.workshop;

import com.sy.coinage.workshop.model.Product;
import com.sy.coinage.workshop.model.Stock;
import java.util.List;

public class WareUtil {

    /**
     * 计算临时库
     *
     * @param stock
     * @param product
     * @return
     */
    public static Integer piecesTotal(Stock stock, Product product) {
        Integer boxTotal = stock.getBoxNum() + stock.getRacketNum() * product.getBoxAmount()
            + stock.getCheckBoxNum();
        return boxTotal * product.getAmountPerBox() + stock.getPiecesTotal();
    }

    /**
     * 计算总库
     *
     * @param list
     * @param product
     * @return
     */
    public static Integer piecesTotal(List<Stock> list, Product product) {
        Integer box = 0;
        for (Stock stock : list) {
            // 总拍数 - 抽出出库的箱数
            box = box + stock.getBoxNum() + stock.getRacketNum() * product.getBoxAmount()
                - stock.getCheckBoxNum();
        }
        return box * product.getAmountPerBox();
    }

}
