Skip to content

Commit

Permalink
[TRAH]/Mitra/ TRAH-3032/ Using currency type from account list for re…
Browse files Browse the repository at this point in the history
…moving GBP for eu client (binary-com#14318)

* refactor: 🔥 using currency type from account list

* fix: 🐛 add landing company check

* fix: 🐛 add the landing company check for current fiat currency
  • Loading branch information
mitra-deriv committed Apr 3, 2024
1 parent 186ff51 commit fd3d3fb
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions packages/core/src/Stores/client-store.js
Expand Up @@ -554,26 +554,22 @@ export default class ClientStore extends BaseStore {
}

get has_fiat() {
const values = Object.values(this.accounts).reduce((acc, item) => {
if (!item.is_virtual && item.landing_company_shortcode === this.landing_company_shortcode) {
acc.push(item.currency);
}
return acc;
}, []);
return !!this.upgradeable_currencies.filter(acc => values.includes(acc.value) && acc.type === 'fiat').length;
return Object.values(this.accounts).some(
item =>
item.currency_type === 'fiat' &&
!item.is_virtual &&
item.landing_company_shortcode === this.landing_company_shortcode
);
}

get current_fiat_currency() {
const values = Object.values(this.accounts).reduce((acc, item) => {
if (!item.is_virtual) {
acc.push(item.currency);
}
return acc;
}, []);

return this.has_fiat
? this.upgradeable_currencies.filter(acc => values.includes(acc.value) && acc.type === 'fiat')[0].value
: undefined;
const account = Object.values(this.accounts).find(
item =>
item.currency_type === 'fiat' &&
!item.is_virtual &&
item.landing_company_shortcode === this.landing_company_shortcode
);
return account?.currency;
}

// return the landing company object that belongs to the current client by matching shortcode
Expand Down

0 comments on commit fd3d3fb

Please sign in to comment.