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;
}
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);
}
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;
}
}
}
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;
}
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());
}
Aggregations