diff --git a/package-lock.json b/package-lock.json index 7a704148..db1cf74d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "quoting-service", - "version": "10.5.4", + "version": "10.5.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fa179dd2..7f0b6d61 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/data/database.js b/src/data/database.js index c7d04082..1bb32b1b 100644 --- a/src/data/database.js +++ b/src/data/database.js @@ -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') @@ -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 @@ -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) ]) diff --git a/test/unit/data/database.test.js b/test/unit/data/database.test.js index b7af2e36..0422fae6 100644 --- a/test/unit/data/database.test.js +++ b/test/unit/data/database.test.js @@ -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) })