Skip to content

Commit

Permalink
Bugfix/fix participant lookup to use currency (#230)
Browse files Browse the repository at this point in the history
* updated to newly released version of event-sdk

* updated dependencies and version

* fix for accept header and content-type header versions being hardcoded

* updated participant lookup to validate against the participant and participant currency table to validate that the participant is active as well as their currency account

* updated the order the sql is run in, seems to give and issue during testing
  • Loading branch information
rmothilal authored Jul 2, 2020
1 parent 63b4a36 commit 5442493
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions 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.3",
"version": "10.5.4",
"author": "ModusBox",
"contributors": [
"James Bush <james.bush@modusbox.com>",
Expand Down Expand Up @@ -62,7 +62,7 @@
"@hapi/hapi": "19.1.1",
"@mojaloop/central-services-error-handling": "10.4.1",
"@mojaloop/central-services-logger": "10.4.0",
"@mojaloop/central-services-shared": "10.5.2",
"@mojaloop/central-services-shared": "10.5.3",
"@mojaloop/event-sdk": "10.4.0",
"@mojaloop/ml-number": "8.2.0",
"@mojaloop/sdk-standard-components": "10.3.2",
Expand Down
2 changes: 1 addition & 1 deletion src/data/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ class Database {
async getParticipant (participantName, participantType, currencyId, ledgerAccountTypeId) {
try {
const rows = await this.queryBuilder('participant')
.innerJoin('participantCurrency AS pc', 'pc.participantId', 'participant.participantId')
.where({ 'participant.name': participantName })
.andWhere({ 'pc.currencyId': currencyId })
.andWhere({ 'pc.ledgerAccountTypeId': ledgerAccountTypeId })
.andWhere({ 'pc.isActive': true })
.andWhere({ 'participant.isActive': true })
.innerJoin('participantCurrency AS pc', 'pc.participantId', 'participant.participantId')
.select(
'participant.*',
'pc.participantCurrencyId',
Expand Down
10 changes: 5 additions & 5 deletions test/unit/data/database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ describe('/database', () => {
const mockList = mockKnexBuilder(
mockKnex,
[{ participantId: 123 }],
['where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'innerJoin', 'select']
['innerJoin', 'where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'select']
)

// Act
Expand All @@ -801,7 +801,7 @@ describe('/database', () => {
// Assert
expect(result).toBe(123)
expect(mockList[0]).toHaveBeenCalledWith('participant')
expect(mockList[1]).toHaveBeenCalledWith({ 'participant.name': participantName })
expect(mockList[1]).toHaveBeenCalledWith('participantCurrency AS pc', 'pc.participantId', 'participant.participantId')
expect(mockList[2]).toHaveBeenCalledTimes(1)
})

Expand All @@ -814,7 +814,7 @@ describe('/database', () => {
mockKnexBuilder(
mockKnex,
undefined,
['where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'innerJoin', 'select']
['innerJoin', 'where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'select']
)

// Act
Expand All @@ -833,7 +833,7 @@ describe('/database', () => {
mockKnexBuilder(
mockKnex,
undefined,
['where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'innerJoin', 'select']
['innerJoin', 'where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'select']
)

// Act
Expand All @@ -851,7 +851,7 @@ describe('/database', () => {
mockKnexBuilder(
mockKnex,
[],
['where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'innerJoin', 'select']
['innerJoin', 'where', 'andWhere', 'andWhere', 'andWhere', 'andWhere', 'select']
)

// Act
Expand Down

0 comments on commit 5442493

Please sign in to comment.