| Id: | 14896 | 
| Product: | finPOWER Connect | 
| Type: | FIX | 
| Version: | 3.00.08 | 
| Opened: | 29/08/2017 | 
| Closed: | 15/09/2017 | 
| Released: | 21/09/2017 | 
| Job: | J019551 | 
|  High Importance | |
Documents; When published Standalone (Ad-Hoc) were not respecting the "Print Document even if Emailed?" option when creating a Bulk Document
Many Documents, e.g., "AL, Account Letter" contain a constants to "CreateBulkDocument".
When published Standalone (Ad-Hoc), e.g., via the Report Explorer, Documents that were configured (via the Options page) to NOT "Print Document even if Emailed?" were still being included in the Bulk Document which, typically, was used to Print Documents that were not Emailed.
In addition to this, when published Standalone, Account Documents for Accounts with only a single recipient would generate two PDF documents in the Account's Document Manager folder. One which was linked to the Account Log and another copy of the same Document with a suffix of "1".
The following Documents have been updated:
- AL: Account Letter - Account_Letter.xml (version 1.01)
- AAL: Account Application Letter - AccountApp_Letter.xml (version 1.01)
- CL: Client Letter - Client_Letter.xml (version 1.01)
- DS: Deposit Statement - Deposit_Statement.xml (version 1.03)
- AR: Disbursement Payment/Remittance Advice - Disbursement_Remittance.xml (version 1.01)
- LS: Loan Statement - Loan_Statement.xml (version 1.03)
- UL: User Letter - User_Letter.xml (version 1.01)
The relevant code changes follow the remark "' Remove entries for Emailed Documents".
The updated Script code for Account Documents is shown below:
'#################################################################' Publish Standalone (Ad-Hoc)'#################################################################Private Function Publish_Standalone(parameters As ISKeyValueList) As BooleanDim Account As finAccountDim AccountLog As finAccountLogDim AccountLogPk As IntegerDim AccountLogPks As List(Of Integer)Dim di As finDocumentRecipientDetailsItemDim dis As finDocumentRecipientDetailsItemsDim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim dr As IDataReaderDim sqb As ISSelectQueryBuilderDim Success As Boolean' Assume SuccessSuccess = True' ValidateIf Success Then' Create ObjectsAccountLogPks = New List(Of Integer)' Create Query (can use DocumentFunctions since we are using Standard Parameters)sqb = finBL.DocumentFunctions.GetAccountSqlSelectQueryBuilder(parameters)' Execute QueryIf sqb.ExecuteDataReader(dr) ThenDo While dr.Read()' Load AccountAccount = finBL.CreateAccount()If Not Account.LoadPk(finBL.Database.GetFieldInteger(dr!Pk)) ThenSuccess = FalseExit DoEnd If' Get Document Recipient Details for relevant Account ClientsIf Not mDocument.GetAccountDocumentRecipientDetailsItems(Account, dis, Nothing, parameters) ThenSuccess = FalseExit DoEnd If' Create Document' NOTE: Will also create and return an Account Log if neccessaryIf CreateAccountDocument(dis, Nothing, 0, AccountLog) Then' Record Account Log so it can be updated with the Bulk Document File Name laterIf AccountLog IsNot Nothing ThenAccountLogPks.Add(AccountLog.Pk)End If' Remove entries for Emailed Documents so they are not included in the Bulk Document since this would typically be used to Print Document that were not EmailedIf CreateBulkDocument ThenFor Each di In disIf di.EmailDetails.EmailSent Then' Remove Word Document so it is not included in the Bulk DocumentmWordDocuments.Remove(di.WordDocument)' Remove Log so it is not updated to refer to the Bulk DocumentIf AccountLog IsNot Nothing ThenAccountLogPks.Remove(AccountLog.Pk)End IfEnd IfNextEnd IfElseSuccess = FalseExit DoEnd IfLoopfinBL.Database.DataReaderClose(dr)ElseSuccess = FalseEnd If' Save Bulk DocumentIf Success AndAlso CreateBulkDocument AndAlso mWordDocuments.Count <> 0 Then' Save DocumentIf finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccount("", mWordDocuments, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenmBulkDocumentFileName = DocumentManagerFileNameElseSuccess = FalseEnd If' Update Account Logs to refer to Bulk Document (if not creating individual Documents)If Success AndAlso Not CreateIndividualDocuments ThenFor Each AccountLogPk In AccountLogPksWith AccountLogIf .Load(AccountLogPk) Then.DocumentFileName = DocumentManagerFileNameRelativeIf Not .Save() Then' Ignore ErrorsEnd IfElse' Ignore ErrorsEnd IfEnd WithNextEnd IfEnd IfEnd IfReturn SuccessEnd Function'#################################################################' Create Document for relevant Account Clients'#################################################################Private Function CreateAccountDocument(dis As finDocumentRecipientDetailsItems,logPublishBatchItem As finLogPublishBatchItem,parentLogPk As Integer,ByRef accountLog As finAccountLog) As BooleanDim di As finDocumentRecipientDetailsItemDim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim DocumentBinaryData As Byte()Dim Success As Boolean' Assume SuccessSuccess = True' InitialisemWordDocumentsAccount.Clear()' Create Document for all relevant Account ClientsFor Each di In dis' Create DocumentIf Not CreateDocument(di) ThenSuccess = FalseExit ForEnd IfNext' Standalone Publish functionalityIf Success ThenIf logPublishBatchItem Is Nothing Then' Embed in Log?If mDocument.EmbedDocumentInLog ThenSuccess = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccount, DocumentBinaryData)End If' Save Individual Document for this Account?If Success AndAlso CreateIndividualDocuments ThenSuccess = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccount(dis(0).AccountId, mWordDocumentsAccount, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)End If' Create LogIf Success AndAlso mDocument.CreateLog ThenIf finBL.AccountFunctions.LogAddDocument(dis(0).Account.Pk, mDocument.DocumentId, accountLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData) Then' Ensure any Email Logs are linked to this new LogparentLogPk = AccountLog.PkElseSuccess = FalseEnd IfEnd IfEnd IfEnd If' Save Combined Document to Document Manager?' NOTE: This is for ALL Account Clients, regardless of whether individual documents will be saved for each Account ClientIf Success AndAlso mDocument.AutoSaveDocument ThenIf logPublishBatchItem IsNot Nothing OrElse mWordDocumentsAccount.Count > 1 ThenSuccess = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccount(di.AccountId, mWordDocumentsAccount, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)End IfEnd If' Embed Combined Document in Log?' NOTE: This is for ALL Account Clients, regardless of whether individual documents will be saved for each Account ClientIf Success AndAlso mDocument.EmbedDocumentInLog ThenSuccess = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccount, DocumentBinaryData)End If' Email Account Clients?' NOTE: This will create additional Account Logs (for each Account Client) where neccessaryIf Success AndAlso dis(0).EmailDetails.PublishEmail ThenSuccess = dis.SendAccountEmailsPdf(parentLogPk)End If' Update Log Publish detailsIf logPublishBatchItem IsNot Nothing ThenWith logPublishBatchItemIf Success Then' Success.PublishSuccess = True.PublishDocumentFileName = DocumentManagerFileNameRelative.PublishDocumentBinaryDataFileType = isefinLogEmbeddedFileType.Pdf.PublishDocumentBinaryData = DocumentBinaryData.PrintStatus = dis(0).PrintStatusElse' Failure.PublishSuccess = False.PublishError = finBL.Error.Message(True, True)End IfEnd WithEnd IfReturn SuccessEnd Function
The updated Script code for Account Application Documents is shown below:
'#################################################################' Publish Standalone (Ad-Hoc)'#################################################################Private Function Publish_Standalone(parameters As ISKeyValueList) As BooleanDim AccountApp As finAccountAppDim AccountAppLog As finAccountAppLogDim AccountAppLogPk As IntegerDim AccountAppLogPks As List(Of Integer)Dim di As finDocumentRecipientDetailsItemDim dis As finDocumentRecipientDetailsItemsDim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim dr As IDataReaderDim sqb As ISSelectQueryBuilderDim Success As Boolean' Assume SuccessSuccess = True' ValidateIf Success Then' Create ObjectsAccountAppLogPks = New List(Of Integer)' Create Query (can use DocumentFunctions since we are using Standard Parameters)sqb = finBL.DocumentFunctions.GetAccountAppSqlSelectQueryBuilder(parameters)' Execute QueryIf sqb.ExecuteDataReader(dr) ThenDo While dr.Read()' Load Account ApplicationAccountApp = finBL.CreateAccountApp()If Not AccountApp.LoadPk(finBL.Database.GetFieldInteger(dr!Pk)) ThenSuccess = FalseExit DoEnd If' Get Document Recipient Details for relevant ApplicantsIf Not mDocument.GetAccountAppDocumentRecipientDetailsItems(AccountApp, dis, Nothing, parameters) ThenSuccess = FalseExit DoEnd If' Create Document' NOTE: Will also create and return an Account Application Log if neccessaryIf CreateAccountAppDocument(dis, Nothing, 0, AccountAppLog) Then' Record Account Application Log so it can be updated with the Bulk Document File Name laterIf AccountAppLog IsNot Nothing ThenAccountAppLogPks.Add(AccountAppLog.Pk)End If' Remove entries for Emailed Documents so they are not included in the Bulk Document since this would typically be used to Print Document that were not EmailedIf CreateBulkDocument ThenFor Each di In disIf di.EmailDetails.EmailSent Then' Remove Word Document so it is not included in the Bulk DocumentmWordDocuments.Remove(di.WordDocument)' Remove Log so it is not updated to refer to the Bulk DocumentIf AccountAppLog IsNot Nothing ThenAccountAppLogPks.Remove(AccountAppLog.Pk)End IfEnd IfNextEnd IfElseSuccess = FalseExit DoEnd IfLoopfinBL.Database.DataReaderClose(dr)ElseSuccess = FalseEnd If' Save Bulk DocumentIf Success AndAlso CreateBulkDocument AndAlso mWordDocuments.Count <> 0 Then' Save DocumentIf mWordDocuments.Count = 0 Then' No Documents created, e.g., no Used ApplicantsElseIf finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp("", mWordDocuments, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenmBulkDocumentFileName = DocumentManagerFileNameElseSuccess = FalseEnd IfEnd If' Update Account Application Logs to refer to Bulk Document (if not creating individual Documents)If Success AndAlso Not CreateIndividualDocuments ThenFor Each AccountAppLogPk In AccountAppLogPksWith AccountAppLogIf .Load(AccountAppLogPk) Then.DocumentFileName = DocumentManagerFileNameRelativeIf Not .Save() Then' Ignore ErrorsEnd IfElse' Ignore ErrorsEnd IfEnd WithNextEnd IfEnd IfEnd IfReturn SuccessEnd Function'#################################################################' Create Document for relevant Account Application Applicants'#################################################################Private Function CreateAccountAppDocument(dis As finDocumentRecipientDetailsItems,logPublishBatchItem As finLogPublishBatchItem,parentLogPk As Integer,ByRef accountAppLog As finAccountAppLog) As BooleanDim di As finDocumentRecipientDetailsItemDim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim DocumentBinaryData As Byte()Dim Success As Boolean' Assume SuccessSuccess = True' InitialisemWordDocumentsAccountApp.Clear()If dis.Count = 0 Then' No Included Applicants' NOTE: This is perfectly legitimate for Account ApplicationsElse' Create Document for all relevant ApplicantsFor Each di In dis' Create DocumentIf Not CreateDocument(di) ThenSuccess = FalseExit ForEnd IfNext' Standalone Publish functionalityIf Success ThenIf logPublishBatchItem Is Nothing Then' Embed in Log?If mDocument.EmbedDocumentInLog ThenSuccess = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccountApp, DocumentBinaryData)End If' Save Individual Document for this Account Application?If Success AndAlso CreateIndividualDocuments ThenSuccess = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp(dis(0).AccountAppId, mWordDocumentsAccountApp, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)End If' Create LogIf Success AndAlso mDocument.CreateLog ThenIf finBL.AccountAppFunctions.LogAddDocument(dis(0).AccountApp.Pk, dis(0).AccountAppApplicant.Pk, mDocument.DocumentId, accountAppLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData) Then' Ensure any Email Logs are linked to this new LogparentLogPk = accountAppLog.PkElseSuccess = FalseEnd IfEnd IfEnd IfEnd If' Save Combined Document to Document Manager?' NOTE: This is for ALL Account Application Applicants, regardless of whether individual documents will be saved for each ApplicantIf Success AndAlso mDocument.AutoSaveDocument ThenIf logPublishBatchItem IsNot Nothing OrElse mWordDocumentsAccountApp.Count > 1 ThenSuccess = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp(di.AccountAppId, mWordDocumentsAccountApp, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)End IfEnd If' Embed Combined Document in Log?' NOTE: This is for ALL Account Application Applicants, regardless of whether individual documents will be saved for each ApplicantIf Success AndAlso mDocument.EmbedDocumentInLog ThenSuccess = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccountApp, DocumentBinaryData)End If' Email Applicants?' NOTE: This will create additional Account Application Logs (for each Applicant) where neccessaryIf Success AndAlso dis(0).EmailDetails.PublishEmail ThenSuccess = dis.SendAccountAppEmailsPdf(parentLogPk)End IfEnd If' Update Log Publish detailsIf logPublishBatchItem IsNot Nothing ThenWith logPublishBatchItemIf Success Then' Success.PublishSuccess = True.PublishDocumentFileName = DocumentManagerFileNameRelative.PublishDocumentBinaryDataFileType = isefinLogEmbeddedFileType.Pdf.PublishDocumentBinaryData = DocumentBinaryDataIf dis.Count <> 0 Then .PrintStatus = dis(0).PrintStatusElse' Failure.PublishSuccess = False.PublishError = finBL.Error.Message(True, True)End IfEnd WithEnd IfReturn SuccessEnd Function
The updated Script code for Client Documents is shown below:
'#################################################################' Publish Standalone (Ad-Hoc)'#################################################################Private Function Publish_Standalone(parameters As ISKeyValueList) As BooleanDim Client As finClientDim ClientLog As finClientLogDim ClientLogPk As IntegerDim ClientLogPks As List(Of Integer)Dim di As finDocumentRecipientDetailsItemDim DocumentBinaryData As Byte()Dim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim dr As IDataReaderDim sqb As ISSelectQueryBuilderDim Success As Boolean' Assume SuccessSuccess = True' ValidateIf Success Then' Create ObjectsClient = finBL.CreateClient()ClientLogPks = New List(Of Integer)' Create Query (can use DocumentFunctions since we are using Standard Parameters)sqb = finBL.DocumentFunctions.GetClientSqlSelectQueryBuilder(parameters)' Execute QueryIf sqb.ExecuteDataReader(dr) ThenDo While dr.Read()' Load ClientIf Not Client.LoadPk(finBL.Database.GetFieldInteger(dr!Pk)) ThenSuccess = FalseExit DoEnd If' Get Document Recipient Details for ClientIf Not mDocument.GetClientDocumentRecipientDetailsItem(Client, di, Nothing, parameters) ThenSuccess = FalseExit DoEnd If' Create DocumentIf Not CreateDocument(di) ThenSuccess = FalseExit DoEnd If' Save Individual Document for this ClientIf CreateIndividualDocuments ThenIf Not finBL.DocumentManagerFunctions.SaveWordDocumentToDocumentManagerPdfClient(di.ClientId, di.WordDocument, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenSuccess = FalseExit DoEnd IfEnd If' Create Client Log?If mDocument.CreateLog Then' Embed in Log?If mDocument.EmbedDocumentInLog ThenIf Not di.WordDocument.SavePdfToByteArray(DocumentBinaryData) ThenSuccess = FalseExit DoEnd IfEnd If' Add Client LogIf finBL.ClientFunctions.LogAddDocument(Client.Pk, mDocument.DocumentId, ClientLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData, Not di.EmailDetails.EmailSent) Then' Record Client Log so it can be updated with the Bulk Document File Name laterIf CreateBulkDocument ThenClientLogPks.Add(ClientLog.Pk)End If' Remove entries for Emailed Documents so they are not included in the Bulk Document since this would typically be used to Print Document that were not EmailedIf CreateBulkDocument ThenIf di.EmailDetails.EmailSent Then' Remove Word Document so it is not included in the Bulk DocumentmWordDocuments.Remove(di.WordDocument)' Remove Log so it is not updated to refer to the Bulk DocumentIf ClientLog IsNot Nothing ThenClientLogPks.Remove(ClientLog.Pk)End IfEnd IfEnd If' Record Email detailsIf di.EmailDetails.EmailSent ThenIf Not di.EmailDetails.ClientLogUpdateForEmailSend(ClientLog.Pk) Then' Ignore ErrorsEnd IfEnd IfElseSuccess = FalseExit DoEnd IfEnd IfLoopfinBL.Database.DataReaderClose(dr)ElseSuccess = FalseEnd If' Save Bulk DocumentIf Success AndAlso CreateBulkDocument AndAlso mWordDocuments.Count <> 0 Then' Save DocumentIf finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfClient("", mWordDocuments, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenmBulkDocumentFileName = DocumentManagerFileNameElseSuccess = FalseEnd If' Update Client Logs to refer to Bulk Document (if not creating individual Documents)If Success AndAlso Not CreateIndividualDocuments ThenFor Each ClientLogPk In ClientLogPksWith ClientLogIf .Load(ClientLogPk) Then.DocumentFileName = DocumentManagerFileNameRelativeIf Not .Save() Then' Ignore ErrorsEnd IfElse' Ignore ErrorsEnd IfEnd WithNextEnd IfEnd IfEnd IfReturn SuccessEnd Function
The updated Script code for User Documents is shown below:
'#################################################################' Publish Standalone (Ad-Hoc)'#################################################################Private Function Publish_Standalone(parameters As ISKeyValueList) As BooleanDim User As finUserDim UserLog As finUserLogDim UserLogPk As IntegerDim UserLogPks As List(Of Integer)Dim di As finDocumentRecipientDetailsItemDim DocumentBinaryData As Byte()Dim DocumentManagerFileName As StringDim DocumentManagerFileNameRelative As StringDim dr As IDataReaderDim sqb As ISSelectQueryBuilderDim Success As Boolean' Assume SuccessSuccess = True' ValidateIf Success Then' Create ObjectsUser = finBL.CreateUser()UserLogPks = New List(Of Integer)' Create Query (can use DocumentFunctions since we are using Standard Parameters)sqb = finBL.DocumentFunctions.GetUserSqlSelectQueryBuilder(parameters)' Execute QueryIf sqb.ExecuteDataReader(dr) ThenDo While dr.Read()' Load UserIf Not User.LoadPk(finBL.Database.GetFieldInteger(dr!Pk)) ThenSuccess = FalseExit DoEnd If' Get Document Recipient Details for UserIf Not mDocument.GetUserDocumentRecipientDetailsItem(User, di, Nothing, parameters) ThenSuccess = FalseExit DoEnd If' Create DocumentIf Not CreateDocument(di) ThenSuccess = FalseExit DoEnd If' Save Individual Document for this UserIf CreateIndividualDocuments ThenIf Not finBL.DocumentManagerFunctions.SaveWordDocumentToDocumentManagerPdfUser(di.UserId, di.WordDocument, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenSuccess = FalseExit DoEnd IfEnd If' Create User Log?If mDocument.CreateLog Then' Embed in Log?If mDocument.EmbedDocumentInLog ThenIf Not di.WordDocument.SavePdfToByteArray(DocumentBinaryData) ThenSuccess = FalseExit DoEnd IfEnd If' Add User LogIf finBL.UserFunctions.LogAddDocument(User.Pk, mDocument.DocumentId, UserLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData, Not di.EmailDetails.EmailSent) Then' Record User Log so it can be updated with the Bulk Document File Name laterIf CreateBulkDocument ThenUserLogPks.Add(UserLog.Pk)End If' Remove entries for Emailed Documents so they are not included in the Bulk Document since this would typically be used to Print Document that were not EmailedIf CreateBulkDocument ThenIf di.EmailDetails.EmailSent Then' Remove Word Document so it is not included in the Bulk DocumentmWordDocuments.Remove(di.WordDocument)' Remove Log so it is not updated to refer to the Bulk DocumentIf UserLog IsNot Nothing ThenUserLogPks.Remove(UserLog.Pk)End IfEnd IfEnd If' Record Email detailsIf di.EmailDetails.EmailSent ThenIf Not di.EmailDetails.UserLogUpdateForEmailSend(UserLog.Pk) Then' Ignore ErrorsEnd IfEnd IfElseSuccess = FalseExit DoEnd IfEnd IfLoopfinBL.Database.DataReaderClose(dr)ElseSuccess = FalseEnd If' Save Bulk DocumentIf Success AndAlso CreateBulkDocument AndAlso mWordDocuments.Count <> 0 Then' Save DocumentIf finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfUser("", mWordDocuments, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) ThenmBulkDocumentFileName = DocumentManagerFileNameElseSuccess = FalseEnd If' Update User Logs to refer to Bulk Document (if not creating individual Documents)If Success AndAlso Not CreateIndividualDocuments ThenFor Each UserLogPk In UserLogPksWith UserLogIf .Load(UserLogPk) Then.DocumentFileName = DocumentManagerFileNameRelativeIf Not .Save() Then' Ignore ErrorsEnd IfElse' Ignore ErrorsEnd IfEnd WithNextEnd IfEnd IfEnd IfReturn SuccessEnd Function