Search in sources :

Example 1 with MProject

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

the class CopyFromProject method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (clear text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    int To_C_Project_ID = getRecord_ID();
    log.info("doIt - From C_Project_ID=" + m_C_Project_ID + " to " + To_C_Project_ID);
    if (To_C_Project_ID == 0)
        throw new IllegalArgumentException("Target C_Project_ID == 0");
    if (m_C_Project_ID == 0)
        throw new IllegalArgumentException("Source C_Project_ID == 0");
    MProject from = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
    MProject to = new MProject(getCtx(), To_C_Project_ID, get_TrxName());
    //
    int no = to.copyDetailsFrom(from);
    return "@Copied@=" + no;
}
Also used : MProject(org.compiere.model.MProject)

Example 2 with MProject

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

the class VBOMDrop 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;
}
Also used : ALayoutConstraint(org.compiere.apps.ALayoutConstraint) BigDecimal(java.math.BigDecimal) MProject(org.compiere.model.MProject) MProjectLine(org.compiere.model.MProjectLine)

Example 3 with MProject

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

the class ProjectClose method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (translated text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    MProject project = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
    log.info("doIt - " + project);
    MProjectLine[] projectLines = project.getLines();
    if (MProject.PROJECTCATEGORY_WorkOrderJob.equals(project.getProjectCategory()) || MProject.PROJECTCATEGORY_AssetProject.equals(project.getProjectCategory())) {
    /** @todo Check if we should close it */
    }
    //	Close lines
    for (int line = 0; line < projectLines.length; line++) {
        projectLines[line].setProcessed(true);
        projectLines[line].saveEx();
    }
    project.setProcessed(true);
    project.saveEx();
    return "";
}
Also used : MProject(org.compiere.model.MProject) MProjectLine(org.compiere.model.MProjectLine)

Example 4 with MProject

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

the class ProjectGenPO method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message 
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    log.info("doIt - C_Project_ID=" + m_C_Project_ID + " - C_ProjectLine_ID=" + m_C_ProjectLine_ID + " - Consolidate=" + m_ConsolidateDocument);
    if (m_C_ProjectLine_ID != 0) {
        MProjectLine projectLine = new MProjectLine(getCtx(), m_C_ProjectLine_ID, get_TrxName());
        MProject project = new MProject(getCtx(), projectLine.getC_Project_ID(), get_TrxName());
        createPO(project, projectLine);
    } else {
        MProject project = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
        MProjectLine[] lines = project.getLines();
        for (int i = 0; i < lines.length; i++) createPO(project, lines[i]);
    }
    return "";
}
Also used : MProjectLine(org.compiere.model.MProjectLine) MProject(org.compiere.model.MProject)

Example 5 with MProject

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

the class ProjectPhaseGenOrder method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (clear text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    m_C_ProjectPhase_ID = getRecord_ID();
    log.info("doIt - C_ProjectPhase_ID=" + m_C_ProjectPhase_ID);
    if (m_C_ProjectPhase_ID == 0)
        throw new IllegalArgumentException("C_ProjectPhase_ID == 0");
    MProjectPhase fromPhase = new MProjectPhase(getCtx(), m_C_ProjectPhase_ID, get_TrxName());
    MProject fromProject = ProjectGenOrder.getProject(getCtx(), fromPhase.getC_Project_ID(), get_TrxName());
    MOrder order = new MOrder(fromProject, true, MOrder.DocSubTypeSO_OnCredit);
    order.setDescription(order.getDescription() + " - " + fromPhase.getName());
    if (!order.save())
        throw new Exception("Could not create Order");
    //	Create an order on Phase Level
    if (fromPhase.getM_Product_ID() != 0) {
        MOrderLine ol = new MOrderLine(order);
        ol.setLine(fromPhase.getSeqNo());
        StringBuffer sb = new StringBuffer(fromPhase.getName());
        if (fromPhase.getDescription() != null && fromPhase.getDescription().length() > 0)
            sb.append(" - ").append(fromPhase.getDescription());
        ol.setDescription(sb.toString());
        //
        ol.setM_Product_ID(fromPhase.getM_Product_ID(), true);
        ol.setQty(fromPhase.getQty());
        ol.setPrice();
        if (fromPhase.getPriceActual() != null && fromPhase.getPriceActual().compareTo(Env.ZERO) != 0)
            ol.setPrice(fromPhase.getPriceActual());
        ol.setTax();
        if (!ol.save())
            log.log(Level.SEVERE, "doIt - Lines not generated");
        return "@C_Order_ID@ " + order.getDocumentNo() + " (1)";
    }
    //	Project Phase Lines
    int count = 0;
    MProjectLine[] lines = fromPhase.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);
    //	Project Tasks
    MProjectTask[] tasks = fromPhase.getTasks();
    for (int i = 0; i < tasks.length; i++) {
        MOrderLine ol = new MOrderLine(order);
        ol.setLine(tasks[i].getSeqNo());
        StringBuffer sb = new StringBuffer(tasks[i].getName());
        if (tasks[i].getDescription() != null && tasks[i].getDescription().length() > 0)
            sb.append(" - ").append(tasks[i].getDescription());
        ol.setDescription(sb.toString());
        //
        ol.setM_Product_ID(tasks[i].getM_Product_ID(), true);
        ol.setQty(tasks[i].getQty());
        ol.setPrice();
        ol.setTax();
        if (ol.save())
            count++;
    }
    //	for all lines
    if (tasks.length != count - lines.length)
        log.log(Level.SEVERE, "doIt - Lines difference - ProjectTasks=" + tasks.length + " <> Saved=" + count);
    return "@C_Order_ID@ " + order.getDocumentNo() + " (" + count + ")";
}
Also used : MOrder(org.compiere.model.MOrder) MProjectTask(org.compiere.model.MProjectTask) MProjectPhase(org.compiere.model.MProjectPhase) MOrderLine(org.compiere.model.MOrderLine) MProject(org.compiere.model.MProject) MProjectLine(org.compiere.model.MProjectLine)

Aggregations

MProject (org.compiere.model.MProject)18 MProjectLine (org.compiere.model.MProjectLine)8 BigDecimal (java.math.BigDecimal)6 MOrder (org.compiere.model.MOrder)3 MOrderLine (org.compiere.model.MOrderLine)3 MProduct (org.compiere.model.MProduct)3 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MActivity (org.compiere.model.MActivity)2 MCampaign (org.compiere.model.MCampaign)2 MOrg (org.compiere.model.MOrg)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MAssetAddition (org.compiere.model.MAssetAddition)1 MBPartner (org.compiere.model.MBPartner)1 MCostDetail (org.compiere.model.MCostDetail)1 MProductCategory (org.compiere.model.MProductCategory)1 MProductPricing (org.compiere.model.MProductPricing)1 MProjectPhase (org.compiere.model.MProjectPhase)1 MProjectTask (org.compiere.model.MProjectTask)1 MProjectType (org.compiere.model.MProjectType)1