diff --git a/app/controllers/admin/finances_controller.rb b/app/controllers/admin/finances_controller.rb index 76a93619..5aae587b 100644 --- a/app/controllers/admin/finances_controller.rb +++ b/app/controllers/admin/finances_controller.rb @@ -5,6 +5,7 @@ class Admin::FinancesController < Admin::BaseController @bank_accounts = BankAccount.order('name') @bank_gateways = BankGateway.order('name') @financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC') + @supplier_categories = SupplierCategory.order('name') end def update_bank_accounts @@ -21,4 +22,9 @@ class Admin::FinancesController < Admin::BaseController @financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC') render :layout => false end + + def update_supplier_categories + @supplier_categories = SupplierCategory.order('name') + render :layout => false + end end diff --git a/app/controllers/admin/supplier_categories_controller.rb b/app/controllers/admin/supplier_categories_controller.rb new file mode 100644 index 00000000..f5768a21 --- /dev/null +++ b/app/controllers/admin/supplier_categories_controller.rb @@ -0,0 +1,41 @@ +class Admin::SupplierCategoriesController < Admin::BaseController + inherit_resources + + def new + @supplier_category = SupplierCategory.new(params[:supplier_category]) + render layout: false + end + + def create + @supplier_category = SupplierCategory.new(params[:supplier_category]) + if @supplier_category.valid? && @supplier_category.save + redirect_to update_supplier_categories_admin_finances_url, status: :see_other + else + render action: 'new', layout: false + end + end + + def edit + @supplier_category = SupplierCategory.find(params[:id]) + render action: 'new', layout: false + end + + def update + @supplier_category = SupplierCategory.find(params[:id]) + + if @supplier_category.update(params[:supplier_category]) + redirect_to update_supplier_categories_admin_finances_url, status: :see_other + else + render action: 'new', layout: false + end + end + + def destroy + @supplier_category = SupplierCategory.find(params[:id]) + @supplier_category.destroy + redirect_to update_supplier_categories_admin_finances_url, status: :see_other + rescue StandardError => e + flash.now[:alert] = e.message + render template: 'shared/alert' + end +end diff --git a/app/views/admin/finances/_supplier_categories.html.haml b/app/views/admin/finances/_supplier_categories.html.haml new file mode 100644 index 00000000..2383beba --- /dev/null +++ b/app/views/admin/finances/_supplier_categories.html.haml @@ -0,0 +1,13 @@ +%table.table.table-striped + %thead + %tr + %th= heading_helper SupplierCategory, :name + %th + %tbody + - @supplier_categories.each do |supplier_category| + %tr + %td= supplier_category.name + %td + = link_to t('ui.edit'), edit_admin_supplier_category_path(supplier_category), remote: true, class: 'btn btn-mini' + = link_to t('ui.delete'), [:admin, supplier_category], :method => :delete, :data => {:confirm => t('ui.confirm_delete', name: supplier_category.name)}, + remote: true, class: 'btn btn-mini btn-danger' diff --git a/app/views/admin/finances/index.html.haml b/app/views/admin/finances/index.html.haml index f798beca..728ea61a 100644 --- a/app/views/admin/finances/index.html.haml +++ b/app/views/admin/finances/index.html.haml @@ -4,6 +4,7 @@ = link_to t('.new_financial_transaction_class'), new_admin_financial_transaction_class_path, remote: true, class: 'btn btn-primary' = link_to t('.new_bank_account'), new_admin_bank_account_path, remote: true, class: 'btn' = link_to t('.new_bank_gateway'), new_admin_bank_gateway_path, remote: true, class: 'btn' + = link_to t('.new_supplier_category'), new_admin_supplier_category_path, remote: true, class: 'btn' - content_for :sidebar do %p= t('.first_paragraph').html_safe @@ -16,3 +17,6 @@ %h2= t('.bank_gateways') #bank_gateways_table= render 'bank_gateways' + +%h2= t('.supplier_categories') +#supplier_categories_table= render 'supplier_categories' diff --git a/app/views/admin/finances/update_supplier_categories.js.haml b/app/views/admin/finances/update_supplier_categories.js.haml new file mode 100644 index 00000000..244d0334 --- /dev/null +++ b/app/views/admin/finances/update_supplier_categories.js.haml @@ -0,0 +1,2 @@ +$('#supplier_categories_table').html('#{escape_javascript(render("admin/finances/supplier_categories"))}'); +$('#modalContainer').modal('hide'); diff --git a/app/views/admin/supplier_categories/_form.html.haml b/app/views/admin/supplier_categories/_form.html.haml new file mode 100644 index 00000000..1d526b60 --- /dev/null +++ b/app/views/admin/supplier_categories/_form.html.haml @@ -0,0 +1,12 @@ += simple_form_for [:admin, @supplier_category], :validate => true, :remote => true do |f| + .modal-header + = close_button :modal + %h3= @supplier_category.new_record? ? t('.title_new') : t('.title_edit') + .modal-body + = f.input :name + = f.input :description + = f.association :financial_transaction_class, :include_blank => false + = f.association :bank_account, :include_blank => false + .modal-footer + = link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'} + = f.submit class: 'btn btn-primary' diff --git a/app/views/admin/supplier_categories/new.js.haml b/app/views/admin/supplier_categories/new.js.haml new file mode 100644 index 00000000..504f5527 --- /dev/null +++ b/app/views/admin/supplier_categories/new.js.haml @@ -0,0 +1,2 @@ +$('#modalContainer').html('#{j(render("form"))}'); +$('#modalContainer').modal(); diff --git a/config/locales/de.yml b/config/locales/de.yml index 2d96146c..9d9e9166 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -193,6 +193,11 @@ de: phone2: Telefon 2 shared_sync_method: Syncronisierungsmethode url: Webseite + supplier_category: + name: Name + description: Beschreibung + financial_transaction_class: Kontotransaktionsklasse + bank_account: Bankkonto task: created_by: Erstellt von created_on: Erstellt am @@ -267,6 +272,7 @@ de: stock_article: Lagerartikel stock_taking: Inventur supplier: Lieferant + supplier_category: Lieferantenkategorie task: Aufgabe user: Benutzerinnen workgroup: Arbeitsgruppe @@ -328,8 +334,11 @@ de: first_paragraph: Hier kannst du die Kontotransaktionsklassen und die dazugehörigen Kontotransaktionstypen verwalten. Jede Finanztansaktion hat einen bestimmten Typ, den du bei jeder Transaktion auswählen muss, falls du mehr als einen Typ angelegt hast. Die Kontotransaktionsklassen können zur Gruppierung der Kontotransaktionstypen verwendet werden und werden in der Kontoübersicht als weitere Spalten angezeigt, falls mehrere angelegt wurden. new_bank_account: Neues Bankkonto anlegen new_financial_transaction_class: Neue Kontotransaktionsklasse anlegen + new_bank_gateway: Neuen Bank Gateway anlegen title: Finanzen transaction_types: Kontotransaktionstypen + supplier_categories: Lieferantenkategorien + new_supplier_category: Neue Lieferantenkategorie anlegen transaction_types: name: Name new_financial_transaction_type: Neuen Kontotransaktionstyp anlegen @@ -428,6 +437,10 @@ de: workgroups: members: Mitglieder name: Name + supplier_categories: + form: + title_new: Neue Lieferantenkategorie anlegen + title_edit: Lieferantenkategorie bearbeiten application: controller: error_authn: Anmeldung erforderlich! diff --git a/config/locales/en.yml b/config/locales/en.yml index d94c7204..4f63a2c1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -193,6 +193,11 @@ en: phone2: Phone 2 shared_sync_method: How to synchronize url: Homepage + supplier_category: + name: Name + description: Description + financial_transaction_class: Financial transacton class + bank_account: Bank account task: created_by: Created by created_on: Created at @@ -267,6 +272,7 @@ en: stock_article: Stock article stock_taking: Stock taking supplier: Supplier + supplier_category: Supplier category task: Task user: User workgroup: Workgroup @@ -328,8 +334,11 @@ en: first_paragraph: Here you can manage the financial transaction classes and the corresponding financial transaction types. Every financial transaction has a type, which you have to select at every transaction, if you created more than one type. The financial transaction classes can be use to group the financial transaction types and will be shown as additional columns in the account overview, if there have been created more than one. new_bank_account: Add new bank account new_financial_transaction_class: Add new financial transaction class + new_bank_gateway: Add new bank gateway title: Finances transaction_types: Financial transaction types + supplier_categories: Supplier categories + new_supplier_category: New supplier category transaction_types: name: Name new_financial_transaction_type: Add new financial transaction type @@ -428,6 +437,10 @@ en: workgroups: members: members name: name + supplier_categories: + form: + title_new: Add supplier category + title_edit: Edit supplier category application: controller: error_authn: Authentication required! diff --git a/config/routes.rb b/config/routes.rb index d1aa8886..5b27eba4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -226,12 +226,14 @@ Rails.application.routes.draw do get :update_bank_accounts, on: :collection get :update_bank_gateways, on: :collection get :update_transaction_types, on: :collection + get :update_supplier_categories, on: :collection end resources :bank_accounts resources :bank_gateways resources :financial_transaction_classes resources :financial_transaction_types + resources :supplier_categories resources :users do post :restore, on: :member