Search in sources :

Example 1 with I_C_Order

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);
}
Also used : I_C_Order(de.metas.adempiere.model.I_C_Order) Properties(java.util.Properties) I_C_OrderLine(org.compiere.model.I_C_OrderLine)

Example 2 with I_C_Order

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();
}
Also used : I_C_Order(de.metas.adempiere.model.I_C_Order) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference)

Example 3 with I_C_Order

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);
}
Also used : I_C_Order(de.metas.adempiere.model.I_C_Order) I_M_Product(org.compiere.model.I_M_Product) QuickInput(de.metas.ui.web.quickinput.QuickInput) IHUOrderBL(de.metas.handlingunits.order.api.IHUOrderBL) 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 4 with I_C_Order

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);
}
Also used : I_C_Order(de.metas.adempiere.model.I_C_Order) IHUPackingAware(de.metas.adempiere.gui.search.IHUPackingAware) I_C_OrderLine(org.compiere.model.I_C_OrderLine)

Aggregations

I_C_Order (de.metas.adempiere.model.I_C_Order)4 I_C_OrderLine (org.compiere.model.I_C_OrderLine)2 IHUPackingAware (de.metas.adempiere.gui.search.IHUPackingAware)1 IHUOrderBL (de.metas.handlingunits.order.api.IHUOrderBL)1 QuickInput (de.metas.ui.web.quickinput.QuickInput)1 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)1 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)1 ProductAndAttributes (de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)1 Properties (java.util.Properties)1 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)1 I_M_Product (org.compiere.model.I_M_Product)1