Search in sources :

Example 41 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepositoryTest method testRetrieveActiveSourceHusQuery_fromShipmentSchedules.

@Test
public void testRetrieveActiveSourceHusQuery_fromShipmentSchedules() {
    final WarehouseId warehouseId = createWarehouse();
    final ProductId productId = createProduct();
    final ShipmentScheduleId shipmentScheduleId1 = createShipmentSchedule(warehouseId, productId);
    final ShipmentScheduleId shipmentScheduleId2 = createShipmentSchedule(warehouseId, productId);
    final MatchingSourceHusQuery query = PickingHURowsRepository.createMatchingSourceHusQuery(PickingSlotRepoQuery.builder().currentShipmentScheduleId(shipmentScheduleId1).shipmentScheduleId(shipmentScheduleId1).shipmentScheduleId(shipmentScheduleId2).build());
    assertThat(query.getWarehouseId()).isEqualTo(warehouseId);
    assertThat(query.getProductIds()).containsExactly(productId);
}
Also used : MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) ShipmentScheduleId(de.metas.inoutcandidate.api.ShipmentScheduleId) ProductId(de.metas.product.ProductId) WarehouseId(org.adempiere.warehouse.WarehouseId) Test(org.junit.jupiter.api.Test)

Example 42 with ProductId

use of de.metas.product.ProductId 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)

Example 43 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class InvoiceLineQuickInputProcessor method process.

@Override
public Set<DocumentId> process(final QuickInput quickInput) {
    final IInvoiceBL invoiceBL = Services.get(IInvoiceBL.class);
    final IInvoiceLineBL invoiceLineBL = Services.get(IInvoiceLineBL.class);
    final I_C_Invoice invoice = quickInput.getRootDocumentAs(I_C_Invoice.class);
    final IInvoiceLineQuickInput invoiceLineQuickInput = quickInput.getQuickInputDocumentAs(IInvoiceLineQuickInput.class);
    // 3834
    final ProductId productId = ProductId.ofRepoId(invoiceLineQuickInput.getM_Product_ID());
    final BPartnerId partnerId = BPartnerId.ofRepoId(invoice.getC_BPartner_ID());
    Services.get(IBPartnerProductBL.class).assertNotExcludedFromSaleToCustomer(productId, partnerId);
    final I_C_InvoiceLine invoiceLine = InterfaceWrapperHelper.newInstance(I_C_InvoiceLine.class, invoice);
    invoiceLine.setC_Invoice(invoice);
    invoiceBL.setProductAndUOM(invoiceLine, invoiceLineQuickInput.getM_Product_ID());
    final PlainHUPackingAware huPackingAware = new PlainHUPackingAware();
    huPackingAware.setBpartnerId(partnerId);
    huPackingAware.setInDispute(false);
    huPackingAware.setProductId(productId);
    huPackingAware.setUomId(UomId.ofRepoIdOrNull(invoiceLine.getC_UOM_ID()));
    huPackingAware.setPiItemProductId(invoiceLineQuickInput.getM_HU_PI_Item_Product_ID() > 0 ? HUPIItemProductId.ofRepoId(invoiceLineQuickInput.getM_HU_PI_Item_Product_ID()) : HUPIItemProductId.VIRTUAL_HU);
    huPackingAwareBL.computeAndSetQtysForNewHuPackingAware(huPackingAware, invoiceLineQuickInput.getQty());
    huPackingAwareBL.prepareCopyFrom(huPackingAware).overridePartner(false).copyTo(InvoiceLineHUPackingAware.of(invoiceLine));
    invoiceLineBL.updatePrices(invoiceLine);
    // invoiceBL.setLineNetAmt(invoiceLine); // not needed; will be called on save
    // invoiceBL.setTaxAmt(invoiceLine);// not needed; will be called on save
    InterfaceWrapperHelper.save(invoiceLine);
    final DocumentId documentId = DocumentId.of(invoiceLine.getC_InvoiceLine_ID());
    return ImmutableSet.of(documentId);
}
Also used : I_C_Invoice(org.compiere.model.I_C_Invoice) PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) I_C_InvoiceLine(de.metas.adempiere.model.I_C_InvoiceLine) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) ProductId(de.metas.product.ProductId) IInvoiceBL(org.adempiere.invoice.service.IInvoiceBL) IInvoiceLineBL(de.metas.invoice.IInvoiceLineBL) BPartnerId(de.metas.bpartner.BPartnerId) IBPartnerProductBL(de.metas.bpartner_product.IBPartnerProductBL)

