-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetching the charge versions data (#15)
https://eaflood.atlassian.net/jira/software/c/projects/WATER/boards/96?modal=detail&selectedIssue=WATER-3787 Here we are fetching the charge versions data from our database.
- Loading branch information
1 parent
50bfd1d
commit 3e339ba
Showing
6 changed files
with
95 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
'use strict' | ||
|
||
const TestSupplementaryService = require('../../services/test/supplementary.service.js') | ||
const SupplementaryService = require('../../services/test/supplementary.service.js') | ||
|
||
class TestSupplementaryController { | ||
class SupplementaryController { | ||
static async index (_request, h) { | ||
const result = await TestSupplementaryService.go() | ||
const result = await SupplementaryService.go() | ||
|
||
return h.response(result).code(200) | ||
} | ||
} | ||
|
||
module.exports = TestSupplementaryController | ||
module.exports = SupplementaryController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,35 @@ | ||
'use strict' | ||
|
||
/** | ||
* @module TestSupplementaryService | ||
* @module SupplementaryService | ||
*/ | ||
|
||
const { db } = require('../../../db/db') | ||
|
||
/** | ||
* Returns charge versions selected for supplementary billing | ||
* At present this returns a set response until further development | ||
*/ | ||
class TestSupplementaryService { | ||
|
||
// Format into the response and return the data | ||
class SupplementaryService { | ||
static async go () { | ||
const chargeVersions = await this._fetchChargeVersions() | ||
const response = { | ||
chargeVersions: [ | ||
{ id: '986d5b14-8686-429e-9ae7-1164c1300f8d', licenceRef: 'AT/SROC/SUPB/01' }, | ||
{ id: 'ca0e4a77-bb13-4eef-a1a1-2ccf9e302cc4', licenceRef: 'AT/SROC/SUPB/03' } | ||
] | ||
chargeVersions | ||
} | ||
|
||
return response | ||
} | ||
|
||
static async _fetchChargeVersions () { | ||
const chargeVersions = db.table('water.charge_versions') | ||
.where('scheme', 'sroc') | ||
.select('chargeVersionId') | ||
.select('licenceRef') | ||
|
||
return chargeVersions | ||
} | ||
} | ||
|
||
module.exports = TestSupplementaryService | ||
module.exports = SupplementaryService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
|
||
/** | ||
* @module ChargeVersionHelper | ||
*/ | ||
|
||
const { db } = require('../../../db/db') | ||
|
||
class ChargeVersionHelper { | ||
static async add (data) { | ||
const result = await db.table('water.charge_versions') | ||
.insert(data) | ||
.returning('charge_version_id') | ||
|
||
return result | ||
} | ||
} | ||
|
||
module.exports = ChargeVersionHelper |