Search in sources :

Example 11 with MProductPrice

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

the class MPriceListVersionTest method testQuery.

public void testQuery() throws Exception {
    MPriceListVersion plv = new MPriceListVersion(getCtx(), 101, getTrxName());
    //red1 tested also with (true) and (false)
    MProductPrice[] pp = plv.getProductPrice("AND isActive='Y'");
    assertTrue("product must have prices", pp.length > 0);
}
Also used : MPriceListVersion(org.compiere.model.MPriceListVersion) MProductPrice(org.compiere.model.MProductPrice)

Example 12 with MProductPrice

use of org.compiere.model.MProductPrice 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

MProductPrice (org.compiere.model.MProductPrice)12 BigDecimal (java.math.BigDecimal)8 MPriceListVersion (org.compiere.model.MPriceListVersion)7 MPriceList (org.compiere.model.MPriceList)5 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 Properties (java.util.Properties)2 MProduct (org.compiere.model.MProduct)2 Query (org.compiere.model.Query)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 SQLException (java.sql.SQLException)1 TreeMap (java.util.TreeMap)1 JLabel (javax.swing.JLabel)1 AdempierePOSException (org.adempiere.pos.AdempierePOSException)1 Label (org.adempiere.webui.component.Label)1 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)1 MAccount (org.compiere.model.MAccount)1 MBPartnerLocation (org.compiere.model.MBPartnerLocation)1