Question

Catalog screen Update non stock item Pallets field total selected quantity when click on Add To Cart both stock and non stock item insert to Cart.

  • 18 March 2024
  • 0 replies
  • 14 views

Hi Everyone,

    In Catalog screen I added non stock item PALLET as shown in screen shot. I want when I insert pallets quantity on stock item that all item quantity total update on non stock item pallets field.as shown screen shot.

 


When click Add To Cart that non stock item also inserted on Cart.
I write below code but non stock item not inserting on Cart.
protected void InventoryLines_RowUpdated(PXCache c, PXRowUpdatedEventArgs e, PXRowUpdated del)
  {
            InventoryLines inventoryLines = e.Row as InventoryLines;
          UpdateNonStockItemPallets();
}
 

private void UpdateNonStockItemPallets()
        {
            PXResultset<InventoryLines> pxresultset = base.Base.FilteredItems.Select(Array.Empty<object>());
            foreach (PXResult<InventoryLines> pxresult in pxresultset)
            {
                InventoryLines row = pxresult;
                // Fetch the non-stock item record
                InventoryItem nonStockItem = PXSelect<InventoryItem,
                                          Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>,
                                                And<InventoryItem.itemType, Equal<INItemTypes.nonStockItem>>>>
                                          .Select(Base, row.InventoryID);

                if (nonStockItem != null)
                {
                    // Calculate the total quantity of items in the cart and selected for order
                    int selectedOrderQty = CalculateSelectedOrderQty();
                  
                    int totalQty = selectedOrderQty;

                    // Update the UsrPallets field for the non-stock item
                    row.GetExtension<InventoryLinesExt>().UsrPallets = totalQty;


                    row.Qty = totalQty;
                    row.Selected = totalQty > 0;
}
}
}

protected int CalculateSelectedOrderQty()
        {
            PXResultset<InventoryLines> pxresultset = base.Base.FilteredItems.Select(Array.Empty<object>());
            decimal num = 0m;
            foreach (PXResult<InventoryLines> pxresult in pxresultset)
            {
                InventoryLines inventoryLines = pxresult;
                num += Convert.ToDecimal(PXCacheEx.GetExtension<InventoryLinesExt>(inventoryLines).UsrPallets);
            }
            return Convert.ToInt32(num);
        }

Thanks


0 replies

Be the first to reply!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved