mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) unable to credit wallet amount
This commit is contained in:
parent
766c08a302
commit
3224daf791
@ -23,7 +23,7 @@ class API::WalletController < API::ApiController
|
||||
@wallet = Wallet.find(credit_params[:id])
|
||||
authorize @wallet
|
||||
service = WalletService.new(user: current_user, wallet: @wallet)
|
||||
transaction = service.credit(credit_params[:amount])
|
||||
transaction = service.credit(credit_params[:amount].to_f)
|
||||
if transaction
|
||||
service.create_avoir(transaction, credit_params[:avoir_date], credit_params[:avoir_description]) if credit_params[:avoir]
|
||||
render :show
|
||||
|
@ -15,7 +15,7 @@ class Wallet < ApplicationRecord
|
||||
|
||||
def credit(amount)
|
||||
if amount.is_a?(Numeric) && amount >= 0
|
||||
self.amount += amount
|
||||
self.amount = (BigDecimal(self.amount.to_s) + BigDecimal(amount.to_s)).to_f
|
||||
return save
|
||||
end
|
||||
false
|
||||
@ -23,7 +23,7 @@ class Wallet < ApplicationRecord
|
||||
|
||||
def debit(amount)
|
||||
if amount.is_a?(Numeric) && amount >= 0
|
||||
self.amount -= amount
|
||||
self.amount = (BigDecimal(self.amount.to_s) - BigDecimal(amount.to_s)).to_f
|
||||
return save
|
||||
end
|
||||
false
|
||||
|
Loading…
x
Reference in New Issue
Block a user