-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shontzu/WALL-865/Incorrect-total-asset-amount #9217
shontzu/WALL-865/Incorrect-total-asset-amount #9217
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-shontzu-deriv-shontzu-wall-865incorre-7cf99c.binary.sx/ |
…/WALL-865/Incorrect-total-asset-amount
…/WALL-865/Incorrect-total-asset-amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shontzu-deriv using const { is_demo } = traders_hub;
just checks if you switch to demo account or not. but you need to check if the passed cfd accounts are demo or not. that's why you need to check account?.account_type
.
please apply my changes and also revert back all changes in the test file and check it the tests are passing as before 🙏
@@ -1,22 +1,23 @@ | |||
import useRealTotalAssetCurrency from './useTotalAssetCurrency'; | |||
import useExchangeRate from './useExchangeRate'; | |||
|
|||
import { useStore } from '@deriv/stores'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { useStore } from '@deriv/stores'; |
const { traders_hub } = useStore(); | ||
const { is_demo } = traders_hub; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { traders_hub } = useStore(); | |
const { is_demo } = traders_hub; |
const base_rate = is_demo ? getRate('USD') : getRate(total_assets_real_currency || ''); | ||
const rate = getRate(total_assets_real_currency || ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const base_rate = is_demo ? getRate('USD') : getRate(total_assets_real_currency || ''); | |
const rate = getRate(total_assets_real_currency || ''); | |
const base_rate = account?.account_type === 'demo' ? 1 : getRate(total_assets_real_currency || ''); | |
const rate = getRate(account.currency || total_assets_real_currency || ''); |
/** | ||
* we can use this hook to get the total balance of the given accounts list. | ||
* it loops through the accounts list and adds the balance of each account | ||
* to the total balance, it also converts the balance to the currency of the | ||
* first account in the list | ||
*/ | ||
|
||
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string }[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string }[]) => { | |
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string; account_type?: string; }[]) => { |
…/WALL-865/Incorrect-total-asset-amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shontzu-deriv I don't think we need to change the existing tests, I think you should add a new test case for the new scenario 🤔
/** | ||
* we can use this hook to get the total balance of the given accounts list. | ||
* it loops through the accounts list and adds the balance of each account | ||
* to the total balance, it also converts the balance to the currency of the | ||
* first account in the list | ||
*/ | ||
|
||
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string }[]) => { | ||
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string; account_type?: string }[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const useTotalAccountBalance = (accounts: { balance?: number; currency?: string; account_type?: string }[]) => { | |
type TAccounts = { | |
balance?: number; | |
currency?: string; | |
account_type?: string | |
}; | |
const useTotalAccountBalance = (accounts: TAccounts[]) => { |
@shontzu-deriv Please extract it into a type above the function 🙏🏻
…/WALL-865/Incorrect-total-asset-amount
Please retry analysis of this Pull-Request directly on SonarCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shontzu-deriv Please update the test file with the new added case 🙏🏻
⏳ Generating Lighthouse report... |
👌 Pull request has been updated with the base branch by Paimon the Release Bot |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
✨ PR has been merged by Paimon the Release Bot |
* shontzu/WALL-865/Incorrect-total-asset-amount (#9217) * fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> * Farabi/bot 317/translation fixes for dbot homepage (#9108) * fix: translation issues * redeploy: vercel retrigger --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> * shahzaib / KYC-270 / fix POI flow after IDV failure and retries (#9222) * chore: fix POI flow after IDV failure and retries * chore: fix onfido infinite trigger for nigeria clients * chore: fix onfido trigger if submission left is zero or less * style: fix manual upload card content alignment * chore: rename prop to default_enabled * fix: nimc slip document step check * chore: add comment to define the use of added prop * maryia/DTRA-297/fix: Crypto profit text & Hide barriers in case of trade params errors (#9347) * chore: remove animation correction * feat: clear barriers upon errors * fix: profit text & hide it for crypto with more than 2 decimals * test: AccumulatorsProfitLossText * Revert "chore: remove animation correction" This reverts commit f9bb5ec. * fix: not hide barriers for ongoing contract in case of trade params error --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> * Kate / DTRA-175 / Enable 'Only ups/downs' in reports and contract details page (#8883) * refactor: move trade type from un to supported * feat: ad contract type check func and add to contract details * feat: add chart markers settings for contract type * chore: add style for mobile * chore: remove gradient * chore: empty commit * chore: add gradient for contract details card for desktop * feat: add chart markers setings and update style * refactor: apply suggestions * chore: empty commit --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> * fix: token leakage to third party api (#9000) Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> --------- Co-authored-by: shontzu <108507236+shontzu-deriv@users.noreply.github.com> Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com> Co-authored-by: Farabi <102643568+farabi-deriv@users.noreply.github.com> Co-authored-by: Shahzaib <shahzaib@deriv.com> Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com> Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com> Co-authored-by: Sui Sin <103026762+suisin-deriv@users.noreply.github.com>
* fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
* fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
* fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
* fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
* fix: attemp #3 * chore: remove irrelevant check * chore: unit test * chore: unit test fail * chore: fixes based on review * chore: empty commit * chore: code revie fixes * chore: revert test case changes * chore: rename type to TUseTotalAccountBalance * chore: format doc and added test case for multiple accounts in different currencies --------- Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
Changes:
MT5 accounts can have non-USD balance.
In Demo tab,
total assets
are in USDMT5's non-USD balance must be converted first
Screenshots: