mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Add activity type field #2691
This commit is contained in:
parent
fa4a2d2987
commit
d6a151b141
9 changed files with 45 additions and 67 deletions
|
@ -30,7 +30,7 @@ class Epp::DomainsController < EppController
|
|||
|
||||
ActiveRecord::Base.transaction do
|
||||
if @domain.save # TODO: Maybe use validate: false here because we have already validated the domain?
|
||||
current_user.registrar.debit!(@domain_price, "#{I18n.t('create')} #{@domain.name}")
|
||||
current_user.registrar.debit!(@domain_price, "#{I18n.t('create')} #{@domain.name}", AccountActivity::CREATE)
|
||||
render_epp_response '/epp/domains/create'
|
||||
else
|
||||
handle_errors(@domain)
|
||||
|
@ -102,7 +102,7 @@ class Epp::DomainsController < EppController
|
|||
fail ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
current_user.registrar.debit!(@domain_price, "#{I18n.t('renew')} #{@domain.name}")
|
||||
current_user.registrar.debit!(@domain_price, "#{I18n.t('renew')} #{@domain.name}", AccountActivity::RENEW)
|
||||
render_epp_response '/epp/domains/renew'
|
||||
else
|
||||
handle_errors(@domain)
|
||||
|
|
|
@ -4,6 +4,10 @@ class AccountActivity < ActiveRecord::Base
|
|||
belongs_to :bank_transaction
|
||||
belongs_to :invoice
|
||||
|
||||
CREATE = 'create'
|
||||
RENEW = 'renew'
|
||||
ADD_CREDIT = 'add_credit'
|
||||
|
||||
after_create :update_balance
|
||||
def update_balance
|
||||
account.balance += sum
|
||||
|
|
|
@ -79,7 +79,8 @@ class BankTransaction < ActiveRecord::Base
|
|||
invoice: invoice,
|
||||
sum: invoice.sum_without_vat,
|
||||
currency: currency,
|
||||
description: description
|
||||
description: description,
|
||||
activity_type: AccountActivity::ADD_CREDIT
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -123,19 +123,21 @@ class Registrar < ActiveRecord::Base
|
|||
accounts.find_by(account_type: Account::CASH)
|
||||
end
|
||||
|
||||
def debit!(sum, description)
|
||||
def debit!(sum, description, type = nil)
|
||||
cash_account.account_activities.create!(
|
||||
sum: -sum,
|
||||
currency: 'EUR',
|
||||
description: description
|
||||
description: description,
|
||||
activity_type: type
|
||||
)
|
||||
end
|
||||
|
||||
def credit!(sum, description)
|
||||
def credit!(sum, description, type = nil)
|
||||
cash_account.account_activities.create!(
|
||||
sum: sum,
|
||||
currency: 'EUR',
|
||||
description: description
|
||||
description: description,
|
||||
activity_type: type
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue