Skip to content

Commit

Permalink
Merge pull request #238 from bcgov/ticdi-109
Browse files Browse the repository at this point in the history
fix provision group deletion
  • Loading branch information
mgtennant authored Oct 1, 2024
2 parents d59466c + 5160aae commit fc6730f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion backend/src/document_type/document_type.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { DocumentTypeController } from './document_type.controller';
import { DocumentType } from './entities/document_type.entity';
import { ProvisionGroup } from './entities/provision_group.entity';
import { DocumentTypeProvision } from 'src/provision/entities/document_type_provision';

@Module({
imports: [TypeOrmModule.forFeature([DocumentType]), TypeOrmModule.forFeature([ProvisionGroup])],
imports: [
TypeOrmModule.forFeature([DocumentType]),
TypeOrmModule.forFeature([ProvisionGroup]),
TypeOrmModule.forFeature([DocumentTypeProvision]),
],
providers: [DocumentTypeService],
controllers: [DocumentTypeController],
exports: [DocumentTypeService],
Expand Down
10 changes: 9 additions & 1 deletion backend/src/document_type/document_type.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { InjectRepository } from '@nestjs/typeorm';
import { In, Repository } from 'typeorm';
import { DocumentType } from './entities/document_type.entity';
import { ProvisionGroup } from './entities/provision_group.entity';
import { DocumentTypeProvision } from 'src/provision/entities/document_type_provision';

@Injectable()
export class DocumentTypeService {
constructor(
@InjectRepository(DocumentType)
private documentTypeRepository: Repository<DocumentType>,
@InjectRepository(ProvisionGroup)
private provisionGroupRepository: Repository<ProvisionGroup>
private provisionGroupRepository: Repository<ProvisionGroup>,
@InjectRepository(DocumentTypeProvision)
private documentTypeProvisionRepository: Repository<DocumentTypeProvision>
) {}

async findById(id: number): Promise<DocumentType | undefined> {
Expand Down Expand Up @@ -120,6 +123,11 @@ export class DocumentTypeService {
}

async removeProvisionGroup(provision_group_id: number) {
await this.documentTypeProvisionRepository.update(
{ provision_group: { id: provision_group_id } },
{ provision_group: null }
);

const result = await this.provisionGroupRepository.delete(provision_group_id);

if (result.affected === 0) {
Expand Down

0 comments on commit fc6730f

Please sign in to comment.