mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Interface for manual binding
This commit is contained in:
parent
adf321bafa
commit
ccb44fa3b9
8 changed files with 189 additions and 23 deletions
|
@ -1,5 +1,29 @@
|
||||||
class Admin::BankTransactionsController < AdminController
|
class Admin::BankTransactionsController < AdminController
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def show; end
|
def update
|
||||||
|
if @bank_transaction.update(bank_transaction_params)
|
||||||
|
flash[:notice] = I18n.t('record_updated')
|
||||||
|
redirect_to [:admin, @bank_transaction]
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||||
|
render 'edit'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bind
|
||||||
|
if @bank_transaction.bind_invoice(params[:invoice_id])
|
||||||
|
flash[:notice] = I18n.t('record_created')
|
||||||
|
redirect_to [:admin, @bank_transaction]
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||||
|
render 'show'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def bank_transaction_params
|
||||||
|
params.require(:bank_transaction).permit(:description, :sum, :reference_no)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ class BankTransaction < ActiveRecord::Base
|
||||||
# For successful binding, reference number, invoice id and sum must match with the invoice
|
# For successful binding, reference number, invoice id and sum must match with the invoice
|
||||||
# rubocop: disable Metrics/PerceivedComplexity
|
# rubocop: disable Metrics/PerceivedComplexity
|
||||||
# rubocop: disable Metrics/CyclomaticComplexity
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
def bind_invoice
|
def autobind_invoice
|
||||||
return if binded?
|
return if binded?
|
||||||
registrar = Registrar.find_by(reference_no: reference_no)
|
registrar = Registrar.find_by(reference_no: reference_no)
|
||||||
return unless registrar
|
return unless registrar
|
||||||
|
@ -33,6 +33,38 @@ class BankTransaction < ActiveRecord::Base
|
||||||
return if invoice.binded?
|
return if invoice.binded?
|
||||||
|
|
||||||
return if invoice.sum != sum
|
return if invoice.sum != sum
|
||||||
|
create_activity(registrar, invoice)
|
||||||
|
end
|
||||||
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
|
def bind_invoice(invoice_id)
|
||||||
|
if binded?
|
||||||
|
errors.add(:base, I18n.t('transaction_is_already_binded'))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
invoice = Invoice.find_by(id: invoice_id)
|
||||||
|
|
||||||
|
unless invoice
|
||||||
|
errors.add(:base, I18n.t('invoice_was_not_found'))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if invoice.binded?
|
||||||
|
errors.add(:base, I18n.t('invoice_is_already_binded'))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if invoice.sum != sum
|
||||||
|
errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match'))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
create_activity(invoice.buyer, invoice)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_activity(registrar, invoice)
|
||||||
create_account_activity(
|
create_account_activity(
|
||||||
account: registrar.cash_account,
|
account: registrar.cash_account,
|
||||||
invoice: invoice,
|
invoice: invoice,
|
||||||
|
@ -41,6 +73,4 @@ class BankTransaction < ActiveRecord::Base
|
||||||
description: description
|
description: description
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/PerceivedComplexity
|
|
||||||
# rubocop: enable Metrics/CyclomaticComplexity
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
.row
|
- content_for :actions do
|
||||||
.col-sm-6
|
= link_to(t('import'), new_admin_bank_statement_path, class: 'btn btn-default')
|
||||||
%h2.text-center-xs= t('bank_statements')
|
= render 'admin/shared/title', name: "#{t(:bank_statements)}"
|
||||||
.col-sm-6
|
|
||||||
%h2.text-right.text-center-xs
|
|
||||||
= link_to(t('import'), new_admin_bank_statement_path, class: 'btn btn-primary')
|
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
74
app/views/admin/bank_transactions/edit.haml
Normal file
74
app/views/admin/bank_transactions/edit.haml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
- content_for :actions do
|
||||||
|
= link_to(t('back'), :back, class: 'btn btn-default')
|
||||||
|
= render 'admin/shared/title', name: "#{t('bank_transaction')}"
|
||||||
|
|
||||||
|
= form_for([:admin, @bank_transaction], html: { class: 'form-horizontal' }) do |f|
|
||||||
|
= render 'shared/full_errors', object: @bank_transaction
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
.form-group
|
||||||
|
= f.label :status, class: 'col-md-2 control-label'
|
||||||
|
- c = @bank_transaction.binded? ? 'text-success' : 'text-danger'
|
||||||
|
.col-md-10.form-control-static{class: c}
|
||||||
|
= @bank_transaction.binded? ? t('binded') : t('not_binded')
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :description, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:description, class: 'form-control')
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :sum, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:sum, class: 'form-control')
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :reference_no, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:reference_no, class: 'form-control')
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :document_no, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:document_no, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :bank_reference, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:bank_reference, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :iban, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:iban, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :buyer_bank_code, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:buyer_bank_code, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :buyer_iban, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:buyer_iban, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :buyer_name, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:buyer_name, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :currency, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:currency, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :paid_at, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= f.text_field(:paid_at, class: 'form-control', disabled: :disabled)
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-8.text-right
|
||||||
|
= button_tag(t('save'), class: 'btn btn-primary')
|
27
app/views/admin/bank_transactions/manual_binding.haml
Normal file
27
app/views/admin/bank_transactions/manual_binding.haml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
- content_for :actions do
|
||||||
|
= link_to(t('back_to_bank_transaction'), [:admin, @bank_transaction], class: 'btn btn-default')
|
||||||
|
= render 'admin/shared/title', name: "#{t('manual_binding')}"
|
||||||
|
|
||||||
|
= form_for([:admin, @bank_transaction], url: {action: :bind}, html: { class: 'form-horizontal' }) do |f|
|
||||||
|
= render 'shared/full_errors', object: @bank_transaction
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
.form-group
|
||||||
|
= f.label :status, class: 'col-md-2 control-label'
|
||||||
|
- c = @bank_transaction.binded? ? 'text-success' : 'text-danger'
|
||||||
|
.col-md-10.form-control-static{class: c}
|
||||||
|
= @bank_transaction.binded? ? t('binded') : t('not_binded')
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
= f.label :sum, class: 'col-md-2 control-label'
|
||||||
|
.col-md-10.form-control-static
|
||||||
|
= "#{@bank_transaction.sum} #{@bank_transaction.currency}"
|
||||||
|
.form-group
|
||||||
|
= label_tag :invoice_id, t('invoice'), class: 'col-md-2 control-label'
|
||||||
|
.col-md-10
|
||||||
|
= text_field_tag(:invoice_id, params[:invoice_id], class: 'form-control')
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-8.text-right
|
||||||
|
= button_tag(t('save'), class: 'btn btn-primary')
|
|
@ -1,11 +1,8 @@
|
||||||
.row
|
- content_for :actions do
|
||||||
.col-sm-6
|
= link_to(t('edit'), edit_admin_bank_transaction_path(@bank_transaction), class: 'btn btn-primary')
|
||||||
%h2.text-center-xs
|
= link_to(t('back_to_bank_statement'), admin_bank_statement_path(@bank_transaction.bank_statement), class: 'btn btn-default')
|
||||||
= t('bank_transaction')
|
= render 'admin/shared/title', name: "#{t('bank_transaction')}"
|
||||||
.col-sm-6
|
= render 'shared/full_errors', object: @bank_transaction
|
||||||
%h2.text-right.text-center-xs
|
|
||||||
= link_to(t('back_to_bank_statement'), admin_bank_statement_path(@bank_transaction.bank_statement), class: 'btn btn-primary')
|
|
||||||
%hr
|
|
||||||
%row
|
%row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
|
@ -20,10 +17,6 @@
|
||||||
- c = @bank_transaction.binded? ? 'text-success' : 'text-danger'
|
- c = @bank_transaction.binded? ? 'text-success' : 'text-danger'
|
||||||
%dd{class: c}= @bank_transaction.binded? ? t('binded') : t('not_binded')
|
%dd{class: c}= @bank_transaction.binded? ? t('binded') : t('not_binded')
|
||||||
|
|
||||||
- if @bank_transaction.binded?
|
|
||||||
%dt= t('binded_invoice')
|
|
||||||
%dd= link_to(@bank_transaction.binded_invoice, admin_invoice_path(@bank_transaction.binded_invoice))
|
|
||||||
|
|
||||||
%dt= t('bank_reference')
|
%dt= t('bank_reference')
|
||||||
%dd= @bank_transaction.bank_reference
|
%dd= @bank_transaction.bank_reference
|
||||||
|
|
||||||
|
@ -53,3 +46,16 @@
|
||||||
|
|
||||||
%dt= t('paid_at')
|
%dt= t('paid_at')
|
||||||
%dd= l(@bank_transaction.paid_at, format: :date_long)
|
%dd= l(@bank_transaction.paid_at, format: :date_long)
|
||||||
|
|
||||||
|
- if @bank_transaction.binded?
|
||||||
|
%dt= t('binded_invoice')
|
||||||
|
%dd= link_to(@bank_transaction.binded_invoice, admin_invoice_path(@bank_transaction.binded_invoice))
|
||||||
|
|
||||||
|
- unless @bank_transaction.binded?
|
||||||
|
= form_for([:admin, @bank_transaction], url: {action: :bind}, html: { class: 'form-inline' }) do |f|
|
||||||
|
.form-group
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt{style: 'padding-top: 5px'}= t('binded_invoice')
|
||||||
|
%dd
|
||||||
|
= text_field_tag(:invoice_id, params[:invoice_id], class: 'form-control')
|
||||||
|
= button_tag(t('bind_manually'), class: 'btn btn-primary')
|
||||||
|
|
|
@ -713,3 +713,8 @@ en:
|
||||||
is a computer that saves and forwards via a general-access data communications network such data that is connected with the domain name and corresponding IP addresses. Your IT helpdesk or Internet service provider will have the necessary information about the domain name servers.
|
is a computer that saves and forwards via a general-access data communications network such data that is connected with the domain name and corresponding IP addresses. Your IT helpdesk or Internet service provider will have the necessary information about the domain name servers.
|
||||||
account_activity: 'Account activity'
|
account_activity: 'Account activity'
|
||||||
receipt_date: 'Receipt date'
|
receipt_date: 'Receipt date'
|
||||||
|
manual_binding: 'Manual binding'
|
||||||
|
transaction_is_already_binded: 'Transaction is already binded'
|
||||||
|
invoice_was_not_found: 'Invoice was not found'
|
||||||
|
invoice_is_already_binded: 'Invoice is already binded'
|
||||||
|
invoice_and_transaction_sums_do_not_match: 'Invoice and transaction sums do not match'
|
||||||
|
|
|
@ -91,7 +91,9 @@ Rails.application.routes.draw do
|
||||||
get 'download_import_file', on: :member
|
get 'download_import_file', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :bank_transactions
|
resources :bank_transactions do
|
||||||
|
patch 'bind', on: :member
|
||||||
|
end
|
||||||
|
|
||||||
resources :invoices
|
resources :invoices
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue