Search in sources :

Example 1 with MRequisition

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

the class Doc_Requisition method loadDocumentDetails.

//	Doc_Requisition
/**
	 *	Load Specific Document Details
	 *  @return error message or null
	 */
protected String loadDocumentDetails() {
    setC_Currency_ID(NO_CURRENCY);
    MRequisition req = (MRequisition) getPO();
    setDateDoc(req.getDateDoc());
    setDateAcct(req.getDateDoc());
    // Amounts
    setAmount(AMTTYPE_Gross, req.getTotalLines());
    setAmount(AMTTYPE_Net, req.getTotalLines());
    // Contained Objects
    p_lines = loadLines(req);
    // log.fine( "Lines=" + p_lines.length + ", Taxes=" + m_taxes.length);
    return null;
}
Also used : MRequisition(org.compiere.model.MRequisition)

Example 2 with MRequisition

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

the class ReplenishReportProduction method createRequisition.

//	createPO
/**
	 * 	Create Requisition
	 */
private void createRequisition() {
    int noReqs = 0;
    String info = "";
    //
    MRequisition requisition = null;
    MWarehouse wh = null;
    X_T_Replenish[] replenishs = getReplenish("M_WarehouseSource_ID IS NULL AND C_BPartner_ID > 0");
    for (int i = 0; i < replenishs.length; i++) {
        X_T_Replenish replenish = replenishs[i];
        if (wh == null || wh.getM_Warehouse_ID() != replenish.getM_Warehouse_ID())
            wh = MWarehouse.get(getCtx(), replenish.getM_Warehouse_ID());
        //
        if (requisition == null || requisition.getM_Warehouse_ID() != replenish.getM_Warehouse_ID()) {
            requisition = new MRequisition(getCtx(), 0, get_TrxName());
            requisition.setAD_User_ID(getAD_User_ID());
            requisition.setC_DocType_ID(p_C_DocType_ID);
            requisition.setDescription(Msg.getMsg(getCtx(), "Replenishment"));
            //	Set Org/WH
            requisition.setAD_Org_ID(wh.getAD_Org_ID());
            requisition.setM_Warehouse_ID(wh.getM_Warehouse_ID());
            if (!requisition.save())
                return;
            log.fine(requisition.toString());
            noReqs++;
            info += " - " + requisition.getDocumentNo();
        }
        //
        MRequisitionLine line = new MRequisitionLine(requisition);
        line.setM_Product_ID(replenish.getM_Product_ID());
        line.setC_BPartner_ID(replenish.getC_BPartner_ID());
        line.setQty(replenish.getQtyToOrder());
        line.setPrice();
        line.save();
    }
    m_info = "#" + noReqs + info;
    log.info(m_info);
}
Also used : X_T_Replenish(org.compiere.model.X_T_Replenish) MRequisitionLine(org.compiere.model.MRequisitionLine) MRequisition(org.compiere.model.MRequisition) MWarehouse(org.compiere.model.MWarehouse)

Example 3 with MRequisition

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

the class CalculateReplenishPlan method insertSupplyLinePO.

/**
	 * Insert Purchase Order and Requisition lines
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param totalSupplyLine
	 * @param subTotalSupplyLine
	 * @param isPO
	 */
public void insertSupplyLinePO(MiniMRPProduct miniMrpProduct, Map<Integer, BigDecimal> totalSupplyLine, Map<Integer, BigDecimal> subTotalSupplyLine, boolean isPO) {
    Map<Integer, Map<Integer, BigDecimal>> supplyLine;
    String typeSupply;
    if (isPO) {
        supplyLine = miniMrpProduct.getSupplyLinePO();
        typeSupply = TYPE_SUPPLY_LINE_PO;
    } else {
        supplyLine = miniMrpProduct.getSupplyLineRQ();
        typeSupply = TYPE_SUPPLY_LINE_RQ;
    }
    if (!supplyLine.isEmpty()) {
        // columnID is C_Order_ID or M_Requisition_ID
        for (Integer columnID : supplyLine.keySet()) {
            Map<Integer, BigDecimal> weeklyDemand = supplyLine.get(columnID);
            if (weeklyDemand.size() > 0) {
                X_M_ReplenishPlanLine miniMRP = getX_M_ReplenishPlanLine(miniMrpProduct, lineNo, typeSupply);
                Timestamp date1;
                String docNo = null;
                if (isPO) {
                    miniMRP.setC_Order_ID(columnID);
                    MOrder order = new MOrder(ctx, columnID, trx);
                    date1 = order.getDatePromised();
                    docNo = order.getDocumentNo();
                } else {
                    miniMRP.setM_Requisition_ID(columnID);
                    MRequisition req = new MRequisition(ctx, columnID, trx);
                    date1 = req.getDateRequired();
                    docNo = req.getDocumentNo();
                }
                String datePromised = requiredFormat.format(date1);
                miniMRP.setOrderInfo(docNo + " - " + datePromised);
                for (Integer week : weeklyDemand.keySet()) {
                    BigDecimal qty = weeklyDemand.get(week);
                    setWeeklyData(miniMRP, week, qty);
                    if (totalSupplyLine.containsKey(week)) {
                        qty = qty.add(totalSupplyLine.get(week));
                    }
                    totalSupplyLine.put(week, qty);
                    BigDecimal qtyProd = weeklyDemand.get(week);
                    if (subTotalSupplyLine.containsKey(week)) {
                        qtyProd = qtyProd.add(subTotalSupplyLine.get(week));
                    }
                    subTotalSupplyLine.put(week, qtyProd);
                }
                miniMRP.saveEx();
            }
            lineNo += 10;
        }
    }
}
Also used : MOrder(org.compiere.model.MOrder) X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) MRequisition(org.compiere.model.MRequisition)

Example 4 with MRequisition

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

the class CalculateReplenishPlan method createRequisition.

/**
	 * Create Requisition Order
	 * 
	 * @param date
	 * @return
	 */
private MRequisition createRequisition(Date date) {
    MRequisition requisition;
    requisition = new MRequisition(ctx, 0, trx);
    //requisition.setAD_Client_ID(AD_Client_ID);
    requisition.setM_Warehouse_ID(M_WarehouseID);
    requisition.setC_DocType_ID(docType_MRPRequisition);
    requisition.setAD_User_ID(AD_User_ID);
    requisition.setDescription("Created from MiniMRP process.");
    requisition.setDateRequired(new Timestamp(date.getTime()));
    requisition.setDateDoc(new Timestamp(date.getTime()));
    requisition.setM_PriceList_ID(M_PriceList_ID);
    requisition.saveEx();
    countReq++;
    requisitionDocs.append(requisition.getDocumentNo()).append(",");
    return requisition;
}
Also used : Timestamp(java.sql.Timestamp) MRequisition(org.compiere.model.MRequisition)

Example 5 with MRequisition

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

the class ReleaseInOutBound method createRequisition.

/**
	 * Create Requisition when the Is create supply is define as yes
	 * @param outBoundOrderLine
	 * @param product Product
	 * @param QtyPlanned Qty Planned
	 */
public void createRequisition(MWMInOutBoundLine outBoundOrderLine, MProduct product, BigDecimal QtyPlanned) {
    //s_log.info("Create Requisition");
    int partnerId = 0;
    int priceListId = 0;
    MProductPO productPOLast;
    MProductPO[] productPOs = MProductPO.getOfProduct(getCtx(), product.getM_Product_ID(), null);
    Arrays.stream(productPOs).forEach(productPO -> {
        if (productPO.isCurrentVendor() && productPO.getC_BPartner_ID() != 0) {
        }
    });
    if (partnerId == 0 && productPOs.length > 0) {
        partnerId = productPOs[0].getC_BPartner_ID();
    }
    if (partnerId == 0) {
        throw new NoVendorForProductException(product.getName());
    }
    final String sql = "SELECT COALESCE(bp." + MBPartner.COLUMNNAME_PO_PriceList_ID + ",bpg." + X_C_BP_Group.COLUMNNAME_PO_PriceList_ID + ")" + " FROM C_BPartner bp" + " INNER JOIN C_BP_Group bpg ON (bpg.C_BP_Group_ID=bp.C_BP_Group_ID)" + " WHERE bp.C_BPartner_ID=?";
    priceListId = DB.getSQLValueEx(get_TrxName(), sql, partnerId);
    MRequisition requisition = new MRequisition(getCtx(), 0, get_TrxName());
    requisition.setAD_Org_ID(outBoundLocator.getAD_Org_ID());
    requisition.setAD_User_ID(getAD_User_ID());
    requisition.setDateRequired(outBoundOrderLine.getPickDate());
    // TODO: add translation
    requisition.setDescription("Generate from Outbound Order");
    requisition.setM_Warehouse_ID(outBoundLocator.getM_Warehouse_ID());
    requisition.setC_DocType_ID(MDocType.getDocType(MDocType.DOCBASETYPE_PurchaseRequisition));
    if (priceListId > 0)
        requisition.setM_PriceList_ID(priceListId);
    requisition.saveEx();
    MRequisitionLine reqline = new MRequisitionLine(requisition);
    reqline.setLine(10);
    reqline.setAD_Org_ID(outBoundLocator.getAD_Org_ID());
    reqline.setC_BPartner_ID(partnerId);
    reqline.setM_Product_ID(product.getM_Product_ID());
    reqline.setPrice();
    reqline.setPriceActual(Env.ZERO);
    reqline.setQty(QtyPlanned);
    reqline.saveEx();
    MOrderLine orderLine = new MOrderLine(getCtx(), outBoundOrderLine.getC_OrderLine_ID(), get_TrxName());
    orderLine.setDescription(orderLine.getDescription() + " " + Msg.translate(getCtx(), MRequisition.COLUMNNAME_M_Requisition_ID) + " : " + requisition.getDocumentNo());
    orderLine.saveEx();
    outBoundOrderLine.setDescription(outBoundOrderLine.getDescription() + " " + Msg.translate(outBoundOrderLine.getCtx(), MRequisition.COLUMNNAME_M_Requisition_ID) + " : " + requisition.getDocumentNo());
}
Also used : NoVendorForProductException(org.adempiere.exceptions.NoVendorForProductException) MProductPO(org.compiere.model.MProductPO) MOrderLine(org.compiere.model.MOrderLine) MRequisitionLine(org.compiere.model.MRequisitionLine) MRequisition(org.compiere.model.MRequisition)

Aggregations

MRequisition (org.compiere.model.MRequisition)18 MRequisitionLine (org.compiere.model.MRequisitionLine)8 Timestamp (java.sql.Timestamp)5 BigDecimal (java.math.BigDecimal)3 TreeMap (java.util.TreeMap)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MOrder (org.compiere.model.MOrder)3 MOrderLine (org.compiere.model.MOrderLine)3 Date (java.util.Date)2 MForecastLine (org.compiere.model.MForecastLine)2 MWarehouse (org.compiere.model.MWarehouse)2 Query (org.compiere.model.Query)2 X_T_Replenish (org.compiere.model.X_T_Replenish)2 MDDOrder (org.eevolution.model.MDDOrder)2 MPPOrder (org.eevolution.model.MPPOrder)2 SQLException (java.sql.SQLException)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1