From 07dbc30e2816583cac1e4f16b8452ae1e868f7dd Mon Sep 17 00:00:00 2001 From: Peter Ndengo Date: Mon, 12 Feb 2024 12:42:16 +0100 Subject: [PATCH 1/2] Return on CDF currency (#128) * KYC save data * KYC save his data * Module to check KYC field * Module to check KYC field * Add Waiting List module * Module for waiting * fix tests * Finished Waiting list * Finished contact form * Finish module for blog * Change all links wiiqare-app.com to app.wiiqare.com * Change link of wiiqare platform * Finish module to get voucher without stripe webhook * Change id stripe payment * Change name endpoint * Add comment modules * Comment form it's working now * Finish with generate voucher module * transaction * Add country field * Change CDF to XOF * Return CDF --------- Co-authored-by: Abhishek Shandilya <97976470+abhishandilya@users.noreply.github.com> --- src/modules/provider-svc/provider-svc.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/provider-svc/provider-svc.service.ts b/src/modules/provider-svc/provider-svc.service.ts index 148604a..f83591b 100644 --- a/src/modules/provider-svc/provider-svc.service.ts +++ b/src/modules/provider-svc/provider-svc.service.ts @@ -294,7 +294,7 @@ export class ProviderService { console.log('computed.total', serviceTotal); - if (transaction.currency !== 'XOF') { + if (transaction.currency !== 'CDF') { throw new ForbiddenException( _403.WRONG_VOUCHER_CURRENCY ); From 9107c29eb4604839e847d5c038e90d461e1e95e6 Mon Sep 17 00:00:00 2001 From: Peter Ndengo Date: Mon, 12 Feb 2024 13:03:33 +0100 Subject: [PATCH 2/2] XOF (#129) * KYC save data * KYC save his data * Module to check KYC field * Module to check KYC field * Add Waiting List module * Module for waiting * fix tests * Finished Waiting list * Finished contact form * Finish module for blog * Change all links wiiqare-app.com to app.wiiqare.com * Change link of wiiqare platform * Finish module to get voucher without stripe webhook * Change id stripe payment * Change name endpoint * Add comment modules * Comment form it's working now * Finish with generate voucher module * transaction * Add country field * Change CDF to XOF * Return CDF * Change to XOF --------- Co-authored-by: Abhishek Shandilya <97976470+abhishandilya@users.noreply.github.com> --- .../payment-svc/payment-swap-svc.service.ts | 2 +- .../provider-svc/provider-svc.service.test.ts | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/modules/payment-svc/payment-swap-svc.service.ts b/src/modules/payment-svc/payment-swap-svc.service.ts index ad63c9f..2d24e35 100644 --- a/src/modules/payment-svc/payment-swap-svc.service.ts +++ b/src/modules/payment-svc/payment-swap-svc.service.ts @@ -28,7 +28,7 @@ export class PaymentSwapService { senderId: randomUUID(), patientId: randomUUID(), currencyPatientAmount: 100, - currencyPatient: 'CDF', + currencyPatient: 'XOF', currencyRate: 1.0, }, }, diff --git a/src/modules/provider-svc/provider-svc.service.test.ts b/src/modules/provider-svc/provider-svc.service.test.ts index 3ffbdee..4bf26fa 100644 --- a/src/modules/provider-svc/provider-svc.service.test.ts +++ b/src/modules/provider-svc/provider-svc.service.test.ts @@ -57,8 +57,8 @@ describe('ProviderService', () => { } as unknown as SmsGatewayService; const mockSmartContractService = { - burnVoucher: () => {}, - mintVoucher: () => {} + burnVoucher: () => { }, + mintVoucher: () => { } } as unknown as SmartContractService; // Mock entities @@ -118,7 +118,7 @@ describe('ProviderService', () => { senderCurrency: 'senderCurrency', amount: 1000, conversionRate: 1, - currency: 'CDF', + currency: 'XOF', senderId: 'senderId', ownerId: 'ownerId', hospitalId: null, @@ -485,36 +485,36 @@ describe('ProviderService', () => { mockCachingService.get = jest.fn().mockResolvedValue('savedSecurityCode'); await expect( - service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000 ), + service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000), ).rejects.toThrow( new ForbiddenException(_403.INVALID_VOUCHER_TRANSFER_VERIFICATION_CODE), ); }); - it('should throw an error if the voucher currency is not CDF', async () => { - transactionRepository.findOne = jest.fn().mockResolvedValue( {...mockTransaction, currency: 'USD'} ); + it('should throw an error if the voucher currency is not XOF', async () => { + transactionRepository.findOne = jest.fn().mockResolvedValue({ ...mockTransaction, currency: 'USD' }); await expect( - service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000 ), + service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000), ).rejects.toThrow( new ForbiddenException(_403.WRONG_VOUCHER_CURRENCY), ); }); it('should split into 2 vouchers with values summing the first voucher', async () => { - mockCachingService.get = jest.fn().mockResolvedValue( securityCode ); + mockCachingService.get = jest.fn().mockResolvedValue(securityCode); const voucher1 = { value: 100 }; const voucher2 = { value: 900 }; transactionRepository.create = jest.fn(). - mockImplementationOnce( ( obj ) => { return {value: obj.amount} } ). - mockImplementationOnce( ( obj ) => { return {value: obj.amount} } ); - - voucherRepository.findOne = jest.fn().mockResolvedValue( mockVoucher ); - voucherRepository.create = jest.fn().mockResolvedValue( + mockImplementationOnce((obj) => { return { value: obj.amount } }). + mockImplementationOnce((obj) => { return { value: obj.amount } }); + + voucherRepository.findOne = jest.fn().mockResolvedValue(mockVoucher); + voucherRepository.create = jest.fn().mockResolvedValue( {} - ); - providerRepository.findOne = jest.fn().mockResolvedValue( mockProvider ); - serviceRepository.find = jest.fn().mockResolvedValue( [ mockService ] ); + ); + providerRepository.findOne = jest.fn().mockResolvedValue(mockProvider); + serviceRepository.find = jest.fn().mockResolvedValue([mockService]); const mockMintedVoucher = { events: { @@ -522,16 +522,16 @@ describe('ProviderService', () => { transactionHash: 'hash1', returnValues: { '0': 1, - '1': [100, 'CDF', 'ownerId', 'hospitalId', 'patientId', 'UNCLAIMED'] + '1': [100, 'XOF', 'ownerId', 'hospitalId', 'patientId', 'UNCLAIMED'] } } } } - mockSmartContractService.mintVoucher = jest.fn().mockResolvedValue( mockMintedVoucher ); + mockSmartContractService.mintVoucher = jest.fn().mockResolvedValue(mockMintedVoucher); - const result = await service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000 ); - expect( transactionRepository.create ).toHaveNthReturnedWith( 1, voucher1 ); - expect( transactionRepository.create ).toHaveNthReturnedWith( 2, voucher2 ); + const result = await service.authorizeVoucherTransfer(shortenHash, providerId, securityCode, services, 1000); + expect(transactionRepository.create).toHaveNthReturnedWith(1, voucher1); + expect(transactionRepository.create).toHaveNthReturnedWith(2, voucher2); }); });