Skip to content
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

Invoicing balance section #46813

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0fa3d34
create Balance component
rezkiy37 Aug 5, 2024
0107f87
add translations
rezkiy37 Aug 5, 2024
bfefb1c
integrate raw WorkspaceInvoiceBalanceSection
rezkiy37 Aug 5, 2024
69fc85c
integrate Balance in CurrentWalletBalance
rezkiy37 Aug 5, 2024
12f2d16
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 6, 2024
0b6c487
add invoice types
rezkiy37 Aug 6, 2024
cac61f8
integrate raw WorkspaceTransferInvoiceBalance
rezkiy37 Aug 6, 2024
efa7d46
fix nav types
rezkiy37 Aug 6, 2024
3cf870b
integrate raw WorkspaceTransferInvoiceBalance
rezkiy37 Aug 6, 2024
3308014
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 7, 2024
d6d4cdd
fix styles
rezkiy37 Aug 7, 2024
c4024d9
improve TransferInvoiceBalance
rezkiy37 Aug 7, 2024
118f9f7
integrate payment methods
rezkiy37 Aug 7, 2024
2349f40
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 8, 2024
98a0b8a
fix optional chain
rezkiy37 Aug 8, 2024
4637092
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 8, 2024
e21a9a2
integrate success view
rezkiy37 Aug 8, 2024
8e59717
remove debug log
rezkiy37 Aug 8, 2024
5340ac6
remove debug condition
rezkiy37 Aug 8, 2024
b923b34
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 9, 2024
8034af8
do not use bankAccountID for request
rezkiy37 Aug 9, 2024
451e139
simplify the logic for selecting the payment account
rezkiy37 Aug 9, 2024
ddd6ca3
update transfer button title
rezkiy37 Aug 9, 2024
e274b8f
clear redundant press
rezkiy37 Aug 9, 2024
52cc88b
update comment
rezkiy37 Aug 9, 2024
f8e7928
add empty lines
rezkiy37 Aug 9, 2024
72ca222
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 13, 2024
a24da4d
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 13, 2024
7710a77
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Aug 14, 2024
e248286
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 2, 2024
002d9d3
uncomment enabling feature line
rezkiy37 Sep 3, 2024
d5801a2
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 3, 2024
1e30fce
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 9, 2024
069e632
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 12, 2024
af65cd7
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 16, 2024
a187445
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 24, 2024
a85c17e
revert transfer balance
rezkiy37 Sep 25, 2024
cda95f1
use hooks and remove withOnyx
rezkiy37 Sep 25, 2024
0970c51
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 25, 2024
ba1d7b3
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 25, 2024
14d26c4
Refactor willBlurTextInputOnTapOutside to use getIsNarrowLayout
rezkiy37 Sep 25, 2024
d7535c3
Revert "Refactor willBlurTextInputOnTapOutside to use getIsNarrowLayout"
rezkiy37 Sep 25, 2024
9e6ab22
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 26, 2024
cb31a55
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 27, 2024
98a04c9
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Sep 30, 2024
96167c0
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Oct 1, 2024
157bc5b
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Oct 2, 2024
d20a84b
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/components/Balance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import type {StyleProp, TextStyle} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import Text from './Text';

type BalanceProps = {
textStyles?: StyleProp<TextStyle>;
balance: number;
};

function Balance({textStyles, balance}: BalanceProps) {
const styles = useThemeStyles();
const formattedBalance = CurrencyUtils.convertToDisplayString(balance);
rezkiy37 marked this conversation as resolved.
Show resolved Hide resolved

return <Text style={[styles.textHeadline, styles.textXXXLarge, textStyles]}>{formattedBalance}</Text>;
}

Balance.displayName = 'Balance';

export default Balance;
32 changes: 13 additions & 19 deletions src/components/CurrentWalletBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import React from 'react';
import type {StyleProp, TextStyle} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import type UserWallet from '@src/types/onyx/UserWallet';
import Text from './Text';
import Balance from './Balance';

type CurrentWalletBalanceOnyxProps = {
/** The user's wallet account */
userWallet: OnyxEntry<UserWallet>;
};

