| InfoToday Tools for Visual Rams |
| Payments |
* First create a payment batch
loITRDS.oBatchLog.New()
loITRDS.oBatchLog.ADDFIELDVALUE("TYPE","PAYMENT")
loITRDS.oBatchLog.Save()
If loITRDS.oBatchlog.lError
* Handle error
EndIf
* Get the batch number
lcBatchNumber = loITRDS.oBatchLog.oData.Number
* Lock the batch
If not loITRDS.oBatchLog.LockBatch(lcBatchNumber)
* Handle error
EndIf
* Now go through the payments and save
Select "curPayments"
Go top
Scan
lcAccount = curPayments.Account
ldDate = Iif(Empty(curPayments.Date),Date(),curPayments.Date)
lcInvoice = curPayments.Invoice &&(note that if this is blank it will carry out the normal rules
&& to determine which invoice to post against or leave blank)
lnAmount = curPayments.Amount
lcPaymentServiceCode = "999900"
* Now place record
loITRDS.oBatch.New()
loITRDS.oBatch.addfieldvalue("ACCOUNT",lcAccount)
loITRDS.oBatch.addfieldvalue("UNITS",1)
loITRDS.oBatch.addfieldvalue("UNIT_AMOUNT",lnAmount)
loITRDS.oBatch.addfieldvalue("INVOICE",lcInvoice)
loITRDS.oBatch.addfieldvalue("CODE",lcPaymentServiceCode)
loITRDS.oBatch.addfieldvalue("DATE",ldDate)
loITRDS.oBatch.addfieldvalue("BATCH",lcBatchNumber)
* Once a batch is locked by the itrds you need to keep passing the lock code
loITRDS.oBatch.cBatchLockCode = loITRDS.oBatchLog.cBatchLockCode
llSuccess = loITRDS.oBatch.Save()
If NOT llSuccess
* Handle error. Don't forget to either delete or unlock the batch
Return .f.
EndIf
* Unlock Batch
If not loITRDS.oBatchLog.UnLockBatch(lcBatchNumber)
* Handle error
EndIf