Skip to content
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
4 changes: 4 additions & 0 deletions openmeter/billing/service/invoicestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ func (m *InvoiceStateMachine) finalizeInvoice(ctx context.Context) error {
}
}

if m.Invoice.IssuedAt == nil {
m.Invoice.IssuedAt = lo.ToPtr(clock.Now().In(time.UTC))
}

return nil, nil
})
}
Expand Down
1 change: 1 addition & 0 deletions test/app/custominvoicing/invocing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (s *CustomInvoicingTestSuite) TestInvoicingFlowHooksEnabled() {
})
s.NoError(err, "failed to handle payment trigger")
s.Equal(billing.InvoiceStatusPaid, invoice.Status, "invoice should be in paid state")
s.NotNil(invoice.IssuedAt, "invoice should have an issued at time")
})

// Payment status handling: we cannot transition the invoice to uncollectible state (full mesh transitions)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- no-op
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" = 'issued';
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" LIKE 'payment_processing.%';
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" = 'paid';
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" = 'overdue';
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" = 'uncollectible';
UPDATE "billing_invoices" SET "issued_at" = "updated_at" WHERE "issued_at" IS NULL AND "status" = 'voided';
4 changes: 3 additions & 1 deletion tools/migrate/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:JpP1Cx+kp6WzfJDwrc/G3ZZP1OGtWgFD00XSewJJp2o=
h1:0LWNhYBjp1Y4ImdOQjUCqwAA9a65PlPQfh/u/HVSWl8=
20240826120919_init.down.sql h1:AIbgwwngjkJEYa3yRZsIXQyBa2+qoZttwMXHxXEbHLI=
20240826120919_init.up.sql h1:/hYHWF3Z3dab8SMKnw99ixVktCuJe2bAw5wstCZIEN8=
20240903155435_entitlement-expired-index.down.sql h1:np2xgYs3KQ2z7qPBcobtGNhqWQ3V8NwEP9E5U3TmpSA=
Expand Down Expand Up @@ -185,3 +185,5 @@ h1:JpP1Cx+kp6WzfJDwrc/G3ZZP1OGtWgFD00XSewJJp2o=
20250422174622_rename-custominvoicing-settings.up.sql h1:LOD/GL4h7npzrzVj4oe8wuXgWVKqpKGExKMPDh6cm/I=
20250424160933_boolean-entitlement-count-annotation.down.sql h1:Kfppxj1Xqr9RFpo1+bG2ZnwAuV+Sc1iJLwEQxzxUnUo=
20250424160933_boolean-entitlement-count-annotation.up.sql h1:CzlS0AexXMvrwU16u787Wk1iQcOOocrRwCM72TIRTgQ=
20250506182753_backfill-invoice-at.down.sql h1:RfF9WrzCcYHMC4kh4dhQLe35U9aZyFhka3bucD2KfKI=
20250506182753_backfill-invoice-at.up.sql h1:+zKc+N6odq1SJ9XqfvIqCgx7inDO4pzQKjQOVyrGuPo=
Loading