use of de.metas.purchasecandidate.PurchaseCandidatesGroup.PurchaseCandidatesGroupBuilder in project metasfresh-webui-api by metasfresh.
the class PurchaseRow method changeRow.
private void changeRow(@NonNull final PurchaseRowChangeRequest request) {
assertRowType(PurchaseRowType.LINE);
assertRowEditable();
//
final PurchaseCandidatesGroup candidatesGroup = getPurchaseCandidatesGroup();
final PurchaseCandidatesGroupBuilder newCandidatesGroup = candidatesGroup.toBuilder();
boolean hasChanges = false;
//
// QtyToPurchase
final Quantity qtyToPurchase = request.getQtyToPurchase(this::getCurrentUOM);
boolean qtyToPurchaseChanged = false;
if (qtyToPurchase != null && !Objects.equals(candidatesGroup.getQtyToPurchase(), qtyToPurchase)) {
newCandidatesGroup.qtyToPurchase(qtyToPurchase);
qtyToPurchaseChanged = true;
hasChanges = true;
}
//
// PurchaseDatePromised
final ZonedDateTime purchaseDatePromised = request.getPurchaseDatePromised();
if (purchaseDatePromised != null) {
newCandidatesGroup.purchaseDatePromised(purchaseDatePromised);
hasChanges = true;
}
// Recompute Profit Info
if (qtyToPurchaseChanged) {
final PurchaseProfitInfo profitInfo = purchaseProfitInfoService.calculateNoFail(PurchaseProfitInfoRequest.builder().salesOrderAndLineIds(candidatesGroup.getSalesOrderAndLineIds()).qtyToPurchase(qtyToPurchase).vendorProductInfo(candidatesGroup.getVendorProductInfo()).build());
newCandidatesGroup.profitInfoOrNull(profitInfo);
hasChanges = true;
}
// Stop here if there were no changes
if (!hasChanges) {
return;
}
//
setPurchaseCandidatesGroup(newCandidatesGroup.build());
}
Aggregations