Skip to content

Commit

Permalink
add XOF currency condition to allow XOF and update voucher/transction…
Browse files Browse the repository at this point in the history
…s with correct currency
  • Loading branch information
artweb11 committed Feb 12, 2024
1 parent 0faf2c8 commit 2e294de
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/modules/provider-svc/provider-svc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2e294de

Please sign in to comment.