Search in sources :

Example 1 with DefaultPackingItemCriteria

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);
}
Also used : DefaultPackingItemCriteria(de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria) I_C_Order(de.metas.adempiere.model.I_C_Order) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductId(de.metas.product.ProductId) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 2 with DefaultPackingItemCriteria

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);
}
Also used : DefaultPackingItemCriteria(de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria) I_C_Invoice(de.metas.adempiere.model.I_C_Invoice) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductId(de.metas.product.ProductId) QuickInput(de.metas.ui.web.quickinput.QuickInput)

Aggregations

I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)2 ProductId (de.metas.product.ProductId)2 DefaultPackingItemCriteria (de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria)2 I_C_Invoice (de.metas.adempiere.model.I_C_Invoice)1 I_C_Order (de.metas.adempiere.model.I_C_Order)1 QuickInput (de.metas.ui.web.quickinput.QuickInput)1 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)1 ProductAndAttributes (de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)1