diff --git a/app/views/orders/_articles.html.haml b/app/views/orders/_articles.html.haml index 1c800cc7..1ce7cee0 100644 --- a/app/views/orders/_articles.html.haml +++ b/app/views/orders/_articles.html.haml @@ -35,9 +35,8 @@ %td= "#{order_article.quantity} + #{order_article.tolerance}" - else %td= "#{order_article.quantity}" - %td{title: units_history_line(order_article, plain: true)} - = units - = pkg_helper order_article.price + = render "units_history", order_article: order_article, units: units + %p = t '.prices_sum' = "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}" diff --git a/app/views/orders/_units_history.haml b/app/views/orders/_units_history.haml new file mode 100644 index 00000000..9c519b23 --- /dev/null +++ b/app/views/orders/_units_history.haml @@ -0,0 +1,3 @@ +%td{title: units_history_line(order_article, plain: true)} + = units + = pkg_helper order_article.price \ No newline at end of file diff --git a/config/database.yml.MySQL_SAMPLE b/config/database.yml.MySQL_SAMPLE deleted file mode 100644 index b31b1006..00000000 --- a/config/database.yml.MySQL_SAMPLE +++ /dev/null @@ -1,46 +0,0 @@ -# Foodsoft database configuration for MySQL -# -# This file is in the public domain -# -# -# MySQL versions 4.1 and 5.0 are recommended. -# -# Install the MYSQL driver -# gem install mysql2 -# -# Ensure the MySQL gem is defined in your Gemfile -# gem 'mysql2' -# -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -development: - adapter: mysql2 - encoding: utf8mb4 - reconnect: false - database: foodsoft_development - pool: 5 - host: localhost -# socket: /tmp/mysql.sock - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: mysql2 - encoding: utf8mb4 - reconnect: false - database: foodsoft_test - pool: 5 - host: localhost -# socket: /tmp/mysql.sock - -production: - adapter: mysql2 - encoding: utf8mb4 - reconnect: false - pool: 5 - host: <%= ENV['FOODSOFT_DB_HOST'] %> - database: <%= ENV['FOODSOFT_DB_NAME'] %> - username: <%= ENV['FOODSOFT_DB_USER'] %> - password: <%= ENV['FOODSOFT_DB_PASSWORD'] %> -# socket: /tmp/mysql.sock diff --git a/config/locales/de.yml b/config/locales/de.yml index 4aadc284..1cae757a 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1554,6 +1554,7 @@ de: starts: läuft von %{starts} starts_ends: läuft von %{starts} bis %{ends} description2: "%{ordergroups} haben %{article_count} Artikel mit einem Gesamtwert von %{net_sum} / %{gross_sum} (netto / brutto) bestellt." + description3: " Zuzüglich Pfand %{net_deposit} / %{deposit} (netto / brutto)." group_orders: 'Gruppenbestellungen:' search_placeholder: articles: Suche nach Artikeln ... diff --git a/plugins/automatic_invoices/app/assets/stylesheets/group_orders.css.less b/plugins/automatic_invoices/app/assets/stylesheets/group_orders.css.less new file mode 100644 index 00000000..651805ad --- /dev/null +++ b/plugins/automatic_invoices/app/assets/stylesheets/group_orders.css.less @@ -0,0 +1,70 @@ +#order-footer-override, .article-info { + text-align: left; + z-index: 1; + position: fixed; + bottom: 0; + background-color: #E4EED6; + border-top: 2px solid #78B74E; + + #total-sum { + width: 22em; + margin: .5em 2em 0 0; + float: right; + #order-button { + margin: .5em 0; + + input:disabled { + background-color: red; } + } + } +} + +/* Hide the orders article info for small screens + to prevent the "save order" button to disappear */ +@media only screen and (max-width: 950px) { + tr.order-article:hover .article-info { + display: none; + } + tr.order-article:focus .article-info { + display: none; + } +} + +#order-footer-override { + width: 100%; + right: 0; + left: 0; +} + +.article-info { + z-index: 2; + width: 40em; + height: 8em; + border: none; + left: 30px; + + .article-name { + text-align: center; + margin: 2px 0; + margin-bottom: 5px; + width: 100%; + font-weight: bold; + } + .pull-right { + width: 35%; + } + .pull-left { + width: 60%; + } +} + +tr.order-article .article-info { + display: none; +} + +tr.order-article:focus{ + background-color: #E4EED6; +} +tr.order-article:focus .article-info { + display: block; +} diff --git a/plugins/automatic_invoices/app/overrides/ordergroups/edit/insert_customer_number_.html.haml.deface b/plugins/automatic_invoices/app/overrides/ordergroups/edit/insert_customer_number_.html.haml.deface new file mode 100644 index 00000000..0bf025fa --- /dev/null +++ b/plugins/automatic_invoices/app/overrides/ordergroups/edit/insert_customer_number_.html.haml.deface @@ -0,0 +1,6 @@ +/ insert_after 'erb:contains(":contact_person")' +- if FoodsoftAutomaticInvoices.enabled? + %p + = f.label :customer_number + %br/ + = f.text_field :customer_number \ No newline at end of file diff --git a/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_changes.html.haml.deface b/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_changes.html.haml.deface new file mode 100644 index 00000000..1a1c66a9 --- /dev/null +++ b/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_changes.html.haml.deface @@ -0,0 +1,5 @@ +/ insert_before 'erb:contains("order.stockit?")' +- if FoodsoftAutomaticInvoices.enabled? + - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) + %th= t '.deposit' + diff --git a/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_data.html.haml.deface b/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_data.html.haml.deface new file mode 100644 index 00000000..c4bccf11 --- /dev/null +++ b/plugins/automatic_invoices/app/overrides/orders/_articles/insert_deposit_data.html.haml.deface @@ -0,0 +1,5 @@ + +/ insert_after 'erb:contains("number_to_currency(gross_price)")' +- if FoodsoftAutomaticInvoices.enabled? + - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) + %td= number_to_currency(order_article.price.deposit) \ No newline at end of file diff --git a/plugins/automatic_invoices/app/overrides/orders/show/insert_deposit_info.html.haml.deface b/plugins/automatic_invoices/app/overrides/orders/show/insert_deposit_info.html.haml.deface new file mode 100644 index 00000000..05ec5b6c --- /dev/null +++ b/plugins/automatic_invoices/app/overrides/orders/show/insert_deposit_info.html.haml.deface @@ -0,0 +1,5 @@ + +/ insert_after 'erb:contains(".description2")' +- if FoodsoftAutomaticInvoices.enabled? + - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) + = t '.description3', net_deposit: number_to_currency(@order.sum(:net_deposit)), deposit: number_to_currency(@order.sum(:deposit)) \ No newline at end of file diff --git a/plugins/automatic_invoices/app/overrides/shared/_group/insert_customer_number.html.haml.deface b/plugins/automatic_invoices/app/overrides/shared/_group/insert_customer_number.html.haml.deface new file mode 100644 index 00000000..290ee31d --- /dev/null +++ b/plugins/automatic_invoices/app/overrides/shared/_group/insert_customer_number.html.haml.deface @@ -0,0 +1,4 @@ +/ insert_after 'erb:contains(" group.contact_address")' +- if FoodsoftAutomaticInvoices.enabled? + %dt= heading_helper(Ordergroup, :customer_number) + ':' + %dd=h group.customer_number diff --git a/plugins/automatic_invoices/app/views/group_orders/_form_override.html.haml b/plugins/automatic_invoices/app/views/group_orders/_form_override.html.haml index 0cd27c76..ca42a203 100644 --- a/plugins/automatic_invoices/app/views/group_orders/_form_override.html.haml +++ b/plugins/automatic_invoices/app/views/group_orders/_form_override.html.haml @@ -20,6 +20,7 @@ }); }); += stylesheet_link_tag 'group_orders' - title t('.title'), false .row-fluid @@ -151,7 +152,7 @@ %br/ #{heading_helper Article, :note}: #{order_article.article.note} %br/ - #order-footer + #order-footer-override #info-box #total-sum %table diff --git a/plugins/automatic_invoices/app/views/ordergroups/edit.html.haml b/plugins/automatic_invoices/app/views/ordergroups/edit.html.haml deleted file mode 100644 index 9e964c89..00000000 --- a/plugins/automatic_invoices/app/views/ordergroups/edit.html.haml +++ /dev/null @@ -1,72 +0,0 @@ -- title t('.title') -- form_for @ordergroup do |f| - = f.error_messages - %p - = f.label :type - %br/ - = f.text_field :type - %p - = f.label :name - %br/ - = f.text_field :name - %p - = f.label :description - %br/ - = f.text_field :description - %p - = f.label :account_balance - %br/ - = f.text_field :account_balance - %p - = f.label :account_updated - %br/ - = f.datetime_select :account_updated - %p - = f.label :created_on - %br/ - = f.datetime_select :created_on - %p - = f.label :role_admin - %br/ - = f.check_box :role_admin - %p - = f.label :role_suppliers - %br/ - = f.check_box :role_suppliers - %p - = f.label :role_article_meta - %br/ - = f.check_box :role_article_meta - %p - = f.label :role_finance - %br/ - = f.check_box :role_finance - %p - = f.label :role_invoices - %br/ - = f.check_box :role_invoices - %p - = f.label :role_orders - %br/ - = f.check_box :role_orders - %p - = f.label :deleted_at - %br/ - = f.datetime_select :deleted_at - %p - = f.label :contact_person - %br/ - = f.text_field :contact_person - %p - = f.label :customer_number - %br/ - = f.text_field :customer_number - %p - = f.label :contact_phone - %br/ - = f.text_field :contact_phone - %p - = f.label :contact_address - %br/ - = f.text_field :contact_address - %p= f.submit t('ui.edit') diff --git a/plugins/automatic_invoices/app/views/orders/_articles.html.haml b/plugins/automatic_invoices/app/views/orders/_articles.html.haml deleted file mode 100644 index ff010144..00000000 --- a/plugins/automatic_invoices/app/views/orders/_articles.html.haml +++ /dev/null @@ -1,53 +0,0 @@ -%table.table.table-hover - %thead - %tr - %th= heading_helper Article, :name - %th= heading_helper Article, :unit - %th= t '.prices' - - if order.stockit? - %th= t '.units_ordered' - - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) - %th= t '.deposit' - - else - %th= 'Members' - %th= t '.units_full' - - total_net, total_gross, counter = 0, 0, 0 - %tbody.list - - order.articles_grouped_by_category.each do |category_name, order_articles| - %tr.list-heading.article-category - %td - = category_name - %i.icon-tag - %td{:colspan => "9"} - - order_articles.each do |order_article| - - net_price = order_article.price.price - - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) - - gross_price = order_article.price.gross_price_without_deposit - - else - - gross_price = order_article.price.gross_price - - unit_quantity = order_article.price.unit_quantity - - units = order_article.units - - total_net += units * unit_quantity * net_price - - total_gross += units * unit_quantity * gross_price - %tr{:class => cycle('even', 'odd', :name => 'articles') + ' ' + order_article_class(order_article)} - %td.name=h order_article.article.name - %td= order_article.article.unit - %td= "#{number_to_currency(net_price)} / #{number_to_currency(gross_price)}" - - if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) - %td= "#{number_to_currency(order_article.price.deposit)}" - - if order.stockit? - %td= units - - else - - if unit_quantity > 1 or order_article.tolerance > 0 - %td= "#{order_article.quantity} + #{order_article.tolerance}" - - else - %td= "#{order_article.quantity}" - %td{title: units_history_line(order_article, plain: true)} - = units - = pkg_helper order_article.price -%p - = t '.prices_sum' - = "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}" -%p - = t '.article_count' - = order.order_articles.ordered.count diff --git a/plugins/automatic_invoices/app/views/orders/show.html.haml b/plugins/automatic_invoices/app/views/orders/show.html.haml deleted file mode 100644 index 1587f8e1..00000000 --- a/plugins/automatic_invoices/app/views/orders/show.html.haml +++ /dev/null @@ -1,97 +0,0 @@ -- title t('.title', name: @order.name) - -- if current_user.role_finance? || current_user.role_invoices? - - content_for :actionbar do - - if @order.invoice.present? - = link_to t('.show_invoice'), finance_invoice_path(@order.invoice), class: 'btn' - - elsif !@order.open? - = link_to t('.create_invoice'), new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier), - class: 'btn' - -.well - = close_button :alert - %p - - description1 = raw t '.description1_order', - state: t("orders.state.#{@order.state}").capitalize, - supplier: supplier_link(@order), - who: show_user_link(@order.created_by) - - description1 += ' ' - - if @order.ends - - description1 += raw t '.description1_period.starts_ends', - starts: format_time(@order.starts), - ends: format_time(@order.ends) - - else - - description1 += raw t '.description1_period.starts', - starts: format_time(@order.starts) - - if @order.pickup - - description1 += ' ' - - description1 += raw t '.description1_period.pickup', - pickup: format_date(@order.pickup) - = description1 + '.' - %br - = raw t '.description2', - ordergroups: ordergroup_count(@order), - article_count: @order.order_articles.ordered.count, - net_sum: number_to_currency(@order.sum(:net) + @order.sum(:net_deposit)), - gross_sum: number_to_currency(@order.sum(:fc)) - - - unless @order.comments.blank? - = link_to t('.comments_link'), '#comments' - - - if @note.present? - %p - = heading_helper(Order, :note) + ': ' - = @order.note - --# Proposing to remove this warning, since there is a valid period when the order is not settled yet. --# Perhaps when the pickup day has been, or when the order isn't settled a week after it has been --# closed, this message could be shown. --#- if @order.finished? and !@order.closed? - .alert.alert-warning - = t '.warn_not_closed' - -.well.well-small - .btn-toolbar - .form-search.pull-right - .input-append - = text_field_tag :query, params[:query], class: 'search-query delayed-search resettable' - %button.add-on.btn.reset-search{:type => :button, :title => t('.search_reset')} - %i.icon.icon-remove - - .btn-toolbar - .btn-group.view_buttons - = update_articles_link @order, t('.articles'), :default, class: 'btn' - = update_articles_link @order, t('.sort_group'), :groups, class: 'btn' - = update_articles_link @order, t('.sort_article'), :articles, class: 'btn' - - - unless @order.open? - = render 'shared/order_download_button', order: @order, klass: '' - - if @order.open? - = link_to t('.action_end'), finish_order_path(@order), method: :post, class: 'btn btn-success', - data: {confirm: t('.confirm_end', order: @order.name)} - - if @order.supplier - - if @order.stock_group_order - = link_to t('.stock_order'), edit_group_order_path(@order.stock_group_order, order_id: @order.id), class: 'btn' - - else - = link_to t('.stock_order'), new_group_order_path(order_id: @order.id, stock_order: true), class: 'btn' - = link_to t('ui.edit'), edit_order_path(@order), class: 'btn' - - elsif not @order.closed? and not @order.stockit? - = link_to t('.send_to_supplier'), send_result_to_supplier_order_path(@order), method: :post, - class: "btn#{' btn-primary' unless @order.last_sent_mail}", - data: {confirm: @order.last_sent_mail && t('.confirm_send_to_supplier', when: format_time(@order.last_sent_mail)) } - = receive_button @order - - unless @order.closed? - = link_to t('ui.delete'), @order, data: {confirm: t('.confirm_delete')}, method: :delete, - class: 'btn btn-danger' - -%section#articles_table - = render @partial, order: @order - -%h2= t '.comments.title' -#comments - = render partial: 'shared/comments', locals: { comments: @order.comments } -#new_comment= render partial: 'order_comments/form', locals: { order_comment: @order.comments.build(user: current_user)} -= link_to_top - -= render 'show_js' -= render 'shared/articles_by/common', order: @order diff --git a/plugins/automatic_invoices/app/views/shared/_group.html.haml b/plugins/automatic_invoices/app/views/shared/_group.html.haml deleted file mode 100644 index c4d00679..00000000 --- a/plugins/automatic_invoices/app/views/shared/_group.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%dl - %dt= heading_helper(Ordergroup, :description) + ':' - %dd=h group.description - - if group.is_a?(Ordergroup) and (@current_user.role_admin? or @current_user.role_finance?) - %dt= heading_helper(Ordergroup, :contact) + ':' - %dd=h group.contact - %dt= heading_helper(Ordergroup, :contact_address) + ':' - %dd= link_to_gmaps group.contact_address - %dt= heading_helper(Ordergroup, :customer_number) + ':' - %dd=h group.customer_number - - if group.break_start? or group.break_end? - %dt= heading_helper(Ordergroup, :break) + ':' - %dd= raw t '.break', start: format_date(group.break_start), end: format_date(group.break_end) - - if group.is_a?(Workgroup) - %dt= t('.access') + ':' - %dd= format_roles(group) - %dt= heading_helper(Ordergroup, :user_tokens) + ':' - %dd - - members = group.users - = "(#{members.size})" - = members.collect{|u| show_user(u)}.join(", ") - - if group.is_a?(Ordergroup) and FoodsoftConfig[:use_apple_points] - %dt= t '.apple_limit' - %dd= group.ignore_apple_restriction ? t('.deactivated') : t('.activated') diff --git a/plugins/automatic_invoices/config/locales/de.yml b/plugins/automatic_invoices/config/locales/de.yml index e0edb042..c09ced5c 100644 --- a/plugins/automatic_invoices/config/locales/de.yml +++ b/plugins/automatic_invoices/config/locales/de.yml @@ -1554,6 +1554,8 @@ de: prices: Netto-/Bruttopreis prices_sum: 'Summe (Netto/Brutto-Preise):' units_full: Volle Gebinde + members: Mitglieder + deposit: Pfand units_ordered: Bestellte Einheiten create: notice: Die Bestellung wurde erstellt. diff --git a/plugins/automatic_invoices/config/locales/en.yml b/plugins/automatic_invoices/config/locales/en.yml index 1ee30987..b259b68b 100644 --- a/plugins/automatic_invoices/config/locales/en.yml +++ b/plugins/automatic_invoices/config/locales/en.yml @@ -1635,6 +1635,7 @@ en: starts: open from %{starts} starts_ends: open from %{starts} until %{ends} description2: "%{ordergroups} ordered %{article_count} articles, with a total value of %{net_sum} / %{gross_sum} (net / gross)." + description3: " Additional deposit of %{net_deposit} / %{deposit} (net / gross)." group_orders: 'Group orders:' search_placeholder: articles: Search for articles... diff --git a/plugins/automatic_invoices/lib/foodsoft_automatic_invoices/engine.rb b/plugins/automatic_invoices/lib/foodsoft_automatic_invoices/engine.rb index 5818bcd2..1f726353 100644 --- a/plugins/automatic_invoices/lib/foodsoft_automatic_invoices/engine.rb +++ b/plugins/automatic_invoices/lib/foodsoft_automatic_invoices/engine.rb @@ -1,5 +1,10 @@ module FoodsoftAutomaticInvoices class Engine < ::Rails::Engine + + initializer 'automatic_invoices.assets.precompile' do |app| + app.config.assets.precompile += %w(group_orders.css.less) + end + def default_foodsoft_config(cfg) cfg[:use_automatic_invoices] = false end