This is actually working really well now, with a little help from my freinds.
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