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