wip multi orders

This commit is contained in:
viehlieb 2025-05-08 11:59:35 +02:00
parent fd769509af
commit f676497e43
29 changed files with 939 additions and 107 deletions

View file

@ -0,0 +1,22 @@
%tr{:class => cycle("even","odd", :name => "multi_order"), 'data-multi_order_id' => multi_order.id}
%td
= check_box_tag "multi_order_ids_for_multi_multi_order[]", multi_order.id, false, class: "multi_order-checkbox", id: "multi_order_#{multi_order.id}_combine", data: { multi_order_id: multi_order.id }
%td
= "*Multi*"
-multi_order.orders.each do |order|
= link_to truncate(order.name), new_finance_order_path(order_id: order.id)
=", " if order != multi_order.orders.last
%td=h format_time(multi_order.ends) unless multi_order.ends.nil?
%td= multi_order.closed? ? t('finance.balancing.orders.cleared', amount: number_to_currency(multi_order.foodcoop_result)) : t('finance.balancing.orders.ended')
%td= show_user(multi_order.updated_by)
%td{id: "group-multi_order-invoices-for-multi-order-#{multi_order.id}", class: 'expand-trigger'}
- if multi_order.closed?
-if FoodsoftConfig[:contact][:tax_number] && multi_order.group_orders.present?
= link_to I18n.t('activerecord.attributes.group_order_invoice.open_details_modal'), "#", remote: true, class: 'btn btn-small'
-else
= I18n.t('activerecord.attributes.group_order_invoice.tax_number_not_set')
- else
= t('orders.index.not_closed')
%tr{:class => 'expanded-row', :id => "expanded-row-#{multi_order.id}", :style => 'display: none;'}
%td{:colspan => '6'}
= render partial: 'ordergroup_invoices/modal', locals: { multi_order: multi_order }

View file

@ -0,0 +1,26 @@
%tr{:class => cycle("even","odd", :name => "order"), 'data-order_id' => order.id}
%td
= check_box_tag "order_ids_for_multi_order[]", order.id, false, class: "order-checkbox", id: "order_#{order.id}_combine", data: { order_id: order.id }
%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? ? t('finance.balancing.orders.cleared', amount: number_to_currency(order.foodcoop_result)) : t('finance.balancing.orders.ended')
%td= show_user(order.updated_by)
%td{id: "group-order-invoices-for-order-#{order.id}", class: 'expand-trigger'}
- if order.closed?
-if FoodsoftConfig[:contact][:tax_number] && order.ordergroups.present?
= link_to I18n.t('activerecord.attributes.group_order_invoice.open_details_modal'), "#", remote: true, class: 'btn btn-small'
-else
= I18n.t('activerecord.attributes.group_order_invoice.tax_number_not_set')
- else
= t('orders.index.not_closed')
%td
- unless order.closed?
- if current_user.role_orders?
- unless order.stockit?
= link_to t('orders.index.action_receive'), receive_order_path(order), class: 'btn btn-small'
- else
= link_to t('orders.index.action_receive'), '#', class: 'btn btn-small disabled'
= link_to t('finance.balancing.orders.clear'), new_finance_order_path(order_id: order.id), class: 'btn btn-small btn-primary'
%tr{:class => 'expanded-row', :id => "expanded-row-#{order.id}", :style => 'display: none;'}
%td{:colspan => '7'}
= render partial: 'group_order_invoices/modal', locals: { order: order }

View file

@ -1,42 +1,27 @@
- unless @orders.empty?
- unless @orders.empty? && @multi_orders.empty?
- if Order.finished.count > 20
= items_per_page
= pagination_links_remote @orders
%table.table.table-striped
%thead
%tr
%th= t('.name')
%th= t('.end')
%th= t('.state')
%th= heading_helper Order, :updated_by
%th= heading_helper GroupOrderInvoice, :name
%th
%th
%tbody
- @orders.each do |order|
%tr{:class => cycle("even","odd", :name => "order"), 'data-order_id' => order.id}
%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? ? t('.cleared', amount: number_to_currency(order.foodcoop_result)) : t('.ended')
%td= show_user(order.updated_by)
%td{id: "group-order-invoices-for-order-#{order.id}", class: 'expand-trigger'}
- if order.closed?
-if FoodsoftConfig[:contact][:tax_number] && order.ordergroups.present?
= link_to I18n.t('activerecord.attributes.group_order_invoice.open_details_modal'), "#", remote: true, class: 'btn btn-small'
-else
= I18n.t('activerecord.attributes.group_order_invoice.tax_number_not_set')
- else
= t('orders.index.not_closed')
%td
- unless order.closed?
- if current_user.role_orders?
- unless order.stockit?
= link_to t('orders.index.action_receive'), receive_order_path(order), class: 'btn btn-small'
- else
= link_to t('orders.index.action_receive'), '#', class: 'btn btn-small disabled'
= link_to t('.clear'), new_finance_order_path(order_id: order.id), class: 'btn btn-small btn-primary'
%tr{:class => 'expanded-row', :id => "expanded-row-#{order.id}", :style => 'display: none;'}
%td{:colspan => '6'}
= render partial: 'group_order_invoices/modal', locals: { order: order }
-# following posed a real problem, multiple submit buttons are within the same form, so only one of them will be submitted
-# convert to javascript
= form_with url: multi_orders_path, method: :post, local: true do |form|
%table.table.table-striped
%thead
%tr
%th=I18n.t('activerecord.attributes.group_order_invoice.links.combine')
%th= t('.name')
%th= t('.end')
%th= t('.state')
%th= heading_helper Order, :updated_by
%th= heading_helper GroupOrderInvoice, :name
%th
%th
%tbody
- @multi_orders.each do |multi_order|
= render partial: 'multi_order_row', locals: { multi_order: multi_order }
- @orders.each do |order|
= render partial: 'order_row', locals: { order: order }
= form.submit "Zusammenführen", class: 'btn btn-primary'
- else
%i= t('.no_closed_orders')