Page 1 of 2

Sales order line column Line Total Ex GST

PostPosted: Wed Sep 18, 2024 2:51 pm
by DannyC
Currently out of the box, there isn't a Line Total Ex GST column.

I'm fiddling with a plugin to get this implemented but not sure of the most appropriate direction. I reckon there are 3 ways to do it.
I'm pretty sure they don't need it saved - it's just they want it displayed in the grid.

1. An extra grid column which calculates
Code: Select all
soLine.DeliveredExGSTAmount * soLine.QuantityThisDelivery;


2. A line custom field which calcs the same formula. This will end up being saved. Doesn't really matter, but not required.

3. Use one of the UserDefinedFloats to do the same formula. Once again this will end up being saved.

Thing is, for points 2 and 3 when displaying closed sales orders the calculation will prompt to save the sales order because I am using the ReadEnd event & iterating the lines to do the calculation.

How would others approach this? Maybe a sample plugin anyone has?

Re: Sales order line column Line Total Ex GST  Topic is solved

PostPosted: Wed Sep 18, 2024 2:56 pm
by Mike.Sheen
Add a column and add a handler for the LineDisplayed event from the form, and in there you set your new column contents to be SalesOrderLine.LineTotal - SalesOrderLine.GSTAmount. SalesOrderLine is passed as an parameter to the event, and so is Row - so it's literally a one line event handler (well you should wrap it in an if statement to not do anything if it is a comment line, so maybe 3 lines).

Re: Sales order line column Line Total Ex GST

PostPosted: Wed Sep 18, 2024 3:59 pm
by DannyC
Thx Mike. Plugin done.
Works nicely :)

For anyone interested...
Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      {
         JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
         _salesOrderForm = salesOrderForm;
         salesOrderForm.grdLines.AddColumn("LineTotalEx", new JiwaCurrencyCellType(),"LineTotal Ex GST",10,false,true,true,true,20,false,false,2,false,false);
         salesOrderForm.grdLines.GridDecimalPlaces("LineTotalEx", -1, 2, -2);
         salesOrderForm.LineDisplayed += my_SalesOrderAddTotExGST;
      }
      
    }
   
   private void my_SalesOrderAddTotExGST(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine soLine, int Row)
   {
      if (!soLine.CommentLine)
      {
         _salesOrderForm.grdLines.set_GridText("LineTotalEx", Row, soLine.LineTotal - soLine.GSTAmount);
      }
   }

Re: Sales order line column Line Total Ex GST

PostPosted: Fri Sep 27, 2024 4:10 pm
by DannyC
Just revisiting this after getting reports from the client that when the sales order is a few lines long, they're getting an error message
invalid row index.jpg
invalid row index.jpg (23.21 KiB) Viewed 27387 times


When I was testing, I only had 1 line on my sales order.
When I have multiple rows, the added column only calculates on the first line.

Thereafter, the column just shows 0.
I'm not getting the error as per client, but neither am I getting the Total Ex displayed. :(
Line Total 1 line only.jpg

Re: Sales order line column Line Total Ex GST

PostPosted: Mon Sep 30, 2024 12:31 pm
by Mike.Sheen
Please provide a plugin which demonstrates the issue that can be used on demo data.

Re: Sales order line column Line Total Ex GST

PostPosted: Mon Sep 30, 2024 3:52 pm
by DannyC
Plugin attached

Re: Sales order line column Line Total Ex GST

PostPosted: Mon Sep 30, 2024 4:02 pm
by Mike.Sheen
DannyC wrote:Plugin attached


Looks fine to me.

Screenshot 2024-09-30 125920.png


Now that you have provided me with a plugin, the next thing is to provide the steps to reproduce.

Re: Sales order line column Line Total Ex GST

PostPosted: Mon Sep 30, 2024 7:28 pm
by DannyC
provide the steps to reproduce


Create a sales order with a few lines. Save.

Also, use the Back button to look at old sales orders.

Re: Sales order line column Line Total Ex GST

PostPosted: Tue Oct 01, 2024 10:25 am
by Mike.Sheen
DannyC wrote:Create a sales order with a few lines. Save.


Did that - screenshot shown below is the result.

Screenshot 2024-10-01 072305.png


Maybe provide some better steps because it might be specific part numbers or debtor?

DannyC wrote:Also, use the Back button to look at old sales orders.


I did, that's what my first screenshot was of. How about citing a specific sales order no. in demo data which exhibits the problem for you?

Re: Sales order line column Line Total Ex GST

PostPosted: Tue Oct 01, 2024 11:01 am
by DannyC
I've had a new revelation...Just discovered that if I move the column somewhere closer to the left of the grid, i.e. not the last column then I get the behaviour as shown. That is, only the first row displays the Total Ex column.
If I leave it as the last column then all good, each line is calced as expected.

What's trick with being able to move it up the order a bit?