Skip to content

Commit

Permalink
fix: #616 Add rule for bcts fom for validityEndDate. (#617)
Browse files Browse the repository at this point in the history
* Add rule for bcts fom for validityEndDate.

* Add rule comment on the logic and use condition in component rather than in view.
  • Loading branch information
ianliuwk1019 authored Apr 11, 2024
1 parent 6cd10bb commit 389bcfb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
9 changes: 8 additions & 1 deletion api/src/app/modules/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,17 @@ export class ProjectService extends DataService<Project, Repository<Project>, Pr
const response = new ProjectResponse();
if (entity.commentingClosedDate) {
response.commentingClosedDate = dayjs(entity.commentingClosedDate).format(this.DATE_FORMAT);
if (entity.bctsMgrName) {
// Note: special rule for BCTS FOMs: validity period is 3 years from commenting close date.
response.validityEndDate = dayjs(entity.commentingClosedDate).add(3, 'year').format(this.DATE_FORMAT);
}
}
if (entity.commentingOpenDate) {
response.commentingOpenDate = dayjs(entity.commentingOpenDate).format(this.DATE_FORMAT);
response.validityEndDate = dayjs(entity.commentingOpenDate).add(3, 'year').format(this.DATE_FORMAT);
if (!entity.bctsMgrName) {
// For Non-BCTS FOMs: validity period is 3 years from commenting open date.
response.validityEndDate = dayjs(entity.commentingOpenDate).add(3, 'year').format(this.DATE_FORMAT);
}
}
response.createTimestamp = entity.createTimestamp.toISOString();
response.description = entity.description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3 class="title">No public notices found.</h3>

<div class="row">
<div class="col-sm-4 bold">Validity Period: </div>
<div class="col-sm-8">{{pn.project.commentingOpenDate | date: 'longDate'}} to {{pn.project.validityEndDate | date: 'longDate'}}</div>
<div class="col-sm-8">{{getValidityStartDate(pn.project) | date: 'longDate'}} to {{pn.project.validityEndDate | date: 'longDate'}}</div>
</div>

<div class="row" *ngIf="pn.project.operationStartYear && pn.project.operationEndYear">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
import { MatCardModule } from '@angular/material/card';
import { MatAccordion, MatExpansionModule } from '@angular/material/expansion';
import { MatTooltipModule } from '@angular/material/tooltip';
import { PublicNoticePublicFrontEndResponse, PublicNoticeService } from '@api-client';
import { ProjectResponse, PublicNoticePublicFrontEndResponse, PublicNoticeService } from '@api-client';
import { ShortenPipe } from '@public-core/pipes/shorten.pipe';
import { UrlService } from '@public-core/services/url.service';
import * as _ from 'lodash';
Expand Down Expand Up @@ -89,6 +89,16 @@ export class PublicNoticesPanelComponent implements OnInit {
return moment(commentingOpenDate).startOf('day') <= moment().startOf('day');
}

getValidityStartDate(project: ProjectResponse) {
// Note: special rule for BCTS FOMs: validity period is 3 years from commenting close date.
if (project.bctsMgrName)
return project.commentingClosedDate;

// For Non-BCTS FOMs: validity period is 3 years from commenting open date.
else
return project.commentingOpenDate;
}

private compareFn() {
// If 'value'(filter value) is null or underfined, consider this as to include all.
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h3>FOM Details</h3>
Commenting closed for this FOM on {{project.commentingClosedDate | date:'longDate'}}.
</div>
<div>
The validity period for this FOM ends on {{this.validityPeriodEndDate | date: 'longDate'}}.
The validity period for this FOM ends on {{project.validityEndDate | date: 'longDate'}}.
<div style="margin-top: 12px;">
This FOM can be relied upon by the FOM holder for the purpose of a cutting permit or road permit application, until the date three years after commencement of the public review and commenting period. FOMs published by BC Timber Sales can be relied upon for the purpose of a cutting permit or road permit application, or the issuance of a Timber Sales License until the date three years after conclusion of the public review and commenting period.
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class DetailsPanelComponent implements OnDestroy, OnInit {
public workflowStatus: _.Dictionary<WorkflowStateCode>;
public projectIdFilter = new Filter<string>({ filter: { queryParam: 'id', value: null } });
public attachments: AttachmentResponse[];
public validityPeriodEndDate: Date;

constructor(
public modalService: NgbModal,
Expand Down Expand Up @@ -110,7 +109,6 @@ export class DetailsPanelComponent implements OnDestroy, OnInit {
this.projectIdFilter.filter.value = this.project.id.toString();
this.saveQueryParameters();
this.update.emit(this.project);
this.validityPeriodEndDate = moment(this.project.commentingOpenDate).add(3, 'year').toDate();
},
error: (err) => {
console.error(err);
Expand Down

0 comments on commit 389bcfb

Please sign in to comment.