Hello,
I'd like to retrieve transactions pending authorization so as to permit bulk authorization.
I do not seen to see anything in the class reference to permit retrieval of transactions pending authorization. Any one able to share any pointers?
For context I am able to list transactions that have already succeeded with the script below
import org.cyclos.model.banking.transactions.TransactionQuery
import org.cyclos.entities.banking.Transfer
def q = new TransactionQuery()
q.setUnlimited()
def transfers=transactionService.search(q)
for (transfer in transfers) {
println transfer.dump()
}
Script to retrieve transactions pending authorization
Moderators: alexandre, hugo, rmvanarkel
Re: Script to retrieve transactions pending authorization
All you need is to include the query. Find the below sample.
Code: Select all
import org.cyclos.model.banking.transactions.TransactionAuthorizationStatus
import org.cyclos.model.banking.transactions.TransactionQuery
def q = new TransactionQuery()
q.authorizationStatuses = [TransactionAuthorizationStatus.PENDING_AUTHORIZATION]
q.setUnlimited()
def transfers = transactionService.search(q)
for (transfer in transfers) {
println transfer.dump()
}Re: Script to retrieve transactions pending authorization
Thanks for your response Rajesh.
However this does not return anything (and I'm sure the user I'm running it as has has two transactions awaiting authorization). Transfers has zero items:
In the meantime I'm also looking at the service TransactionAuthorizationService that claims to:
Service interface for transaction authorizations.
It allow authorize, deny etc a transaction and search for transactions to authorize and already authorized.
Although its implementation does not seem to include any search function as per this link: https://documentation.cyclos.org/4.15.6/scripting-api-docs/org/cyclos/impl/banking/TransactionAuthorizationServiceImpl.html
Will keep on trying various things till I crack it.
However this does not return anything (and I'm sure the user I'm running it as has has two transactions awaiting authorization). Transfers has zero items:
Code: Select all
<org.cyclos.utils.PageImpl@72709060 pageItems=[] currentPage=0 pageSize=1000 totalCount=0 hasNextPage=false>Service interface for transaction authorizations.
It allow authorize, deny etc a transaction and search for transactions to authorize and already authorized.
Although its implementation does not seem to include any search function as per this link: https://documentation.cyclos.org/4.15.6/scripting-api-docs/org/cyclos/impl/banking/TransactionAuthorizationServiceImpl.html
Will keep on trying various things till I crack it.
Re: Script to retrieve transactions pending authorization
I have given the script after verification, am not sure why is not returning any rows to you.
Please note that transfers will be created only after (all) transaction authorizations. So, you will have to use TransacactionService, may be you shall try with TransactionOverviewQuery at your end.
Please note that transfers will be created only after (all) transaction authorizations. So, you will have to use TransacactionService, may be you shall try with TransactionOverviewQuery at your end.
Re: Script to retrieve transactions pending authorization
Hi mcash.
The javadoc of the service is outdated, since 4.14, when we merged the transaction authorization search with the transaction search itself.
rajesh's answer uses a search with the point-of-view of an account owner, ie, transactions with positive / negative amounts are returned.
You could try, instead, this script for searching a transaction overview, in which each result has a from and to (and always positive amount), instead of a related account. Also, I've modified it a bit in order to iterate, so, if you have too many, it won't load thousands of entries in memory. Finally, I've included an example on how to authorize them all at once.
The javadoc of the service is outdated, since 4.14, when we merged the transaction authorization search with the transaction search itself.
rajesh's answer uses a search with the point-of-view of an account owner, ie, transactions with positive / negative amounts are returned.
You could try, instead, this script for searching a transaction overview, in which each result has a from and to (and always positive amount), instead of a related account. Also, I've modified it a bit in order to iterate, so, if you have too many, it won't load thousands of entries in memory. Finally, I've included an example on how to authorize them all at once.
Code: Select all
import org.cyclos.model.banking.authorizations.TransactionAuthorizationDTO
import org.cyclos.model.banking.transactions.TransactionAuthorizationStatus
import org.cyclos.model.banking.transactions.TransactionOverviewQuery
import org.cyclos.model.banking.transactions.TransactionVO
def affected = 0
def q = new TransactionOverviewQuery()
q.authorizationStatuses = [TransactionAuthorizationStatus.PENDING_AUTHORIZATION]
def transactions = transactionSearchHandler.iterateEntities(q)
scriptHelper.processBatch(transactions) { transaction ->
transactionAuthorizationService.authorize(new TransactionAuthorizationDTO(
transaction: new TransactionVO(transaction.id)
))
affected++
}
return "Authorized $affected pending transactions"Luis Fernando Planella Gonzalez
Cyclos development team
Cyclos development team
Re: Script to retrieve transactions pending authorization
Thanks a lot Luis.
This works perfectly
This works perfectly