use of org.compiere.model.MProject 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;
}
use of org.compiere.model.MProject in project adempiere by adempiere.
the class ProjectGenOrder method doIt.
// prepare
/**
* Perform process.
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("C_Project_ID=" + m_C_Project_ID);
if (m_C_Project_ID == 0)
throw new IllegalArgumentException("C_Project_ID == 0");
MProject fromProject = getProject(getCtx(), m_C_Project_ID, get_TrxName());
// Set SO context
Env.setSOTrx(getCtx(), true);
/** @todo duplicate invoice prevention */
MOrder order = new MOrder(fromProject, true, MOrder.DocSubTypeSO_OnCredit);
if (!order.save())
throw new Exception("Could not create Order");
// *** Lines ***
int count = 0;
// Service Project
if (MProject.PROJECTCATEGORY_ServiceChargeProject.equals(fromProject.getProjectCategory())) {
/** @todo service project invoicing */
throw new Exception("Service Charge Projects are on the TODO List");
} else // Service Lines
// Order Lines
{
MProjectLine[] lines = fromProject.getLines();
for (int i = 0; i < lines.length; i++) {
MOrderLine ol = new MOrderLine(order);
ol.setLine(lines[i].getLine());
ol.setDescription(lines[i].getDescription());
//
ol.setM_Product_ID(lines[i].getM_Product_ID(), true);
ol.setQty(lines[i].getPlannedQty().subtract(lines[i].getInvoicedQty()));
ol.setPrice();
if (lines[i].getPlannedPrice() != null && lines[i].getPlannedPrice().compareTo(Env.ZERO) != 0)
ol.setPrice(lines[i].getPlannedPrice());
ol.setDiscount();
ol.setTax();
if (ol.save())
count++;
}
// for all lines
if (lines.length != count)
log.log(Level.SEVERE, "Lines difference - ProjectLines=" + lines.length + " <> Saved=" + count);
}
return "@C_Order_ID@ " + order.getDocumentNo() + " (" + count + ")";
}
use of org.compiere.model.MProject in project adempiere by adempiere.
the class ProjectCreateAsset method doIt.
// prepare
/**
* Perform process.
* @return Message (translated text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
if (m_C_Project_ID == 0) {
return "Missing Mandatory Field Value (Project)";
}
MProject project = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
log.info("doIt - " + project);
// Goodwill
if (!MProject.PROJECTCATEGORY_AssetProject.equals(project.getProjectCategory()))
return "Project is not asset type";
//
MProduct product = new MProduct(getCtx(), m_Product_ID, get_TrxName());
MProductCategory pc = MProductCategory.get(getCtx(), product.getM_Product_Category_ID());
if (pc.getA_Asset_Group_ID() == 0) {
return "Product is not asset type";
}
MAssetAddition assetAdd = MAssetAddition.createAsset(project, product);
assetAdd.setDateAcct(m_DateTrx);
assetAdd.setDateDoc(m_DateTrx);
assetAdd.setM_Product_ID(m_Product_ID);
if (m_UseLifeYears > 0) {
assetAdd.setDeltaUseLifeYears(m_UseLifeYears);
assetAdd.setDeltaUseLifeYears_F(m_UseLifeYears);
}
assetAdd.saveEx();
if (!assetAdd.processIt(DocAction.ACTION_Complete)) {
return "Error Process Asset Addition";
}
assetAdd.saveEx();
message += ". @A_Asset_Addition_ID@ - " + assetAdd;
return "Asset Created " + message;
}
use of org.compiere.model.MProject in project adempiere by adempiere.
the class HTMLMessenger method getMfcOrderInfo.
public String getMfcOrderInfo(MPPOrder o) {
MProject pj = new MProject(Env.getCtx(), o.getC_Project_ID(), null);
MProduct pd = new MProduct(Env.getCtx(), o.getM_Product_ID(), null);
Object[] obj = new Object[] { o.getDocumentNo(), o.getDateStartSchedule(), o.getDateFinishSchedule(), (pj.getName() == null ? "-" : pj.getName()) + (pj.getValue() == null ? "" : " (" + pj.getValue() + ")"), pd.getName() + " (" + pd.getValue() + ")", o.getQtyOrdered(), o.getQtyDelivered() };
return MessageFormat.format(PP_ORDER_INFO_PATTERN, obj);
}
use of org.compiere.model.MProject in project adempiere by adempiere.
the class VProductConfigurationBOM method cmd_saveProject.
// cmd_saveInvoice
/**
* Save to Project
* @param C_Project_ID id
* @return true if saved
*/
private boolean cmd_saveProject(int C_Project_ID) {
log.config("C_Project_ID=" + C_Project_ID);
MProject project = new MProject(Env.getCtx(), C_Project_ID, null);
if (project.get_ID() == 0) {
log.log(Level.SEVERE, "Not found - C_Project_ID=" + C_Project_ID);
return false;
}
int lineCount = 0;
// for all bom lines
for (int i = 0; i < m_selectionList.size(); i++) {
if (isSelectionSelected(m_selectionList.get(i))) {
BigDecimal qty = (BigDecimal) ((VNumber) m_qtyList.get(i)).getValue();
int M_Product_ID = ((Integer) m_productList.get(i)).intValue();
// Create Line
MProjectLine pl = new MProjectLine(project);
pl.setM_Product_ID(M_Product_ID);
pl.setPlannedQty(qty);
// pl.setPlannedPrice();
if (pl.save())
lineCount++;
else
log.log(Level.SEVERE, "Line not saved");
}
// line selected
}
// for all bom lines
log.config("#" + lineCount);
return true;
}
Aggregations