Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTC-643 using api to create settlement models #318

Open
wants to merge 1 commit into
base: feature/OTC
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/integration/helpers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const axios = require('axios')
const Utils = require('./utils')
const Logger = require('@mojaloop/central-services-logger')

async function createSettlementModel (settlementModel) {
const url = `${Config.CENTRAL_LEDGER_URL}/settlementModels`
return axios.post(url, settlementModel)
}


async function getParticipantAccount (currency) {
const url = `${Config.CENTRAL_LEDGER_URL}/participants/Hub/accounts?currency=${currency}`
const res = await axios.get(url)
Expand Down Expand Up @@ -137,6 +143,7 @@ module.exports = {
addParticipantEndpoint,
createNetDebitCapInitialPositionAndLimit,
createParticipantAccount,
createSettlementModel,
getParticipantAccount,
sendTransfer,
waitForTransferToBeCommited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,33 @@ const currencies = ['USD', 'TZS']

const settlementModels = [
{
name: 'DEFERRED_NET',
settlementGranularityId: 2, // NET
settlementInterchangeId: 2, // MULTILATERAL
settlementDelayId: 2, // DEFERRED
ledgerAccountTypeId: 1, // POSITION
name: 'DEFERREDNET',
settlementGranularity: 'NET', // NET
settlementInterchange: 'MULTILATERAL', // MULTILATERAL
settlementDelay: 'DEFERRED', // DEFERRED
ledgerAccountType: 'POSITION', // POSITION
autoPositionReset: true,
currencyId: null
requireLiquidityCheck: true,
},
{
name: 'DEFERRED_NET_USD',
settlementGranularityId: 2, // NET
settlementInterchangeId: 2, // MULTILATERAL
settlementDelayId: 2, // DEFERRED
ledgerAccountTypeId: 1, // POSITION
name: 'DEFERREDNETUSD',
settlementGranularity: 'NET', // NET
settlementInterchange: 'MULTILATERAL', // MULTILATERAL
settlementDelay: 'DEFERRED', // DEFERRED
ledgerAccountType: 'POSITION', // POSITION
autoPositionReset: true,
currencyId: 'USD'
currency: 'USD',
requireLiquidityCheck: true,
},
{
name: 'CONTINUALGROSSUSD',
settlementGranularity: 'GROSS', // NET
settlementInterchange: 'BILATERAL', // MULTILATERAL
settlementDelay: 'IMMEDIATE', // DEFERRED
ledgerAccountType: 'POSITION', // POSITION
autoPositionReset: true,
currency: 'USD',
requireLiquidityCheck: true
}
]

Expand Down Expand Up @@ -105,7 +116,8 @@ async function init () {
Logger.info('Initializing transfers')
await initTransfers()
} catch (err) {
Logger.error(`Error setting up initial settlement data ${err}`)
Logger.error(`Error setting up initial scenario data ${err}`)
process.exit(1)
}
}

Expand All @@ -118,7 +130,9 @@ async function initSettlementModels () {
await knex.raw('SET FOREIGN_KEY_CHECKS = 0;')
await Db.settlementModel.truncate()
await knex.raw('SET FOREIGN_KEY_CHECKS = 1;')
await knex.batchInsert('settlementModel', settlementModels)
await Api.createSettlementModel(settlementModels[0])
await Api.createSettlementModel(settlementModels[1])
await Api.createSettlementModel(settlementModels[2])
}

/**
Expand Down