DEPRECATED

This document contains ad hoc examples of manipulating TM accounts mainly for loan purposes.

How to get user’s accounts (including main account) in TM

There are several methods:

  • Use account-manager API

  • List loan accounts using poc-simulator.py. Grab the user id and list its accounts in TM Operations dashboard (see [OLD] Dev environment to get access to dev TM). You can see all the account postings for the account too.

PoC Simulator

This tool has been developed for PoC purposes and is able to list loan accounts, their parameters and send installment payments. The source code can be used to learn interactions with TM.

Location: SafiMono/services/loan-manager/tools/poc-simulator.py

poc-simulator.py list

Lists all present loan accounts in TM. The first column is the user id, the second one is the loan account id.

poc-simulator.py autodeduction

Gets outstanding payments for all loan accounts and emits postings to pay the outstanding payment from user’s main account.

poc-simulator.py installments [account_id]

Shows installment plan with associated payments for a selected loan account.

poc-simulator.py pay-installment [account_id]

Pay next unpaid installment in select loan account.

poc-simulator.py fix-parameters [account_id]

Example of reading loan account parameters, making change and storing back. Used for fix incorrectly stored smart contract parameters.

poc-simulator.py do-payment [account_from] [account_to] [amount]

Simple command allowing to transfer selected amount from one account to other. The account does not need to be loan.

Sending posting using TM Posting API

@KafkaClient
interface PostingApiProducer {
    @Topic("vault.core.postings.requests.v1")
    fun sendPosting(@KafkaKey id: String, data: ByteArray)
}

fun sendPosting() {
    val request = createPostingInstructionBatchRequest {
        requestId = UUID.randomUUID().toString()
        postingInstructionBatch = postingInstructionBatch {
            clientId = "AsyncCreatePostingInstructionBatch"
            clientBatchId = UUID.randomUUID().toString()
            postingInstructions += postingInstruction {
                clientTransactionId = UUID.randomUUID().toString()
                transfer = transfer {
                    amount = "100"
                    denomination = "PHP"
                    debtorTargetAccount = targetAccount {
                        accountId = "TEST_ASSET_INTERNAL_ACCOUNT"
                    }
                    creditorTargetAccount = targetAccount {
                        accountId = "9ee87e87-bd9f-81d1-0911-2cff5e29b18b"
                    }
                }
            }
        }
    }
    producer.sendPosting(request.postingInstructionBatch.clientBatchId, request.toByteArray())
}

Attachments: