UoM - Serial Selection popup  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

UoM - Serial Selection popup

Postby Riyaz » Tue Jan 30, 2018 3:22 pm

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
Attachments
Plugin HAB - Purchase and Sales Order set Default UOM.xml
(37.9 KiB) Downloaded 81 times
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: UoM - Serial Selection popup

Postby Riyaz » Tue Jan 30, 2018 3:23 pm

document with screenshots also attached
Attachments
UoM-serial-popup.pdf
(79.51 KiB) Downloaded 80 times
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: UoM - Serial Selection popup  Topic is solved

Postby Mike.Sheen » Tue Jan 30, 2018 4:19 pm

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 85 times

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: UoM - Serial Selection popup

Postby Riyaz » Fri Feb 02, 2018 11:37 am

Hi Mike

Thanks for that, worked like a charm
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 28 guests