use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_MoveTUsToDirectWarehouse method checkPreconditionsApplicable.
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!isHUEditorView()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
}
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (!selectedRowIds.isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final DocumentId rowId = selectedRowIds.getSingleDocumentId();
final HUEditorRow huRow = getView().getById(rowId);
if (huRow.isLU()) {
if (!huRow.hasIncludedTUs()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("no TUs");
}
} else if (huRow.isTU()) {
// OK
} else {
return ProcessPreconditionsResolution.rejectWithInternalReason("not a LU or TU");
}
if (!huRow.isHUStatusActive()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("HUStatus is not Active");
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_Receipt_Base method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!isViewClass(HUEditorView.class)) {
return ProcessPreconditionsResolution.rejectWithInternalReason("The current view is not an HUEditorView");
}
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (selectedRowIds.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
}
final MutableInt checkedDocumentsCount = new MutableInt(0);
final ProcessPreconditionsResolution firstRejection = getView(HUEditorView.class).streamByIds(selectedRowIds).filter(document -> document.isPureHU()).peek(// count checked documents
document -> checkedDocumentsCount.incrementAndGet()).map(// create reject resolution if any
document -> rejectResolutionOrNull(document)).filter(// filter out those which are not errors
resolution -> resolution != null).findFirst().orElse(null);
if (firstRejection != null) {
// found a record which is not eligible => don't run the process
return firstRejection;
}
if (checkedDocumentsCount.getValue() <= 0) {
return ProcessPreconditionsResolution.rejectWithInternalReason("no eligible rows");
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_ReturnTUsToVendor method checkPreconditionsApplicable.
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!isHUEditorView()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
}
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (!selectedRowIds.isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final DocumentId rowId = selectedRowIds.getSingleDocumentId();
final HUEditorRow huRow = getView().getById(rowId);
if (huRow.isLU()) {
if (!huRow.hasIncludedTUs()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("no TUs");
}
} else if (huRow.isTU()) {
// OK
} else {
return ProcessPreconditionsResolution.rejectWithInternalReason("not a LU or TU");
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class C_Invoice_Candidate_ApproveForInvoicing method retrieveInvoiceCandidatesToApproveQuery.
private final IQuery<I_C_Invoice_Candidate> retrieveInvoiceCandidatesToApproveQuery() {
final IQueryBuilder<I_C_Invoice_Candidate> queryBuilder = Services.get(IQueryBL.class).createQueryBuilder(I_C_Invoice_Candidate.class).filter(getProcessInfo().getQueryFilter()).addOnlyActiveRecordsFilter().addNotEqualsFilter(I_C_Invoice_Candidate.COLUMN_Processed, // not processed
true).addNotEqualsFilter(I_C_Invoice_Candidate.COLUMN_ApprovalForInvoicing, // not already approved
true);
// Only selected rows
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (!selectedRowIds.isAll()) {
final Set<Integer> invoiceCandidateIds = selectedRowIds.toIntSet();
if (invoiceCandidateIds.isEmpty()) {
// shall not happen
throw new AdempiereException("@NoSelection@");
}
queryBuilder.addInArrayFilter(I_C_Invoice_Candidate.COLUMN_C_Invoice_Candidate_ID, invoiceCandidateIds);
}
return queryBuilder.create();
}
use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.
the class HUReportProcessInstancesRepository method checkApplies.
private boolean checkApplies(WebuiHUProcessDescriptor descriptor, ViewAsPreconditionsContext viewContext) {
final DocumentIdsSelection rowIds = viewContext.getSelectedRowIds();
if (rowIds.isEmpty()) {
return false;
}
final HUEditorView huView = viewContext.getView(HUEditorView.class);
final boolean foundNotMatchingRows = huView.streamByIds(rowIds).anyMatch(row -> !checkApplies(row, descriptor));
return !foundNotMatchingRows;
}
Aggregations