Search in sources :

Example 1 with MProjectLine

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

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

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

the class ProjectIssue method issueProjectLine.

//	issueExpense
/**
	 *	Issue Project Line
	 *	@return Message (clear text)
	 */
private String issueProjectLine() {
    MProjectLine pl = new MProjectLine(getCtx(), m_C_ProjectLine_ID, get_TrxName());
    if (pl.getM_Product_ID() == 0)
        throw new IllegalArgumentException("Projet Line has no Product");
    if (pl.getC_ProjectIssue_ID() != 0)
        throw new IllegalArgumentException("Projet Line already been issued");
    if (m_M_Locator_ID == 0)
        throw new IllegalArgumentException("No Locator");
    //	Set to Qty 1
    if (pl.getPlannedQty() == null || pl.getPlannedQty().signum() == 0)
        pl.setPlannedQty(Env.ONE);
    //
    MProjectIssue pi = new MProjectIssue(m_project);
    pi.setMandatory(m_M_Locator_ID, pl.getM_Product_ID(), pl.getPlannedQty());
    if (//	default today
    m_MovementDate != null)
        pi.setMovementDate(m_MovementDate);
    if (m_Description != null && m_Description.length() > 0)
        pi.setDescription(m_Description);
    else if (pl.getDescription() != null)
        pi.setDescription(pl.getDescription());
    pi.process();
    //	Update Line
    pl.setMProjectIssue(pi);
    pl.saveEx();
    addLog(pi.getLine(), pi.getMovementDate(), pi.getMovementQty(), null);
    return "@Created@ 1";
}
Also used : MProjectIssue(org.compiere.model.MProjectIssue) MProjectLine(org.compiere.model.MProjectLine)

Example 4 with MProjectLine

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

Example 5 with MProjectLine

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

Aggregations

MProjectLine (org.compiere.model.MProjectLine)12 MProject (org.compiere.model.MProject)8 MProjectIssue (org.compiere.model.MProjectIssue)4 BigDecimal (java.math.BigDecimal)3 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MOrder (org.compiere.model.MOrder)2 MOrderLine (org.compiere.model.MOrderLine)2 MInOut (org.compiere.model.MInOut)1 MInOutLine (org.compiere.model.MInOutLine)1 MProductPricing (org.compiere.model.MProductPricing)1 MProjectPhase (org.compiere.model.MProjectPhase)1 MProjectTask (org.compiere.model.MProjectTask)1 MTimeExpense (org.compiere.model.MTimeExpense)1 MTimeExpenseLine (org.compiere.model.MTimeExpenseLine)1