Example 44 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ForecastLineQuickInputDescriptorFactory method onProductChangedCallout.

private static void onProductChangedCallout(final ICalloutField calloutField) {
    final QuickInput quickInput = QuickInput.getQuickInputOrNull(calloutField);
    if (quickInput == null) {
        return;
    }
    final IForecastLineQuickInput quickInputModel = quickInput.getQuickInputDocumentAs(IForecastLineQuickInput.class);
    final LookupValue productLookupValue = quickInputModel.getM_Product_ID();
    if (productLookupValue == null) {
        return;
    }
    final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(productLookupValue);
    final ProductId quickInputProduct = productAndAttributes.getProductId();
    final I_M_Forecast forecast = quickInput.getRootDocumentAs(I_M_Forecast.class);
    Services.get(IHUOrderBL.class).findM_HU_PI_Item_ProductForForecast(forecast, quickInputProduct, quickInputModel::setM_HU_PI_Item_Product);
}
Also used : ProductId(de.metas.product.ProductId) QuickInput(de.metas.ui.web.quickinput.QuickInput) IHUOrderBL(de.metas.handlingunits.order.api.IHUOrderBL) I_M_Forecast(org.compiere.model.I_M_Forecast) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 45 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class M_DiscountSchemaBreak_CopyToOtherSchema_Product method getParameterDefaultValue.

@Override
public Object getParameterDefaultValue(final IProcessDefaultParameter parameter) {
    final String parameterName = parameter.getColumnName();
    if (PARAM_M_Product_ID.equals(parameterName)) {
        final IQueryFilter<I_M_DiscountSchemaBreak> selectionQueryFilter = getProcessInfo().getQueryFilterOrElse(ConstantQueryFilter.of(false));
        final ProductId uniqueProductIdForSelection = pricingConditionsRepo.retrieveUniqueProductIdForSelectionOrNull(selectionQueryFilter);
        if (uniqueProductIdForSelection == null) {
            // should not happen because of the preconditions above
            return IProcessDefaultParametersProvider.DEFAULT_VALUE_NOTAVAILABLE;
        }
        return uniqueProductIdForSelection.getRepoId();
    } else {
        return IProcessDefaultParametersProvider.DEFAULT_VALUE_NOTAVAILABLE;
    }
}
Also used : I_M_DiscountSchemaBreak(org.compiere.model.I_M_DiscountSchemaBreak) ProductId(de.metas.product.ProductId) ITranslatableString(de.metas.i18n.ITranslatableString)

Aggregations

ProductId (de.metas.product.ProductId)56 HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)8 BPartnerId (de.metas.bpartner.BPartnerId)7 HuId (de.metas.handlingunits.HuId)7 Quantity (de.metas.quantity.Quantity)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 I_M_HU (de.metas.handlingunits.model.I_M_HU)6 IHUProductStorage (de.metas.handlingunits.storage.IHUProductStorage)5 IHUStorage (de.metas.handlingunits.storage.IHUStorage)5 ITranslatableString (de.metas.i18n.ITranslatableString)5 BigDecimal (java.math.BigDecimal)5 I_C_UOM (org.compiere.model.I_C_UOM)5 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)4 ArrayList (java.util.ArrayList)4 ImmutableAttributeSet (org.adempiere.mm.attributes.api.ImmutableAttributeSet)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ImmutableList (com.google.common.collect.ImmutableList)3 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)3 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)3 IProductBL (de.metas.product.IProductBL)3