Page 1 of 1

UoM - Serial Selection popup

PostPosted: Tue Jan 30, 2018 3:22 pm
by Riyaz
Hi There

Have a situation wherein we need to show the UoM Quantity need to appear in the Serial Selection pop up of the sales order.

If I add a serialized item in the sales order, a Serial Selection pop up appears, and this has the Stock Keeping Unit mentioned as quantity in it. Instead what we need is a preferred UoM entry to be mentioned as quantity in this pop up, say, Bag Quantity. This appears correctly once after the line item is added and then we manually choose the required UoM from the dropdown and then add quantity. But its an unwanted step of cancelling the initial pop up and then choosing the required UoM all the time, for every line item we add.

What I've tried so far is as below

1, Have a plugin which sets the default UoM on AddInventoryItemEnd event, this works fine but it still brings up the serial popup with wring UoM Quantity

2, I tried to close the serial popup with this event DialogFactory.AfterDialogStart , it worked fine, but it didnt trigger the event mentioned under 1, and also the UoM's werent loaded for that line item

Am kind of stuck here, can you pls advise on how to solve this issue. Have attached the plugin for your reference

Re: UoM - Serial Selection popup

PostPosted: Tue Jan 30, 2018 3:23 pm
by Riyaz
document with screenshots also attached

Re: UoM - Serial Selection popup  Topic is solved

PostPosted: Tue Jan 30, 2018 4:19 pm
by Mike.Sheen
Hi Riyaz,

The trick here is to add another handler before the quantity is set which will force the serial selection mode to be FIFO instead of prompted, then switch it back afterwards.

Adding the handlers:
Code: Select all
var SalesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)JiwaBusinessLogic;
SalesOrder.SalesOrderLines.Added += SalesOrder_Lines_Added; // Occurs after line added to collection, but BEFORE quantity is set and thus before serial selection dialog shown.
SalesOrder.SalesOrderLines.AddInventoryItemEnd += SalesOrder_Lines_AddInventoryItemEnd;   


The handlers themselves:
Code: Select all
public void SalesOrder_Lines_Added(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine salesOrderLine)
{
   // if serialised item, force temporarily to use FIFO for serial selection instead of user prompting
   if (salesOrderLine.UseSerials)
      salesOrderLine.SalesOrderSerialStockSelectionType = JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine.SalesOrderSerialStockSelectionTypes.e_SalesOrderSerialStockSelectionFIFO;
}

private void SalesOrder_Lines_AddInventoryItemEnd(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine item)      
{
   // Set back serial selection to be prompted
   if (item.UseSerials)
      item.SalesOrderSerialStockSelectionType = JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine.SalesOrderSerialStockSelectionTypes.e_SalesOrderSerialStockSelectionPrompted;
   
   // Set the UOM to "Bag" if one exists for the item
   JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.UnitOfMeasure bagUOM = item.UnitOfMeasureCollection.Cast<JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.UnitOfMeasure>().FirstOrDefault(uom => uom.Name == "Bag");
   if (bagUOM != null)
      item.UnitOfMeasure = bagUOM;
   
   // Set the quantity to cause the serial selection dialog to display (as we suppressed it earlier)
   item.QuantityOrdered = item.QuantityOrdered;
}


Plugin attached is your plugin adapted with these changes.
Plugin HAB - Purchase and Sales Order set Default UOM.xml
Modified Plugin
(39.73 KiB) Downloaded 534 times

Mike

Re: UoM - Serial Selection popup

PostPosted: Fri Feb 02, 2018 11:37 am
by Riyaz
Hi Mike

Thanks for that, worked like a charm