Search in sources :

Example 1 with I_C_Order

use of org.compiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.

the class SalesOrder2PurchaseViewFactory method saveRowsAndEnqueueIfOrderCompleted.

private void saveRowsAndEnqueueIfOrderCompleted(final PurchaseView purchaseView) {
    final List<PurchaseCandidate> purchaseCandidates = saveRows(purchaseView);
    if (purchaseCandidates.isEmpty()) {
        return;
    }
    // 
    // If the sales order was already completed, enqueue the purchase candidates
    final I_C_Order salesOrder = getSingleSalesOrder(purchaseCandidates);
    if (IDocument.STATUS_Completed.equals(salesOrder.getDocStatus())) {
        final Set<Integer> purchaseCandidateIds = purchaseCandidates.stream().filter(purchaseCandidate -> !purchaseCandidate.isProcessedOrLocked()).filter(purchaseCandidate -> purchaseCandidate.getQtyToPurchase().signum() > 0).map(PurchaseCandidate::getPurchaseCandidateId).collect(ImmutableSet.toImmutableSet());
        if (purchaseCandidateIds.size() > 0) {
            C_PurchaseCandidates_GeneratePurchaseOrders.enqueue(purchaseCandidateIds);
        }
    }
}
Also used : ArrayKey(org.compiere.util.Util.ArrayKey) IDocument(de.metas.document.engine.IDocument) CCache(org.compiere.util.CCache) GuavaCollectors(org.adempiere.util.GuavaCollectors) ViewFactory(de.metas.ui.web.view.ViewFactory) Env(org.compiere.util.Env) WEBUI_SalesOrder_Apply_Availability_Row(de.metas.ui.web.order.sales.purchasePlanning.process.WEBUI_SalesOrder_Apply_Availability_Row) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) IViewsIndexStorage(de.metas.ui.web.view.IViewsIndexStorage) I_C_Order(org.compiere.model.I_C_Order) PurchaseCandidateRepository(de.metas.purchasecandidate.PurchaseCandidateRepository) IView(de.metas.ui.web.view.IView) ISysConfigBL(org.adempiere.service.ISysConfigBL) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) IViewFactory(de.metas.ui.web.view.IViewFactory) Nullable(javax.annotation.Nullable) IADProcessDAO(de.metas.process.IADProcessDAO) RemovalNotification(com.google.common.cache.RemovalNotification) SalesOrderLines(de.metas.purchasecandidate.SalesOrderLines) Properties(java.util.Properties) ImmutableSet(com.google.common.collect.ImmutableSet) C_PurchaseCandidates_GeneratePurchaseOrders(de.metas.purchasecandidate.async.C_PurchaseCandidates_GeneratePurchaseOrders) ViewCloseReason(de.metas.ui.web.view.ViewCloseReason) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) PurchaseCandidate(de.metas.purchasecandidate.PurchaseCandidate) ViewProfileId(de.metas.ui.web.view.ViewProfileId) Set(java.util.Set) WindowId(de.metas.ui.web.window.datatypes.WindowId) WEBUI_SalesOrder_PurchaseView_Launcher(de.metas.ui.web.order.sales.purchasePlanning.process.WEBUI_SalesOrder_PurchaseView_Launcher) TimeUnit(java.util.concurrent.TimeUnit) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) AdempiereException(org.adempiere.exceptions.AdempiereException) Check(org.adempiere.util.Check) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) Preconditions(com.google.common.base.Preconditions) CacheBuilder(com.google.common.cache.CacheBuilder) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) Cache(com.google.common.cache.Cache) ViewId(de.metas.ui.web.view.ViewId) I_C_Order(org.compiere.model.I_C_Order) PurchaseCandidate(de.metas.purchasecandidate.PurchaseCandidate)

Example 2 with I_C_Order

use of org.compiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.

the class SalesOrder2PurchaseViewFactory method getSingleSalesOrder.

private final I_C_Order getSingleSalesOrder(@NonNull final List<PurchaseCandidate> purchaseCandidates) {
    Check.assumeNotEmpty(purchaseCandidates, "purchaseCandidates not empty");
    final int salesOrderId = purchaseCandidates.stream().map(PurchaseCandidate::getSalesOrderId).distinct().collect(GuavaCollectors.singleElementOrThrow(() -> new AdempiereException("More or less than one salesOrderId found in the given purchaseCandidates").appendParametersToMessage().setParameter("purchaseCandidates", purchaseCandidates)));
    final I_C_Order salesOrder = load(salesOrderId, I_C_Order.class);
    return salesOrder;
}
Also used : I_C_Order(org.compiere.model.I_C_Order) AdempiereException(org.adempiere.exceptions.AdempiereException) PurchaseCandidate(de.metas.purchasecandidate.PurchaseCandidate)

Example 3 with I_C_Order

use of org.compiere.model.I_C_Order in project lar_361 by comitsrl.

the class FiscalDocumentPrint method loadShipmentOrderNumbers.

/**
 * Retrieve shipment and sales order numbers, if they exists.
 *
 * @param mInvoice ADempiere invoice document
 * @param document fiscal printer document
 */
private void loadShipmentOrderNumbers(final MInvoice mInvoice, final Invoice document) {
    final I_C_Order order = mInvoice.getC_Order();
    if (order.getC_Order_ID() > 0)
        document.addObservation(Msg.translate(ctx, "C_Order_ID") + ": " + order.getDocumentNo());
    final MInvoiceLine[] iLines = mInvoice.getLines();
    for (final MInvoiceLine line : iLines) {
        final I_M_InOutLine ioline = line.getM_InOutLine();
        if (ioline.getM_InOutLine_ID() > 0) {
            String obs = ioline.getM_InOut().getDocumentNo();
            if (!document.getObservations().contains(obs))
                document.addObservation(obs);
        }
    }
}
Also used : I_C_Order(org.compiere.model.I_C_Order) MInvoiceLine(org.compiere.model.MInvoiceLine) I_M_InOutLine(org.compiere.model.I_M_InOutLine)

Aggregations

PurchaseCandidate (de.metas.purchasecandidate.PurchaseCandidate)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 I_C_Order (org.compiere.model.I_C_Order)2 Preconditions (com.google.common.base.Preconditions)1 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 IDocument (de.metas.document.engine.IDocument)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 IADProcessDAO (de.metas.process.IADProcessDAO)1 RelatedProcessDescriptor (de.metas.process.RelatedProcessDescriptor)1 PurchaseCandidateRepository (de.metas.purchasecandidate.PurchaseCandidateRepository)1 SalesOrderLines (de.metas.purchasecandidate.SalesOrderLines)1 C_PurchaseCandidates_GeneratePurchaseOrders (de.metas.purchasecandidate.async.C_PurchaseCandidates_GeneratePurchaseOrders)1 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)1 WEBUI_SalesOrder_Apply_Availability_Row (de.metas.ui.web.order.sales.purchasePlanning.process.WEBUI_SalesOrder_Apply_Availability_Row)1 WEBUI_SalesOrder_PurchaseView_Launcher (de.metas.ui.web.order.sales.purchasePlanning.process.WEBUI_SalesOrder_PurchaseView_Launcher)1 CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)1 IView (de.metas.ui.web.view.IView)1