Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-schumann/66f8529fc447146a88d5ccc995252b09 to your computer and use it in GitHub Desktop.
Save j-schumann/66f8529fc447146a88d5ccc995252b09 to your computer and use it in GitHub Desktop.
Cyclos test: retrieve balances & trasnfers for account
import org.cyclos.model.banking.accounts.AccountBalanceHistoryParams
import org.cyclos.model.banking.accounts.AccountHistoryQuery
import org.cyclos.model.banking.accounts.AccountVO
import org.cyclos.model.users.users.UserVO
import org.cyclos.model.utils.DatePeriodDTO
import org.cyclos.utils.DateTime
def begin = new DateTime(2020, 3, 1)
def end = new DateTime(2020, 5, 1)
def month = new DatePeriodDTO(begin: begin , end: end)
def abhp = new AccountBalanceHistoryParams(period: [begin: begin, end: end], account: new AccountVO(account.id))
def a = accountService.getAccountBalanceHistory(abhp)
println('balances:')
a.balances.each {
println(it.date.toString() +" - " + it.amount.toString())
}
println()
def ahq = new AccountHistoryQuery(account: [account.id], period: month)
def b = accountService.searchAccountHistory(ahq)
println('transfers:')
b.each {
println(it.date.toString() +" - " + it.amount.toString() + " ("
+ it.relatedAccount.id + ")")
}
println()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment