use of de.metas.purchasecandidate.PurchaseCandidate in project metasfresh-webui-api by metasfresh.
the class PurchaseRowsLoader method handleResultForAsyncAvailabilityCheck.
private void handleResultForAsyncAvailabilityCheck(@Nullable final Multimap<PurchaseCandidate, AvailabilityResult> availabilityCheckResult) {
if (availabilityCheckResult == null) {
return;
}
final //
Set<Entry<PurchaseCandidate, Collection<AvailabilityResult>>> entrySet = availabilityCheckResult.asMap().entrySet();
final List<DocumentId> changedRowIds = new ArrayList<>();
for (final Entry<PurchaseCandidate, Collection<AvailabilityResult>> entry : entrySet) {
final PurchaseRow purchaseRowToAugment = purchaseCandidate2purchaseRow.get(entry.getKey());
final ImmutableList.Builder<PurchaseRow> availabilityResultRows = ImmutableList.builder();
for (final AvailabilityResult availabilityResult : entry.getValue()) {
final PurchaseRow availabilityResultRow = purchaseRowFactory.rowFromAvailabilityResultBuilder().parentRow(purchaseRowToAugment).availabilityResult(availabilityResult).build();
availabilityResultRows.add(availabilityResultRow);
}
purchaseRowToAugment.setAvailabilityInfoRows(availabilityResultRows.build());
changedRowIds.add(purchaseRowToAugment.getId());
}
notifyViewOfChanges(changedRowIds);
}
use of de.metas.purchasecandidate.PurchaseCandidate in project metasfresh-webui-api by metasfresh.
the class PurchaseRowsLoader method load.
public List<PurchaseRow> load() {
final ImmutableList.Builder<PurchaseRow> result = ImmutableList.builder();
final ImmutableMap.Builder<PurchaseCandidate, PurchaseRow> purchaseCandidate2purchaseRowBuilder = ImmutableMap.builder();
for (final SalesOrderLineWithCandidates salesOrderLineWithCandidates : salesOrderLines.getSalesOrderLinesWithCandidates()) {
final I_C_OrderLine salesOrderLine = salesOrderLineWithCandidates.getSalesOrderLine();
final ImmutableList.Builder<PurchaseRow> rows = ImmutableList.builder();
for (final PurchaseCandidate purchaseCandidate : salesOrderLineWithCandidates.getPurchaseCandidates()) {
final PurchaseRow candidateRow = purchaseRowFactory.rowFromPurchaseCandidateBuilder().purchaseCandidate(purchaseCandidate).vendorProductInfo(purchaseCandidate.getVendorProductInfo()).datePromised(salesOrderLine.getDatePromised()).build();
purchaseCandidate2purchaseRowBuilder.put(purchaseCandidate, candidateRow);
rows.add(candidateRow);
}
final //
PurchaseRow groupRow = purchaseRowFactory.createGroupRow(salesOrderLine, rows.build());
result.add(groupRow);
}
purchaseCandidate2purchaseRow = purchaseCandidate2purchaseRowBuilder.build();
return result.build();
}
use of de.metas.purchasecandidate.PurchaseCandidate in project metasfresh-webui-api by metasfresh.
the class PurchaseRowsSaver method updatePurchaseCandidate.
private PurchaseCandidate updatePurchaseCandidate(@NonNull final PurchaseRow purchaseRow, @NonNull final Map<Integer, PurchaseCandidate> existingPurchaseCandidatesById) {
Check.errorUnless(PurchaseRowType.LINE.equals(purchaseRow.getType()), "The given row's type needs to be {}, but is {}; purchaseRow={}", PurchaseRowType.LINE, purchaseRow.getType(), purchaseRow);
final PurchaseCandidate purchaseCandidate = existingPurchaseCandidatesById.get(purchaseRow.getPurchaseCandidateId());
Check.errorIf(purchaseCandidate == null, "Missing purchaseCandidate with C_PurchaseCandidate_ID={}; purchaseRow={}, existingPurchaseCandidatesById={}", purchaseRow.getPurchaseCandidateId(), purchaseRow, existingPurchaseCandidatesById);
purchaseCandidate.setQtyToPurchase(purchaseRow.getQtyToPurchase());
purchaseCandidate.setDateRequired(purchaseRow.getDatePromised());
Check.errorIf(purchaseCandidate.isProcessedOrLocked() && purchaseCandidate.hasChanges(), "The given purchaseRow has changes, but its purchaseCandidate is not editable; purchaseRow={}; purchaseCandidate={}", purchaseRow, purchaseCandidate);
return purchaseCandidate;
}
use of de.metas.purchasecandidate.PurchaseCandidate in project metasfresh-webui-api by metasfresh.
the class SalesOrder2PurchaseViewFactory method getSingleSalesOrder.
private final I_C_Order getSingleSalesOrder(@NonNull final List<PurchaseCandidate> purchaseCandidates) {
Check.assumeNotEmpty(purchaseCandidates, "purchaseCandidates not empty");
final int salesOrderId = purchaseCandidates.stream().map(PurchaseCandidate::getSalesOrderId).distinct().collect(GuavaCollectors.singleElementOrThrow(() -> new AdempiereException("More or less than one salesOrderId found in the given purchaseCandidates").appendParametersToMessage().setParameter("purchaseCandidates", purchaseCandidates)));
final I_C_Order salesOrder = load(salesOrderId, I_C_Order.class);
return salesOrder;
}
Aggregations