Page 1 of 1

setting the sales order line tax rate

PostPosted: Tue Apr 19, 2016 7:05 pm
by DannyC
Hi,

Just writing a quick little plugin to force the Sales Order line tax rate to "No Code" based on a particular condition - in this case a debtor classification.
It seems I can't set the TaxRate because it is read only.
version 7.0.157.
Language: The proper one. VB .Net.

What do you recommend to set it?
My code at the moment
Code: Select all
   Sub LineAdded(SalesOrderLine As JiwaSales.SalesOrder.SalesOrderLine)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(SalesOrderLine.SalesOrderLines.SalesOrder, JiwaSales.SalesOrder.SalesOrder)
      Dim MyTaxRate As JiwaApplication.JiwaTaxSystemRates.TaxRates =JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaApplication.JiwaTaxSystemRates.TaxRates)(Nothing)
      'MyTaxRate.Read("1c8929e75bd341a19d4d")  doesn't work
      MyTaxRate.Read()   'unsure if this is needed.
      'Find the debtor classification
      If salesOrder.Debtor.Classification.Description = "Whatever" Then
         SalesOrderLine.TaxRate = MyTaxRate
      End If
   End Sub   


Thanks

Re: setting the sales order line tax rate

PostPosted: Thu Apr 21, 2016 9:22 am
by Scott.Pearce
You don't "set" the tax rate, your .Read() it:

Code: Select all
      If salesOrder.Debtor.Classification.Description = "Whatever" Then
         SalesOrderLine.TaxRate.Read("1c8929e75bd341a19d4d")
      End If


Also, your declaration and use of MyTaxRate is erroneous.

Re: setting the sales order line tax rate

PostPosted: Thu Apr 21, 2016 4:15 pm
by DannyC
How can I set it?
I need it to change based on the debtor class.

Re: setting the sales order line tax rate

PostPosted: Thu Apr 21, 2016 5:26 pm
by Scott.Pearce
How can I set it?


You can't. You must .Read() it:

Code: Select all
      If salesOrder.Debtor.Classification.Description = "Whatever" Then
         SalesOrderLine.TaxRate.Read("1c8929e75bd341a19d4d")
      ElseIf salesOrder.Debtor.Classification.Description = "Whatever else" Then
         SalesOrderLine.TaxRate.Read("zzzzzzzzzz0000000000")
      End If

Re: setting the sales order line tax rate

PostPosted: Wed Apr 27, 2016 8:55 pm
by DannyC
Sorry Scott, still no go.
When compiling the code I am getting an error on the Read('nnnnnn') lines
Public Event Read() is an event, and cannot be called directly. Use a RaiseEvent statement to raise an event.

Re: setting the sales order line tax rate  Topic is solved

PostPosted: Thu Apr 28, 2016 8:44 am
by Scott.Pearce
Try .ReadRecord instead.

Re: setting the sales order line tax rate

PostPosted: Fri Apr 29, 2016 4:04 pm
by DannyC
Duh! Well, thats embarrassing - I should've tried that!

Looks like that has it sorted.
Cheers Scott.