Sales order branch warning  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Sales order branch warning

Postby DannyC » Thu Apr 30, 2026 1:35 pm

Client has branches which loosely match warehouses.

That means when a sales order is in say, the VIC warehouse, the branch should also match VIC.
Branch masking is set up in the ledger config. The reason for branch masking and not warehouse masking is because there is often a scenario when sales may need to be done in warehouse NSW because that's where the stock is, but the GL needs to reflect VIC, so branch = VIC.

What I'd like is a visual alert when that scenario happens. I am thinking a little flashing exclamation mark (like when a debtor email address looks dodgy) just left of the combobox.

Although I haven't attempted a plugin yet, I'd like to know a few things:
1. What SalesOrderEntryForm event should I hook into, or how best to display the alert?
2. What is the code that implements the flashing exclamation mark?

I'm OK to do the warehouse/branch comparison.
User avatar
DannyC
Senpai
Senpai
 
Posts: 723
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

Re: Sales order branch warning

Postby Mike.Sheen » Thu Apr 30, 2026 1:48 pm

Use the ErrorIcon_Display helper method of the base maintenance class form to display the flashing exclamation - here's how we use it for showing against the debtor lookup on the sales order form:

Code: Select all
If SalesOrder.Debtor.TradingStatus = JiwaSales.SalesOrder.Debtor.DebtorTradingStatuses.e_DebtorTradingStatusInActive Then
    ErrorIcon_Display(ErrorProvider1, DebtorLookup, "This debtor Trading Status is set to Inactive.")
ElseIf SalesOrder.Debtor.OnHold Then
    ErrorIcon_Display(ErrorProvider1, DebtorLookup, "This debtor is set to be On Hold.")
Else
    ErrorIcon_Clear(ErrorProvider1, DebtorLookup)
End If
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: 2586
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 813

Re: Sales order branch warning

Postby DannyC » Fri May 01, 2026 12:30 pm

Thanks Mike.
I'm close but getting compilation errors. BTW, line 54 is the salesOrderForm.ErrorIcon_Display line.
Compile Err.jpg


I have tried with and without the ref on the parameters.
I am using lblBranch because when I see the DebtorLookup on your example, the indicator is way to the right. I'd prefer it be between the label and the lookup, so just to the left of the branch lookup, outside of the control.

Here's my code
Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
   {
      JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)JiwaForm;
      salesOrderForm.SalesOrder.Created += BranchIndicator;
   }
}

private void BranchIndicator(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes newType, ref JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quote)
{
   JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
   JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)salesOrder.Client;
   
   string warehouse = salesOrder.LogicalWarehouseResidingIn.Description;
   string branch = salesOrder.Branch.Description;
   System.Windows.Forms.ErrorProvider errorProvider1;
   
   double score = JaroWinkler(warehouse, branch);
   bool isSimilar = score >= 0.85;
   
   if (!isSimilar) //this just compares the strings for likeness.
   {
       errorProvider1 = salesOrderForm.ErrorProvider1;
      salesOrderForm.ErrorIcon_Display(ref errorProvider1, ref salesOrderForm.lblBranch, "Warehouse and branch does not match.");
      
      //ErrorIcon_Display(ErrorProvider1, DebtorLookup, "This debtor Trading Status is set to Inactive.");
   }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 723
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

Re: Sales order branch warning  Topic is solved

Postby Mike.Sheen » Fri May 01, 2026 2:45 pm

It's complaining it wants a System.Windows.Forms.Control to be passed, so you just needed to give it what it wanted.

Code: Select all
System.Windows.Forms.ErrorProvider errorProvider = salesOrderForm.ErrorProvider1;
System.Windows.Forms.Control lblBranch = salesOrderForm.lblBranch;
salesOrderForm.ErrorIcon_Display(ref errorProvider, ref lblBranch, "Warehouse and branch does not match.");


ErrorProvider.png


Of course you could also not use that helper method - nothing stops you from creating an ErrorProvider control of your own and using that.

Working plugin attached.
Attachments
Plugin Sales Order Form Error Indicator.xml
(12.1 KiB) Downloaded 6 times
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: 2586
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 813

Re: Sales order branch warning

Postby DannyC » Fri May 01, 2026 5:12 pm

Brilliant.

Got my plugin working with a few tweaks.
User avatar
DannyC
Senpai
Senpai
 
Posts: 723
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 52 guests