From 0236fb5a603369ba5ead040d9f6164d552678f2e Mon Sep 17 00:00:00 2001 From: benni Date: Sat, 10 Nov 2012 16:44:05 +0100 Subject: [PATCH] Fixed finance module to work with bootstrap design. --- .../bootstrap_and_overrides.css.less | 4 +- app/controllers/articles_controller.rb | 26 +++--- .../finance/balancing_controller.rb | 15 +--- app/controllers/finance/base_controller.rb | 11 +++ .../financial_transactions_controller.rb | 13 +-- .../finance/invoices_controller.rb | 46 +++-------- .../finance/ordergroups_controller.rb | 12 +-- app/helpers/application_helper.rb | 32 +++++--- app/helpers/finance/order_articles_helper.rb | 4 +- app/models/group_order_article.rb | 2 +- app/views/articles/_articles.html.haml | 14 ++-- app/views/articles/new.js.haml | 2 +- .../finance/balancing/_edit_note.html.haml | 11 ++- .../_edit_results_by_articles.html.haml | 15 ++-- .../balancing/_group_order_articles.html.haml | 32 ++++---- .../balancing/_order_article.html.haml | 7 +- .../balancing/_order_article_result.html.haml | 2 +- app/views/finance/balancing/_orders.html.haml | 26 ++++++ app/views/finance/balancing/_summary.haml | 22 ++--- app/views/finance/balancing/confirm.html.haml | 27 +++---- app/views/finance/balancing/edit_note.js.haml | 3 +- app/views/finance/balancing/index.html.haml | 64 +-------------- app/views/finance/balancing/index.js.haml | 1 + app/views/finance/balancing/list.html.haml | 29 ------- app/views/finance/balancing/new.html.haml | 80 +++++++++---------- app/views/finance/balancing/new.js.haml | 2 +- .../finance/balancing/update_note.js.haml | 4 +- .../financial_transactions/_ordergroup.haml | 5 +- .../_transactions.html.haml | 41 ++++------ .../financial_transactions/index.html.haml | 32 ++++---- .../new_collection.html.haml | 20 +++-- .../group_order_articles/_form.html.haml | 18 +++-- .../finance/group_order_articles/edit.js.haml | 3 +- .../finance/group_order_articles/new.js.haml | 3 +- .../group_order_articles/update.js.haml | 8 +- app/views/finance/index.html.haml | 60 ++++++++++++++ app/views/finance/invoices/_form.html.haml | 8 +- .../finance/invoices/_invoices.html.haml | 31 +++++++ app/views/finance/invoices/edit.html.haml | 5 +- app/views/finance/invoices/index.html.haml | 33 +------- app/views/finance/invoices/index.js.haml | 1 + .../finance/order_articles/_edit.html.haml | 42 +++++----- .../finance/order_articles/_new.html.haml | 13 +-- .../finance/order_articles/create.js.haml | 5 +- app/views/finance/order_articles/edit.js.haml | 3 +- app/views/finance/order_articles/new.js.haml | 3 +- .../finance/order_articles/update.js.haml | 5 +- .../ordergroups/_ordergroups.html.haml | 30 +++---- app/views/finance/ordergroups/index.html.haml | 31 +++---- app/views/finance/ordergroups/index.js.haml | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/orders/_orders.html.haml | 6 +- config/locales/de.yml | 4 + config/navigation.rb | 3 +- config/routes.rb | 3 +- 55 files changed, 440 insertions(+), 486 deletions(-) create mode 100644 app/controllers/finance/base_controller.rb create mode 100644 app/views/finance/balancing/_orders.html.haml create mode 100644 app/views/finance/balancing/index.js.haml delete mode 100644 app/views/finance/balancing/list.html.haml create mode 100644 app/views/finance/index.html.haml create mode 100644 app/views/finance/invoices/_invoices.html.haml create mode 100644 app/views/finance/invoices/index.js.haml diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index d73930c3..e0b236a5 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -50,10 +50,10 @@ footer { table { - th.sortdown a:after { + a.sortdown:after { content: ' \25BC'; } - th.sortup a:after { + a.sortup:after { content: ' \25B2'; } diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 38f70c2e..4044d454 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -4,23 +4,23 @@ class ArticlesController < ApplicationController def index if params['sort'] - sort = case params['sort'] - when "name" then "articles.name" - when "unit" then "articles.unit" - when "category" then "article_categories.name" - when "note" then "articles.note" - when "availability" then "articles.availability" - when "name_reverse" then "articles.name DESC" - when "unit_reverse" then "articles.unit DESC" - when "category_reverse" then "article_categories.name DESC" - when "note_reverse" then "articles.note DESC" - when "availability_reverse" then "articles.availability DESC" - end + sort = case params['sort'] + when "name" then "articles.name" + when "unit" then "articles.unit" + when "category" then "article_categories.name" + when "note" then "articles.note" + when "availability" then "articles.availability" + when "name_reverse" then "articles.name DESC" + when "unit_reverse" then "articles.unit DESC" + when "category_reverse" then "article_categories.name DESC" + when "note_reverse" then "articles.note DESC" + when "availability_reverse" then "articles.availability DESC" + end else sort = "article_categories.name, articles.name" end - @articles = @supplier.articles.includes(:article_category).order(sort) + @articles = Article.where(supplier_id: @supplier).includes(:article_category).order(sort) @articles = @articles.where('articles.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil? @articles = @articles.page(params[:page]).per(@per_page) diff --git a/app/controllers/finance/balancing_controller.rb b/app/controllers/finance/balancing_controller.rb index 727c12e7..1b55d177 100644 --- a/app/controllers/finance/balancing_controller.rb +++ b/app/controllers/finance/balancing_controller.rb @@ -1,15 +1,8 @@ # encoding: utf-8 -class Finance::BalancingController < ApplicationController - before_filter :authenticate_finance +class Finance::BalancingController < Finance::BaseController def index - @financial_transactions = FinancialTransaction.order('created_on DESC').limit(8) - @orders = Order.finished_not_closed - @unpaid_invoices = Invoice.unpaid - end - - def list - @orders = Order.finished.paginate :page => params[:page], :per_page => 10, :order => 'ends DESC' + @orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC') end def new @@ -62,10 +55,10 @@ class Finance::BalancingController < ApplicationController def close @order = Order.find(params[:id]) @order.close!(@current_user) - redirect_to finance_balancing_url, notice: "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert." + redirect_to finance_root_url, notice: "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert." rescue => error - redirect_to finance_balancing_url, alert: "Ein Fehler ist beim Abrechnen aufgetreten: #{error.message}" + redirect_to new_finance_order_url(order_id: @order.id), alert: "Ein Fehler ist beim Abrechnen aufgetreten: #{error.message}" end # Close the order directly, without automaticly updating ordergroups account balances diff --git a/app/controllers/finance/base_controller.rb b/app/controllers/finance/base_controller.rb new file mode 100644 index 00000000..706965c1 --- /dev/null +++ b/app/controllers/finance/base_controller.rb @@ -0,0 +1,11 @@ +class Finance::BaseController < ApplicationController + before_filter :authenticate_finance + + def index + @financial_transactions = FinancialTransaction.order('created_on DESC').limit(8) + @orders = Order.finished_not_closed + @unpaid_invoices = Invoice.unpaid + + render template: 'finance/index' + end +end \ No newline at end of file diff --git a/app/controllers/finance/financial_transactions_controller.rb b/app/controllers/finance/financial_transactions_controller.rb index 80ae340f..f0ef8d30 100644 --- a/app/controllers/finance/financial_transactions_controller.rb +++ b/app/controllers/finance/financial_transactions_controller.rb @@ -19,15 +19,10 @@ class Finance::FinancialTransactionsController < ApplicationController sort = "created_on DESC" end - @financial_transactions = @ordergroup.financial_transactions.order(sort) + @financial_transactions = @ordergroup.financial_transactions.unscoped.order(sort) @financial_transactions = @financial_transactions.where('note LIKE ?', "%#{params[:query]}%") unless params[:query].nil? - @financial_transactions = @financial_transactions.paginate :page => params[:page], :per_page => 10 - - respond_to do |format| - format.html - format.js { render :layout => false } - end + @financial_transactions = @financial_transactions.page(params[:page]).per(@per_page) end def new @@ -55,9 +50,9 @@ class Finance::FinancialTransactionsController < ApplicationController Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user) end end - redirect_to finance_ordergroups_url, :notice => "Alle Transaktionen wurden gespeichert." + redirect_to finance_ordergroups_url, notice: "Alle Transaktionen wurden gespeichert." rescue => error - redirect_to :action => 'new_collection', :alert => "Ein Fehler ist aufgetreten: " + error.to_s + redirect_to finance_new_transaction_collection_url, alert: "Ein Fehler ist aufgetreten: " + error.to_s end protected diff --git a/app/controllers/finance/invoices_controller.rb b/app/controllers/finance/invoices_controller.rb index 81cfde48..60459e06 100644 --- a/app/controllers/finance/invoices_controller.rb +++ b/app/controllers/finance/invoices_controller.rb @@ -1,39 +1,23 @@ class Finance::InvoicesController < ApplicationController def index - @invoices = Invoice.includes(:supplier, :delivery, :order).order('date DESC').paginate(page: params[:page]) - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @invoices } - end + @invoices = Invoice.includes(:supplier, :delivery, :order).order('date DESC').page(params[:page]).per(@per_page) end def show @invoice = Invoice.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @invoice } - end end def new @invoice = Invoice.new :supplier_id => params[:supplier_id], - :delivery_id => params[:delivery_id], :order_id => params[:order_id] - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @invoice } - end + :delivery_id => params[:delivery_id], + :order_id => params[:order_id] end def edit @invoice = Invoice.find(params[:id]) end - # POST /invoices - # POST /invoices.xml def create @invoice = Invoice.new(params[:invoice]) @@ -41,7 +25,7 @@ class Finance::InvoicesController < ApplicationController flash[:notice] = "Rechnung wurde erstellt." if @invoice.order # Redirect to balancing page - redirect_to :controller => 'balancing', :action => 'new', :id => @invoice.order + redirect_to new_finance_order_url(order_id: @invoice.order.id) else redirect_to [:finance, @invoice] end @@ -50,32 +34,20 @@ class Finance::InvoicesController < ApplicationController end end - # PUT /invoices/1 - # PUT /invoices/1.xml def update @invoice = Invoice.find(params[:id]) - respond_to do |format| - if @invoice.update_attributes(params[:invoice]) - flash[:notice] = 'Invoice was successfully updated.' - format.html { redirect_to([:finance, @invoice]) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity } - end + if @invoice.update_attributes(params[:invoice]) + redirect_to [:finance, @invoice], notice: "Rechnung wurde aktualisiert." + else + render :edit end end - # DELETE /invoices/1 - # DELETE /invoices/1.xml def destroy @invoice = Invoice.find(params[:id]) @invoice.destroy - respond_to do |format| - format.html { redirect_to(finance_invoices_path) } - format.xml { head :ok } - end + redirect_to finance_invoices_url end end diff --git a/app/controllers/finance/ordergroups_controller.rb b/app/controllers/finance/ordergroups_controller.rb index 463fe457..3b618e37 100644 --- a/app/controllers/finance/ordergroups_controller.rb +++ b/app/controllers/finance/ordergroups_controller.rb @@ -1,6 +1,5 @@ -class Finance::OrdergroupsController < ApplicationController - before_filter :authenticate_finance - +class Finance::OrdergroupsController < Finance::BaseController + def index if params["sort"] sort = case params["sort"] @@ -16,11 +15,6 @@ class Finance::OrdergroupsController < ApplicationController @ordergroups = Ordergroup.order(sort) @ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].nil? - @ordergroups = @ordergroups.paginate :page => params[:page], :per_page => @per_page - - respond_to do |format| - format.html - format.js { render :layout => false } - end + @ordergroups = @ordergroups.page(params[:page]).per(@per_page) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b28e0007..bf41d188 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -45,25 +45,33 @@ module ApplicationHelper end end - - def sort_td_class_helper(param) - result = 'sortup' if params[:sort] == param.to_s - result = 'sortdown' if params[:sort] == param.to_s + "_reverse" - result - end def sort_link_helper(text, key, options = {}) - per_page = options[:per_page] || @per_page + # Hmtl options remote = options[:remote].nil? ? true : options[:remote] - key += "_reverse" if params[:sort] == key - url = url_for(:sort => key, :page => nil, :per_page => per_page) - + class_name = case params[:sort] + when key then + 'sortup' + when key + '_reverse' then + 'sortdown' + else + nil + end html_options = { :title => "Nach #{text} sortieren", - :remote => remote + :remote => remote, + :class => class_name } - link_to(text, url, html_options) + + # Url options + key += "_reverse" if params[:sort] == key + per_page = options[:per_page] || @per_page + url_options = params.merge(per_page: per_page, sort: key) + url_options.merge!({page: params[:page]}) if params[:page] + url_options.merge!({query: params[:query]}) if params[:query] + + link_to(text, url_for(url_options), html_options) end # Generates a link to the top of the website diff --git a/app/helpers/finance/order_articles_helper.rb b/app/helpers/finance/order_articles_helper.rb index dd2faf39..548dfc4f 100644 --- a/app/helpers/finance/order_articles_helper.rb +++ b/app/helpers/finance/order_articles_helper.rb @@ -2,9 +2,9 @@ module Finance::OrderArticlesHelper def new_order_articles_collection if @order.stockit? - StockArticle.order(:name) + StockArticle.order('articles.name') else - @order.supplier.articles.order(:name) + @order.supplier.articles.order('articles.name') end end end diff --git a/app/models/group_order_article.rb b/app/models/group_order_article.rb index 2a3c2823..63624bb5 100644 --- a/app/models/group_order_article.rb +++ b/app/models/group_order_article.rb @@ -8,7 +8,7 @@ class GroupOrderArticle < ActiveRecord::Base belongs_to :order_article has_many :group_order_article_quantities, :dependent => :destroy - validates_presence_of :group_order_id, :order_article_id + validates_presence_of :group_order, :order_article validates_inclusion_of :quantity, :in => 0..99 validates_inclusion_of :result, :in => 0..99, :allow_nil => true validates_inclusion_of :tolerance, :in => 0..99 diff --git a/app/views/articles/_articles.html.haml b/app/views/articles/_articles.html.haml index 400ae528..0a0f6c17 100644 --- a/app/views/articles/_articles.html.haml +++ b/app/views/articles/_articles.html.haml @@ -2,19 +2,15 @@ = items_per_page = pagination_links_remote @articles -%table#articles_table.table.table-striped +%table#articles_table.table.table-hover %thead %tr %th - %th{class: sort_td_class_helper(:name)} - = sort_link_helper "Name", "name" + %th= sort_link_helper "Name", "name" %th - %th{class: sort_td_class_helper(:category)} - = sort_link_helper "Kategorie", "category" - %th{class: sort_td_class_helper(:unit)} - = sort_link_helper "Einheit", "unit" - %th{class: sort_td_class_helper(:note)} - = sort_link_helper "Notiz", "note" + %th= sort_link_helper "Kategorie", "category" + %th= sort_link_helper "Einheit", "unit" + %th= sort_link_helper "Notiz", "note" %th{:style => "width: 4em;"} Gebgr. %th{:style => "width: 5em;"} Preis %th{:style => "width: 3.5em;"} MwSt diff --git a/app/views/articles/new.js.haml b/app/views/articles/new.js.haml index 735f9589..504f5527 100644 --- a/app/views/articles/new.js.haml +++ b/app/views/articles/new.js.haml @@ -1,2 +1,2 @@ -$('#modalContainer').html('#{escape_javascript(render("form"))}'); +$('#modalContainer').html('#{j(render("form"))}'); $('#modalContainer').modal(); diff --git a/app/views/finance/balancing/_edit_note.html.haml b/app/views/finance/balancing/_edit_note.html.haml index 4322556b..24a32708 100644 --- a/app/views/finance/balancing/_edit_note.html.haml +++ b/app/views/finance/balancing/_edit_note.html.haml @@ -1,4 +1,9 @@ -%h2 Notiz bearbeiten = simple_form_for @order, url: update_note_finance_order_path(@order), remote: true, method: :put do |f| - = f.input :note, inner_html: {size: "60x20"} - = f.submit \ No newline at end of file + .modal-header + = button_tag "x", class: 'close', data: {dismiss: 'modal'} + %h3 Notiz bearbeiten + .modal-body + = f.input :note, input_html: {class: 'input-xlarge'} + .modal-footer + = button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'} + = f.submit "Speichern", class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/finance/balancing/_edit_results_by_articles.html.haml b/app/views/finance/balancing/_edit_results_by_articles.html.haml index e4a5e388..b3a1d766 100644 --- a/app/views/finance/balancing/_edit_results_by_articles.html.haml +++ b/app/views/finance/balancing/_edit_results_by_articles.html.haml @@ -1,15 +1,10 @@ -%p{:style => "float:left"} - %b Lieferung bearbeiten -%p{:style => "float:right"} - = link_to "Artikel hinzufügen", new_finance_order_order_article_path(@order), remote: true +%h3 Bestellung bearbeiten -%table{:class => "ordered_articles", :style => "clear:both"} +%table.ordered-articles.table.table-striped %thead %tr - %th{colspan: "1", class: sort_td_class_helper("name")} - = sort_link_helper "Artikel", "name" - %th{class: sort_td_class_helper("order_number")} - = sort_link_helper "Nr.", "order_number" + %th= sort_link_helper "Artikel", "name" + %th= sort_link_helper "Nr.", "order_number" %th Menge %th GebGr * Einheit %th Netto @@ -17,6 +12,8 @@ %th MwSt %th Pfand %th{:colspan => "2"} + = link_to "Artikel hinzufügen", new_finance_order_order_article_path(@order), remote: true, + class: 'btn btn-small' %tbody#result_table - for order_article in @articles = render :partial => "order_article_result", :locals => {:order_article => order_article} diff --git a/app/views/finance/balancing/_group_order_articles.html.haml b/app/views/finance/balancing/_group_order_articles.html.haml index aff458e4..3cc34dfd 100644 --- a/app/views/finance/balancing/_group_order_articles.html.haml +++ b/app/views/finance/balancing/_group_order_articles.html.haml @@ -1,5 +1,5 @@ %td{:colspan => "7"} - %table + %table.table.table-striped %thead %tr %td @@ -7,35 +7,35 @@ %td Einheiten %td Gesamtpreis %td{:colspan => "3",:style => "width:14em"} - = link_to '[Gruppe hinzufügen]', new_finance_group_order_article_path(order_article_id: order_article.id), - remote: true + = link_to 'Gruppe hinzufügen', new_finance_group_order_article_path(order_article_id: order_article.id), + remote: true, class: 'btn btn-mini' %tbody - for group_order_article in order_article.group_order_articles.ordered.all(:include => [:group_order]) - %tr{:class => cycle('even', 'odd', :name => 'results')}[group_order_article] + %tr[group_order_article] %td %td{:style=>"width:50%"} = group_order_article.group_order.ordergroup.name %td{:id => "group_order_article_#{group_order_article.id}_quantity", :style => "white-space:nowrap"} = group_order_article.result - = button_to "+", update_result_finance_group_order_article_path(group_order_article, modifier: '+'), - method: :put, remote: true, style: 'float:left' - = button_to "-", update_result_finance_group_order_article_path(group_order_article, modifier: '-'), - method: :put, remote: true - %td.currency + = link_to "+", update_result_finance_group_order_article_path(group_order_article, modifier: '+'), + method: :put, remote: true, class: 'btn btn-mini' + = link_to "-", update_result_finance_group_order_article_path(group_order_article, modifier: '-'), + method: :put, remote: true, class: 'btn btn-mini' + %td.numeric = number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "") %td.actions{:style=>"width:1em"} - = link_to icon(:edit), edit_finance_group_order_article_path(group_order_article), remote: true + = link_to "Bearbeiten", edit_finance_group_order_article_path(group_order_article), remote: true, + class: 'btn btn-mini' %td.actions{:style=>"width:1em"} - = link_to icon(:delete), finance_group_order_article_path(group_order_article), method: :delete, - remote: true + = link_to "Löschen", finance_group_order_article_path(group_order_article), method: :delete, + remote: true, class: 'btn btn-mini btn-danger' %td %tfoot - %tr{:class => cycle('even', 'odd', :name => 'results')} + %tr %td %td{:style => "width:8em"} Summe (FC-Preis) %td{:id => "group_orders_sum_quantity_#{order_article.id}"} = order_article.group_orders_sum[:quantity] - %td{:id => "group_orders_sum_price_#{order_article.id}", :class => "currency"} + %td.numeric{:id => "group_orders_sum_price_#{order_article.id}"} = number_to_currency(order_article.group_orders_sum[:price], :unit => "") - %td{:colspan => "3"} - - reset_cycle('results') \ No newline at end of file + %td{:colspan => "3"} \ No newline at end of file diff --git a/app/views/finance/balancing/_order_article.html.haml b/app/views/finance/balancing/_order_article.html.haml index bd43d01b..6781f426 100644 --- a/app/views/finance/balancing/_order_article.html.haml +++ b/app/views/finance/balancing/_order_article.html.haml @@ -19,7 +19,8 @@ %td= order_article.price.tax %td= order_article.price.deposit %td - = link_to icon(:edit), edit_finance_order_order_article_path(order_article.order, order_article), remote: true + = link_to "Bearbeiten", edit_finance_order_order_article_path(order_article.order, order_article), remote: true, + class: 'btn btn-mini' %td - = link_to icon(:delete), finance_order_order_article_path(order_article.order, order_article), method: :delete, - remote: true, confirm: 'Bist du sicher?' \ No newline at end of file + = link_to "Löschen", finance_order_order_article_path(order_article.order, order_article), method: :delete, + remote: true, confirm: 'Bist du sicher?', class: 'btn btn-danger btn-mini' \ No newline at end of file diff --git a/app/views/finance/balancing/_order_article_result.html.haml b/app/views/finance/balancing/_order_article_result.html.haml index 8728c0fd..a66187ae 100644 --- a/app/views/finance/balancing/_order_article_result.html.haml +++ b/app/views/finance/balancing/_order_article_result.html.haml @@ -1,4 +1,4 @@ -%tr{:class => cycle('even', 'odd', :name => 'articles')}[order_article] +%tr[order_article] = render :partial => 'finance/balancing/order_article', :locals => {:order_article => order_article} %tr{:id => "group_order_articles_#{order_article.id}", :class => "results", :style => "display:none"} diff --git a/app/views/finance/balancing/_orders.html.haml b/app/views/finance/balancing/_orders.html.haml new file mode 100644 index 00000000..ae5e5d8b --- /dev/null +++ b/app/views/finance/balancing/_orders.html.haml @@ -0,0 +1,26 @@ +- unless @orders.empty? + - if Order.finished.count > 20 + = items_per_page + = pagination_links_remote @orders + %table.table.table-striped + %thead + %tr + %th Name + %th Ende + %th Status + %th zuletzt bearbeitet von + %th + %tbody + - @orders.each do |order| + %tr{:class => cycle("even","odd", :name => "order")} + %td= link_to truncate(order.name), new_finance_order_path(order_id: order.id) + %td=h format_time(order.ends) unless order.ends.nil? + %td= order.closed? ? "abgerechnet (#{number_to_currency order.foodcoop_result})" : "beendet" + %td= order.updated_by.nil? ? '??' : order.updated_by.nick + %td + - unless order.closed? + = link_to "abrechnen", new_finance_order_path(order_id: order.id), class: 'btn btn-mini btn-primary' + = link_to 'direkt schließen', close_direct_finance_order_path(order), + :confirm => 'Wirklich die Bestellung schließen setzen?', :method => :put, class: 'btn btn-mini' +- else + %i derzeit gibt es keine beendeten Bestellungen \ No newline at end of file diff --git a/app/views/finance/balancing/_summary.haml b/app/views/finance/balancing/_summary.haml index de6a689d..b43b3e58 100644 --- a/app/views/finance/balancing/_summary.haml +++ b/app/views/finance/balancing/_summary.haml @@ -5,19 +5,23 @@ %table %tr %td Nettobetrag: - %td= number_to_currency(order.sum(:net)) + %td.numeric= number_to_currency(order.sum(:net)) %tr %td Bruttobetrag: - %td= number_to_currency(order.sum(:gross)) + %td.numeric= number_to_currency(order.sum(:gross)) %tr %td FC-Betrag: - %td= number_to_currency(order.sum(:fc)) + %td.numeric= number_to_currency(order.sum(:fc)) %tr - %td Summe der Gruppenbeträge: - %td= number_to_currency(order.sum(:groups)) + %td Gruppenbeträge: + %td.numeric= number_to_currency(order.sum(:groups)) %tr - %td FC Gewinn ohne Aufschlag: - %td= number_to_currency(order.profit(:without_markup => true)) + %td + FC Gewinn + %small ohne Aufschlag: + %td.numeric= number_to_currency(order.profit(:without_markup => true)) %tr - %td FC Gewinn mit Aufschlag: - %td#order_profit= number_to_currency(order.profit) \ No newline at end of file + %td + FC Gewinn + %small mit Aufschlag: + %td#order_profit.numeric= number_to_currency(order.profit) \ No newline at end of file diff --git a/app/views/finance/balancing/confirm.html.haml b/app/views/finance/balancing/confirm.html.haml index 48784f43..950a3d0f 100644 --- a/app/views/finance/balancing/confirm.html.haml +++ b/app/views/finance/balancing/confirm.html.haml @@ -1,16 +1,13 @@ -title "Bestellung abschließen" -%div{:style => "width: 40em"} - %p - Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert. - %br/ - Die Konten werden wie folgt belastet: - %table.list{:style => "width:35em"} - - for group_order in @order.group_orders - %tr{:class => cycle('even', 'odd')} - %td= group_order.ordergroup.name - %td= number_to_currency(group_order.price) - %p - %div{:style => "float:left"} - = button_to "Abschließen", close_finance_order_path(@order), method: :put - %div{:style => "float:right"} - = link_to 'Zurück zur Abrechnung', new_finance_order_path(order_id: @order.id) \ No newline at end of file +%p + Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert. + %br/ + Die Konten werden wie folgt belastet: +%table.table.table-striped{:style => "width:35em"} + - for group_order in @order.group_orders + %tr{:class => cycle('even', 'odd')} + %td= group_order.ordergroup.name + %td.numeric= number_to_currency(group_order.price) +.form-actions + = link_to "Abschließen", close_finance_order_path(@order), method: :put, class: 'btn btn-primary' + = link_to 'oder zurück zur Abrechnung', new_finance_order_path(order_id: @order.id) \ No newline at end of file diff --git a/app/views/finance/balancing/edit_note.js.haml b/app/views/finance/balancing/edit_note.js.haml index d8a47632..e64bf6db 100644 --- a/app/views/finance/balancing/edit_note.js.haml +++ b/app/views/finance/balancing/edit_note.js.haml @@ -1 +1,2 @@ -$.fancybox('#{escape_javascript(render("edit_note"))}'); +$('#modalContainer').html('#{j(render("edit_note"))}'); +$('#modalContainer').modal(); \ No newline at end of file diff --git a/app/views/finance/balancing/index.html.haml b/app/views/finance/balancing/index.html.haml index 3d1bd13b..1bf729d5 100644 --- a/app/views/finance/balancing/index.html.haml +++ b/app/views/finance/balancing/index.html.haml @@ -1,63 +1,3 @@ -%h1 Finanzbereich -.left_column{:style => 'width: 50%'} - .box_title - %h2 Unbezahlte Rechnungen - .column_content - %p= link_to "Zeige alle Rechnungen", finance_invoices_path - %table.list - %thead - %tr - %th Datum - %th Betrag - %th Lieferantin - %th - %tbody - - for invoice in @unpaid_invoices - %tr{:class => cycle("even","odd", :name => "invoices")} - %td= format_date(invoice.date) - %td= number_to_currency(invoice.amount) - %td=h invoice.supplier.name - %td= link_to "Bearbeiten", edit_finance_invoice_path(invoice) +- title "beendete Bestellungen" - .box_title - %h2 letzte Überweisungen - .column_content - %p - = link_to "Bestellgruppen", :controller => 'financial_transactions' - %table.list - %thead - %tr - %th Datum - %th Gruppe - %th Notiz - %th Betrag - %tbody - - @financial_transactions.each do |ft| - %tr{:class => cycle("even","odd", :name => "financial_transaction")} - %td= format_date(ft.created_on) - %td= ft.ordergroup.name - %td{:style => "width:50%"}=h ft.note - %td{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}", :class => "currency"}= number_to_currency(ft.amount) - -.right_column{:style => 'width: 46%'} - .box_title - %h2 noch nicht abgerechnet - .column_content - %p= link_to "Bestellungsübersicht", finance_balancing_path - - unless @orders.empty? - %table.list - %thead - %tr - %th Lieferantin - %th Ende - %th Betrag(FC) - %th - %tbody - - @orders.each do |order| - %tr{:class => cycle("even","odd", :name => "order")} - %td= order.name - %td= format_date(order.ends) - %td{:class => "currency"}= number_to_currency(order.sum(:fc)) - %td= link_to "abrechnen", new_finance_order_path(order_id: order.id) - - else - Super, alles schon abgerechnet... \ No newline at end of file +#ordersTable= render 'orders' \ No newline at end of file diff --git a/app/views/finance/balancing/index.js.haml b/app/views/finance/balancing/index.js.haml new file mode 100644 index 00000000..eeb0ed06 --- /dev/null +++ b/app/views/finance/balancing/index.js.haml @@ -0,0 +1 @@ +$('#ordersTable').html('#{j(render('orders'))}'); \ No newline at end of file diff --git a/app/views/finance/balancing/list.html.haml b/app/views/finance/balancing/list.html.haml deleted file mode 100644 index b60ce9c2..00000000 --- a/app/views/finance/balancing/list.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -- title "beendete Bestellungen" -.left_column{:style => "width:70em"} - .box_title - .column_content - - unless @orders.empty? - = will_paginate @orders - %table.list - %thead - %tr - %th Name - %th Ende - %th Status - %th zuletzt bearbeitet von - %th - %tbody - - @orders.each do |order| - %tr{:class => cycle("even","odd", :name => "order")} - %td= link_to truncate(order.name), new_finance_order_path(order_id: order.id) - %td=h format_time(order.ends) unless order.ends.nil? - %td= order.closed? ? "abgerechnet (#{number_to_currency order.foodcoop_result})" : "beendet" - %td= order.updated_by.nil? ? '??' : order.updated_by.nick - %td - - unless order.closed? - = link_to "abrechnen", new_finance_order_path(order_id: order.id) - | - = link_to 'direkt schließen', close_direct_finance_order_path(order), - :confirm => 'Wirklich die Bestellung schließen setzen?', :method => :put - - else - %i derzeit gibt es keine beendeten Bestellungen \ No newline at end of file diff --git a/app/views/finance/balancing/new.html.haml b/app/views/finance/balancing/new.html.haml index 96f79d75..1b057d5e 100644 --- a/app/views/finance/balancing/new.html.haml +++ b/app/views/finance/balancing/new.html.haml @@ -1,53 +1,49 @@ - title "#{@order.name} abrechnen" -.left_column{:style => 'width: 24em'} - .box_title - %h2 Zusammenfassung - .column_content#summary - = render :partial => "summary", :locals => {:order => @order} +- content_for :sidebar do + .well.well-small + %h3 Zusammenfassung + #summary= render 'summary', order: @order -- unless @order.stockit? - .middle_column{:style => 'width: 24em'} - .box_title - %h2 Rechnung - .column_content#invoice - = render :partial => "invoice", :locals => {:invoice => @order.invoice} + .well.well-small + %h3 Rechnung + #invoice= render 'invoice', invoice: @order.invoice -.right_column{:style => 'width: 20em'} - .box_title - %h2 Aktionen - .column_content - %ul - - unless @order.invoice or @order.stockit? - %li= link_to "Rechnung anlegen", new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier) - - unless @order.closed? - %li= link_to "Bestellung abschließen", :action => "confirm", :id => @order - -.right_column{:style => 'clear:both;width: 28%'} - .box_title - %h2 Notizen/Protokoll - .column_content + .well.well-small + %h3 Notizen/Protokoll #note - unless @order.note.empty? = simple_format @order.note - else %p Hier kannst Du deine Abrechnung kommentieren = link_to "Notiz bearbeiten", edit_note_finance_order_path(@order), remote: true - .box_title - %h2 Kommentare - .column_content - #comments - = render :partial => 'shared/comments', locals: {comments: @order.comments} - -.left_column{:style => 'width: 69%'} - .box_title - #editOrderNav - %ul - %li= link_to 'Bestellung bearbeiten', new_finance_order_path(order_id: @order.id, view: 'edit_results'), remote: true - %li= link_to 'Gruppenübersicht', new_finance_order_path(order_id: @order.id, view: 'groups_overview'), remote: true - %li= link_to 'Artikelübersicht', new_finance_order_path(order_id: @order.id, view: 'articles_overview'), remote: true - .column_content - #results - = render partial: 'edit_results_by_articles' - %p= link_to_top + + .well.well-small + %h3 Kommentare + #comments= render :partial => 'shared/comments', locals: {comments: @order.comments} + +.well.well-small + .btn-toolbar + .btn-group + - unless @order.invoice or @order.stockit? + = link_to "Rechnung anlegen", new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier), + class: 'btn' + - unless @order.closed? + = link_to "Bestellung abschließen", confirm_finance_order_path(@order), class: 'btn btn-primary' + + #editOrderNav.btn-group.pull-right + = link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do + Ansichtsoptionen + %span.caret + %ul.dropdown-menu + %li= link_to 'Bestellung bearbeiten', new_finance_order_path(order_id: @order.id, view: 'edit_results'), + remote: true + %li= link_to 'Gruppenübersicht', new_finance_order_path(order_id: @order.id, view: 'groups_overview'), + remote: true + %li= link_to 'Artikelübersicht', new_finance_order_path(order_id: @order.id, view: 'articles_overview'), + remote: true + +%section#results + = render 'edit_results_by_articles' +%p= link_to_top #edit_box{:style => 'display:none'} \ No newline at end of file diff --git a/app/views/finance/balancing/new.js.haml b/app/views/finance/balancing/new.js.haml index bc70b799..0bd073fd 100644 --- a/app/views/finance/balancing/new.js.haml +++ b/app/views/finance/balancing/new.js.haml @@ -1 +1 @@ -$('#results').html('#{escape_javascript(render(partial: balancing_view_partial, locals: {order: @order}))}'); +$('#results').html('#{j(render(balancing_view_partial, order: @order))}'); diff --git a/app/views/finance/balancing/update_note.js.haml b/app/views/finance/balancing/update_note.js.haml index 1fb35c3d..e51110cb 100644 --- a/app/views/finance/balancing/update_note.js.haml +++ b/app/views/finance/balancing/update_note.js.haml @@ -1,2 +1,2 @@ -$.fancybox.close(); -$('#note').html('#{escape_javascript(simple_format(@order.note))}'); +$('#modalContainer').modal('hide'); +$('#note').html('#{j(simple_format(@order.note))}'); diff --git a/app/views/finance/financial_transactions/_ordergroup.haml b/app/views/finance/financial_transactions/_ordergroup.haml index f4578661..50bdd9b1 100644 --- a/app/views/finance/financial_transactions/_ordergroup.haml +++ b/app/views/finance/financial_transactions/_ordergroup.haml @@ -2,5 +2,6 @@ %td = select_tag 'financial_transactions[][ordergroup_id]', options_for_select(Ordergroup.order(:name).all.map { |g| [ g.name, g.id ] }) - %td= text_field_tag 'financial_transactions[][amount]' - %td= link_to icon(:delete), "#", :title => "Gruppe enfernen", 'data-remove-transaction' => true \ No newline at end of file + %td= text_field_tag 'financial_transactions[][amount]', nil, class: 'input-small' + %td= link_to "Entfernen", "#", :title => "Gruppe enfernen", 'data-remove-transaction' => true, + class: 'btn btn-small' \ No newline at end of file diff --git a/app/views/finance/financial_transactions/_transactions.html.haml b/app/views/finance/financial_transactions/_transactions.html.haml index 4a0fd184..2d6d03e7 100644 --- a/app/views/finance/financial_transactions/_transactions.html.haml +++ b/app/views/finance/financial_transactions/_transactions.html.haml @@ -1,26 +1,17 @@ -- if @total == 0 - %p Keine gefunden -- else - %p - Anzahl gefundener Transaktionen: - %b= @total - %p - = pagination_links_remote @financial_transactions, :update => 'transactions', | - :params => {:sort => params[:sort], :query => params['query']} | - %table - %thead +- if @ordergroup.financial_transactions.count > 20 + = items_per_page += pagination_links_remote @financial_transactions +%table.table.table-striped + %thead + %tr + %td= sort_link_helper "Datum", "date" + %td Wer + %td= sort_link_helper "Notiz", "note" + %td= sort_link_helper "Betrag", "amount" + %tbody + - @financial_transactions.each do |t| %tr - - \#{sort_link_helper "Datum", "date"} - %td Wer - - \#{sort_link_helper "Notiz", "note"} - - \#{sort_link_helper "Betrag", "amount"} - %tbody - - @financial_transactions.each do |t| - %tr{:class => cycle("even","odd")} - %td= format_time(t.created_on) - %td= h t.user.nil? ? '??' : t.user.nick - %td= h t.note - %td.currency{:style => "color:#{t.amount < 0 ? 'red' : 'black'}; width:5em"}= number_to_currency(t.amount) + %td= format_time(t.created_on) + %td= h t.user.nil? ? '??' : t.user.nick + %td= h t.note + %td.currency{:style => "color:#{t.amount < 0 ? 'red' : 'black'}; width:5em"}= number_to_currency(t.amount) diff --git a/app/views/finance/financial_transactions/index.html.haml b/app/views/finance/financial_transactions/index.html.haml index 0e21a97b..bdcd573c 100644 --- a/app/views/finance/financial_transactions/index.html.haml +++ b/app/views/finance/financial_transactions/index.html.haml @@ -1,18 +1,16 @@ - title "Kontoauszug für #{@ordergroup.name}" -%p - %b - Kontostand: #{number_to_currency(@ordergroup.account_balance)} - %span{:style => "color:grey"} - (zuletzt aktualisiert vor #{distance_of_time_in_words(Time.now, @ordergroup.account_updated)}) -.left_column{:style => "width:100%"} - .box_title - %h2 Überweisungen - .column_content - = form_tag finance_ordergroup_transactions_path(@ordergroup), :method => :get, :style=>"display:inline;", :id => 'ordergroup_search', - :remote => true, 'data-submit-onchange' => true do - %label{:for => 'article_name'} Suche in Notiz: - = text_field_tag :query, params[:query], :size => 10 - #transactions - = render :partial => "transactions" - %p= link_to 'Neue Transaktion', new_finance_ordergroup_transaction_path(@ordergroup) - = link_to 'Gruppenübersicht', finance_ordergroups_path + +- content_for :sidebar do + %p= link_to 'Neue Transaktion anlegen', new_finance_ordergroup_transaction_path(@ordergroup), class: 'btn btn-primary' + .well.well-small + %strong Kontostand: #{number_to_currency(@ordergroup.account_balance)} + %br/ + %small (zuletzt aktualisiert vor #{distance_of_time_in_words(Time.now, @ordergroup.account_updated)}) +.well.well-small + = form_tag finance_ordergroup_transactions_path(@ordergroup), :method => :get, :remote => true, + 'data-submit-onchange' => true, class: 'form-search' do + = text_field_tag :query, params[:query], class: 'input-medium search-query', + placeholder: 'Suchen ...' + + +#transactions= render 'transactions' \ No newline at end of file diff --git a/app/views/finance/financial_transactions/new_collection.html.haml b/app/views/finance/financial_transactions/new_collection.html.haml index b3d2aa4b..37d6dfeb 100644 --- a/app/views/finance/financial_transactions/new_collection.html.haml +++ b/app/views/finance/financial_transactions/new_collection.html.haml @@ -1,6 +1,6 @@ -- title "Mehrer Konten aktualisieren" +- title "Mehrere Konten aktualisieren" -- content_for :head do +- content_for :javascript do :javascript var ordergroup = "#{escape_javascript(render('ordergroup'))}" @@ -16,19 +16,23 @@ }); }); -- form_tag finance_create_transaction_collection_path do +- content_for :sidebar do + .well.well-small + Hier kannst Du mehrere Konten gleichzeitig aktualsieren. + Z.B. alle Überweisungen der Bestellgruppen aus einem Kontoauszug. + += form_tag finance_create_transaction_collection_path do %p %b Notiz - = text_field_tag :note + = text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required' %p %table#ordergroups{:style => "width:20em"} %tr %th Bestellgruppe %th Betrag = render :partial => 'ordergroup', :collection => [1, 2, 3] - %p - = link_to "Neue Bestellgruppe hinzufügen", '#', 'data-add-transaction' => true - %p - = submit_tag "Transaktionen speichern" + = link_to "Weitere Bestellgruppe hinzufügen", '#', 'data-add-transaction' => true, class: 'btn' + .form-actions + = submit_tag "Transaktionen speichern", class: 'btn btn-primary' = link_to "oder abbrechen", finance_ordergroups_path \ No newline at end of file diff --git a/app/views/finance/group_order_articles/_form.html.haml b/app/views/finance/group_order_articles/_form.html.haml index 9b674c56..679caf97 100644 --- a/app/views/finance/group_order_articles/_form.html.haml +++ b/app/views/finance/group_order_articles/_form.html.haml @@ -1,9 +1,11 @@ -%h2 Mengenänderung -%p - %b Artikel: #{@order_article.article.name} - -- simple_form_for [:finance, @group_order_article], remote: true do |form| += simple_form_for [:finance, @group_order_article], remote: true do |form| = form.hidden_field :order_article_id - = form.input :ordergroup_id, as: :select, collection: Ordergroup.all.map { |g| [g.name, g.id] } - = form.input :result, hint: "Einheit: #{@order_article.article.unit}" - = form.submit 'Speichern' \ No newline at end of file + .modal-header + = button_tag "x", class: 'close', data: {dismiss: 'modal'} + %h3 Mengenänderung für #{@order_article.article.name} + .modal-body + = form.input :ordergroup_id, as: :select, collection: Ordergroup.all.map { |g| [g.name, g.id] } + = form.input :result, hint: "Einheit: #{@order_article.article.unit}" + .modal-footer + = button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'} + = form.submit "Speichern", class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/finance/group_order_articles/edit.js.haml b/app/views/finance/group_order_articles/edit.js.haml index 09419d16..35b0e7c2 100644 --- a/app/views/finance/group_order_articles/edit.js.haml +++ b/app/views/finance/group_order_articles/edit.js.haml @@ -1 +1,2 @@ -$.fancybox('#{escape_javascript(render('form'))}'); +$('#modalContainer').html('#{j(render("form"))}'); +$('#modalContainer').modal(); \ No newline at end of file diff --git a/app/views/finance/group_order_articles/new.js.haml b/app/views/finance/group_order_articles/new.js.haml index 76013027..35b0e7c2 100644 --- a/app/views/finance/group_order_articles/new.js.haml +++ b/app/views/finance/group_order_articles/new.js.haml @@ -1 +1,2 @@ -$.fancybox('#{escape_javascript(render("form"))}'); +$('#modalContainer').html('#{j(render("form"))}'); +$('#modalContainer').modal(); \ No newline at end of file diff --git a/app/views/finance/group_order_articles/update.js.haml b/app/views/finance/group_order_articles/update.js.haml index 1fa42370..cff2d68a 100644 --- a/app/views/finance/group_order_articles/update.js.haml +++ b/app/views/finance/group_order_articles/update.js.haml @@ -1,5 +1,3 @@ -$.fancybox.close(); -$('#order_article_#{@order_article.id}'). -html('#{escape_javascript(render(partial: 'finance/balancing/order_article', locals: {order_article: @order_article}))}'); -$('#group_order_articles_#{@order_article.id}'). -html('#{escape_javascript(render(partial: 'finance/balancing/group_order_articles', locals: {order_article: @order_article}))}'); +$('#modalContainer').modal('hide'); +$('#order_article_#{@order_article.id}').html('#{j(render('finance/balancing/order_article', order_article: @order_article))}'); +$('#group_order_articles_#{@order_article.id}').html('#{j(render('finance/balancing/group_order_articles', order_article: @order_article))}'); diff --git a/app/views/finance/index.html.haml b/app/views/finance/index.html.haml new file mode 100644 index 00000000..a44db1dd --- /dev/null +++ b/app/views/finance/index.html.haml @@ -0,0 +1,60 @@ +- title "Finanzbereich" + +.row-fluid + .span6 + %h2 + Unbezahlte Rechnungen + %small= link_to "alle anzeigen", finance_invoices_path + %table.table.table-striped + %thead + %tr + %th Datum + %th.numeric Betrag + %th Lieferantin + %th + %tbody + - for invoice in @unpaid_invoices + %tr + %td= format_date(invoice.date) + %td.numeric= number_to_currency(invoice.amount) + %td= invoice.supplier.name + %td= link_to "Bearbeiten", edit_finance_invoice_path(invoice), class: 'btn btn-mini' + + %h2 + letzte Überweisungen + %small= link_to "alle anzeigen", finance_ordergroups_path + %table.table.table-striped + %thead + %tr + %th Datum + %th Gruppe + %th Notiz + %th.numeric Betrag + %tbody + - @financial_transactions.each do |ft| + %tr + %td= format_date(ft.created_on) + %td= ft.ordergroup.name + %td= ft.note + %td.numeric{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}"}= number_to_currency(ft.amount) + .span6 + %h2 + noch nicht abgerechnet + %small= link_to "alle anzeigen", finance_order_index_path + - unless @orders.empty? + %table.table.table-striped + %thead + %tr + %th Lieferantin + %th Ende + %th.numeric Betrag(FC) + %th + %tbody + - @orders.each do |order| + %tr + %td= order.name + %td= format_date(order.ends) + %td.numeric= number_to_currency(order.sum(:fc)) + %td= link_to "Abrechnen", new_finance_order_path(order_id: order.id), class: 'btn btn-mini' + - else + Super, alles schon abgerechnet... \ No newline at end of file diff --git a/app/views/finance/invoices/_form.html.haml b/app/views/finance/invoices/_form.html.haml index 176ae305..f6322175 100644 --- a/app/views/finance/invoices/_form.html.haml +++ b/app/views/finance/invoices/_form.html.haml @@ -9,10 +9,12 @@ = f.association :supplier, hint: false = f.input :number - = f.input :date - = f.input :paid_on + = f.input :date, as: :date_picker + = f.input :paid_on, as: :date_picker = f.input :amount, as: :string = f.input :deposit, as: :string = f.input :deposit_credit, as: :string = f.input :note - = f.submit + .form-actions + = f.submit class: 'btn' + = link_to "oder abbrechen", :back diff --git a/app/views/finance/invoices/_invoices.html.haml b/app/views/finance/invoices/_invoices.html.haml new file mode 100644 index 00000000..9da4b40f --- /dev/null +++ b/app/views/finance/invoices/_invoices.html.haml @@ -0,0 +1,31 @@ +- if Invoice.count > 20 + = items_per_page += pagination_links_remote @invoices + +%table.table.table-striped + %thead + %tr + %th Nummer + %th Lieferantin + %th Datum + %th Bezahlt am + %th Betrag + %th Lieferung + %th Bestellung + %th Note + %th + %th + %tbody + - for invoice in @invoices + %tr + %td= link_to h(invoice.number), finance_invoice_path(invoice) + %td= invoice.supplier.name + %td= format_date invoice.date + %td= format_date invoice.paid_on + %td= number_to_currency invoice.amount + %td= link_to "Lieferung", [invoice.supplier,invoice.delivery] if invoice.delivery + %td= link_to format_date(invoice.order.ends), new_finance_order_path(order_id: invoice.order_id) if invoice.order + %td= truncate(invoice.note) + %td= link_to "Bearbeiten", edit_finance_invoice_path(invoice), class: 'btn btn-mini' + %td= link_to "Löschen", finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete, + class: 'btn btn-danger btn-mini' \ No newline at end of file diff --git a/app/views/finance/invoices/edit.html.haml b/app/views/finance/invoices/edit.html.haml index 3a3425fc..61026cbf 100644 --- a/app/views/finance/invoices/edit.html.haml +++ b/app/views/finance/invoices/edit.html.haml @@ -1,5 +1,2 @@ - title "Rechnung bearbeiten" -= render :partial => 'form' -= link_to "Anzeigen", [:finance, @invoice] -| -\#{link_to 'Zurück', finance_invoices_path} += render :partial => 'form' \ No newline at end of file diff --git a/app/views/finance/invoices/index.html.haml b/app/views/finance/invoices/index.html.haml index c90a0286..f1b6c55e 100644 --- a/app/views/finance/invoices/index.html.haml +++ b/app/views/finance/invoices/index.html.haml @@ -1,30 +1,5 @@ - title "Rechnungen" -%p= will_paginate @invoices -%table.list{:style => "width:70em"} - %thead - %tr - %th Nummer - %th Lieferantin - %th Datum - %th Bezahlt am - %th Betrag - %th Lieferung - %th Bestellung - %th Note - %th - %th - %tbody - - for invoice in @invoices - %tr - %td= link_to h(invoice.number), finance_invoice_path(invoice) - %td= invoice.supplier.name - %td= format_date invoice.date - %td= format_date invoice.paid_on - %td= number_to_currency invoice.amount - %td= link_to "Lieferung", [invoice.supplier,invoice.delivery] if invoice.delivery - %td= link_to format_date(invoice.order.ends), new_finance_order_path(order_id: invoice.order_id) if invoice.order - %td= truncate(invoice.note) - %td= link_to icon(:edit), edit_finance_invoice_path(invoice) - %td= link_to icon(:delete), finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete -%br/ -= link_to 'Neue Rechnung anlegen', new_finance_invoice_path + += link_to 'Neue Rechnung anlegen', new_finance_invoice_path, class: 'btn btn-primary' + +#invoicesTable= render 'invoices' diff --git a/app/views/finance/invoices/index.js.haml b/app/views/finance/invoices/index.js.haml new file mode 100644 index 00000000..1228f579 --- /dev/null +++ b/app/views/finance/invoices/index.js.haml @@ -0,0 +1 @@ +$('#invoicesTable').html('#{j(render('invoices'))}'); \ No newline at end of file diff --git a/app/views/finance/order_articles/_edit.html.haml b/app/views/finance/order_articles/_edit.html.haml index 200d7e26..acda7fce 100644 --- a/app/views/finance/order_articles/_edit.html.haml +++ b/app/views/finance/order_articles/_edit.html.haml @@ -1,25 +1,19 @@ -%h2 Artikel aktualisieren += simple_form_for [:finance, @order, @order_article], remote: true do |form| + .modal-header + = button_tag "x", class: 'close', data: {dismiss: 'modal'} + %h3 Artikel aktualisieren + .modal-body + = form.input :units_to_order -= form_for [:finance, @order, @order_article], remote: true do |form| - %table - %tr - %th Name - %th Nr. - %th - %abbr{:title=>"Anzahl gelieferter Gebinde"} Menge - %th Einheit - %th GebGr - %th Netto - %th MwSt. - %th Pfand - %tr - %td= text_field_tag 'article[name]', @order_article.article.name, :size => 20 - %td= text_field_tag 'article[order_number]', @order_article.article.order_number, :size => 3 - %td= text_field_tag 'order_article[units_to_order]', @order_article.units_to_order, :size => 5 - %td= text_field_tag 'article[unit]', @order_article.article.unit, :size => 5 - %td= text_field_tag 'price[unit_quantity]', @order_article.price.unit_quantity, :size => 3 - %td= text_field_tag 'price[price]', @order_article.price.price, :size => 3 - %td= text_field_tag 'price[tax]', @order_article.price.tax, :size => 3 - %td= text_field_tag 'price[deposit]', @order_article.price.deposit, :size => 3 - %br/ - = submit_tag "Speichern" \ No newline at end of file + = simple_fields_for @order_article.article do |f| + = f.input :name + = f.input :order_number + = f.input :unit + = f.input :unit_quantity + = f.input :price + = f.input :tax + = f.input :deposit + + .modal-footer + = button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'} + = form.submit class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/finance/order_articles/_new.html.haml b/app/views/finance/order_articles/_new.html.haml index 03f29132..634a8538 100644 --- a/app/views/finance/order_articles/_new.html.haml +++ b/app/views/finance/order_articles/_new.html.haml @@ -1,6 +1,9 @@ -%h2 - Neuer gelieferter Artikel die Bestellung - = simple_form_for [:finance, @order, @order_article], remote: true do |form| - = form.input :article_id, as: :select, collection: new_order_articles_collection - = form.submit \ No newline at end of file + .modal-header + = button_tag "x", class: 'close', data: {dismiss: 'modal'} + %h3 Neuer gelieferter Artikel die Bestellung + .modal-body + = form.input :article_id, as: :select, collection: new_order_articles_collection + .modal-footer + = button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'} + = form.submit class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/finance/order_articles/create.js.haml b/app/views/finance/order_articles/create.js.haml index 9557e5f1..8498e09c 100644 --- a/app/views/finance/order_articles/create.js.haml +++ b/app/views/finance/order_articles/create.js.haml @@ -1,3 +1,2 @@ -$.fancybox.close(); -$('#result_table'). -prepend('#{escape_javascript(render(partial: 'finance/balancing/order_article_result', locals: {order_article: @order_article}))}'); +$('#modalContainer').modal('hide'); +$('#result_table').prepend('#{j(render('finance/balancing/order_article_result', order_article: @order_article))}'); diff --git a/app/views/finance/order_articles/edit.js.haml b/app/views/finance/order_articles/edit.js.haml index d90c20f3..979e34cb 100644 --- a/app/views/finance/order_articles/edit.js.haml +++ b/app/views/finance/order_articles/edit.js.haml @@ -1 +1,2 @@ -$.fancybox('#{escape_javascript(render("edit"))}'); +$('#modalContainer').html('#{j(render("edit"))}'); +$('#modalContainer').modal(); \ No newline at end of file diff --git a/app/views/finance/order_articles/new.js.haml b/app/views/finance/order_articles/new.js.haml index 6d021e97..4a44300f 100644 --- a/app/views/finance/order_articles/new.js.haml +++ b/app/views/finance/order_articles/new.js.haml @@ -1 +1,2 @@ -$.fancybox('#{escape_javascript(render("new"))}'); +$('#modalContainer').html('#{j(render("new"))}'); +$('#modalContainer').modal(); \ No newline at end of file diff --git a/app/views/finance/order_articles/update.js.haml b/app/views/finance/order_articles/update.js.haml index fd9a5cbf..1e895329 100644 --- a/app/views/finance/order_articles/update.js.haml +++ b/app/views/finance/order_articles/update.js.haml @@ -1,3 +1,2 @@ -$.fancybox.close(); -$('#order_article_#{@order_article.id}'). -html('#{escape_javascript(render(partial: 'finance/balancing/order_article', locals: {order_article: @order_article}))}'); +$('#modalContainer').modal('hide'); +$('#order_article_#{@order_article.id}').html('#{j(render('finance/balancing/order_article', order_article: @order_article))}'); diff --git a/app/views/finance/ordergroups/_ordergroups.html.haml b/app/views/finance/ordergroups/_ordergroups.html.haml index 7167da4c..253b1aea 100644 --- a/app/views/finance/ordergroups/_ordergroups.html.haml +++ b/app/views/finance/ordergroups/_ordergroups.html.haml @@ -1,30 +1,20 @@ -%p - Gefunden: - = @ordergroups.size -%p - %table{:style => "width:100%"} - %tr - %td - = pagination_links_remote @ordergroups, :update => :ordergroups, :params => {:sort => params[:sort]} - %td{:style => "text-align:right"} - - if @ordergroups.size > 20 - = items_per_page -%table.list +- if Ordergroup.count > 20 + = items_per_page += pagination_links_remote @ordergroups +%table.table.table-striped %thead %tr %th= sort_link_helper "Name", "name", :per_page => @per_page %th Kontakt - %th= sort_link_helper "Kontostand", "account_balance", :per_page => @per_page + %th.numeric= sort_link_helper "Kontostand", "account_balance", :per_page => @per_page %th %tbody - for ordergroup in @ordergroups - %tr{:class => cycle('even','odd', :name => 'ordergroups')} + %tr %td= ordergroup.name %td= ordergroup.contact - %td{:class => "currency", :style => "width:5em"}= number_to_currency(ordergroup.account_balance) - %td{:class => "actions"} - = link_to image_tag("euro_new.png", :size => "16x16", :alt => "Neue Transaktion", :border => "0"), - new_finance_ordergroup_transaction_path(ordergroup), :title => "Neue Transaktion" - = link_to image_tag("b_browse.png", :size => "16x16", :border => "0", :alt => 'Kontoauszug'), - finance_ordergroup_transactions_path(ordergroup), :title => "Kontoauszug" + %td.numeric= number_to_currency(ordergroup.account_balance) + %td + = link_to "Neue Transaktion", new_finance_ordergroup_transaction_path(ordergroup), class: 'btn btn-mini' + = link_to "Kontoauszug", finance_ordergroup_transactions_path(ordergroup), class: 'btn btn-mini' \ No newline at end of file diff --git a/app/views/finance/ordergroups/index.html.haml b/app/views/finance/ordergroups/index.html.haml index c1420b29..1bd13900 100644 --- a/app/views/finance/ordergroups/index.html.haml +++ b/app/views/finance/ordergroups/index.html.haml @@ -1,20 +1,15 @@ - title "Konten verwalten" -%p - %i - Um mehrer Transaktionen auf einmal anzulegen folge bitte diesem - = link_to "Link", finance_new_transaction_collection_path -.left_column{:style=>"width:50em"} - .box_title - %h2 Bestellgruppen - .column_content - #group_filter - = form_tag finance_ordergroups_path, :method => :get, :style=>"display:inline;", :id => 'ordergroup_search', - :remote => true, 'data-submit-onchange' => true do - %label{:for => 'article_name'} Suche nach Name: - = text_field_tag :query, params[:query], :size => 10 - #ordergroups - = render :partial => "ordergroups" - %br/ - - if @current_user.role_admin? - = link_to "Neue Bestellgruppe anlegen", new_admin_ordergroup_path \ No newline at end of file +- content_for :sidebar do + .well.well-small + Hier kannst du mehrere Transaktionen gleichzeitig anlegen: + = link_to "Neue Überweisungen eingeben", finance_new_transaction_collection_path, class: 'btn btn-primary' + +.well.well-small + = form_tag finance_ordergroups_path, :method => :get, :remote => true, + 'data-submit-onchange' => true, class: 'form-search' do + = text_field_tag :query, params[:query], class: 'input-medium search-query', + placeholder: 'Suchen ...' + +#ordergroupsTable + = render :partial => "ordergroups" \ No newline at end of file diff --git a/app/views/finance/ordergroups/index.js.haml b/app/views/finance/ordergroups/index.js.haml index e991afec..90a22154 100644 --- a/app/views/finance/ordergroups/index.js.haml +++ b/app/views/finance/ordergroups/index.js.haml @@ -1 +1 @@ -$('#ordergroups').html('#{escape_javascript(render("ordergroups"))}'); +$('#ordergroupsTable').html('#{escape_javascript(render("ordergroups"))}'); diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b3dc0b8d..6da5e282 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -33,4 +33,4 @@ %footer %p Foodsoft, open source software to manage a non-profit food coop. - #modalContainer.modal(tabindex="-1" role="dialog" style="display:none") + #modalContainer.modal.hide.fade(tabindex="-1" role="dialog") diff --git a/app/views/orders/_orders.html.haml b/app/views/orders/_orders.html.haml index 7a7ca614..60ec0853 100644 --- a/app/views/orders/_orders.html.haml +++ b/app/views/orders/_orders.html.haml @@ -2,11 +2,9 @@ %table.table.table-striped %thead %tr - %th{class: sort_td_class_helper(:supplier)} - = sort_link_helper "Lieferantin", "supplier" + %th= sort_link_helper "Lieferantin", "supplier" %th Start - %th{class: sort_td_class_helper(:ends)} - = sort_link_helper "Ende", "ends" + %th= sort_link_helper "Ende", "ends" %th Status %th{:colspan => "2"} %tbody diff --git a/config/locales/de.yml b/config/locales/de.yml index cd9d7df8..d53e9593 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -371,6 +371,8 @@ de: paid_on: Bezahlt am deposit: Pfand berechnet deposit_credit: Pfand gutgeschrieben + order_article: + units_to_order: Menge hints: @@ -386,3 +388,5 @@ de: supplier: '' message: private: Nachricht erscheint nicht im Foodsoft Posteingang + order_article: + units_to_order: Anzahl gelieferter Gebinde diff --git a/config/navigation.rb b/config/navigation.rb index 3b098dd3..e8f66ec7 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -32,8 +32,9 @@ SimpleNavigation::Configuration.run do |navigation| end primary.item :finance, 'Finanzen', '#', if: Proc.new { current_user.role_finance? } do |subnav| + subnav.item :finance_home, 'Übersicht', finance_root_path subnav.item :accounts, 'Konten verwalten', finance_ordergroups_path, id: nil - subnav.item :balancing, 'Bestellungen abrechnen', finance_balancing_path, id: nil + subnav.item :balancing, 'Bestellungen abrechnen', finance_order_index_path, id: nil subnav.item :invoices, 'Rechnungen', finance_invoices_path, id: nil end diff --git a/config/routes.rb b/config/routes.rb index c83241ff..aa8e0e29 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,8 +125,7 @@ Foodsoft::Application.routes.draw do ########### Finance namespace :finance do - root :to => 'balancing#index' - match 'balancing/list' => 'balancing#list', :as => 'balancing' + root :to => 'base#index' resources :order, controller: 'balancing', path: 'balancing' do member do