Extending Inventory Import  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Extending Inventory Import

Postby SBarnes » Thu Jul 11, 2019 3:55 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Extending Inventory Import

Postby pricerc » Thu Jul 11, 2019 6:08 pm

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.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: Extending Inventory Import

Postby SBarnes » Fri Jul 12, 2019 10:47 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Extending Inventory Import

Postby SBarnes » Fri Jul 12, 2019 11:54 am

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"}));
      
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Extending Inventory Import

Postby Mike.Sheen » Tue Jul 16, 2019 10:08 am

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"}));
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: Extending Inventory Import

Postby SBarnes » Tue Jul 16, 2019 11:24 am

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"}));
   }
Attachments
Plugin Import P1...P10 Selling Prices 7.2.xml
(86.33 KiB) Downloaded 50 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Extending Inventory Import

Postby Mike.Sheen » Tue Jul 16, 2019 2:58 pm

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!
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: Extending Inventory Import

Postby SBarnes » Wed Jul 17, 2019 3:41 pm

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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Extending Inventory Import

Postby Mike.Sheen » Fri Jul 19, 2019 6:00 pm

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.
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: Extending Inventory Import

Postby SBarnes » Fri Jul 19, 2019 6:07 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron