Skip to content

Commit

Permalink
Merge pull request #592 from code4romania/feature/589
Browse files Browse the repository at this point in the history
feat: [589] Non Political Affiliation and Balance Sheet files
  • Loading branch information
dragos1195 authored Jul 24, 2024
2 parents a492756 + 3e12d76 commit 57e56dd
Show file tree
Hide file tree
Showing 19 changed files with 754 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class BalanceSheetAndNonPoliticalAffiliation1721632351165
implements MigrationInterface
{
name = 'BalanceSheetAndNonPoliticalAffiliation1721632351165';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "organization_legal" ADD "balance_sheet_file" character varying`,
);
await queryRunner.query(
`ALTER TABLE "organization_legal" ADD "non_political_affiliation_file" character varying`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "organization_legal" DROP COLUMN "non_political_affiliation_file"`,
);
await queryRunner.query(
`ALTER TABLE "organization_legal" DROP COLUMN "balance_sheet_file"`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class ApplicationService {
`${APPLICATIONS_FILES_DIR}`,
logo,
FILE_TYPE.IMAGE,
createApplicationDto.name,
);

createApplicationDto = {
Expand Down Expand Up @@ -339,7 +338,6 @@ export class ApplicationService {
`${APPLICATIONS_FILES_DIR}`,
logo,
FILE_TYPE.IMAGE,
application.name,
);

applicationPayload = {
Expand Down
18 changes: 18 additions & 0 deletions backend/src/modules/organization/constants/errors.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export const ORGANIZATION_ERRORS = {
message: 'Error while uploading the files',
errorCode: 'ORG_010',
},
UPLOAD_NON_POLITICAL_AFFILIATION: {
message: 'Error while uploading the non political affiliation file',
errorCode: 'ORG_030',
},

UPLOAD_BALANCE_SHEET: {
message: 'Error while uploading the balance sheet file',
errorCode: 'ORG_031',
},
GET_REPORT: {
message: 'Report not found',
errorCode: 'ORG_011',
Expand All @@ -68,6 +77,15 @@ export const ORGANIZATION_ERRORS = {
message: 'Error while deleting the organization statute',
errorCode: 'ORG_027',
},
NON_POLITICAL_AFFILIATION: {
message:
'Error while deleting the organization non political affiliation file',
errorCode: 'ORG_027',
},
BALANCE_SHEET: {
message: 'Error while deleting the organization balance sheet file',
errorCode: 'ORG_027',
},
},
ALREADY_RESTRICTED: {
message: 'Organization is already RESTRICTED',
Expand Down
2 changes: 2 additions & 0 deletions backend/src/modules/organization/constants/files.constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const ORGANIZATION_FILES_DIR = {
LOGO: 'logo',
STATUTE: 'statute',
NON_POLITICAL_AFFILITION: 'non_political_affiliation',
BALANCE_SHEET: 'balance_sheet',
REPORTS: 'reports',
PARTNERS: 'partners',
INVESTORS: 'investors',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class OrganizationProfileController {
FileFieldsInterceptor([
{ name: 'logo', maxCount: 1 },
{ name: 'organizationStatute', maxCount: 1 },
{ name: 'nonPoliticalAffiliationFile', maxCount: 1 },
{ name: 'balanceSheetFile', maxCount: 1 },
]),
)
@Patch()
Expand All @@ -65,16 +67,22 @@ export class OrganizationProfileController {
{
logo,
organizationStatute,
nonPoliticalAffiliationFile,
balanceSheetFile,
}: {
logo: Express.Multer.File[];
organizationStatute: Express.Multer.File[];
nonPoliticalAffiliationFile: Express.Multer.File[];
balanceSheetFile: Express.Multer.File[];
},
) {
return this.organizationService.update(
user.organizationId,
updateOrganizationDto,
logo,
organizationStatute,
nonPoliticalAffiliationFile,
balanceSheetFile,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export class OrganizationController {
FileFieldsInterceptor([
{ name: 'logo', maxCount: 1 },
{ name: 'organizationStatute', maxCount: 1 },
{ name: 'nonPoliticalAffiliationFile', maxCount: 1 },
{ name: 'balanceSheetFile', maxCount: 1 },
]),
)
@Patch(':id')
Expand All @@ -222,16 +224,22 @@ export class OrganizationController {
{
logo,
organizationStatute,
nonPoliticalAffiliationFile,
balanceSheetFile,
}: {
logo: Express.Multer.File[];
organizationStatute: Express.Multer.File[];
nonPoliticalAffiliationFile: Express.Multer.File[];
balanceSheetFile: Express.Multer.File[];
},
) {
return this.organizationService.update(
+id,
updateOrganizationDto,
logo,
organizationStatute,
nonPoliticalAffiliationFile,
balanceSheetFile,
);
}

Expand Down Expand Up @@ -321,6 +329,29 @@ export class OrganizationController {
);
}

@Roles(Role.SUPER_ADMIN, Role.ADMIN)
@ApiParam({ name: 'id', type: String })
@Delete(':id/non-political-affiliation')
deleteNonPoliticalAffiliation(
@ExtractUser() user: User,
@Param('id') id: number,
) {
// for admin user.organizationId has precedence
return this.organizationService.deleteNonPoliticalAffiliation(
user?.organizationId || id,
);
}

@Roles(Role.SUPER_ADMIN, Role.ADMIN)
@ApiParam({ name: 'id', type: String })
@Delete(':id/balance-sheet')
deleteBalanceSheet(@ExtractUser() user: User, @Param('id') id: number) {
// for admin user.organizationId has precedence
return this.organizationService.deleteBalanceSheet(
user?.organizationId || id,
);
}

@Roles(Role.SUPER_ADMIN)
@ApiParam({ name: 'id', type: String })
@ApiBody({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ export class UpdateOrganizationLegalDto {
@IsOptional()
@IsString()
organizationStatute?: string;

@IsOptional()
@IsString()
nonPoliticalAffiliationFile?: string;

@IsOptional()
@IsString()
balanceSheetFile?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@ export class OrganizationLegal extends BaseEntity {

@Column({ type: 'varchar', name: 'organization_statute', nullable: true })
organizationStatute: string;

@Column({
type: 'varchar',
name: 'non_political_affiliation_file',
nullable: true,
})
nonPoliticalAffiliationFile: string;

@Column({
type: 'varchar',
name: 'balance_sheet_file',
nullable: true,
})
balanceSheetFile: string;
}
Loading

0 comments on commit 57e56dd

Please sign in to comment.