Add Sort Order to purchase orders  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Add Sort Order to purchase orders

Postby DannyC » Fri Feb 16, 2018 10:03 am

In sales orders, we can use the direction arrows to scroll forward and back according to the sort order which includes the debtor account no, or debtor name.

I've tried to add sort order to Purchase Orders so we can forward/back by creditor account no or creditor name, but I failed.
Can you assist?

For version 7.0.175

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add Sort Order to purchase orders

Postby SBarnes » Fri Feb 16, 2018 10:29 am

Hi Danny

Seeing we've been working on this together the following code kind of works, when added as a business logic plugin, when I say kind of it adds the sort and will scroll to first and last but produces an error on next and previous. Maybe Mike or Scott can resolve it.

Code: Select all
 public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      //System.Diagnostics.Debugger.Launch();
      
      if(JiwaBusinessLogic.GetType() == typeof(JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder))
      {
      JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder purchaseorder  =(JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder) JiwaBusinessLogic;
      purchaseorder.SortOrders.Add(new JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.SortKey {
                               Description = "Creditor Name",
                               FieldName = "CR_Main.Name+PO_Main.OrderNo"
                              });   
      //salesorder.TableName = "";
      purchaseorder.BaseFindSQLQuery = "SELECT TOP 1 PO_Main.OrderID FROM  PO_Main INNER JOIN CR_Main ON PO_Main.CreditorID = CR_Main.CreditorID";

      }      
    }


The error its producing is attached.
Attachments
sort error.png
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add Sort Order to purchase orders

Postby Mike.Sheen » Fri Feb 16, 2018 2:06 pm

Hi Danny & Stuart,

This is a limitation of the Maintenance business logic design.

The problem occurs because the SortFieldValue property of the purchase order business logic is used by the base Maintenance.UserInterface class and this method has hard-coded return values, and cannot be modified via external code.

I've logged an improvement to address this DEV-6483 - it'd mean just adding a parameter to the Add of the SortOrders collection to allow a delegate function be supplied to return the desired SortFieldValue.

Mike
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: Add Sort Order to purchase orders

Postby SBarnes » Fri Feb 16, 2018 2:19 pm

Hi Mike,

Am I right in assuming this improvement would then work for all maintenance screens not just the purchase order screen?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add Sort Order to purchase orders

Postby Mike.Sheen » Fri Feb 16, 2018 2:20 pm

SBarnes wrote:Am I right in assuming this improvement would then work for all maintenance screens not just the purchase order screen?


Yes!
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: Add Sort Order to purchase orders

Postby SBarnes » Fri Feb 16, 2018 2:24 pm

Brilliant :D
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add Sort Order to purchase orders

Postby Mike.Sheen » Wed Feb 28, 2018 6:52 pm

FYI - 7.00.175.00 Service Release 5 has this improvement included and had been released.
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: Add Sort Order to purchase orders

Postby DannyC » Mon Jun 04, 2018 4:43 pm

Mike,

Can you let me know why this doesn't work? There is a compile error on the SortFieldValueMethod line. "Cannot convert anonymous method to delegate type JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.SortFieldValue Delegate"
Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    if(JiwaBusinessLogic.GetType() == typeof(JiwaFinancials.Jiwa.JiwaInvReceival.Receival))
      {
      JiwaFinancials.Jiwa.JiwaInvReceival.Receival GRN  =(JiwaFinancials.Jiwa.JiwaInvReceival.Receival) JiwaBusinessLogic;
      GRN.SortOrders.Add(new JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.SortKey{
         Description = "Slip Date",
         FieldName = "RE_Main.SlipDate",
         SortFieldValueMethod = delegate() {return GRN.SlipDate; }
         });
      GRN.BaseFindSQLQuery = "SELECT TOP 1 RE_Main.SlipDate FROM RE_Main ORDER BY RE_Main.SlipDate DESC";
       }
   }
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add Sort Order to purchase orders

Postby SBarnes » Mon Jun 04, 2018 4:59 pm

Hi Danny,

I believe your issue may well be solved by making

Code: Select all
 SortFieldValueMethod = delegate() {return GRN.SlipDate; }


be

Code: Select all
 SortFieldValueMethod = delegate() {return GRN.SlipDate.ToString(); }


The delegate must return a string not a date.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add Sort Order to purchase orders

Postby DannyC » Mon Jun 04, 2018 5:10 pm

Bingo!
This is the final code.
Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    if(JiwaBusinessLogic.GetType() == typeof(JiwaFinancials.Jiwa.JiwaInvReceival.Receival))
      {
      JiwaFinancials.Jiwa.JiwaInvReceival.Receival GRN  =(JiwaFinancials.Jiwa.JiwaInvReceival.Receival) JiwaBusinessLogic;
      GRN.SortOrders.Insert(0, new JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.SortKey{
      //GRN.SortOrders.Add(new JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.SortKey{
         Description = "Slip Date",
         FieldName = "RE_Main.SlipDate",
         SortFieldValueMethod = delegate() {return GRN.SlipDate.ToString("yyyyMMdd"); }
         });
      GRN.BaseFindSQLQuery = "SELECT TOP 1 RE_Main.PackSlipID FROM RE_Main ";
       }
   }


I remmed out the Add and used Insert so I can put in a index in the hope that will be the first option which appears when opening the module.
And I also made the SlipDate return a string as per Stuart's suggestion but formatted to yyyyMMdd. Without that formatting, it throws an error using the green Previous/Next buttons.

Seems to work but It only works when 1 GRN has been done on any day.
If there are mutiple GRNs on the same day, it doesn't scroll previous/next to the next GRN. I suspect I need it to recognise hours & minutes but have tried all kinds of syntax tweaks but none work.

Suggestions?
Last edited by DannyC on Mon Jun 04, 2018 6:38 pm, edited 1 time in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 15 guests