Import Pre-processor  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Import Pre-processor

Postby SBarnes » Wed Mar 30, 2022 1:59 pm

Is there any way or an event for debtor import screen or inventory import screen to be able to through plugin code to pre-process the fields so say for example someone has accidently formatted say RRP as $699.00 so that you can change it into 699.00?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Import Pre-processor

Postby Mike.Sheen » Wed Mar 30, 2022 6:18 pm

SBarnes wrote:Is there any way or an event for debtor import screen or inventory import screen to be able to through plugin code to pre-process the fields so say for example someone has accidently formatted say RRP as $699.00 so that you can change it into 699.00?


Add a handler for the ReadEnd event of the JiwaInventory.Import.InventoryImport.DestinationProperties:

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaBusinessLogic is JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport)
   {
      JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport inventoryImport = (JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport)JiwaBusinessLogic;
      inventoryImport.DestinationProperties.ReadEnd += DestinationProperties_ReadEnd; // We need to re-add our destination property if the collection is ever re-read.
   }
}


And inside therem override the SetterMethod for the DestinationProperty with the RecID "Inventory.RRPPrice":

Code: Select all
private void DestinationProperties_ReadEnd(object sender, System.EventArgs e)
{
    JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection destinationPropertyCollection = (JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection)sender;
    destinationPropertyCollection["Inventory.RRPPrice"].SetterMethod = delegate(JiwaFinancials.Jiwa.JiwaInventory.Inventory inventory, string value, string rowData, string[] row, int rowNo, JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping
mapping)
    {
        inventory.RRPPrice = decimal.Parse(value.Replace("$", ""));
    };
}
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: Import Pre-processor  Topic is solved

Postby Mike.Sheen » Wed Mar 30, 2022 6:25 pm

I just realised ReadEnd is too late to add that handler - So you need to override the SetterMethod as shown in both the ReadEnd handler AND the setup method. Either copy the code into Setup, or refactor it into a method called by both Setup and ReadEnd handler.
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: Import Pre-processor

Postby SBarnes » Wed Mar 30, 2022 6:44 pm

Thanks Mike,

Actually I think if memory serves correct you could do it in the readend but you have to remove the original handler/property, I did something similar to status for inventory so that if you changed the status to discontinued it would go off and clear out back orders and close purchase orders so the status change doesn't throw an exception, I'll start there.

By the way this same client discovered you can't have double quotes in the data such as product x with diameter 2" apparently excel will escape a double quote by turning it into "" when you convert to csv but Jiwa doesn't like that at all and of course ends up with its fields out of alignment and producing weird and wonderful errors that are then hard to diagnose.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 16 guests