use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class ProductsToIssueDetailsHooks method fillQuantitiesInAdditionalUnit.
public void fillQuantitiesInAdditionalUnit(final ViewDefinitionState view) {
AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference("issues");
for (FormComponent form : adl.getFormComponents()) {
Entity issue = form.getPersistedEntityWithIncludedFormValues();
FieldComponent quantityField = form.findFieldComponentByName("issueQuantity");
Either<Exception, Optional<BigDecimal>> maybeQuantity = BigDecimalUtils.tryParse(quantityField.getFieldValue().toString(), LocaleContextHolder.getLocale());
BigDecimal conversion = issue.getDecimalField(IssueFields.CONVERSION);
if (Objects.nonNull(conversion) && maybeQuantity.isRight() && maybeQuantity.getRight().isPresent()) {
Entity product = issue.getBelongsToField(IssueFields.PRODUCT);
String unit = product.getStringField(ProductFields.UNIT);
String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
BigDecimal issueQuantity = maybeQuantity.getRight().get();
BigDecimal issuedQuantityAdditionalUnit = calculationQuantityService.calculateAdditionalQuantity(issueQuantity, conversion, Optional.fromNullable(additionalUnit).or(unit));
issue.setField(IssueFields.ISSUE_QUANTITY_ADDITIONAL_UNIT, issuedQuantityAdditionalUnit);
form.setEntity(issue);
}
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class AnomalyProductionTrackingDetailsListeners method createAnomalies.
private void createAnomalies(final ViewDefinitionState view) {
AwesomeDynamicListComponent anomalyProductionTrackingEntriesADL = (AwesomeDynamicListComponent) view.getComponentByReference("anomalyProductionTrackingEntries");
List<Entity> entities = anomalyProductionTrackingEntriesADL.getEntities();
for (Entity entity : entities) {
createAnomaly(entity);
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class AnomalyProductionTrackingDetailsListeners method validate.
private boolean validate(final ViewDefinitionState view) {
AwesomeDynamicListComponent anomalyProductionTrackingEntriesADL = (AwesomeDynamicListComponent) view.getComponentByReference("anomalyProductionTrackingEntries");
List<Entity> entities = anomalyProductionTrackingEntriesADL.getEntities();
boolean valid = Boolean.TRUE;
for (Entity entry : entities) {
List<Entity> anomalyContainers = entry.getHasManyField("anomalyReasons");
if (anomalyContainers.isEmpty()) {
valid = Boolean.FALSE;
}
for (Entity ac : anomalyContainers) {
if (Objects.isNull(ac.getBelongsToField("anomalyReason"))) {
valid = Boolean.FALSE;
}
}
}
return valid;
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class AnomalyProductionTrackingDetailsListeners method clearQuantitiesInRR.
private void clearQuantitiesInRR(ViewDefinitionState view) {
AwesomeDynamicListComponent anomalyProductionTrackingEntriesADL = (AwesomeDynamicListComponent) view.getComponentByReference("anomalyProductionTrackingEntries");
List<Entity> entities = anomalyProductionTrackingEntriesADL.getEntities();
for (Entity entity : entities) {
Entity trackingOperationProductInComponent = entity.getBelongsToField("trackingOperationProductInComponent");
trackingOperationProductInComponent.setField(TrackingOperationProductInComponentFields.USED_QUANTITY, BigDecimal.ZERO);
trackingOperationProductInComponent.setField(TrackingOperationProductInComponentFields.GIVEN_QUANTITY, BigDecimal.ZERO);
trackingOperationProductInComponent = trackingOperationProductInComponent.getDataDefinition().save(trackingOperationProductInComponent);
if (!trackingOperationProductInComponent.isValid()) {
throw new EntityRuntimeException(trackingOperationProductInComponent);
}
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class AnomalyProductionTrackingDetailsHooks method updateADLState.
private void updateADLState(final ViewDefinitionState view, final List<Entity> entries) {
AwesomeDynamicListComponent anomalyProductionTrackingEntriesADL = (AwesomeDynamicListComponent) view.getComponentByReference("anomalyProductionTrackingEntries");
anomalyProductionTrackingEntriesADL.setFieldValue(entries);
anomalyProductionTrackingEntriesADL.requestComponentUpdateState();
}
Aggregations