use of de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputCallout method updateM_HU_PI_Item_Product.
private void updateM_HU_PI_Item_Product(@NonNull final QuickInput quickInput) {
if (!quickInput.hasField(IOrderLineQuickInput.COLUMNNAME_M_HU_PI_Item_Product_ID)) {
// there are users whose systems don't have M_HU_PI_Item_Product_ID in their quick-input
return;
}
final IOrderLineQuickInput quickInputModel = quickInput.getQuickInputDocumentAs(IOrderLineQuickInput.class);
final LookupValue productLookupValue = quickInputModel.getM_Product_ID();
if (productLookupValue == null) {
return;
}
final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(productLookupValue);
final ProductId quickInputProductId = productAndAttributes.getProductId();
final I_C_Order order = quickInput.getRootDocumentAs(I_C_Order.class);
final Optional<DefaultPackingItemCriteria> defaultPackingItemCriteria = DefaultPackingItemCriteria.of(order, quickInputProductId);
final I_M_HU_PI_Item_Product huPIItemProduct = defaultPackingItemCriteria.flatMap(packingItemProductFieldHelper::getDefaultPackingMaterial).orElse(null);
quickInputModel.setM_HU_PI_Item_Product(huPIItemProduct);
}
use of de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria in project metasfresh-webui-api by metasfresh.
the class InvoiceLineQuickInputCallout method onProductChange.
public void onProductChange(@NonNull final ICalloutField calloutField) {
final QuickInput quickInput = QuickInput.getQuickInputOrNull(calloutField);
if (quickInput == null) {
return;
}
if (!quickInput.hasField(IInvoiceLineQuickInput.COLUMNNAME_M_HU_PI_Item_Product_ID)) {
return;
}
final IInvoiceLineQuickInput invoiceLineQuickInput = quickInput.getQuickInputDocumentAs(IInvoiceLineQuickInput.class);
final ProductId productId = ProductId.ofRepoIdOrNull(invoiceLineQuickInput.getM_Product_ID());
if (productId == null) {
return;
}
final I_C_Invoice invoice = quickInput.getRootDocumentAs(I_C_Invoice.class);
final Optional<DefaultPackingItemCriteria> defaultPackingItemCriteria = DefaultPackingItemCriteria.of(invoice, productId);
final I_M_HU_PI_Item_Product huPIItemProduct = defaultPackingItemCriteria.flatMap(packingItemProductFieldHelper::getDefaultPackingMaterial).orElse(null);
invoiceLineQuickInput.setM_HU_PI_Item_Product(huPIItemProduct);
}
Aggregations