mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-11 22:24:21 +01:00
25 lines
443 B
Ruby
25 lines
443 B
Ruby
class Wallet < ActiveRecord::Base
|
|
include AmountConcern
|
|
|
|
belongs_to :user
|
|
has_many :wallet_transactions, dependent: :destroy
|
|
|
|
validates :user, presence: true
|
|
|
|
def credit(amount)
|
|
if amount.is_a?(Numeric) and amount >= 0
|
|
self.amount += amount
|
|
return save
|
|
end
|
|
false
|
|
end
|
|
|
|
def debit(amount)
|
|
if amount.is_a?(Numeric) and amount >= 0
|
|
self.amount -= amount
|
|
return save
|
|
end
|
|
false
|
|
end
|
|
end
|