From 58141dca9454c95d095b6d5a184eebc0bb5331df Mon Sep 17 00:00:00 2001 From: kbe Date: Wed, 17 Sep 2025 00:08:14 +0200 Subject: [PATCH] fix(event model): duplicate payout status enum removed --- app/models/event.rb | 9 --------- app/services/stripe_connect_service.rb | 16 ++++++++-------- db/schema.rb | 12 +++++++----- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index ad59b2e..46090e2 100755 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -67,15 +67,6 @@ class Event < ApplicationRecord # === Instance Methods === - # Payout status enum - enum :payout_status, { - not_requested: 0, - requested: 1, - processing: 2, - completed: 3, - failed: 4 - }, default: :not_requested - # Payout methods def can_request_payout? event_ended? && earnings.pending.any? && user.can_receive_payouts? diff --git a/app/services/stripe_connect_service.rb b/app/services/stripe_connect_service.rb index 55466f7..206a549 100644 --- a/app/services/stripe_connect_service.rb +++ b/app/services/stripe_connect_service.rb @@ -3,15 +3,15 @@ class StripeConnectService return if user.stripe_connected_account_id.present? account = Stripe::Account.create( - type: 'express', - country: 'FR', + type: "express", + country: "FR", email: user.email, capabilities: { - card_payments: {requested: true}, - transfers: {requested: true} + card_payments: { requested: true }, + transfers: { requested: true } } ) - + user.update!(stripe_connected_account_id: account.id) account end @@ -23,13 +23,13 @@ class StripeConnectService account: user.stripe_connected_account_id, refresh_url: Rails.application.routes.url_helpers.promoter_stripe_refresh_url, return_url: Rails.application.routes.url_helpers.promoter_stripe_return_url, - type: 'account_onboarding' + type: "account_onboarding" ) - + account_link.url end def self.get_account_details(account_id) Stripe::Account.retrieve(account_id) end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index 956d390..3cc8abe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,18 +10,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_09_16_215119) do +ActiveRecord::Schema[8.0].define(version: 2025_09_16_220259) do create_table "earnings", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t| t.integer "amount_cents" t.integer "fee_cents" t.integer "status" t.string "stripe_payout_id" + t.integer "net_amount_cents" t.bigint "event_id", null: false t.bigint "user_id", null: false t.bigint "order_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "net_amount_cents" t.index ["event_id"], name: "index_earnings_on_event_id" t.index ["order_id"], name: "index_earnings_on_order_id" t.index ["user_id"], name: "index_earnings_on_user_id" @@ -42,12 +42,13 @@ ActiveRecord::Schema[8.0].define(version: 2025_09_16_215119) do t.boolean "featured", default: false, null: false t.bigint "user_id", null: false t.boolean "allow_booking_during_event", default: false, null: false + t.integer "payout_status" + t.datetime "payout_requested_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.datetime "payout_requested_at" - t.integer "payout_status" t.index ["featured"], name: "index_events_on_featured" t.index ["latitude", "longitude"], name: "index_events_on_latitude_and_longitude" + t.index ["payout_status"], name: "index_events_on_payout_status" t.index ["state"], name: "index_events_on_state" t.index ["user_id"], name: "index_events_on_user_id" end @@ -117,10 +118,11 @@ ActiveRecord::Schema[8.0].define(version: 2025_09_16_215119) do t.string "company_website" t.string "stripe_customer_id" t.boolean "onboarding_completed", default: false, null: false + t.string "stripe_connected_account_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "stripe_connected_account_id" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["stripe_connected_account_id"], name: "index_users_on_stripe_connected_account_id", unique: true end end