Search in sources :

Example 11 with MPriceListVersion

use of org.compiere.model.MPriceListVersion in project adempiere by adempiere.

the class DistributionRunOrders method groovy.

public String groovy(String A_TrxName, Properties A_Ctx, int P_M_Warehouse_ID, int P_M_PriceList_Version_ID, int P_M_DistributionList_ID) {
    MPriceListVersion plv = new MPriceListVersion(A_Ctx, P_M_PriceList_Version_ID, A_TrxName);
    MPriceList pl = new MPriceList(A_Ctx, plv.getM_PriceList_ID(), A_TrxName);
    MWarehouse w = new MWarehouse(A_Ctx, P_M_Warehouse_ID, A_TrxName);
    MDistributionRun dr = new MDistributionRun(A_Ctx, 0, A_TrxName);
    dr.setName(plv.getName());
    dr.setIsActive(true);
    dr.setAD_Org_ID(w.getAD_Org_ID());
    dr.saveEx();
    MProductPrice[] products = plv.getProductPrice(true);
    int seq = 10;
    for (MProductPrice pp : products) {
        int M_Product_ID = pp.getM_Product_ID();
        BigDecimal QtyAvailable = MStorage.getQtyAvailable(P_M_Warehouse_ID, M_Product_ID, 0, 0, A_TrxName);
        BigDecimal QtyOnHand = MPPMRP.getQtyOnHand(A_Ctx, P_M_Warehouse_ID, M_Product_ID, A_TrxName);
        MDistributionRunLine drl = new MDistributionRunLine(A_Ctx, 0, A_TrxName);
        drl.setM_DistributionRun_ID(dr.get_ID());
        drl.setLine(seq);
        drl.setM_Product_ID(M_Product_ID);
        drl.setM_DistributionList_ID(P_M_DistributionList_ID);
        drl.setDescription(Msg.translate(A_Ctx, "QtyAvailable") + " = " + QtyAvailable + " | " + Msg.translate(A_Ctx, "QtyOnHand") + " = " + QtyOnHand);
        drl.setTotalQty(QtyAvailable);
        drl.saveEx();
    }
    return "";
}
Also used : MDistributionRun(org.compiere.model.MDistributionRun) MDistributionRunLine(org.compiere.model.MDistributionRunLine) MPriceListVersion(org.compiere.model.MPriceListVersion) MPriceList(org.compiere.model.MPriceList) MWarehouse(org.compiere.model.MWarehouse) BigDecimal(java.math.BigDecimal) MProductPrice(org.compiere.model.MProductPrice)

Aggregations

MPriceListVersion (org.compiere.model.MPriceListVersion)11 MPriceList (org.compiere.model.MPriceList)8 MProductPrice (org.compiere.model.MProductPrice)7 BigDecimal (java.math.BigDecimal)6 Properties (java.util.Properties)4 Query (org.compiere.model.Query)3 Timestamp (java.sql.Timestamp)2 MProduct (org.compiere.model.MProduct)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 TreeMap (java.util.TreeMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CostDimension (org.adempiere.engine.CostDimension)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 AdempierePOSException (org.adempiere.pos.AdempierePOSException)1 MAccount (org.compiere.model.MAccount)1 MAcctSchema (org.compiere.model.MAcctSchema)1 MBPartnerLocation (org.compiere.model.MBPartnerLocation)1 MCost (org.compiere.model.MCost)1 MCostElement (org.compiere.model.MCostElement)1