diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index e938a9d79..d2f9db426 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -10,4 +10,14 @@ class Admin::InvoicesController < AdminController def show @invoice = Invoice.find(params[:id]) end + + def cancel + if @invoice.cancel + flash[:notice] = t('record_updated') + redirect_to([:admin, @invoice]) + else + flash.now[:alert] = t('failed_to_update_record') + render :show + end + end end diff --git a/app/views/admin/invoices/show.haml b/app/views/admin/invoices/show.haml index 6f683c15d..ccae84913 100644 --- a/app/views/admin/invoices/show.haml +++ b/app/views/admin/invoices/show.haml @@ -4,8 +4,12 @@ = @invoice .col-sm-6 %h1.text-right.text-center-xs - = link_to(t('back'), :back, class: 'btn btn-default') + - if !@invoice.cancelled? && !@invoice.binded? + = link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-default') + = link_to(t('back'), admin_invoices_path, class: 'btn btn-default') %hr += render 'shared/full_errors', object: @invoice + .row .col-md-6= render 'registrar/invoices/partials/details' .row diff --git a/config/routes.rb b/config/routes.rb index d332402a2..6609bf9a1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -102,7 +102,9 @@ Rails.application.routes.draw do patch 'bind', on: :member end - resources :invoices + resources :invoices do + patch 'cancel', on: :member + end resources :domains do resources :domain_versions