use of com.axelor.apps.sale.db.ConfiguratorCreator in project axelor-open-suite by axelor.
the class ConfiguratorCreatorSaleRepository method copy.
@Override
public ConfiguratorCreator copy(ConfiguratorCreator entity, boolean deep) {
ConfiguratorCreator copy = super.copy(entity, deep);
copy.setCopyNeedingUpdate(true);
copy.setName(copy.getName() + " (" + I18n.get(IExceptionMessage.COPY) + ")");
return copy;
}
use of com.axelor.apps.sale.db.ConfiguratorCreator in project axelor-open-suite by axelor.
the class ConfiguratorServiceImpl method computeIndicatorValue.
/**
* Compute the value of one indicator. Using the corresponding formula and the values in {@link
* Configurator#attributes}
*
* @param configurator
* @param indicatorName
* @param jsonAttributes
* @return
*/
protected Object computeIndicatorValue(Configurator configurator, String indicatorName, JsonContext jsonAttributes) {
ConfiguratorCreator creator = configurator.getConfiguratorCreator();
List<? extends ConfiguratorFormula> formulas;
if (creator.getGenerateProduct()) {
formulas = creator.getConfiguratorProductFormulaList();
} else {
formulas = creator.getConfiguratorSOLineFormulaList();
}
String groovyFormula = null;
for (ConfiguratorFormula formula : formulas) {
String fieldName = indicatorName;
fieldName = fieldName.substring(0, fieldName.indexOf('_'));
MetaField metaField = formula.getMetaField();
if (metaField.getName().equals(fieldName)) {
groovyFormula = formula.getFormula();
break;
}
}
if (groovyFormula == null || jsonAttributes == null) {
return null;
}
return computeFormula(groovyFormula, jsonAttributes);
}
use of com.axelor.apps.sale.db.ConfiguratorCreator in project axelor-open-suite by axelor.
the class ConfiguratorCreatorServiceImpl method getConfiguratorCreatorDomain.
public String getConfiguratorCreatorDomain() {
User user = AuthUtils.getUser();
Group group = user.getGroup();
List<ConfiguratorCreator> configuratorCreatorList = configuratorCreatorRepo.all().filter("self.isActive = true").fetch();
if (configuratorCreatorList == null || configuratorCreatorList.isEmpty()) {
return "self.id in (0)";
}
configuratorCreatorList.removeIf(creator -> !creator.getAuthorizedUserSet().contains(user) && !creator.getAuthorizedGroupSet().contains(group));
return "self.id in (" + StringTool.getIdListString(configuratorCreatorList) + ")";
}
Aggregations