After thinking about this some more - you probably want to change the order the transactions appear on each email...
As you would already know, the order the transactions appear on the email matches that of the payment form - which is controlled by a system setting. When composing the email - we simply add the transactions in the order there are in the InvoicePaymentLines collection of each creditor (see code below)
- Code: Select all
Public Sub SendRemittanceEmail(ByVal Creditor As JiwaCreditorChqPay.Creditor, ByVal OveriddenEmailAddress As String)
Dim EmailObject As JiwaApplication.JiwaEmail.EmailMessage
EmailObject = Manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaApplication.JiwaEmail.EmailMessage)(Nothing)
EmailObject.CreateNew()
EmailObject.BodyIsHTML = True
EmailObject.EmailFrom = ResolveTokens(From, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.EmailTo = ResolveTokens(EmailTo, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.EmailCC = ResolveTokens(CC, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.EmailBCC = ResolveTokens(BCC, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.EmailSubject = ResolveTokens(Subject, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.EmailBody = ResolveTokens(SelectedEmailTemplate.Header, Creditor, Nothing, OveriddenEmailAddress)
For Each invoice As JiwaCreditorChqPay.clsPayLineInvoice In Creditor.InvoicePaymentLines
EmailObject.EmailBody &= ResolveTokens(SelectedEmailTemplate.Body, Creditor, invoice, OveriddenEmailAddress)
Next
EmailObject.EmailBody &= ResolveTokens(SelectedEmailTemplate.Footer, Creditor, Nothing, OveriddenEmailAddress)
EmailObject.SourceID = _ChequePaymentForm.CRChequePayObject.RecID
EmailObject.SourceType = "Creditor Cheque Payments"
EmailObject.SourceDisplayNo = _ChequePaymentForm.CRChequePayObject.BatchNo
EmailObject.SourceForm = "JiwaFinancials.Jiwa.JiwaCreditorChqPayUI.CreditorChqPay"
If RequestReadReceipt Then
EmailObject.RequestReadReceipt = True
End If
EmailObject.Status = JiwaApplication.JiwaEmail.EmailMessage.EmailStatuses.Sent
EmailObject.Save()
End Sub
You could try intercepting the tool click of the email button and at that point iterate through each creditor and use a bit of linq to sort the InvoicePaymentLines in the order you want. To prevent unexpected behaviours after the the dialog closes it might be a good idea to sort it back in the order it was, or at least re-read the batch to discard any changes the sorting made.