Skip to content

Commit a232c5d

Browse files
author
Brijesh
committed
#1257 - In Progress status for exemption
1 parent a15cf1b commit a232c5d

5 files changed

Lines changed: 52 additions & 3 deletions

File tree

exemptionTemplate.docx

183 Bytes
Binary file not shown.

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export const ATTACHMENT_TYPE = {
136136

137137
export const AGREEMENT_EXEMPTION_STATUS = {
138138
NOT_EXEMPTED: 'NOT_EXEMPTED',
139+
IN_PROGRESS: 'IN_PROGRESS',
139140
ACTIVE: 'ACTIVE',
140141
SCHEDULED: 'SCHEDULED',
141142
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// MyRA
3+
//
4+
// Copyright © 2018 Province of British Columbia
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Created for adding IN_PROGRESS exemption status.
19+
//
20+
21+
'use strict';
22+
23+
const table = 'agreement_exemption_status';
24+
25+
exports.up = async (knex) => {
26+
await knex.raw(
27+
`
28+
INSERT INTO ${table} (id, code, description, active)
29+
VALUES (?, ?, ?, ?)
30+
ON CONFLICT (code) DO NOTHING
31+
`,
32+
[4, 'IN_PROGRESS', 'In Progress', true],
33+
);
34+
};
35+
36+
exports.down = async (knex) => {
37+
await knex(table).where({ code: 'IN_PROGRESS' }).del();
38+
};

src/libs/db2/model/agreement.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export default class Agreement extends Model {
8686
switch (status) {
8787
case AGREEMENT_EXEMPTION_STATUS.NOT_EXEMPTED:
8888
return 'Not Exempted';
89+
case AGREEMENT_EXEMPTION_STATUS.IN_PROGRESS:
90+
return 'In Progress';
8991
case AGREEMENT_EXEMPTION_STATUS.ACTIVE:
9092
return 'Active';
9193
case AGREEMENT_EXEMPTION_STATUS.SCHEDULED:
@@ -225,9 +227,9 @@ export default class Agreement extends Model {
225227
const lowerKey = columnFilters[key].toLowerCase();
226228
q.where('agreement.has_current_schedule', lowerKey === 'y' ? 1 : lowerKey === 'n' ? 0 : null);
227229
}
228-
} else if (key === 'agreement.agreement_exemption_status_id') {
230+
} else if (key === 'agreement.exemption_status') {
229231
if (columnFilters[key] && columnFilters[key].length > 0) {
230-
q.whereIn('agreement_exemption_status.id', columnFilters[key]);
232+
q.whereIn('agreement_exemption_status.code', columnFilters[key]);
231233
}
232234
} else if (key === 'agreement.percentage_use') {
233235
// Handle numeric comparison operators for percentage_use

src/router/controllers_v1/ExemptionController.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { errorWithCode, logger } from '@bcgov/nodejs-common-utils';
22
import { checkRequiredFields } from '../../libs/utils';
33
import DataManager from '../../libs/db2';
44
import config from '../../config';
5-
import { EXEMPTION_STATUS } from '../../constants';
5+
import { EXEMPTION_STATUS, AGREEMENT_EXEMPTION_STATUS } from '../../constants';
66
import { PlanRouteHelper } from '../helpers';
77
import ExemptionStatusHistory from '../../libs/db2/model/exemptionstatushistory';
88
import ExemptionAttachment from '../../libs/db2/model/exemptionattachment';
@@ -234,6 +234,14 @@ export default class ExemptionController {
234234

235235
const fullExemption = await Exemption.findById(trx, newExemption.id);
236236
const [agreement] = await Agreement.find(trx, { forest_file_id: agreementId });
237+
238+
// Set agreement exemption status to IN_PROGRESS when exemption is created
239+
await Agreement.update(
240+
trx,
241+
{ forest_file_id: agreementId },
242+
{ exemption_status: AGREEMENT_EXEMPTION_STATUS.IN_PROGRESS },
243+
);
244+
237245
const zone = await Zone.findById(trx, agreement.zoneId);
238246
const rangeOfficer = await User.findById(trx, zone.userId);
239247
const { emails } = await NotificationHelper.getParticipants(trx, agreementId);

0 commit comments

Comments
 (0)