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);
}
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);
}
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);
}
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);
}
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;
}
}
Aggregations