remove crypto balance from backend

This commit is contained in:
João Geonizeli
2021-09-13 20:54:21 -03:00
parent d43939dee4
commit d6b6b997d5
33 changed files with 836 additions and 1422 deletions

View File

@@ -1,35 +0,0 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: balances
#
# id :bigint not null, primary key
# amount :decimal(20, 10) default(0.0), not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_balances_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
class Balance < ApplicationRecord
include Trackable
belongs_to :user
validates :amount, presence: true, numericality: { greater_than_or_equal_to: 0 }
def withdrawal!(value)
update!(amount: amount - value)
end
def deposit!(value)
update!(amount: amount + value)
end
end

View File

@@ -29,7 +29,6 @@ class User < ApplicationRecord
has_many :documents, class_name: "UserDocument", dependent: :destroy
has_many :stake_orders, dependent: :restrict_with_error
has_one :balance, dependent: :restrict_with_error
has_one :fiat_balance, dependent: :restrict_with_error
validates :first_name, :last_name, :email, presence: true