type CurrentWalletBalanceProps = CurrentWalletBalanceOnyxProps & {
type CurrentWalletBalanceProps = {
balanceStyles?: StyleProp<TextStyle>;
};

function CurrentWalletBalance({userWallet, balanceStyles}: CurrentWalletBalanceProps) {
function CurrentWalletBalance({balanceStyles}: CurrentWalletBalanceProps) {
const styles = useThemeStyles();
rezkiy37 marked this conversation as resolved.
Show resolved Hide resolved
const formattedBalance = CurrencyUtils.convertToDisplayString(userWallet?.currentBalance ?? 0);
return <Text style={[styles.pv5, styles.alignSelfCenter, styles.textHeadline, styles.textXXXLarge, balanceStyles]}>{formattedBalance}</Text>;
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET);

return (
<Balance
textStyles={[styles.pv5, styles.alignSelfCenter, balanceStyles]}
balance={userWallet?.currentBalance ?? 0}
/>
);
}

CurrentWalletBalance.displayName = 'CurrentWalletBalance';

export default withOnyx<CurrentWalletBalanceProps, CurrentWalletBalanceOnyxProps>({
userWallet: {
key: ONYXKEYS.USER_WALLET,
},
})(CurrentWalletBalance);
export default CurrentWalletBalance;
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3656,6 +3656,8 @@ const translations = {
payingAsIndividual: 'Paying as an individual',
payingAsBusiness: 'Paying as a business',
},
invoiceBalance: 'Invoice balance',
invoiceBalanceSubtitle: 'Here’s your current balance from collecting payments on invoices.',
bankAccountsSubtitle: 'Add a bank account to receive invoice payments.',
},
invite: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3697,6 +3697,8 @@ const translations = {
payingAsIndividual: 'Pago individual',
payingAsBusiness: 'Pagar como una empresa',
},
invoiceBalance: 'Saldo de la factura',
invoiceBalanceSubtitle: 'Aquí está su saldo actual de la recaudación de pagos en las facturas.',
bankAccountsSubtitle: 'Agrega una cuenta bancaria para recibir pagos de facturas.',
},
invite: {
Expand Down
33 changes: 33 additions & 0 deletions src/pages/workspace/invoices/WorkspaceInvoiceBalanceSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import {useOnyx} from 'react-native-onyx';
import Balance from '@components/Balance';
import Section from '@components/Section';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import ONYXKEYS from '@src/ONYXKEYS';

type WorkspaceInvoiceBalanceSectionProps = {
/** The policy ID currently being configured */
policyID: string;
};

function WorkspaceInvoiceBalanceSection({policyID}: WorkspaceInvoiceBalanceSectionProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);

return (
<Section
title={translate('workspace.invoices.invoiceBalance')}
subtitle={translate('workspace.invoices.invoiceBalanceSubtitle')}
isCentralPane
titleStyles={styles.textStrong}
childrenStyles={styles.pt5}
subtitleMuted
>
<Balance balance={policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0} />
</Section>
);
}

export default WorkspaceInvoiceBalanceSection;
2 changes: 2 additions & 0 deletions src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import type SCREENS from '@src/SCREENS';
import WorkspaceInvoiceBalanceSection from './WorkspaceInvoiceBalanceSection';
import WorkspaceInvoicesNoVBAView from './WorkspaceInvoicesNoVBAView';
import WorkspaceInvoicesVBAView from './WorkspaceInvoicesVBAView';
import WorkspaceInvoiceVBASection from './WorkspaceInvoiceVBASection';
Expand All @@ -34,6 +35,7 @@ function WorkspaceInvoicesPage({route}: WorkspaceInvoicesPageProps) {
>
{(hasVBA?: boolean, policyID?: string) => (
<View style={[styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{policyID && <WorkspaceInvoiceBalanceSection policyID={policyID} />}
{policyID && <WorkspaceInvoiceVBASection policyID={policyID} />}
{!hasVBA && policyID && <WorkspaceInvoicesNoVBAView policyID={policyID} />}
{hasVBA && policyID && <WorkspaceInvoicesVBAView policyID={policyID} />}
Expand Down
Loading