Page 2 of 3

Re: More ranges for Manual Backorder Release

PostPosted: Mon Jun 03, 2019 5:56 pm
by Mike.Sheen
Hi Danny,

I've come full circle on this and have concluded you still need to essentially re-do the business logic and form to extend this in any meaningful way.

The code I showed to replace the AddRange method won't actually work (I've gone and tried it) because the item being added to the collection of lines has properties which are classes that contain friend property setters - so any class outside the assembly won't be allowed to set certain properties... for instance, this part:

Code: Select all
If manualBoReleaseForm.ManualBOBatch.InventoryItems.Contains(InventoryID) = False Then
   newInventoryItem = manualBoReleaseForm.Manager.CollectionItemFactory.CreateCollectionItem(Of InventoryItem)
   newInventoryItem.Inventory.ReadRecord(InventoryID)
   newInventoryItem.QuantityAvailable = .Sanitise(SQLReader, "QuantityAvailable")
   newInventoryItem.RecID = InventoryID
   manualBoReleaseForm.ManualBOBatch.InventoryItems.Add(newInventoryItem)
End If


will not be able to work because the QuantityAvailable property of the InventoryItem class has a friend setter. And you cannot just inherit from InventoryItem and shadow the setter because you still won't be able to add that to the InventoryItems collection because it wan'ts it's type of InventoryItem, not a decended one.

And there's a whole bunch more in other classes - specifically SalesOrder and BatchLine.

I think perhaps what Nina was doing was repurposing the Manual BO Release form so that it did something completely different? I can't see how Nina's code could have added to the BatchLines collection and have the form behave as it should after that point.

Re: More ranges for Manual Backorder Release

PostPosted: Tue Jun 04, 2019 9:06 am
by DannyC
I can't see how Nina's code could have added to the BatchLines collection and have the form behave as it should after that point.


I've fiddled a bit more too and can't get it going. Nina has missed a key part of code...There seems to be a custom class or namespace called CustomRanges which is essential for Nina's code to be complete. Nina, if you have that code too, that'd be great!

Re: More ranges for Manual Backorder Release

PostPosted: Tue Jun 04, 2019 8:42 pm
by Mike.Sheen
Hi Danny,

Nina was generous enough to communicate with me via a side-channel to give me some guidance on how they implemented this. It's not appropriate for Nina to share the code, so I'll whip something up clean-room fashion to re-invent the technique and post it here, thereby sidestepping any IP / privacy issues around it - so stay tuned!

Hint: reflection

Mike

Re: More ranges for Manual Backorder Release

PostPosted: Wed Jun 05, 2019 12:54 pm
by DannyC
Nina was generous enough to communicate with me via a side-channel

Cool! Thanks Nina, really appreciated & definitely understand re confidentiality.

Cheers

Re: More ranges for Manual Backorder Release  Topic is solved

PostPosted: Wed Jun 19, 2019 3:27 pm
by Mike.Sheen
As promised, attached is a sample plugin for 7.2 which achieves this.

As per the plugin description:
Adds 2 ranges to the Manual BO Realse Batch form which are passed to the stored procedure used to return results to the BackOrders grid.
The Documents tab contains a SQL script to create a custom stored procedure which accepts the two extra parameters.

Plugin Manual BO Release Batch Extend Ranges.xml
(53.2 KiB) Downloaded 141 times

Re: More ranges for Manual Backorder Release

PostPosted: Thu Jun 27, 2019 12:20 pm
by DannyC
Mike,

That's great.
I tweaked the stored procedure to actually use the passed in parameters and it works!

Re: More ranges for Manual Backorder Release

PostPosted: Fri Sep 04, 2020 6:24 pm
by DannyC
Another question about the Manual Backorder Release screen.

The plugin from this thread is awesome for extending the ranges and passing into a custom stored proc...but I have been asked if it's possible to add a couple of columns to the results grid.
1. Unprocessed backorders
2. Qty on purchase orders

I don't need to know the SQL to get the figures above, but I do need assistance to show those extra columns on the grid.

Would be grateful for any guidance.

Re: More ranges for Manual Backorder Release

PostPosted: Fri Sep 04, 2020 6:33 pm
by SBarnes
I'll be honest I haven't looked if the form operates the same way as the debtors sales screen in that it draws each line as its added to the collection of line for the business object and at this time on a Friday night I am not going to but if it does which you can probably work out for yourself by looking at the code in Just Decompile then have a look at this post viewtopic.php?f=26&t=1366

Re: More ranges for Manual Backorder Release

PostPosted: Fri Sep 04, 2020 7:04 pm
by SBarnes
Ok it doesn't operate like the other form but Mike is displaying the lines by calling the following code in the plugin so after that code if you had added some columns to the grid in your set up you could in theory roll over the grid and fill them in or alternatively have a look at DisplayBatchLine and DisplayBatchLines in the form and rewrite them to include the extra columns and do away with Mike's code below.

Code: Select all
      ' Invoke the private method of the form to display the lines
      'manualBoReleaseForm.GetType.InvokeMember("DisplayBatchLines", BindingFlags.NonPublic Or BindingFlags.Instance, Nothing, Me, Nothing)
      Dim dynMethod As MethodInfo = manualBoReleaseForm.GetType().GetMethod("DisplayBatchLines", BindingFlags.NonPublic Or BindingFlags.Instance)
      dynMethod.Invoke(manualBoReleaseForm, Nothing)

Re: More ranges for Manual Backorder Release

PostPosted: Tue Sep 22, 2020 11:55 am
by SBarnes
Hi Mike,

There is a bug in the plugin provided on this forum post, what happens is the when you tick the fulfil button it is not changing the quantities which is normal Jiwa behaviour.

Interestingly if you disable the plugin any batches created whilst the plugin was active still have the same problem it is only when you disable the plugin and create a new batch that you don't get the problems.