Trying to add/ change Sales Order Journal  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Re: Trying to add/ change Sales Order Journal

Postby Ernst » Thu Mar 30, 2023 6:20 pm

OK got this working also

Code: Select all
   Public Sub Process_JournalSetsSaveStart(SalesOrder As JiwaFinancials.Jiwa.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.JournalSet))


But how do I access these 2 lists in the Sub.
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Trying to add/ change Sales Order Journal

Postby SBarnes » Thu Mar 30, 2023 6:34 pm

The below should give you the journal to change


Code: Select all
Public Sub Process_DebtorTransactionsStart(ByVal SalesOrder As JiwaFinancials.Jiwa.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.JournalSet ))
   Dim journal As JiwaFinancials.Jiwa.JiwaJournalSets.JournalSet = JournalSets.Item(0)
End Sub
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Trying to add/ change Sales Order Journal  Topic is solved

Postby Ernst » Thu Mar 30, 2023 7:49 pm

This is actually working really well now, with a little help from my freinds. :D Ive adjusted the existing Debtor Freight Journal Line, and added 2 New Journal LInes, POsting External freight.
All inside the existing sales order Journal..

Code: Select all
Public Sub Process_DebtorTransactionsStart(ByVal SalesOrder As JiwaFinancials.Jiwa.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.JournalSet ))
Dim journal As JiwaFinancials.Jiwa.JiwaJournalSets.JournalSet = JournalSets.Item(0)
Dim SalesOrderH As JiwaSales.SalesOrder.SalesOrderHistory = salesOrder.SalesOrderHistorys(salesorder.CurrentHistoryNo)
' Check if a consignment charge exists.
Dim ConsignMentNoteCarrierCharge As Double = 0
For Each ConsignmentNoteLine As JiwaSales.SalesOrder.ConsignmentNote In SalesOrderH.Carrier.ConsignmentNoteCollection
   ConsignMentNoteCarrierCharge = ConsignmentNoteLine.ExGSTAmount
Next
If ConsignMentNoteCarrierCharge > 0 Then
' Set up the account numbers you require
Dim NewAccountno1 As String
Dim NewAccountno2 As String
If SalesOrderH.Carrier.CarrierName = " XXX" Then
   NewAccountno1 = "2110-100-50"
Else
   NewAccountno1 = "2110-100-10"
End If
NewAccountno2 = "2110" + salesOrder.Debtor.LedgerDebtorFreight.AccountNo.Substring(4,5) + "40"
' Post the 2 LInes
Dim NewJournalLine As JiwaFinancials.Jiwa.JiwaJournalSets.Line = SalesOrder.Manager.CollectionItemFactory.CreateCollectionItem ( Of JiwaFinancials.Jiwa.JiwaJournalSets.Line)
NewJournalLine.GLAccount.ReadRecordFromAccountNo(NewAccountno1)
NewJournalLine.DebitAmount = ConsignMentNoteCarrierCharge
journal.Lines.Add(NewJournalLine)
Dim NewJournalLine2 As JiwaFinancials.Jiwa.JiwaJournalSets.Line = SalesOrder.Manager.CollectionItemFactory.CreateCollectionItem ( Of JiwaFinancials.Jiwa.JiwaJournalSets.Line)
NewJournalLine2.GLAccount.ReadRecordFromAccountNo(NewAccountno2)
NewJournalLine2.CreditAmount = ConsignMentNoteCarrierCharge
journal.Lines.Add(NewJournalLine2)
End If ' If ConsignMentNoteCarrierCharge > 0 then

' Adjust the existing Freight Line as Required

   Private Sub SalesOrder_ProcessingStart(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      Dim SalesOrderH As JiwaSales.SalesOrder.SalesOrderHistory = salesOrder.SalesOrderHistorys(salesorder.CurrentHistoryNo)
   ' Change Freight Accountno to Internal if Internal Delivery.
      If SalesOrderH.Carrier.CarrierName = " XXXX" Then
         Dim NewAccountno As String
         NewAccountno = salesOrder.Debtor.LedgerDebtorFreight.AccountNo.Substring(0,9) + "20"
      '   msgbox (NewAccountno)
         salesOrder.Debtor.ParentDebtor.LedgerDebtorFreight.ReadRecordFromAccountNo(NewAccountno)
         salesOrder.Debtor.LedgerDebtorFreight.ReadRecordFromAccountNo(NewAccountno)
         
      End If

      
   End Sub
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Trying to add/ change Sales Order Journal

Postby SBarnes » Fri Mar 31, 2023 8:55 am

Glad to see you got it working and you were able to use the code block and spare Mike from a headache or seizure :lol:
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Previous

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 46 guests