subtract debits from cake balance

This commit is contained in:
João Geonizeli
2021-09-18 16:08:49 -03:00
parent fb957803cc
commit 698befd7aa
6 changed files with 27 additions and 9 deletions

View File

@@ -1,4 +1,6 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
default_scope { order(created_at: :desc) }
end

View File

@@ -33,6 +33,9 @@ class StakeOrder < ApplicationRecord
super & ["pool_name", "amount"]
end
scope :add, -> { where("amount > 0") }
scope :remove, -> { where("amount < 0") }
private
def notification_message

View File

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