Search in sources :

Example 1 with MProductPricing

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

the class CPOS method addOrUpdate.

//	addOrUpdateLine
/**
	 *  Save Line
	 * @param productId
	 * @param qtyOrdered
     * @return
     */
public String addOrUpdate(int productId, BigDecimal qtyOrdered) {
    String errorMessage = null;
    try {
        MProduct product = MProduct.get(ctx, productId);
        if (product == null)
            return "@No@ @InfoProduct@";
        MProductPricing productPricing = new MProductPricing(productId, getC_BPartner_ID(), qtyOrdered, true, null);
        productPricing.setM_PriceList_ID(getM_PriceList_ID());
        productPricing.calculatePrice();
        //	Validate if exists a order
        if (hasOrder()) {
            addOrUpdateLine(product, qtyOrdered, productPricing);
        } else {
            return "@POS.MustCreateOrder@";
        }
    } catch (Exception e) {
        errorMessage = e.getMessage();
    }
    //	
    return errorMessage;
}
Also used : MProductPricing(org.compiere.model.MProductPricing) MProduct(org.compiere.model.MProduct) AdempierePOSException(org.adempiere.pos.AdempierePOSException) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 2 with MProductPricing

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

the class ProjectLinePricing method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (clear text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    if (m_C_ProjectLine_ID == 0)
        throw new IllegalArgumentException("No Project Line");
    MProjectLine projectLine = new MProjectLine(getCtx(), m_C_ProjectLine_ID, get_TrxName());
    log.info("doIt - " + projectLine);
    if (projectLine.getM_Product_ID() == 0)
        throw new IllegalArgumentException("No Product");
    //
    MProject project = new MProject(getCtx(), projectLine.getC_Project_ID(), get_TrxName());
    if (project.getM_PriceList_ID() == 0)
        throw new IllegalArgumentException("No PriceList");
    //
    boolean isSOTrx = true;
    MProductPricing pp = new MProductPricing(projectLine.getM_Product_ID(), project.getC_BPartner_ID(), projectLine.getPlannedQty(), isSOTrx, null);
    pp.setM_PriceList_ID(project.getM_PriceList_ID());
    pp.setPriceDate(project.getDateContract());
    //
    projectLine.setPlannedPrice(pp.getPriceStd());
    projectLine.setPlannedMarginAmt(pp.getPriceStd().subtract(pp.getPriceLimit()));
    projectLine.saveEx();
    //
    String retValue = Msg.getElement(getCtx(), "PriceList") + pp.getPriceList() + " - " + Msg.getElement(getCtx(), "PriceStd") + pp.getPriceStd() + " - " + Msg.getElement(getCtx(), "PriceLimit") + pp.getPriceLimit();
    return retValue;
}
Also used : MProductPricing(org.compiere.model.MProductPricing) MProjectLine(org.compiere.model.MProjectLine) MProject(org.compiere.model.MProject)

Aggregations

MProductPricing (org.compiere.model.MProductPricing)2 AdempiereException (org.adempiere.exceptions.AdempiereException)1 AdempierePOSException (org.adempiere.pos.AdempierePOSException)1 MProduct (org.compiere.model.MProduct)1 MProject (org.compiere.model.MProject)1 MProjectLine (org.compiere.model.MProjectLine)1