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