Files
ubicloud/migrate/20230806_invoices.rb
Burak Yucesoy 4de6fa0e61 Add mechanism to generate invoices
With this commit, we added InvoiceGenerator class that processes billing records
to generate invoices. We generate one invoice per project. It might make sense
to generate one invoice per organization, but we don't have organization like
structure yet. An alternative could be generating invoice per user, but it is
also not clear which user owns a given project, as there is no owner concept in
ABAC. Instead, what we agreed so far is that each project would have its own
billing information (credit card details, billing address etc.), in such model
it makes sense to generate invoice per project.

Invoice line items are kept in a JSONB columns grouped by resource ids, which
might seem unnecessary at the moment as VMs, our only paid resource, only has
one line item, that is core count. However more complex resources would have
multiple line items associated with them. For example Postgres service would
have 2 lines items; core count and storage.

It is important to note that invoice generation, in its current form, is not
complete. Most notably, invoice number generation and tax part is missing. We
are planning to use Stripe APIs for those.
2023-08-07 10:52:22 +03:00

14 lines
374 B
Ruby

# frozen_string_literal: true
Sequel.migration do
up do
create_table(:invoice) do
column :id, :uuid, primary_key: true, default: nil
column :project_id, :project, type: :uuid, null: false
column :content, :jsonb, null: false
column :created_at, :timestamptz, null: false, default: Sequel.lit("now()")
index :project_id
end
end
end