diff --git a/src/modules/provider-svc/provider-svc.service.ts b/src/modules/provider-svc/provider-svc.service.ts index 792ce21..b91ea30 100644 --- a/src/modules/provider-svc/provider-svc.service.ts +++ b/src/modules/provider-svc/provider-svc.service.ts @@ -294,10 +294,8 @@ export class ProviderService { console.log('computed.total', serviceTotal); - if (transaction.currency !== 'CDF') { - throw new ForbiddenException( - _403.WRONG_VOUCHER_CURRENCY - ); + if (transaction.currency !== 'CDF' && transaction.currency !== 'XOF') { + throw new ForbiddenException(_403.WRONG_VOUCHER_CURRENCY); } const voucherValueInCDF = Math.round(voucher.value); @@ -319,14 +317,14 @@ export class ProviderService { const firstVoucher = { amount: Math.round(serviceTotal), ownerId: transaction.senderId, - currency: 'CDF', - patientId: transaction.ownerId + currency: transaction.currency == 'CDF' ? 'CDF' : 'XOF', + patientId: transaction.ownerId, } const secondVoucher = { amount: (voucherValueInCDF - Math.round(serviceTotal)), ownerId: transaction.senderId, - currency: 'CDF', + currency: transaction.currency == 'CDF' ? 'CDF' : 'XOF', patientId: transaction.ownerId } @@ -438,9 +436,9 @@ export class ProviderService { //save first transaction split const transactionToSave1 = this.transactionRepository.create({ senderAmount: firstVoucher.amount, - senderCurrency: 'CDF', + senderCurrency: firstVoucher.currency, amount: firstVoucher.amount, - currency: 'CDF', + currency: firstVoucher.currency, conversionRate: 0, senderId: transaction.senderId, ownerId: transaction.ownerId, @@ -473,9 +471,9 @@ export class ProviderService { //save second transaction split const transactionToSave2 = this.transactionRepository.create({ senderAmount: secondVoucher.amount, - senderCurrency: 'CDF', + senderCurrency: secondVoucher.currency, amount: secondVoucher.amount, - currency: 'CDF', + currency: secondVoucher.currency, conversionRate: 0, senderId: transaction.senderId, ownerId: transaction.ownerId,