Page 1 of 2

Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 4:31 pm
by Ernst
Hi, In JIWA 721 is it possible to add lines to the end of the sales order journal that has been generated.
Client want to 2 freight cost lines and also change the debtor freight line depending on logic.

Ive tried this code as per below to get to it. But get a Compiler Error: Type Expected? The Types look good to me??

I can load up a full plugin.

Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
If TypeOf JiwaBusinessLogic Is JiwaSales.SalesOrder.SalesOrder Then
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(JiwaBusinessLogic, JiwaSales.SalesOrder.SalesOrder)
AddHandler salesOrder.Process_DebtorTransactionsStart, AddressOf Process_DebtorTransactionsStart

Private Sub Process_DebtorTransactionsStart(ByVal SalesOrder As JiwaSales.SalesOrder.SalesOrder, ByRef DebtorTransactions As system.Collections.Generic.List(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.DebtorTransaction ), ByRef JournalSets As system.Collections.Generic.List(Of JiwaFinancials.Jiwa.JiwaJournalSets ))

Compiler Error: Type Expected?

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 5:15 pm
by SBarnes
Hi Ernst

The event you are going after is the correct one Mike very kindly added this a few years ago when I needed to create multiple debtor transactions against the sales order i.e. payments at 30 days, 60 days and 90 days, hence the reason for the lists, that being said it looks like the following in c#

Code: Select all
salesorder.Process_DebtorTransactionsStart += Process_DebtorTransactionsStart;


and

Code: Select all
public void Process_DebtorTransactionsStart(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder SalesOrder, ref List<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.DebtorTransaction> DebtorTransactions, ref List<JournalSet> JournalSets)
{
}


Telerik converts it to

Code: Select all
Public Sub Process_DebtorTransactionsStart(ByVal SalesOrder As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder, ByRef DebtorTransactions As List(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.DebtorTransaction), ByRef JournalSets As List(Of JournalSet))
End Sub


I also have the following using statements at the top of the plugin

Code: Select all
using JiwaFinancials.Jiwa.JiwaSales.SalesOrder;
using JiwaFinancials.Jiwa.JiwaJournalSets;



Hope this helps

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 5:21 pm
by Mike.Sheen
Process_JournalSetsSaveStart and Process_JournalSetsSaveEnd events are also useful for meddling with the journal set(s) emitted from processing a sales order.

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 5:26 pm
by SBarnes
The other thing I just remembered also is that whilst it will checks that everything adds up it doesn't validate the the tax value against the codes you set i.e. it didn't check that the GST was 10% and on the transaction if you touch it make sure that you set the amount and the fx amount otherwise this can cause problems with allocations further down the track.

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 5:40 pm
by Mike.Sheen
SBarnes wrote:The other thing I just remembered also is that whilst it will checks that everything adds up it doesn't validate the the tax value against the codes you set i.e. it didn't check that the GST was 10% and on the transaction if you touch it make sure that you set the amount and the fx amount otherwise this can cause problems with allocations further down the track.


It doesn't seem like Ernst wants to do anything with tax, so that shouldn't be a concern here.

Ernst your error is probably something you've overlooked - I can't readily see what.

I want to introduce you to the Code tag when putting code on forums.

It's the Code button above the textbox you put your post in.

If you put code in forum posts, decorating the code blocks with these tags provides us with the basic courtesy of being able to read your code without causing headaches or seizures.

For example, here's a code block with the event signatures of the events you would be interested in for this topic:
Code: Select all
Public Event Process_DebtorTransactionsStart(SalesOrder As SalesOrder, ByRef DebtorTransactions As List(Of DebtorTransaction), ByRef JournalSets As List(Of Jiwa.JiwaJournalSets.JournalSet))
Public Event Process_DebtorTransactionsEnd(SalesOrder As SalesOrder, ByRef DebtorTransactions As List(Of DebtorTransaction), ByRef JournalSets As List(Of Jiwa.JiwaJournalSets.JournalSet))
Public Event Process_JournalSetsSaveStart(SalesOrder As SalesOrder, ByRef DebtorTransactions As List(Of DebtorTransaction), ByRef JournalSets As List(Of Jiwa.JiwaJournalSets.JournalSet))
Public Event Process_JournalSetsSaveEnd(SalesOrder As SalesOrder, ByRef DebtorTransactions As List(Of DebtorTransaction), ByRef JournalSets As List(Of Jiwa.JiwaJournalSets.JournalSet))


It's much easier to read than plain text.

Also, providing an actual plugin with all unnecessary and irrelevant bits stripped out with no dependencies on non-standard stuff and just showing the problem you have is always going to be the fastest way to help us to help you.

Of course, taking the time and effort to do that might not be the quickest for you, but it will mean you've done everything you can to make it as easy as possible for us to help you - and if you want someone to help you, rule #1 is don't make it hard for them to do so.

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 5:48 pm
by SBarnes
Mike.Sheen wrote:Also, providing an actual plugin with all unnecessary and irrelevant bits stripped out with no dependencies on non-standard stuff and just showing the problem you have is always going to be the fastest way to help us to help you.


I couldn't agree more although it probably won't be the problem in this case, I've seen instances where someone has posted code where there was noting wrong with it and asking why it wouldn't work but the problem was they didn't have the correct form references or business logic references on the plugin so the code was not being called at all and a second set of eyes spots these kind of things fairly quickly.

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 6:03 pm
by Ernst
Thanks for all the help.

The code from Stuart, didnt like lists and didnt like the Journal name.

Have fixed those and back to Compiler Error: Type expected.

See plugin below

Plugin Sales Order Adjust Journal.xml
(33.35 KiB) Downloaded 1155 times

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 6:08 pm
by Ernst
OK Got it compiled by adding a .Journalset at he end of sub.

So is it possible to add lines to Journal using this breakout Or the Process_journalset Start breakout?

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 6:11 pm
by SBarnes
yeah JiwaFinancials.Jiwa.JiwaJournalSets is the namespace not the class

Re: Trying to add/ change Sales Order Journal

PostPosted: Thu Mar 30, 2023 6:15 pm
by Ernst
Thanks Mike, will look out for the code button, does make it easier to read.