Page 1 of 1

Readng Expiry Dates of Work Order inputs

PostPosted: Wed Aug 05, 2026 3:23 pm
by DannyC
Sort of similar to viewtopic.php?f=26&t=2550

I want to read the expiry dates of all input lines on Work Orders. Client wants to display a little popup to advise if an item is expired.
Like with the outputs, I guess I need to use a similar implementation of the IJiwaSOHConsumer?

Will this work when the work order is only at Forecast status? I reckon this might be where the complexity lies. When W/O is at Started or Closed is too late for this client. The popup needs to show at forecast. I know no inputs have been allocated yet from SOH so I'll need some way to know what the likely SOH lines would get allocated based on FIFO.

If I could have a starting point beyond what I have here that should at least give me some guidance.
Code: Select all
if (workOrder.Status == JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder.Statuses.Forecast)
{
   foreach(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.Stage stage in workOrder.Stages)
   {
      foreach(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem inputItem in stage.InputItems)
      {
         //look for expiry dates   
      }
   }
}

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Wed Aug 05, 2026 3:57 pm
by Mike.Sheen
See viewtopic.php?f=26&t=2550#p9734 - same as that, but for InputItems.

Will this work when the work order is only at Forecast status?


No, it's not taken any stock.

You need to query the IN_SOH table yourself.

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Thu Aug 06, 2026 9:58 am
by DannyC
You need to query the IN_SOH table yourself.


As I expected.
No worries.

Thx for the confirmation.

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Thu Aug 06, 2026 7:28 pm
by DannyC
Instead of querying the IN_SOH table, does the following code make sense?

It's not working and I think it's something to do with the foreach SOHline in SOHCollection.
Code: Select all
if (workOrder.Status == JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.WorkOrder.Statuses.Forecast)
{
   foreach(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.Stage stage in workOrder.Stages)
   {
      foreach(JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem inputItem in stage.InputItems)
      {      
         System.Diagnostics.Debugger.Launch();
         //read the full inventory object to get the SOH line details
         JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory = workOrder.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaInventory.Inventory>(null);
         inventory.Read(inputItem.Inventory.InventoryID);
         foreach (JiwaFinancials.Jiwa.JiwaInventory.SOH SOHline in inventory.SOHCollection)
         {
            if (SOHline.QuantityLeft > 0)
            {
               if (SOHline.ExpiryDate < inputItem.Manager.Database.SysDateTime.AddDays(7) && inventory.PhysicalItem && inventory.UseExpiryDate)
               {
                  MessageBox.Show("Item " + inputItem.Inventory.PartNo + " may use stock with expiry date either expired or nearing expiry.");
               }                     
                     
            }
         }
               
      }
   }
}

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Fri Aug 07, 2026 12:27 pm
by DannyC
Found the issue.

I realised I needed to read the SOHCollection.
All OK now.

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Fri Aug 07, 2026 12:31 pm
by Mike.Sheen
Another trick you could try is to create a new, temporary instance of the work order, read your forecast work order and set it's status to started - it'll grab all the stock for you on a FIFO basis and you could examine the LineDetails of the input items it took - and then you can just abandon the temporary work order without saving it - leaving your forecast order untouched.

So that will essentially give you the ability to determine what stock the work order would take, if it were to take stock - which is what I think you were trying to do.

Re: Readng Expiry Dates of Work Order inputs

PostPosted: Wed Aug 12, 2026 4:11 pm
by DannyC
Another trick you could try is to create a new, temporary instance of the work order


Makes sense. I might try that if I get grief from the client.

Appreciate the help as always