use of de.metas.adempiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method process.
@Override
public DocumentId process(final QuickInput quickInput) {
final I_C_Order order = quickInput.getRootDocumentAs(I_C_Order.class);
final Properties ctx = InterfaceWrapperHelper.getCtx(order);
final I_C_OrderLine newOrderLine = OrderFastInput.addOrderLine(ctx, order, orderLineObj -> updateOrderLine(orderLineObj, quickInput));
final int newOrderLineId = newOrderLine.getC_OrderLine_ID();
return DocumentId.of(newOrderLineId);
}
use of de.metas.adempiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.
the class WEBUI_SalesOrder_PurchaseView_Launcher method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable(final IProcessPreconditionsContext context) {
if (!context.isSingleSelection()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("one and only one order shall be selected");
}
// Only sales orders
final I_C_Order salesOrder = context.getSelectedModel(I_C_Order.class);
if (!salesOrder.isSOTrx()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("only sales orders are allowed");
}
final String docStatus = salesOrder.getDocStatus();
if (!IDocument.STATUS_Drafted.equals(docStatus) && !IDocument.STATUS_Completed.equals(docStatus)) {
return ProcessPreconditionsResolution.rejectWithInternalReason("only draft or completed orders are allowed");
}
// At least one sales order line shall be selected
final //
Set<TableRecordReference> selectedOrderLineRefs = context.getSelectedIncludedRecords();
if (selectedOrderLineRefs.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.adempiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputDescriptorFactory method onProductChangedCallout.
private static void onProductChangedCallout(final ICalloutField calloutField) {
final QuickInput quickInput = QuickInput.getQuickInputOrNull(calloutField);
if (quickInput == null) {
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 I_M_Product quickInputProduct = load(productAndAttributes.getProductId(), I_M_Product.class);
final I_C_Order order = quickInput.getRootDocumentAs(I_C_Order.class);
Services.get(IHUOrderBL.class).findM_HU_PI_Item_Product(order, quickInputProduct, quickInputModel::setM_HU_PI_Item_Product);
}
use of de.metas.adempiere.model.I_C_Order in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method updateOrderLine.
private final void updateOrderLine(final Object orderLineObj, final QuickInput fromQuickInput) {
final I_C_Order order = fromQuickInput.getRootDocumentAs(I_C_Order.class);
final IOrderLineQuickInput fromOrderLineQuickInput = fromQuickInput.getQuickInputDocumentAs(IOrderLineQuickInput.class);
final IHUPackingAware quickInputPackingAware = createQuickInputPackingAware(order, fromOrderLineQuickInput);
final I_C_OrderLine orderLineToUpdate = InterfaceWrapperHelper.create(orderLineObj, I_C_OrderLine.class);
final IHUPackingAware orderLinePackingAware = OrderLineHUPackingAware.of(orderLineToUpdate);
huPackingAwareBL.prepareCopyFrom(quickInputPackingAware).overridePartner(false).asiCopyMode(// because we just created the ASI
ASICopyMode.CopyID).copyTo(orderLinePackingAware);
}
Aggregations