Skip to content

Commit

Permalink
fix: use period end instead of due at (#10151)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Aug 21, 2024
1 parent a1599e9 commit 6492679
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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

0 comments on commit 6492679

Please sign in to comment.