Aggiunge pagamento con bonifico e importo concordato per società.
Il piano si attiva solo dopo la conferma admin; Stripe resta a listino se non c'è un prezzo commerciale. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
class AddBankTransferBilling < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :billing_club_quotes, id: :uuid do |t|
|
||||
t.references :club, null: false, foreign_key: true, type: :uuid, index: false
|
||||
t.string :plan_slug, null: false
|
||||
t.string :billing_interval, null: false
|
||||
t.integer :amount_cents, null: false
|
||||
t.string :currency, null: false, default: "eur"
|
||||
t.string :note
|
||||
t.boolean :active, null: false, default: true
|
||||
t.references :created_by_admin, foreign_key: { to_table: :admin_accounts }, type: :uuid
|
||||
t.timestamps
|
||||
end
|
||||
add_index :billing_club_quotes, :club_id, unique: true, where: "active = TRUE",
|
||||
name: "index_billing_club_quotes_active_club"
|
||||
|
||||
create_table :billing_transfer_orders, id: :uuid do |t|
|
||||
t.references :club, null: false, foreign_key: true, type: :uuid
|
||||
t.references :billing_club_quote, foreign_key: true, type: :uuid
|
||||
t.references :billing_payment, foreign_key: true, type: :uuid
|
||||
t.string :plan_slug, null: false
|
||||
t.string :billing_interval, null: false
|
||||
t.integer :amount_cents, null: false
|
||||
t.string :currency, null: false, default: "eur"
|
||||
t.string :kind, null: false
|
||||
t.string :status, null: false, default: "awaiting_payment"
|
||||
t.string :reference_code, null: false
|
||||
t.references :requested_by_user, foreign_key: { to_table: :users }, type: :uuid
|
||||
t.references :confirmed_by_admin, foreign_key: { to_table: :admin_accounts }, type: :uuid
|
||||
t.datetime :confirmed_at
|
||||
t.datetime :cancelled_at
|
||||
t.timestamps
|
||||
end
|
||||
add_index :billing_transfer_orders, :reference_code, unique: true
|
||||
add_index :billing_transfer_orders, :status
|
||||
add_index :billing_transfer_orders, :club_id, unique: true, where: "status = 'awaiting_payment'",
|
||||
name: "index_billing_transfer_orders_awaiting_club"
|
||||
|
||||
add_column :billing_payments, :provider, :string, null: false, default: "stripe"
|
||||
add_index :billing_payments, :provider
|
||||
end
|
||||
end
|
||||
Generated
+52
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_08_13_184100) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_08_18_220000) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
@@ -51,6 +51,21 @@ ActiveRecord::Schema[7.2].define(version: 2026_08_13_184100) do
|
||||
t.index ["username"], name: "index_admin_accounts_on_username", unique: true
|
||||
end
|
||||
|
||||
create_table "billing_club_quotes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "club_id", null: false
|
||||
t.string "plan_slug", null: false
|
||||
t.string "billing_interval", null: false
|
||||
t.integer "amount_cents", null: false
|
||||
t.string "currency", default: "eur", null: false
|
||||
t.string "note"
|
||||
t.boolean "active", default: true, null: false
|
||||
t.uuid "created_by_admin_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["club_id"], name: "index_billing_club_quotes_active_club", unique: true, where: "(active = true)"
|
||||
t.index ["created_by_admin_id"], name: "index_billing_club_quotes_on_created_by_admin_id"
|
||||
end
|
||||
|
||||
create_table "billing_invoices", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "club_id", null: false
|
||||
t.uuid "billing_payment_id"
|
||||
@@ -87,11 +102,40 @@ ActiveRecord::Schema[7.2].define(version: 2026_08_13_184100) do
|
||||
t.string "receipt_url"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "provider", default: "stripe", null: false
|
||||
t.index ["club_id", "paid_at"], name: "index_billing_payments_on_club_id_and_paid_at"
|
||||
t.index ["club_id"], name: "index_billing_payments_on_club_id"
|
||||
t.index ["provider"], name: "index_billing_payments_on_provider"
|
||||
t.index ["stripe_invoice_id"], name: "index_billing_payments_on_stripe_invoice_id", unique: true, where: "(stripe_invoice_id IS NOT NULL)"
|
||||
end
|
||||
|
||||
create_table "billing_transfer_orders", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "club_id", null: false
|
||||
t.uuid "billing_club_quote_id"
|
||||
t.uuid "billing_payment_id"
|
||||
t.string "plan_slug", null: false
|
||||
t.string "billing_interval", null: false
|
||||
t.integer "amount_cents", null: false
|
||||
t.string "currency", default: "eur", null: false
|
||||
t.string "kind", null: false
|
||||
t.string "status", default: "awaiting_payment", null: false
|
||||
t.string "reference_code", null: false
|
||||
t.uuid "requested_by_user_id"
|
||||
t.uuid "confirmed_by_admin_id"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "cancelled_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["billing_club_quote_id"], name: "index_billing_transfer_orders_on_billing_club_quote_id"
|
||||
t.index ["billing_payment_id"], name: "index_billing_transfer_orders_on_billing_payment_id"
|
||||
t.index ["club_id"], name: "index_billing_transfer_orders_awaiting_club", unique: true, where: "((status)::text = 'awaiting_payment'::text)"
|
||||
t.index ["club_id"], name: "index_billing_transfer_orders_on_club_id"
|
||||
t.index ["confirmed_by_admin_id"], name: "index_billing_transfer_orders_on_confirmed_by_admin_id"
|
||||
t.index ["reference_code"], name: "index_billing_transfer_orders_on_reference_code", unique: true
|
||||
t.index ["requested_by_user_id"], name: "index_billing_transfer_orders_on_requested_by_user_id"
|
||||
t.index ["status"], name: "index_billing_transfer_orders_on_status"
|
||||
end
|
||||
|
||||
create_table "club_memberships", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "user_id", null: false
|
||||
t.uuid "club_id", null: false
|
||||
@@ -427,9 +471,16 @@ ActiveRecord::Schema[7.2].define(version: 2026_08_13_184100) do
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "billing_club_quotes", "admin_accounts", column: "created_by_admin_id"
|
||||
add_foreign_key "billing_club_quotes", "clubs"
|
||||
add_foreign_key "billing_invoices", "billing_payments"
|
||||
add_foreign_key "billing_invoices", "clubs"
|
||||
add_foreign_key "billing_payments", "clubs"
|
||||
add_foreign_key "billing_transfer_orders", "admin_accounts", column: "confirmed_by_admin_id"
|
||||
add_foreign_key "billing_transfer_orders", "billing_club_quotes"
|
||||
add_foreign_key "billing_transfer_orders", "billing_payments"
|
||||
add_foreign_key "billing_transfer_orders", "clubs"
|
||||
add_foreign_key "billing_transfer_orders", "users", column: "requested_by_user_id"
|
||||
add_foreign_key "club_memberships", "clubs"
|
||||
add_foreign_key "club_memberships", "users"
|
||||
add_foreign_key "device_states", "stream_sessions"
|
||||
|
||||
Reference in New Issue
Block a user