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

fix: use period end instead of due at #10151

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const InvoiceRow = (props: Props) => {
graphql`
fragment InvoiceRow_invoice on Invoice {
id
dueAt
periodEndAt
total
payUrl
status
}
`,
invoiceRef
)
const {dueAt, total, payUrl, status} = invoice
const {periodEndAt, total, payUrl, status} = invoice
const isEstimate = status === 'UPCOMING'

return (
Expand All @@ -88,8 +88,8 @@ const InvoiceRow = (props: Props) => {
<InfoRow>
<InvoiceTitle>
{status === 'UPCOMING'
? `Due on ${makeDateString(dueAt)}`
: `${makeDateString(dueAt)}`}
? `Due on ${makeDateString(periodEndAt)}`
: `${makeDateString(periodEndAt)}`}
</InvoiceTitle>
<InfoRowRight>
<InvoiceAmount>
Expand Down
8 changes: 4 additions & 4 deletions packages/server/graphql/public/fields/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ export const invoices: NonNullable<UserResolvers['invoices']> = async (
])
const parabolUpcomingInvoice: Invoice = {
id: `upcoming_${orgId}`,
dueAt: fromEpochSeconds(upcomingInvoice.due_date!),
periodEndAt: fromEpochSeconds(upcomingInvoice.period_end!),
total: upcomingInvoice.total,
payUrl: session.url,
status: 'UPCOMING'
}

const parabolPastInvoices: Invoice[] = invoices.data.map((stripeInvoice) => {
const {id, due_date, total, status: stripeStatus} = stripeInvoice
const {id, period_end, total, status: stripeStatus} = stripeInvoice
const status: InvoiceStatusEnum =
stripeStatus === 'uncollectible' ? 'FAILED' : stripeStatus === 'paid' ? 'PAID' : 'PENDING'
return {
id,
dueAt: fromEpochSeconds(due_date!),
periodEndAt: fromEpochSeconds(period_end!),
total,
payUrl: session.url,
status
}
})
const edges = [parabolUpcomingInvoice, ...parabolPastInvoices].map((node) => ({
cursor: node.dueAt,
cursor: node.periodEndAt,
node
}))
const firstEdge = edges[0]
Expand Down
4 changes: 2 additions & 2 deletions packages/server/graphql/public/typeDefs/Invoice.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type Invoice {
id: ID!

"""
The datetime the invoice is due
The datetime the invoice period has ended
"""
dueAt: DateTime!
periodEndAt: DateTime!

"""
The total amount for the invoice (in USD)
Expand Down
Loading