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

Bugfix/fix participant lookup to use currency #231

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6510e54
updated to newly released version of event-sdk
rmothilal Mar 2, 2020
680f0fd
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Mar 2, 2020
c0b645b
updated dependencies and version
rmothilal Mar 2, 2020
5aa9b6b
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Mar 3, 2020
7939283
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Mar 17, 2020
308babe
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Mar 19, 2020
a2f221c
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal May 29, 2020
d583ced
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Jun 8, 2020
52a7c31
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Jun 30, 2020
3cf3910
Merge branch 'master' of https://github.com/mojaloop/quoting-service
rmothilal Jul 1, 2020
b9fd596
fix for accept header and content-type header versions being hardcoded
rmothilal Jul 2, 2020
c4e08b1
updated participant lookup to validate against the participant and pa…
rmothilal Jul 2, 2020
573b40e
Merge branch 'master' of https://github.com/mojaloop/quoting-service …
rmothilal Jul 2, 2020
aed1b25
Merge branch 'master' of https://github.com/mojaloop/quoting-service …
rmothilal Jul 2, 2020
516b4ea
updated the order the sql is run in, seems to give and issue during t…
rmothilal Jul 2, 2020
5f83ecc
Merge branch 'master' of https://github.com/mojaloop/quoting-service …
rmothilal Jul 2, 2020
b8ad943
fix for createPartyQuote not passing all values to getParticipant
rmothilal Jul 2, 2020
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "quoting-service",
"description": "Quoting Service hosted by a scheme",
"license": "Apache-2.0",
"version": "10.5.4",
"version": "10.5.5",
"author": "ModusBox",
"contributors": [
"James Bush <james.bush@modusbox.com>",
Expand Down
17 changes: 9 additions & 8 deletions src/data/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const util = require('util')
const Logger = require('@mojaloop/central-services-logger')
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const MLNumber = require('@mojaloop/ml-number')
const Enum = require('@mojaloop/central-services-shared').Enum

const LOCAL_ENUM = require('../lib/enum')
const { getStackOrInspect } = require('../lib/util')
Expand Down Expand Up @@ -341,19 +342,19 @@ class Database {
*
* @returns {promise} - id of the participant
*/
async getParticipant (participantName, participantType, currencyId, ledgerAccountTypeId) {
async getParticipant (participantName, participantType, currencyId, ledgerAccountTypeId = Enum.Accounts.LedgerAccountType.POSITION) {
try {
const rows = await this.queryBuilder('participant')
.innerJoin('participantCurrency AS pc', 'pc.participantId', 'participant.participantId')
.innerJoin('participantCurrency', 'participantCurrency.participantId', 'participant.participantId')
.where({ 'participant.name': participantName })
.andWhere({ 'pc.currencyId': currencyId })
.andWhere({ 'pc.ledgerAccountTypeId': ledgerAccountTypeId })
.andWhere({ 'pc.isActive': true })
.andWhere({ 'participantCurrency.currencyId': currencyId })
.andWhere({ 'participantCurrency.ledgerAccountTypeId': ledgerAccountTypeId })
.andWhere({ 'participantCurrency.isActive': true })
.andWhere({ 'participant.isActive': true })
.select(
'participant.*',
'pc.participantCurrencyId',
'pc.currencyId'
'participantCurrency.participantCurrencyId',
'participantCurrency.currencyId'
)
if ((!rows) || rows.length < 1) {
// active participant does not exist, this is an error
Expand Down Expand Up @@ -458,7 +459,7 @@ class Database {
const enumVals = await Promise.all([
this.getPartyType(partyType),
this.getPartyIdentifierType(party.partyIdInfo.partyIdType),
this.getParticipant(party.partyIdInfo.fspId),
this.getParticipant(party.partyIdInfo.fspId, participantType, currency),
this.getTransferParticipantRoleType(participantType),
this.getLedgerEntryType(ledgerEntryType)
])
Expand Down
2 changes: 1 addition & 1 deletion test/unit/data/database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ describe('/database', () => {
// Assert
expect(result).toBe(123)
expect(mockList[0]).toHaveBeenCalledWith('participant')
expect(mockList[1]).toHaveBeenCalledWith('participantCurrency AS pc', 'pc.participantId', 'participant.participantId')
expect(mockList[1]).toHaveBeenCalledWith('participantCurrency', 'participantCurrency.participantId', 'participant.participantId')
expect(mockList[2]).toHaveBeenCalledTimes(1)
})

Expand Down