use of org.eevolution.model.X_I_Forecast in project adempiere by adempiere.
the class ImportForecast method doIt.
// prepare
/**
* Perform process.
*
* @return Message
* @throws Exception
*/
protected String doIt() throws java.lang.Exception {
if (m_DeleteOldImported) {
int no = 0;
for (X_I_Forecast forecast : getRecords(true, false)) {
forecast.deleteEx(true);
no++;
}
log.fine("Delete Old Impored =" + no);
}
fillIDValues();
importRecords();
return "Imported: " + imported + ", Not imported: " + notimported;
}
use of org.eevolution.model.X_I_Forecast in project adempiere by adempiere.
the class ImportForecast method importRecords.
// doIt
/**
* import records using Import Forecast table
*/
private void importRecords() {
for (X_I_Forecast ifl : getRecords(false, m_IsImportOnlyNoErrors)) {
isImported = false;
MForecastLine fl = importForecast(ifl);
if (fl != null)
isImported = true;
if (isImported) {
ifl.setM_ForecastLine_ID(fl.getM_ForecastLine_ID());
ifl.setI_IsImported(true);
ifl.setProcessed(true);
ifl.setI_ErrorMsg("");
ifl.saveEx();
imported++;
} else {
ifl.setI_IsImported(false);
ifl.setProcessed(true);
ifl.saveEx();
notimported++;
}
}
}
use of org.eevolution.model.X_I_Forecast in project adempiere by adempiere.
the class ImportForecast method fillIDValues.
/**
* fill IDs values based on Search Key
*
* @throws SQLException
*/
private void fillIDValues() throws SQLException {
for (X_I_Forecast ifl : getRecords(false, m_IsImportOnlyNoErrors)) {
// Forecast ID
int M_Forecast_ID = 0;
if (ifl.getM_Forecast_ID() > 0)
M_Forecast_ID = getID(MForecast.Table_Name, "M_Forecast_ID = ?", ifl.getM_Forecast_ID());
// Organization
int AD_Org_ID = 0;
if (ifl.getAD_Org_ID() > 0)
AD_Org_ID = getID(MOrg.Table_Name, "AD_Org_ID = ?", ifl.getAD_Org_ID());
if (AD_Org_ID <= 0 && ifl.getOrgValue() != null) {
AD_Org_ID = getID(MOrg.Table_Name, "Value = ?", ifl.getOrgValue());
ifl.setAD_Org_ID(AD_Org_ID);
} else
ifl.setAD_Org_ID(AD_Org_ID);
// Sales Rep ID
int SalesRep_ID = 0;
if (ifl.getSalesRep_ID() > 0)
SalesRep_ID = getID(MUser.Table_Name, "AD_User_ID = ?", ifl.getSalesRep_ID());
if (SalesRep_ID <= 0 && ifl.getSalesRep_Name() != null) {
SalesRep_ID = getID(MUser.Table_Name, "Name = ?", ifl.getSalesRep_Name());
ifl.setSalesRep_ID(SalesRep_ID);
} else
ifl.setSalesRep_ID(SalesRep_ID);
// Product
int M_Product_ID = 0;
if (ifl.getM_Product_ID() > 0)
M_Product_ID = getID(MProduct.Table_Name, "M_Product_ID = ?", ifl.getM_Product_ID());
if (M_Product_ID <= 0 && ifl.getProductValue() != null) {
M_Product_ID = getID(MProduct.Table_Name, "Value = ?", ifl.getProductValue());
ifl.setM_Product_ID(M_Product_ID);
} else
ifl.setM_Product_ID(M_Product_ID);
// Warehouse
int M_Warehouse_ID = 0;
if (ifl.getM_Warehouse_ID() > 0)
M_Warehouse_ID = getID(MWarehouse.Table_Name, "M_Warehouse_ID = ?", ifl.getM_Warehouse_ID());
if (M_Warehouse_ID <= 0 && ifl.getWarehouseValue() != null) {
M_Warehouse_ID = getID(MWarehouse.Table_Name, "Value = ?", ifl.getWarehouseValue());
ifl.setM_Warehouse_ID(M_Warehouse_ID);
} else
ifl.setM_Warehouse_ID(M_Warehouse_ID);
ifl.saveEx();
StringBuffer err = new StringBuffer("");
if (ifl.getM_Forecast_ID() <= 0)
err.append(" @M_Forecast_ID@ @NotFound@,");
if (ifl.getAD_Org_ID() <= 0)
err.append(" @AD_Org_ID@ @NotFound@,");
if (ifl.getM_Product_ID() <= 0)
err.append(" @M_Product_ID@ @NotFound@,");
if (ifl.getM_Warehouse_ID() <= 0)
err.append(" @M_Warehouse_ID@ @NotFound@,");
if (ifl.getDatePromised() == null)
err.append(" @DatePromised@ @NotFound@,");
if (err.toString() != null && err.toString().length() > 0) {
notimported++;
ifl.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString()));
ifl.saveEx();
}
ifl.saveEx();
commitEx();
}
}
Aggregations