use of org.compiere.model.MProjectLine in project adempiere by adempiere.
the class WBOMDrop 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 = m_qtyList.get(i).getValue();
int M_Product_ID = m_productList.get(i).intValue();
// Create Line
MProjectLine pl = new MProjectLine(project);
pl.setM_Product_ID(M_Product_ID);
pl.setPlannedQty(qty);
if (pl.save())
lineCount++;
else
log.log(Level.SEVERE, "Line not saved");
}
// line selected
}
// for all bom lines
FDialog.info(-1, this, project.getName() + " " + Msg.translate(Env.getCtx(), "Inserted") + "=" + lineCount);
log.config("#" + lineCount);
return true;
}
use of org.compiere.model.MProjectLine in project adempiere by adempiere.
the class ProjectIssue method issueExpense.
// issueReceipt
/**
* Issue Expense Report
* @return Message (clear text)
*/
private String issueExpense() {
// Get Expense Report
MTimeExpense expense = new MTimeExpense(getCtx(), m_S_TimeExpense_ID, get_TrxName());
if (!expense.isProcessed())
throw new IllegalArgumentException("Time+Expense not processed - " + expense);
// for all expense lines
MTimeExpenseLine[] expenseLines = expense.getLines(false);
int counter = 0;
for (int i = 0; i < expenseLines.length; i++) {
// Need to have a Product
if (expenseLines[i].getM_Product_ID() == 0)
continue;
// Need to have Quantity
if (expenseLines[i].getQty() == null || expenseLines[i].getQty().signum() == 0)
continue;
// Need to the same project
if (expenseLines[i].getC_Project_ID() != m_project.getC_Project_ID())
continue;
// not issued yet
if (projectIssueHasExpense(expenseLines[i].getS_TimeExpenseLine_ID()))
continue;
// Find Location
int M_Locator_ID = 0;
// MProduct product = new MProduct (getCtx(), expenseLines[i].getM_Product_ID());
// if (product.isStocked())
M_Locator_ID = MStorage.getM_Locator_ID(expense.getM_Warehouse_ID(), // no ASI
expenseLines[i].getM_Product_ID(), // no ASI
0, expenseLines[i].getQty(), null);
if (// Service/Expense - get default (and fallback)
M_Locator_ID == 0)
M_Locator_ID = expense.getM_Locator_ID();
// Create Issue
MProjectIssue pi = new MProjectIssue(m_project);
pi.setMandatory(M_Locator_ID, expenseLines[i].getM_Product_ID(), expenseLines[i].getQty());
if (// default today
m_MovementDate != null)
pi.setMovementDate(m_MovementDate);
if (m_Description != null && m_Description.length() > 0)
pi.setDescription(m_Description);
else if (expenseLines[i].getDescription() != null)
pi.setDescription(expenseLines[i].getDescription());
pi.setS_TimeExpenseLine_ID(expenseLines[i].getS_TimeExpenseLine_ID());
pi.process();
// Find/Create Project Line
MProjectLine pl = new MProjectLine(m_project);
// setIssue
pl.setMProjectIssue(pi);
pl.saveEx();
addLog(pi.getLine(), pi.getMovementDate(), pi.getMovementQty(), null);
counter++;
}
return "@Created@ " + counter;
}
use of org.compiere.model.MProjectLine in project adempiere by adempiere.
the class ProjectIssue method issueInventory.
// issueProjectLine
/**
* Issue from Inventory
* @return Message (clear text)
*/
private String issueInventory() {
if (m_M_Locator_ID == 0)
throw new IllegalArgumentException("No Locator");
if (m_M_Product_ID == 0)
throw new IllegalArgumentException("No Product");
// Set to Qty 1
if (m_MovementQty == null || m_MovementQty.signum() == 0)
m_MovementQty = Env.ONE;
//
MProjectIssue pi = new MProjectIssue(m_project);
pi.setMandatory(m_M_Locator_ID, m_M_Product_ID, m_MovementQty);
if (// default today
m_MovementDate != null)
pi.setMovementDate(m_MovementDate);
if (m_Description != null && m_Description.length() > 0)
pi.setDescription(m_Description);
pi.process();
// Create Project Line
MProjectLine pl = new MProjectLine(m_project);
pl.setMProjectIssue(pi);
pl.saveEx();
addLog(pi.getLine(), pi.getMovementDate(), pi.getMovementQty(), null);
return "@Created@ 1";
}
use of org.compiere.model.MProjectLine in project adempiere by adempiere.
the class ProjectIssue method issueReceipt.
// doIt
/**
* Issue Receipt
* @return Message (clear text)
*/
private String issueReceipt() {
MInOut inOut = new MInOut(getCtx(), m_M_InOut_ID, null);
if (inOut.isSOTrx() || !inOut.isProcessed() || !(MInOut.DOCSTATUS_Completed.equals(inOut.getDocStatus()) || MInOut.DOCSTATUS_Closed.equals(inOut.getDocStatus())))
throw new IllegalArgumentException("Receipt not valid - " + inOut);
log.info(inOut.toString());
// Set Project of Receipt
if (inOut.getC_Project_ID() == 0) {
inOut.setC_Project_ID(m_project.getC_Project_ID());
inOut.saveEx();
} else if (inOut.getC_Project_ID() != m_project.getC_Project_ID())
throw new IllegalArgumentException("Receipt for other Project (" + inOut.getC_Project_ID() + ")");
MInOutLine[] inOutLines = inOut.getLines(false);
int counter = 0;
for (int i = 0; i < inOutLines.length; i++) {
// Need to have a Product
if (inOutLines[i].getM_Product_ID() == 0)
continue;
// Need to have Quantity
if (inOutLines[i].getMovementQty() == null || inOutLines[i].getMovementQty().signum() == 0)
continue;
// not issued yet
if (projectIssueHasReceipt(inOutLines[i].getM_InOutLine_ID()))
continue;
// Create Issue
MProjectIssue pi = new MProjectIssue(m_project);
pi.setMandatory(inOutLines[i].getM_Locator_ID(), inOutLines[i].getM_Product_ID(), inOutLines[i].getMovementQty());
if (// default today
m_MovementDate != null)
pi.setMovementDate(m_MovementDate);
if (m_Description != null && m_Description.length() > 0)
pi.setDescription(m_Description);
else if (inOutLines[i].getDescription() != null)
pi.setDescription(inOutLines[i].getDescription());
else if (inOut.getDescription() != null)
pi.setDescription(inOut.getDescription());
pi.setM_InOutLine_ID(inOutLines[i].getM_InOutLine_ID());
pi.process();
// Find/Create Project Line
MProjectLine pl = null;
MProjectLine[] pls = m_project.getLines();
for (int ii = 0; ii < pls.length; ii++) {
// The Order we generated is the same as the Order of the receipt
if (pls[ii].getC_OrderPO_ID() == inOut.getC_Order_ID() && pls[ii].getM_Product_ID() == inOutLines[i].getM_Product_ID() && // not issued
pls[ii].getC_ProjectIssue_ID() == 0) {
pl = pls[ii];
break;
}
}
if (pl == null)
pl = new MProjectLine(m_project);
// setIssue
pl.setMProjectIssue(pi);
pl.saveEx();
addLog(pi.getLine(), pi.getMovementDate(), pi.getMovementQty(), null);
counter++;
}
return "@Created@ " + counter;
}
use of org.compiere.model.MProjectLine 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;
}
Aggregations