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')

View file

@ -9,7 +9,6 @@
= f.label :invoice_date, I18n.t('activerecord.attributes.group_order_invoice.links.invoice_date')
= f.date_field :invoice_date, {value: Date.today, max: Date.today, required: true}
= f.hidden_field :order_id, value: order.id
= f.submit I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'), class: 'btn btn'
%table.table.group-order-invoices-table

View file

@ -0,0 +1,71 @@
- show_generate_with_date = true
- multi_order.multi_group_orders.each do |mgo|
- if mgo.ordergroup_invoice.present?
- show_generate_with_date = false
- if show_generate_with_date
= form_for :ordergroup_invoice, url: url_for('ordergroup_invoice#create_multiple'), remote: true do |f|
= f.label :invoice_date, I18n.t('activerecord.attributes.group_order_invoice.links.invoice_date')
= f.date_field :invoice_date, {value: Date.today, max: Date.today, required: true}
= f.hidden_field :multi_order_id, value: multi_order.id
= f.submit I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'), class: 'btn btn'
%table.table.group-order-invoices-table
%thead
%tr
%th=I18n.t('activerecord.attributes.group_order_invoice.links.ordergroup')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.paid')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_downloaded')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_sequence_type')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_select')
%th
%tbody
- multi_order.multi_group_orders.each do |mgo|
-if mgo.ordergroup_invoice.present?
- if mgo.ordergroup_invoice
= mgo.ordergroup_invoice.invoice_number
%tr.order-row{id: "multi_group_order_#{mgo.id}"}
%td= link_to mgo.ordergroup&.name, edit_admin_ordergroup_path(mgo.ordergroup)
%td
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.download'), ordergroup_invoice_path(mgo.ordergroup_invoice, :format => 'pdf'), class: 'btn btn-block'
-# .div{id: "paid_#{mgo.ordergroup_invoice.id}"}
-# = render :partial => "group_order_invoices/toggle_paid", locals: { group_order_invoice: go.group_order_invoice }
-# %td
-# .div{id: "sepa_downloaded_#{go.group_order_invoice.id}"}
-# = render :partial => "group_order_invoices/toggle_sepa_downloaded", locals: { group_order_invoice: go.group_order_invoice }
-# %td
-# .div{id: "select_sepa_sequence_type_#{go.group_order_invoice.id}"}
-# =render :partial => 'group_order_invoices/select_sepa_sequence_type', locals:{ group_order_invoice: go.group_order_invoice, group_order: go }
-# %td
-# = check_box_tag "group_order_ids_for_order_#{multi_order.id}", go.id, false, class: "group-order-checkbox", id: "group_order_#{go.id}_included_in_sepa", data: { order_id: go.id }
-# = link_to I18n.t('activerecord.attributes.group_order_invoice.links.delete'), go.group_order_invoice, method: :delete, class: 'btn btn-block btn-danger', remote: true, data: { confirm: I18n.t('ui.confirm_delete', name: "Bestellgruppenrechnung für #{go.ordergroup.name}" ) }
-# - else
-# %tr
-# %td
-# = go.ordergroup&.name
-# = button_to I18n.t('activerecord.attributes.group_order_invoice.links.generate'), group_order_invoices_path(:method => :post, group_order: go) ,class: 'btn btn-small', params: {id: multi_order.id}, remote: true
-# %td
-# %td
-# %td
-# %td
-# %td
-# - if multi_order.group_orders.map(&:group_order_invoice).compact.present?
-# %tr.order-row
-# %td= I18n.t('activerecord.attributes.group_order_invoice.links.actions_for_all')
-# %td
-# .div{id: "toggle_all_paid_#{multi_order.id}"}
-# = render :partial => 'group_order_invoices/toggle_all_paid', locals: { order: order }
-# %td
-# .div{id: "toggle_all_sepa_downloaded_#{multi_order.id}"}
-# = render :partial => 'group_order_invoices/toggle_all_sepa_downloaded', locals: { order: order }
-# %td
-# .div{id: "select_all_sepa_sequence_type_#{multi_order.id}"}
-# = render :partial => 'group_order_invoices/select_all_sepa_sequence_type', locals: { order: multi_order }
-# %td
-# .div{id: "select_all_sepa_#{multi_order.id}"}
-# = render :partial => 'group_order_invoices/collective_direct_debit', locals: { order: multi_order }
-# %td
-# = link_to I18n.t('activerecord.attributes.group_order_invoice.links.download_all_zip'), download_all_group_order_invoices_path(multi_order), class: 'btn btn-block'

View file

@ -0,0 +1,2 @@
.div{id: "multi_order_#{multi_order.id}_modal", class: 'multi-order-modal', data: { multi_order_id: multi_order.id, supplier: multi_order&.name } }
= render :partial => 'ordergroup_invoices/links', locals: { multi_order: multi_order }