Search in sources :

Example 1 with I_M_Product

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

the class ModelValidator method beforeSave.

//beforeDelete
private boolean beforeSave(MInvoiceLine invoiceLine, boolean newRecord) {
    //Goodwill - Check for asset invoice 
    if (invoiceLine.isA_CreateAsset()) {
        I_M_Product product = invoiceLine.getM_Product();
        if (X_C_InvoiceLine.A_CAPVSEXP_Capital.equals(invoiceLine.getA_CapvsExp()) && product.getM_Product_Category().getA_Asset_Group_ID() == 0)
            throw new AdempiereException("@A_Asset_Group_ID@ @NotFound@ @To@ @M_Product_ID@ : " + product.getName());
        // Check for asset group and product differences
        if (X_C_InvoiceLine.A_CAPVSEXP_Capital.equals(invoiceLine.getA_CapvsExp()) && invoiceLine.getA_Asset_ID() > 0) {
            if (invoiceLine.getA_Asset_Group_ID() != invoiceLine.getA_Asset().getA_Asset_Group_ID()) {
                throw new AdempiereException(Msg.translate(invoiceLine.getCtx(), "Asset Group on Invoice Line is different from Asset Group on Asset"));
            }
            if (invoiceLine.getM_Product_ID() != invoiceLine.getA_Asset().getM_Product_ID()) {
                throw new AdempiereException(Msg.translate(invoiceLine.getCtx(), "Product on Invoice Line is different from Asset Product"));
            }
        }
        //Expense Asset_ID check
        if (X_C_InvoiceLine.A_CAPVSEXP_Expense.equals(invoiceLine.getA_CapvsExp()) && invoiceLine.getA_Asset_ID() <= 0) {
            throw new AdempiereException("@A_Asset_ID@ @NotFound@");
        }
        if (X_C_InvoiceLine.A_CAPVSEXP_Expense.equals(invoiceLine.getA_CapvsExp()) && invoiceLine.getA_Asset_ID() > 0) {
            invoiceLine.setA_Asset_ID(invoiceLine.getA_Asset().getA_Asset_ID());
            invoiceLine.setA_Asset_Group_ID(invoiceLine.getA_Asset().getA_Asset_Group_ID());
            invoiceLine.setA_CapvsExp(X_C_InvoiceLine.A_CAPVSEXP_Expense);
        }
    }
    return true;
}
Also used : I_M_Product(org.compiere.model.I_M_Product) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 2 with I_M_Product

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

the class MRPUtil method getPlanning.

/**
	 * Helper Method : Create Product Planning
	 */
public static I_PP_Product_Planning getPlanning(String productValue, String Order_Policy, int Order_Min, int Order_Max, int Order_Pack, int SafetyStock, int Order_Period, int LeadTime) {
    boolean isPurchased = true;
    int PlanningHorizon = 365;
    //
    Properties ctx = Env.getCtx();
    //		int AD_Client_ID = Env.getAD_Client_ID(ctx);
    int AD_Org_ID = MRPUtil.getFirst_Org_ID();
    I_M_Warehouse wh = MRPUtil.getCreateWarehouse(AD_Org_ID, productValue);
    I_S_Resource plant = MRPUtil.getCreatePlant(productValue, wh.getM_Warehouse_ID(), PlanningHorizon);
    I_M_Product product = MRPUtil.getCreateProduct(ctx, productValue, isPurchased);
    //
    MPPProductPlanning pp = new MPPProductPlanning(ctx, 0, null);
    pp.setIsCreatePlan(true);
    pp.setIsRequiredMRP(true);
    pp.setIsRequiredDRP(false);
    pp.setM_Product_ID(product.getM_Product_ID());
    pp.setAD_Org_ID(AD_Org_ID);
    pp.setM_Warehouse_ID(wh.getM_Warehouse_ID());
    pp.setS_Resource_ID(plant.getS_Resource_ID());
    //
    pp.setOrder_Policy(Order_Policy);
    pp.setOrder_Min(BigDecimal.valueOf(Order_Min));
    pp.setOrder_Max(BigDecimal.valueOf(Order_Max));
    pp.setOrder_Pack(BigDecimal.valueOf(Order_Pack));
    pp.setSafetyStock(BigDecimal.valueOf(SafetyStock));
    pp.setOrder_Period(BigDecimal.valueOf(Order_Period));
    pp.setDeliveryTime_Promised(BigDecimal.valueOf(LeadTime));
    //
    return pp;
}
Also used : I_S_Resource(org.compiere.model.I_S_Resource) I_M_Product(org.compiere.model.I_M_Product) MPPProductPlanning(org.eevolution.model.MPPProductPlanning) Properties(java.util.Properties) I_M_Warehouse(org.compiere.model.I_M_Warehouse)

Aggregations

I_M_Product (org.compiere.model.I_M_Product)2 Properties (java.util.Properties)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 I_M_Warehouse (org.compiere.model.I_M_Warehouse)1 I_S_Resource (org.compiere.model.I_S_Resource)1 MPPProductPlanning (org.eevolution.model.MPPProductPlanning)1