Skip to content

Commit

Permalink
Add FSP reconciliation modules
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben <[email protected]>
  • Loading branch information
Ruben committed Jan 14, 2025
1 parent 422112e commit 4aa6fbd
Show file tree
Hide file tree
Showing 45 changed files with 1,490 additions and 1,312 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ProgramsServiceApiService {
const templates: { name: string; template: string[] }[] =
await this.apiService.get(
environment.url_121_service_api,
`/programs/${programId}/payments/fsp-reconciliation/import-template`,
`/programs/${programId}/payments/excel-reconciliation/template`,
);

for (const template of templates) {
Expand Down Expand Up @@ -377,7 +377,7 @@ export class ProgramsServiceApiService {
const formData = new FormData();
formData.append('file', file);

const path = `/programs/${programId}/payments/${payment}/fsp-reconciliation`;
const path = `/programs/${programId}/payments/${payment}/excel-reconciliation`;

return new Promise<ImportResult>((resolve, reject) => {
this.apiService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ export class PaymentApiService extends DomainApiService {

getReconciliationDataTemplates(projectId: Signal<number | string>) {
return this.generateQueryOptions<Dto<GetImportTemplateResponseDto>[]>({
path: [
...BASE_ENDPOINT(projectId),
'fsp-reconciliation',
'import-template',
],
path: [...BASE_ENDPOINT(projectId), 'excel-reconciliation', 'template'],
});
}

Expand All @@ -140,7 +136,7 @@ export class PaymentApiService extends DomainApiService {
endpoint: this.pathToQueryKey([
...BASE_ENDPOINT(projectId),
paymentId,
'fsp-reconciliation',
'excel-reconciliation',
]).join('/'),
body: formData,
isUpload: true,
Expand Down
16 changes: 15 additions & 1 deletion services/121-service/module-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,19 @@ graph LR
TransactionJobProcessorsModule-->EventsModule
TransactionJobProcessorsModule-->MessageTemplateModule
FinancialServiceProviderCallbackJobProcessorsModule-->RedisModule
FinancialServiceProviderCallbackJobProcessorsModule-->SafaricomModule
FinancialServiceProviderCallbackJobProcessorsModule-->SafaricomReconciliationModule
SafaricomReconciliationModule-->SafaricomModule
SafaricomReconciliationModule-->RedisModule
SafaricomReconciliationModule-->TransactionsModule
SafaricomReconciliationModule-->QueuesRegistryModule
CommercialBankEthiopiaReconciliationModule-->CommercialBankEthiopiaModule
CommercialBankEthiopiaReconciliationModule-->RegistrationsModule
ExcelReconcilicationModule-->ActionsModule
ExcelReconcilicationModule-->TransactionsModule
ExcelReconcilicationModule-->ExcelModule
ExcelReconcilicationModule-->RegistrationsModule
IntersolveVisaReconciliationModule-->IntersolveVisaModule
IntersolveVoucherReconciliationModule-->IntersolveVoucherModule
IntersolveVoucherReconciliationModule-->ProgramModule
IntersolveVoucherReconciliationModule-->ProgramFinancialServiceProviderConfigurationsModule
```
10 changes: 10 additions & 0 deletions services/121-service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { NoteModule } from '@121-service/src/notes/notes.module';
import { MessageModule } from '@121-service/src/notifications/message.module';
import { MessageIncomingModule } from '@121-service/src/notifications/message-incoming/message-incoming.module';
import { OrganizationModule } from '@121-service/src/organization/organization.module';
import { CommercialBankEthiopiaReconciliationModule } from '@121-service/src/payments/reconciliation/commercial-bank-ethiopia-reconciliation/commercial-bank-ethiopia-reconciliation.module';
import { ExcelReconcilicationModule } from '@121-service/src/payments/reconciliation/excel/excel-reconciliation.module';
import { IntersolveVisaReconciliationModule } from '@121-service/src/payments/reconciliation/intersolve-visa-reconciliation/intersolve-visa-reconciliation.module';
import { IntersolveVoucherReconciliationModule } from '@121-service/src/payments/reconciliation/intersolve-voucher-reconciliation/intersolve-voucher-reconciliation.module';
import { SafaricomReconciliationModule } from '@121-service/src/payments/reconciliation/safaricom-reconciliation/safaricom-reconciliation.module';
import { ProgramAidworkerAssignmentEntity } from '@121-service/src/programs/program-aidworker.entity';
import { ProgramModule } from '@121-service/src/programs/programs.module';
import { QueuesRegistryModule } from '@121-service/src/queues-registry/queues-registry.module';
Expand Down Expand Up @@ -73,6 +78,11 @@ import { TypeOrmModule } from '@121-service/src/typeorm.module';
TransactionQueuesModule,
TransactionJobProcessorsModule,
FinancialServiceProviderCallbackJobProcessorsModule,
CommercialBankEthiopiaReconciliationModule,
ExcelReconcilicationModule,
IntersolveVisaReconciliationModule,
IntersolveVoucherReconciliationModule,
SafaricomReconciliationModule,
],
controllers: [AppController],
providers: [
Expand Down
10 changes: 5 additions & 5 deletions services/121-service/src/cronjob/cronjob.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ export class CronjobService {
public async validateCommercialBankEthiopiaAccountEnquiries(): Promise<void> {
// Calling via API/HTTP instead of directly the Service so scope-functionality works, which needs a HTTP request to work which a cronjob does not have
const accessToken = await this.axiosCallsService.getAccessToken();
const url = `${this.axiosCallsService.getBaseUrl()}/financial-service-providers/commercial-bank-ethiopia/account-enquiries/validation`;
const url = `${this.axiosCallsService.getBaseUrl()}/financial-service-providers/commercial-bank-ethiopia/account-enquiries`;
const headers = this.axiosCallsService.accesTokenToHeaders(accessToken);
await this.httpService.post(url, {}, headers);
await this.httpService.put(url, {}, headers);
}

@Cron(CronExpression.EVERY_DAY_AT_3AM, {
disabled: !shouldBeEnabled(
process.env.CRON_INTERSOLVE_VOUCHER_CACHE_UNUSED_VOUCHERS,
),
})
public async cronCacheUnusedVouchers(): Promise<void> {
public async cronRetrieveAndUpdatedUnusedIntersolveVouchers(): Promise<void> {
// Calling via API/HTTP instead of directly the Service so scope-functionality works, which needs a HTTP request to work which a cronjob does not have
const accessToken = await this.axiosCallsService.getAccessToken();
const url = `${this.axiosCallsService.getBaseUrl()}/financial-service-providers/intersolve-voucher/cache-unused-vouchers`;
const url = `${this.axiosCallsService.getBaseUrl()}/financial-service-providers/intersolve-voucher/unused-vouchers`;
const headers = this.axiosCallsService.accesTokenToHeaders(accessToken);
await this.httpService.post(url, {}, headers);
await this.httpService.patch(url, {}, headers);
}

@Cron(CronExpression.EVERY_DAY_AT_6AM, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { Module } from '@nestjs/common';

import { FinancialServiceProviderCallbackJobProcessorsService } from '@121-service/src/financial-service-provider-callback-job-processors/financial-service-provider-callback-job-processors.service';
import { TimeoutCallbackJobProcessorSafaricom } from '@121-service/src/financial-service-provider-callback-job-processors/processors/safaricom-timeout-callback-job.processor';
import { TransferCallbackJobProcessorSafaricom } from '@121-service/src/financial-service-provider-callback-job-processors/processors/safaricom-transfer-callback-job.processor';
import { SafaricomModule } from '@121-service/src/payments/fsp-integration/safaricom/safaricom.module';
import { SafaricomReconciliationModule } from '@121-service/src/payments/reconciliation/safaricom-reconciliation/safaricom-reconciliation.module';
import { RedisModule } from '@121-service/src/payments/redis/redis.module';
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { createScopedRepositoryProvider } from '@121-service/src/utils/scope/createScopedRepositoryProvider.helper';

@Module({
imports: [RedisModule, SafaricomModule],
imports: [RedisModule, SafaricomReconciliationModule],
providers: [
TransferCallbackJobProcessorSafaricom,
TimeoutCallbackJobProcessorSafaricom,
FinancialServiceProviderCallbackJobProcessorsService,
createScopedRepositoryProvider(TransactionEntity),
],
})
export class FinancialServiceProviderCallbackJobProcessorsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject } from '@nestjs/common';
import { Job } from 'bull';
import Redis from 'ioredis';

import { FinancialServiceProviderCallbackJobProcessorsService } from '@121-service/src/financial-service-provider-callback-job-processors/financial-service-provider-callback-job-processors.service';
import { SafaricomReconciliationService } from '@121-service/src/payments/reconciliation/safaricom-reconciliation/safaricom-reconciliation.service';
import {
getRedisSetName,
REDIS_CLIENT,
Expand All @@ -14,15 +14,15 @@ import { JobNames } from '@121-service/src/shared/enum/job-names.enum';
@Processor(SafaricomCallbackQueueNames.timeout)
export class TimeoutCallbackJobProcessorSafaricom {
constructor(
private readonly financialServiceProviderCallbackJobProcessorsService: FinancialServiceProviderCallbackJobProcessorsService,
private readonly safaricomReconciliationService: SafaricomReconciliationService,
@Inject(REDIS_CLIENT)
private readonly redisClient: Redis,
) {}

@Process(JobNames.default)
async handleSafaricomTimeoutCallbackJob(job: Job): Promise<void> {
try {
await this.financialServiceProviderCallbackJobProcessorsService.processSafaricomTimeoutCallbackJob(
await this.safaricomReconciliationService.processSafaricomTimeoutCallbackJob(
job.data,
);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject } from '@nestjs/common';
import { Job } from 'bull';
import Redis from 'ioredis';

import { FinancialServiceProviderCallbackJobProcessorsService } from '@121-service/src/financial-service-provider-callback-job-processors/financial-service-provider-callback-job-processors.service';
import { SafaricomReconciliationService } from '@121-service/src/payments/reconciliation/safaricom-reconciliation/safaricom-reconciliation.service';
import {
getRedisSetName,
REDIS_CLIENT,
Expand All @@ -14,15 +14,15 @@ import { JobNames } from '@121-service/src/shared/enum/job-names.enum';
@Processor(SafaricomCallbackQueueNames.transfer)
export class TransferCallbackJobProcessorSafaricom {
constructor(
private readonly financialServiceProviderCallbackJobProcessorsService: FinancialServiceProviderCallbackJobProcessorsService,
private readonly safaricomReconciliationService: SafaricomReconciliationService,
@Inject(REDIS_CLIENT)
private readonly redisClient: Redis,
) {}

@Process(JobNames.default)
async handleSafaricomTransferCallbackJob(job: Job): Promise<void> {
try {
await this.financialServiceProviderCallbackJobProcessorsService.processSafaricomTransferCallbackJob(
await this.safaricomReconciliationService.processSafaricomTransferCallbackJob(
job.data,
);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
HttpStatus,
Param,
ParseIntPipe,
Post,
UseGuards,
} from '@nestjs/common';
import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
Expand Down Expand Up @@ -48,48 +47,4 @@ export class CommercialBankEthiopiaController {
programId,
);
}

@AuthenticatedUser({ isAdmin: true })
@ApiOperation({
summary:
'Get and store account enquiry data from Commercial Bank of Ethiopia for all registrations in this program.',
})
@ApiResponse({
status: HttpStatus.OK,
description:
'Done getting and storing account enquiry data for all registrations in this program.',
})
@ApiParam({ name: 'programId', required: true, type: 'integer' })
@Post(
'programs/:programId/financial-service-providers/commercial-bank-ethiopia/account-enquiries/validation',
)
public async validate(
@Param('programId', ParseIntPipe)
programId: number,
): Promise<void> {
return this.commercialBankEthiopiaService.validatePasForProgram(programId);
}

@AuthenticatedUser({ isAdmin: true })
@ApiOperation({
summary:
'[CRON] Get and store account enquiry data from Commercial Bank of Ethiopia for all registrations in all programs.',
})
@ApiResponse({
status: HttpStatus.OK,
description:
'Done getting and storing account enquiry data for all registrations in all programs.',
})
@Post(
'financial-service-providers/commercial-bank-ethiopia/account-enquiries/validation',
)
public async validateAllPas(): Promise<void> {
console.info(
'CronjobService - Started: validateCommercialBankEthiopiaAccountEnquiries',
);
await this.commercialBankEthiopiaService.validateAllPas();
console.info(
'CronjobService - Complete: validateCommercialBankEthiopiaAccountEnquiries',
);
}
}
Loading

0 comments on commit 4aa6fbd

Please sign in to comment.