Page 1 of 2

Extending Inventory Import

PostPosted: Thu Jul 11, 2019 3:55 pm
by SBarnes
Is there a way to extend the fields that the inventory import screen supports, including custom fields through a plugin or would it require the creation of a new screen to support this?

My question is based upon providing a customer a quote on the time required to make this happen but they want the combo list to pick up any additional custom fields that may be added over time and I am trying to determine whether or not this will able to be added to the existing screen or it will require starting from scratch as a completely new screen.

Re: Extending Inventory Import

PostPosted: Thu Jul 11, 2019 6:08 pm
by pricerc
Mike did supply an extension plugin (in the samples) for 7.0; not sure if it still applies to 7.2.

Otherwise, if you're considering a whole new plugin, then one I posted in reply to my own question about importing from Access is possibly a good base from which to start.

It's not dynamic; it was intended for a specific customer with specific requirements, so I didn't want to spend too much time generalizing it, but I did try to make it easy to extend.

It is a whole form with a data-entry grid that can easily be extended, or left out and replaced with something else, or loaded from an Excel spreadsheet; my goal was just copy-and-paste from somewhere else, but the farspread sheet is easy to populate from Excel or CSV.

The actual 'import' just generates an XML document and uses the standard JIWA Inventory deserializer (which is a key reason why the plugin is in VB, for building the XML).

The data-entry grid uses a combination of combobox and lookup buttons for the categories and classifications my client uses, and would be simple to extend this logic for other fields.

Re: Extending Inventory Import

PostPosted: Fri Jul 12, 2019 10:47 am
by SBarnes
Thanks Ryan,

I'll have a look at the sample Mike had done, unfortunately any other screen won't do in this case as the customer wants it to work exactly as the import screen does.

Re: Extending Inventory Import

PostPosted: Fri Jul 12, 2019 11:54 am
by SBarnes
Unfortunately the plugin doesn't compile as the constructor for JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty now takes no arguments as opposed to the version below.

I think you need to now under 7.2 call the constructor with no arguments and then call create so that JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty ends up with it's own manager but I am going to need some help from Jiwa to translate the code to 7.2 to achieve this.

Code: Select all
destinationPropertyCollection.Add(new JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty( "Inventory.P1", "P1 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P1"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P1"].Price;
                                 },
                                 new String[] {"P1", "P1 Price"}));
      

Re: Extending Inventory Import

PostPosted: Tue Jul 16, 2019 10:08 am
by Mike.Sheen
The Create method is used as a kind of factory function to create a DestinationProperty, which you can then add to the DestinationPropertyCollection - so like this:

Code: Select all
destinationPropertyCollection.Add(destinationPropertyCollection.Create(Manager, "Inventory.P1", "P1 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P1"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P1"].Price;
                                 },
                                 new String[] {"P1", "P1 Price"}));

Re: Extending Inventory Import

PostPosted: Tue Jul 16, 2019 11:24 am
by SBarnes
Hi Mike

Actually the code you posted was incorrect as the create was on the Destination Property not the Destination Property Collection but the following now compiles and should work I believe, I've also attached the updated plugin.

Code: Select all
private void AppendProperties(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection destinationPropertyCollection)
   {      
      

      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P1", "P1 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P1"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P1"].Price;
                                 },
                                 new String[] {"P1", "P1 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P2", "P2 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P2"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P2"].Price;
                                 },
                                 new String[] {"P2", "P2 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P3", "P3 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P3"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P3"].Price;
                                 },
                                 new String[] {"P3", "P3 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P4", "P4 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P4"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P4"].Price;
                                 },
                                 new String[] {"P4", "P4 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P5", "P5 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P5"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P5"].Price;
                                 },
                                 new String[] {"P5", "P5 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P6", "P6 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P6"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P6"].Price;
                                 },
                                 new String[] {"P6", "P6 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P7", "P7 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P7"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P7"].Price;
                                 },
                                 new String[] {"P7", "P7 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P8", "P8 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P8"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P8"].Price;
                                 },
                                 new String[] {"P8", "P8 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P9", "P9 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P9"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P9"].Price;
                                 },
                                 new String[] {"P9", "P9 Price"}));
      
      destinationPropertyCollection.Add(JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationProperty.Create(destinationPropertyCollection.Manager, "Inventory.P10", "P10 Sell Price",
                                 delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping mapping)
                                 {
                                 inventory.SellingPrices["P10"].Price = Microsoft.VisualBasic.Information.IsNumeric(value) ? Decimal.Parse(value) : inventory.SellingPrices["P10"].Price;
                                 },
                                 new String[] {"P10", "P10 Price"}));
   }

Re: Extending Inventory Import

PostPosted: Tue Jul 16, 2019 2:58 pm
by Mike.Sheen
SBarnes wrote:Hi Mike

Actually the code you posted was incorrect as the create was on the Destination Property not the Destination Property Collection but the following now compiles and should work I believe, I've also attached the updated plugin.



Oops!

Re: Extending Inventory Import

PostPosted: Wed Jul 17, 2019 3:41 pm
by SBarnes
Hi Mike,

One last question on this if you throw an exception in the delegate function will the screen then report this as an error?

Re: Extending Inventory Import

PostPosted: Fri Jul 19, 2019 6:00 pm
by Mike.Sheen
SBarnes wrote:Hi Mike,

One last question on this if you throw an exception in the delegate function will the screen then report this as an error?


I'm going to say yes.

I've not tested it, but it should bubble the exception up to the UI as we do everywhere else.

Re: Extending Inventory Import

PostPosted: Fri Jul 19, 2019 6:07 pm
by SBarnes
Thanks Mike,

I've actually moved on from the issue of custom fields as I discovered they are actually there in 7.2 at any rate, to the possibility of loading an image based a path in the cell and possibly doing the status update which of course would mean it needs to cancel back orders and close down open purchase orders but throw an exception for SOH.