Skip to content

Commit

Permalink
Refactor DIRECT_REIMBURSEMENT_CURRENCIES array in CONST.ts and update…
Browse files Browse the repository at this point in the history
… type declaration in ReportUtils.ts
  • Loading branch information
marcochavezf committed Jan 5, 2024
1 parent bb8ea40 commit cafdad7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,7 @@ const CONST = {
EUR: 'EUR',
},
get DIRECT_REIMBURSEMENT_CURRENCIES() {
return [
this.CURRENCY.USD,
this.CURRENCY.AUD,
this.CURRENCY.CAD,
this.CURRENCY.GBP,
this.CURRENCY.NZD,
this.CURRENCY.EUR,
];
return [this.CURRENCY.USD, this.CURRENCY.AUD, this.CURRENCY.CAD, this.CURRENCY.GBP, this.CURRENCY.NZD, this.CURRENCY.EUR];
},
EXAMPLE_PHONE_NUMBER: '+15005550006',
CONCIERGE_CHAT_NAME: 'Concierge',
Expand Down Expand Up @@ -1307,7 +1300,7 @@ const CONST = {
REIMBURSEMENT_YES: 'reimburseYes',
REIMBURSEMENT_NO: 'reimburseNo',
REIMBURSEMENT_MANUAL: 'reimburseManual',
}
},
},

CUSTOM_UNITS: {
Expand Down
9 changes: 7 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4275,10 +4275,15 @@ function canBeAutoReimbursed(report: OnyxEntry<Report>, policy: OnyxEntry<Policy
if (!policy) {
return false;
}
type CurrencyType = typeof CONST.DIRECT_REIMBURSEMENT_CURRENCIES[number];
type CurrencyType = (typeof CONST.DIRECT_REIMBURSEMENT_CURRENCIES)[number];
const reimbursableTotal = getMoneyRequestReimbursableTotal(report);
const autoReimbursementLimit = policy.autoReimbursementLimit ?? 0;
const isAutoReimbursable = isGroupPolicy(report) && policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES && autoReimbursementLimit >= reimbursableTotal && reimbursableTotal > 0 && CONST.DIRECT_REIMBURSEMENT_CURRENCIES.includes(report?.currency as CurrencyType);
const isAutoReimbursable =
isGroupPolicy(report) &&
policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES &&
autoReimbursementLimit >= reimbursableTotal &&
reimbursableTotal > 0 &&
CONST.DIRECT_REIMBURSEMENT_CURRENCIES.includes(report?.currency as CurrencyType);
return isAutoReimbursable;
}

Expand Down

0 comments on commit cafdad7

Please sign in to comment.