issue with an external BOI script to populate and post cash receipts entries

Hello all, 

I'm seeing an odd issue with an external BOI script to populate and post cash receipts entries.

The short story is that automatic posting results in a duplicate bank rec deposit entry and leaves an orphaned deposit record in AR_CashReceiptsDeposit after update.

Manual posting of the BOI populated CR entry works as expected.

I'm also noticing that the batch total is doubled, but that does not seem to affect anything as I've seen the same thing for VI imports of cash receipts. 

Any info or suggestions are much appreciated.  Please see code and notes below. 

Thanks,

Louis 

'''''''''''Code here to populate CR batch and deposit record and CR details


'if code is terminated here and Deposit CR entry records are reviewed they look normal and can be updated manually without any problem or issue


' if the following CR Posting code is run to automatically update the CR batch, the batch posts and AR, invoice history, open invoice etc. are updated as expected and GL is updated correctly when the DTR is posted via BOI or manually.


' HOWEVER, when CR is updated via BOI, the deposit is duplicated in BR_Transaction with two nearly identical records, identical amounts, timestamps etc.; only EntryNo is different.

' ALSO, when updated via BOI, the deposit record in  AR_CashReceiptsDeposit remains even though the records in  AR_CashReceiptsDetail,  AR_CashReceiptsDetail and GL_CompanyActiveBatch are cleared as expected.


' Again, if the code is terminated BEFORE CR update and the updated is done in the interface, there are no duplicate BR entries or orphaned deposit records.
 

''''''''''''Post the CR batch


If Not(IsObject(oGL_Source)) Then

  retVal = oSS.nSetDate("G/L", vModuleDate)

  retVal = oSS.nSetModule("G/L")

  retVal = oSS.nSetProgram(oSS.nLookupTask("GL_SourceJournal_UI"))

  Set oGL_Source = oPVX.NewObject("GL_SourceJournal_svc", oSS)

 

End if
 

retVal = oGL_Source.nFind("CR")

retVal = oGL_Source.nGetValue("NextRegisterNo$", RegNo)
 

CurReg = "CR" & RegNo & chr(13)


If Not(IsObject(oCRTran)) Then

  retVal = oSS.nSetDate("A/R", vModuleDate)

  retVal = oSS.nSetModule("A/R")

  retVal = oSS.nSetProgram(oSS.nLookupTask("AR_CashReceiptsJournal_ui"))

  Set oCRTran = oPVX.NewObject("AR_CashReceiptsJournal_upd", oSS)

                              

End If


retVal = oCRTran.nSelectBatch(vBatchNo)

retVal = oCRTran.nSetPostingDate(vModuleDate)

retVal = oCRTran.nProcessReport(vdestination)  'PRINT OR PREVIEW

retVal = oCRTran.nUpdate()

oCRTran.DropObject

 

''''''''''''  Post the Daily Transaction Register  ''''''''''''


' No problems with DTR update