Skip to content

Commit

Permalink
121-service fix: rename endpoint & check for array (#6439)
Browse files Browse the repository at this point in the history
* fix: rename endpoint & check for array

* fix

* fix
  • Loading branch information
PeterSmallenbroek authored Jan 30, 2025
1 parent 273209d commit 96c7cc9
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { AuthenticatedUser } from '@121-service/src/guards/authenticated-user.de
import { AuthenticatedUserGuard } from '@121-service/src/guards/authenticated-user.guard';
import { IntersolveVoucherJobDetails } from '@121-service/src/payments/fsp-integration/intersolve-voucher/dto/job-details.dto';
import { IntersolveVoucherReconciliationService } from '@121-service/src/payments/reconciliation/intersolve-voucher-reconciliation/intersolve-voucher-reconciliation.service';
import { AzureLogService } from '@121-service/src/shared/services/azure-log.service';

@UseGuards(AuthenticatedUserGuard)
@ApiTags('financial-service-providers/intersolve-voucher')
@Controller()
export class IntersolveVoucherReconciliationController {
public constructor(
private intersolveVoucherReconciliationService: IntersolveVoucherReconciliationService,
private azureLogService: AzureLogService,
) {}

//TODO: mention this in WORKFLOWS?
Expand Down Expand Up @@ -55,7 +57,7 @@ export class IntersolveVoucherReconciliationController {
status: HttpStatus.CREATED,
description: 'Cached unused vouchers',
})
@Patch('/financial-service-providers/intersolve-voucher/vouchers')
@Patch('/financial-service-providers/intersolve-voucher/unused-vouchers')
public async cronRetrieveAndUpdatedUnusedIntersolveVouchers(): Promise<void> {
console.info(
'CronjobService - Started: cronRetrieveAndUpdatedUnusedIntersolveVouchers',
Expand All @@ -69,9 +71,7 @@ export class IntersolveVoucherReconciliationController {
return;
})
.catch((error) => {
throw new Error(
`CronjobService - Failed: cronRetrieveAndUpdatedUnusedIntersolveVouchers - ${error}`,
);
this.azureLogService.logError(error, true);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IntersolveVoucherReconciliationController } from '@121-service/src/paym
import { IntersolveVoucherReconciliationService } from '@121-service/src/payments/reconciliation/intersolve-voucher-reconciliation/intersolve-voucher-reconciliation.service';
import { ProgramFinancialServiceProviderConfigurationsModule } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configurations.module';
import { ProgramModule } from '@121-service/src/programs/programs.module';
import { AzureLogService } from '@121-service/src/shared/services/azure-log.service';
import { createScopedRepositoryProvider } from '@121-service/src/utils/scope/createScopedRepositoryProvider.helper';

@Module({
Expand All @@ -19,6 +20,7 @@ import { createScopedRepositoryProvider } from '@121-service/src/utils/scope/cre
providers: [
IntersolveVoucherReconciliationService,
createScopedRepositoryProvider(IntersolveVoucherEntity),
AzureLogService,
],
controllers: [IntersolveVoucherReconciliationController],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,18 @@ export class IntersolveVoucherReconciliationService {
programId,
})
.getMany();
const credentials =
await this.programFspConfigurationRepository.getUsernamePasswordPropertiesByVoucherId(
previouslyUnusedVouchers[0].id,
);
for await (const voucher of previouslyUnusedVouchers) {
await this.intersolveVoucherService.getAndUpdateBalance(
voucher,
programId,
credentials,
);
if (previouslyUnusedVouchers.length) {
const credentials =
await this.programFspConfigurationRepository.getUsernamePasswordPropertiesByVoucherId(
previouslyUnusedVouchers[0].id,
);
for await (const voucher of previouslyUnusedVouchers) {
await this.intersolveVoucherService.getAndUpdateBalance(
voucher,
programId,
credentials,
);
}
}
id += 1000;
}
Expand Down
Loading

0 comments on commit 96c7cc9

Please sign in to comment.