Skip to content

Commit

Permalink
fix: use totalDueAmountCents instead of totalAmountCents
Browse files Browse the repository at this point in the history
  • Loading branch information
keellyp committed Jan 27, 2025
1 parent d9a2b37 commit 365bcc6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
19 changes: 13 additions & 6 deletions src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2909,8 +2909,7 @@ export enum IntegrationTypeEnum {
RevenueAnalytics = 'revenue_analytics',
RevenueShare = 'revenue_share',
Salesforce = 'salesforce',
Xero = 'xero',
ZeroAmountFees = 'zero_amount_fees'
Xero = 'xero'
}

export type Invite = {
Expand Down Expand Up @@ -2990,6 +2989,7 @@ export type Invoice = {
taxesAmountCents: Scalars['BigInt']['output'];
taxesRate: Scalars['Float']['output'];
totalAmountCents: Scalars['BigInt']['output'];
totalDueAmountCents: Scalars['BigInt']['output'];
updatedAt: Scalars['ISO8601DateTime']['output'];
versionNumber: Scalars['Int']['output'];
voidable: Scalars['Boolean']['output'];
Expand Down Expand Up @@ -4523,8 +4523,7 @@ export enum PremiumIntegrationTypeEnum {
RevenueAnalytics = 'revenue_analytics',
RevenueShare = 'revenue_share',
Salesforce = 'salesforce',
Xero = 'xero',
ZeroAmountFees = 'zero_amount_fees'
Xero = 'xero'
}

export type Properties = {
Expand Down Expand Up @@ -4699,6 +4698,8 @@ export type Query = {
overdueBalances: OverdueBalanceCollection;
/** Query a password reset by token */
passwordReset: ResetPassword;
/** Query a single Payment */
payment?: Maybe<Payment>;
/** Query a single payment provider */
paymentProvider?: Maybe<PaymentProvider>;
/** Query organization's payment providers */
Expand Down Expand Up @@ -5057,6 +5058,11 @@ export type QueryPasswordResetArgs = {
};


export type QueryPaymentArgs = {
id: Scalars['ID']['input'];
};


export type QueryPaymentProviderArgs = {
code?: InputMaybe<Scalars['String']['input']>;
id?: InputMaybe<Scalars['ID']['input']>;
Expand All @@ -5078,6 +5084,7 @@ export type QueryPaymentRequestsArgs = {


export type QueryPaymentsArgs = {
externalCustomerId?: InputMaybe<Scalars['ID']['input']>;
invoiceId?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['Int']['input']>;
page?: InputMaybe<Scalars['Int']['input']>;
Expand Down Expand Up @@ -8627,7 +8634,7 @@ export type GetPayableInvoiceQueryVariables = Exact<{
}>;


export type GetPayableInvoiceQuery = { __typename?: 'Query', invoice?: { __typename?: 'Invoice', id: string, number: string, paymentStatus: InvoicePaymentStatusTypeEnum, status: InvoiceStatusTypeEnum, totalAmountCents: any, issuingDate: any, currency?: CurrencyEnum | null } | null };
export type GetPayableInvoiceQuery = { __typename?: 'Query', invoice?: { __typename?: 'Invoice', id: string, number: string, paymentStatus: InvoicePaymentStatusTypeEnum, status: InvoiceStatusTypeEnum, totalDueAmountCents: any, issuingDate: any, currency?: CurrencyEnum | null } | null };

export type CreatePaymentMutationVariables = Exact<{
input: CreatePaymentInput;
Expand Down Expand Up @@ -22199,7 +22206,7 @@ export const GetPayableInvoiceDocument = gql`
number
paymentStatus
status
totalAmountCents
totalDueAmountCents
issuingDate
currency
}
Expand Down
19 changes: 11 additions & 8 deletions src/pages/CreatePayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ gql`
number
paymentStatus
status
totalAmountCents
totalDueAmountCents
issuingDate
currency
}
Expand Down Expand Up @@ -135,14 +135,14 @@ const CreatePayment = () => {
(value: string) => {
const amount = Number(value)

return amount > 0 && amount <= deserializeAmount(invoice?.totalAmountCents ?? 0, currency)
return amount > 0 && amount <= deserializeAmount(invoice?.totalDueAmountCents ?? 0, currency)
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[invoice],
)

const remainingAmount = useMemo(() => {
const totalAmount = deserializeAmount(invoice?.totalAmountCents ?? 0, currency)
const totalAmount = deserializeAmount(invoice?.totalDueAmountCents ?? 0, currency)
const amount = Number(formikProps.values.amountCents)

return totalAmount - amount
Expand Down Expand Up @@ -230,14 +230,17 @@ const CreatePayment = () => {
content: ({ number }) => number,
},
{
key: 'totalAmountCents',
key: 'totalDueAmountCents',
title: translate('text_17374735502775afvcm9pqxk'),
textAlign: 'right',
content: ({ totalAmountCents }) => (
content: ({ totalDueAmountCents }) => (
<Typography variant="bodyHl" color="textSecondary">
{intlFormatNumber(deserializeAmount(totalAmountCents, currency), {
currency,
})}
{intlFormatNumber(
deserializeAmount(totalDueAmountCents, currency),
{
currency,
},
)}
</Typography>
),
},
Expand Down

0 comments on commit 365bcc6

Please sign in to comment.