-
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.
Persist match and allocate issues and status (#772)
https://eaflood.atlassian.net/browse/WATER-4378 During the refinement of future two-part tariff tickets, it was noted that the status of a licence could be changed by the user from a 'review' status to a 'ready' status. Before this was noted we were working out the licence status based on the issues the licence has with its returns and charge elements. This is done on every page where the licence status is being shown. Now that we know a status can be overwritten regardless of its issues, we now need to persist the licence status during the first time the engine works it out and show the persisted status instead of working it out each time. This will allow users to manually change the status. The same thing applies to the charge elements. The status of the element is determined by the issues on it. This status at the moment is worked out every time it is displayed on a page. We have since learnt through refinement that a user can allocate volumes on the element and this will change the status from 'review' to 'ready'. This is regardless of the issues that remain on a charge element. So with this new information, it has made it clear that we now need to persist the initial status of the charge element to allow this to be overwritten when needed. This opened up a lot of discussions about how we could refactor the review tables to work more effectively with how the two-part tariff engine works now. When we first built the tables we did so with the knowledge we had at the time. Now that we have worked on more tickets and started building actual pages we realised we could persist the data better. TLDR: Review tables updated to add status and issues
- Loading branch information
Showing
73 changed files
with
1,798 additions
and
2,110 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
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_charge_elements_returns | ||
* @module ReviewChargeElementReturnModel | ||
*/ | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewChargeElementReturnModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewChargeElementsReturns' | ||
} | ||
} | ||
|
||
module.exports = ReviewChargeElementReturnModel |
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,43 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_charge_elements | ||
* @module ReviewChargeElementModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewChargeElementModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewChargeElements' | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
reviewChargeReference: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: 'review-charge-reference.model', | ||
join: { | ||
from: 'reviewChargeElements.reviewChargeReferenceId', | ||
to: 'reviewChargeReferences.id' | ||
} | ||
}, | ||
reviewReturns: { | ||
relation: Model.ManyToManyRelation, | ||
modelClass: 'review-return.model', | ||
join: { | ||
from: 'reviewChargeElements.id', | ||
through: { | ||
from: 'reviewChargeElementsReturns.reviewChargeElementId', | ||
to: 'reviewChargeElementsReturns.reviewReturnId' | ||
}, | ||
to: 'reviewReturns.id' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = ReviewChargeElementModel |
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,39 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_charge_references | ||
* @module ReviewChargeReferenceModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewChargeReferenceModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewChargeReferences' | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
reviewChargeVersion: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: 'review-charge-version.model', | ||
join: { | ||
from: 'reviewChargeReferences.reviewChargeVersionId', | ||
to: 'reviewChargeVersions.id' | ||
} | ||
}, | ||
reviewChargeElements: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'review-charge-element.model', | ||
join: { | ||
from: 'reviewChargeReferences.id', | ||
to: 'reviewChargeElements.reviewChargeReferenceId' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = ReviewChargeReferenceModel |
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,39 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_charge_versions | ||
* @module ReviewChargeVersionModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewChargeVersionModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewChargeVersions' | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
reviewLicence: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: 'review-licence.model', | ||
join: { | ||
from: 'reviewChargeVersions.reviewLicenceId', | ||
to: 'reviewLicences.id' | ||
} | ||
}, | ||
reviewChargeReferences: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'review-charge-reference.model', | ||
join: { | ||
from: 'reviewChargeVersions.id', | ||
to: 'reviewChargeReferences.reviewChargeVersionId' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = ReviewChargeVersionModel |
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,47 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_licences | ||
* @module ReviewLicenceModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewLicenceModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewLicences' | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
licence: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: 'licence.model', | ||
join: { | ||
from: 'reviewLicences.licenceId', | ||
to: 'licences.id' | ||
} | ||
}, | ||
reviewChargeVersions: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'review-charge-version.model', | ||
join: { | ||
from: 'reviewLicences.id', | ||
to: 'reviewChargeVersions.reviewLicenceId' | ||
} | ||
}, | ||
reviewReturns: { | ||
relation: Model.HasManyRelation, | ||
modelClass: 'review-return.model', | ||
join: { | ||
from: 'reviewLicences.id', | ||
to: 'reviewReturns.reviewLicenceId' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = ReviewLicenceModel |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for review_returns | ||
* @module ReviewReturnModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class ReviewReturnModel extends BaseModel { | ||
static get tableName () { | ||
return 'reviewReturns' | ||
} | ||
|
||
// Defining which fields contain json allows us to insert an object without needing to stringify it first | ||
static get jsonAttributes () { | ||
return [ | ||
'purposes' | ||
] | ||
} | ||
|
||
static get relationMappings () { | ||
return { | ||
reviewLicence: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: 'review-licence.model', | ||
join: { | ||
from: 'reviewReturns.reviewLicenceId', | ||
to: 'reviewLicences.id' | ||
} | ||
}, | ||
reviewChargeElements: { | ||
relation: Model.ManyToManyRelation, | ||
modelClass: 'review-charge-element.model', | ||
join: { | ||
from: 'reviewReturns.id', | ||
through: { | ||
from: 'reviewChargeElementsReturns.reviewReturnId', | ||
to: 'reviewChargeElementsReturns.reviewChargeElementId' | ||
}, | ||
to: 'reviewChargeElements.id' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = ReviewReturnModel |
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
Oops, something went wrong.