Search in sources :

Example 6 with MPriceList

use of org.compiere.model.MPriceList in project lar_361 by comitsrl.

the class SubOrder method getM_PriceList_Version_ID.

// getC_BPartner_Location_ID
/**
 * Get M_PriceList_Version_ID. Set Currency
 * @return plv
 */
public int getM_PriceList_Version_ID() {
    if (m_M_PriceList_Version_ID == 0) {
        int M_PriceList_ID = p_pos.getM_PriceList_ID();
        if (m_bpartner != null && m_bpartner.getM_PriceList_ID() != 0)
            M_PriceList_ID = m_bpartner.getM_PriceList_ID();
        // 
        MPriceList pl = MPriceList.get(p_ctx, M_PriceList_ID, null);
        setCurrency(MCurrency.getISO_Code(p_ctx, pl.getC_Currency_ID()));
        // 
        MPriceListVersion plv = pl.getPriceListVersion(p_posPanel.getToday());
        if (plv != null && plv.getM_PriceList_Version_ID() != 0) {
            m_M_PriceList_Version_ID = plv.getM_PriceList_Version_ID();
        }
    }
    return m_M_PriceList_Version_ID;
}
Also used : MPriceListVersion(org.compiere.model.MPriceListVersion) MPriceList(org.compiere.model.MPriceList)

Example 7 with MPriceList

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

the class InventoryUtil method getCreatePriceList.

public static MPriceList getCreatePriceList(String value, boolean IsSOPriceList) {
    Properties ctx = Env.getCtx();
    int C_Currency_ID = Env.getContextAsInt(ctx, "$C_Currency_ID");
    String whereClause = MPriceList.COLUMNNAME_Name + "=?" + " AND " + MPriceList.COLUMNNAME_IsSOPriceList + "=?" + " AND " + MPriceList.COLUMNNAME_C_Currency_ID + "=?";
    MPriceList pl = new Query(ctx, MPriceList.Table_Name, whereClause, null).setParameters(new Object[] { value, IsSOPriceList, C_Currency_ID }).setClient_ID().setOnlyActiveRecords(true).firstOnly();
    if (pl == null) {
        pl = new MPriceList(ctx, 0, null);
        pl.setName(value);
        pl.setIsSOPriceList(IsSOPriceList);
        pl.setC_Currency_ID(C_Currency_ID);
    }
    setGeneratedTag(pl);
    pl.setIsTaxIncluded(false);
    pl.saveEx();
    //
    Timestamp ValidFrom = TimeUtil.getDay(1970, 1, 1);
    MPriceListVersion plv = pl.getPriceListVersion(ValidFrom);
    if (plv == null) {
        plv = new MPriceListVersion(pl);
        plv.setValidFrom(ValidFrom);
        plv.setM_DiscountSchema_ID(getM_DiscountSchema_ID());
        setGeneratedTag(plv);
        plv.saveEx();
    }
    //
    return pl;
}
Also used : Query(org.compiere.model.Query) MPriceListVersion(org.compiere.model.MPriceListVersion) MPriceList(org.compiere.model.MPriceList) Properties(java.util.Properties) Timestamp(java.sql.Timestamp)

Example 8 with MPriceList

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

the class InventoryUtil method getCreatePriceList.

public static MPriceList getCreatePriceList(String value, boolean IsSOPriceList) {
    Properties ctx = Env.getCtx();
    int C_Currency_ID = Env.getContextAsInt(ctx, "$C_Currency_ID");
    String whereClause = MPriceList.COLUMNNAME_Name + "=?" + " AND " + MPriceList.COLUMNNAME_IsSOPriceList + "=?" + " AND " + MPriceList.COLUMNNAME_C_Currency_ID + "=?";
    MPriceList pl = new Query(ctx, MPriceList.Table_Name, whereClause, null).setParameters(new Object[] { value, IsSOPriceList, C_Currency_ID }).setClient_ID().setOnlyActiveRecords(true).firstOnly();
    if (pl == null) {
        pl = new MPriceList(ctx, 0, null);
        pl.setName(value);
        pl.setIsSOPriceList(IsSOPriceList);
        pl.setC_Currency_ID(C_Currency_ID);
    }
    setGeneratedTag(pl);
    pl.setIsTaxIncluded(false);
    pl.saveEx();
    //
    Timestamp ValidFrom = TimeUtil.getDay(1970, 1, 1);
    MPriceListVersion plv = pl.getPriceListVersion(ValidFrom);
    if (plv == null) {
        plv = new MPriceListVersion(pl);
        plv.setValidFrom(ValidFrom);
        plv.setM_DiscountSchema_ID(getM_DiscountSchema_ID());
        setGeneratedTag(plv);
        plv.saveEx();
    }
    //
    return pl;
}
Also used : Query(org.compiere.model.Query) MPriceListVersion(org.compiere.model.MPriceListVersion) MPriceList(org.compiere.model.MPriceList) Properties(java.util.Properties) Timestamp(java.sql.Timestamp)

Example 9 with MPriceList

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

the class CPOS method loadPriceListVersion.

//	getM_PriceList_ID
/**
	 * Load Price List Version from Price List
	 * @param priceListId
	 * @return
	 * @return MPriceListVersion
	 */
protected MPriceListVersion loadPriceListVersion(int priceListId) {
    priceListVersionId = 0;
    this.priceListId = priceListId;
    MPriceList priceList = MPriceList.get(ctx, priceListId, null);
    //
    MPriceListVersion priceListVersion = priceList.getPriceListVersion(getToday());
    if (priceListVersion != null && priceListVersion.getM_PriceList_Version_ID() != 0) {
        priceListVersionId = priceListVersion.getM_PriceList_Version_ID();
    }
    //	Default Return
    return priceListVersion;
}
Also used : MPriceListVersion(org.compiere.model.MPriceListVersion) MPriceList(org.compiere.model.MPriceList)

Example 10 with MPriceList

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

MPriceList (org.compiere.model.MPriceList)10 MPriceListVersion (org.compiere.model.MPriceListVersion)9 BigDecimal (java.math.BigDecimal)5 MProductPrice (org.compiere.model.MProductPrice)5 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 DateFormat (java.text.DateFormat)1 TreeMap (java.util.TreeMap)1 MAccount (org.compiere.model.MAccount)1 MDistributionRun (org.compiere.model.MDistributionRun)1 MDistributionRunLine (org.compiere.model.MDistributionRunLine)1 MElementValue (org.compiere.model.MElementValue)1 MWarehouse (org.compiere.model.MWarehouse)1 X_I_PriceList (org.compiere.model.X_I_PriceList)1 X_M_ProductPriceVendorBreak (org.compiere.model.X_M_ProductPriceVendorBreak)1 X_M_Product_Acct (org.compiere.model.X_M_Product_Acct)1