Add transport costs to Order

This commit is contained in:
Patrick Gansterer 2020-03-19 00:22:20 +01:00
parent 8cb70d819e
commit 4c567fece1
16 changed files with 141 additions and 6 deletions

View file

@ -36,8 +36,15 @@
%th= heading_helper Article, :tax
%th= heading_helper Article, :deposit
%th{:colspan => "2"}
= link_to t('.add_article'), new_order_order_article_path(@order), remote: true,
class: 'btn btn-small' unless @order.closed?
- unless @order.closed?
.btn-group
= link_to t('.add_article'), new_order_order_article_path(@order), remote: true,
class: 'btn btn-small'
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn btn-small dropdown-toggle' do
%span.caret
%ul.dropdown-menu
%li= link_to t('.add_article'), new_order_order_article_path(@order), remote: true
%li= link_to t('.edit_transport'), edit_transport_finance_order_path(@order), remote: true
%tbody.list#result_table
- for order_article in @articles.select { |oa| oa.units > 0 }
= render :partial => "order_article_result", :locals => {:order_article => order_article}
@ -47,3 +54,10 @@
- for order_article in @articles.select { |oa| oa.units == 0 }
= render :partial => "order_article_result", :locals => {:order_article => order_article}
- if @order.transport
%tr
%td{ colspan: 5 }= heading_helper Order, :transport
%td{ colspan: 3, data: {value: @order.transport} }= number_to_currency(@order.transport)
%td= link_to t('ui.edit'), edit_transport_finance_order_path(@order), remote: true,
class: 'btn btn-mini' unless order_article.order.closed?

View file

@ -0,0 +1,11 @@
= simple_form_for @order, url: update_transport_finance_order_path(@order), method: :put do |f|
.modal-header
= close_button :modal
%h3= t('.title')
.modal-body
= f.input :transport
= f.input :transport_distribution, as: :radio_buttons, collection: Order.transport_distributions,
include_blank: false, label_method: ->(k){ t("activerecord.attributes.order.transport_distributions.#{k.first}") }
.modal-footer
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
= f.submit t('ui.save'), class: 'btn btn-primary'

View file

@ -8,7 +8,7 @@
- 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)
%td.numeric= number_to_currency(group_order.total)
.form-actions
= submit_tag t('.clear'), class: 'btn btn-primary'
= link_to t('.or_cancel'), new_finance_order_path(order_id: @order.id)

View file

@ -0,0 +1,2 @@
$('#modalContainer').html('#{j(render("edit_transport"))}');
$('#modalContainer').modal();

View file

@ -24,6 +24,11 @@
= number_to_currency(@group_order.price)
- else
= t '.not_ordered'
- if @group_order && @group_order.transport
%dt= heading_helper GroupOrder, :transport
%dd= number_to_currency(@group_order.transport)
%dt= heading_helper GroupOrder, :total
%dd= number_to_currency(@group_order.total)
- if @order.closed?
%dt= heading_helper Order, :closed_by
%dd= show_user_link @order.updated_by
@ -83,6 +88,13 @@
%tr{class: cycle('even', 'odd', name: 'articles')}
%th{colspan: "5"}= heading_helper GroupOrder, :price
%th= number_to_currency(@group_order.price)
- if @group_order.transport
%tr{class: cycle('even', 'odd', name: 'articles')}
%td{colspan: "5"}= heading_helper GroupOrder, :transport
%td= number_to_currency(@group_order.transport)
%tr{class: cycle('even', 'odd', name: 'articles')}
%th{colspan: "5"}= heading_helper GroupOrder, :total
%th= number_to_currency(@group_order.total)
%br/
= link_to_top
- else

View file

@ -12,3 +12,13 @@
= render 'shared/articles_by/article_single', order_article: order_article
%tr
%td{colspan: 4}
- if order.transport
%tbody
%tr.list-heading
%th{colspan: 4}>
%h4.name.pull-left= heading_helper GroupOrder, :transport
- for go in order.group_orders
- if go.transport
%tr
%td{colspan: 3, style: 'width:70%'}= go.ordergroup_name
%td= number_to_currency(go.transport)

View file

@ -27,4 +27,11 @@
el_price_sum.text(I18n.l('currency', new_price_sum));
el_price_sum.data('value', new_price_sum);
}
var el_total = $('.total', el_sum);
if (el_total.length) {
var old_total = el_total.data('value');
var new_total = old_total - old_price + e.group_order_article_price;
el_total.text(I18n.l('currency', new_total));
el_total.data('value', new_total);
}
});

View file

@ -8,8 +8,16 @@
- total += goa.total_price
= render 'shared/articles_by/group_single_goa', goa: goa
%tr{class: cycle('even', 'odd', :name => 'articles')}
%th{colspan: 7}= t 'shared.articles_by.price_sum'
%th{colspan: 7}= heading_helper GroupOrder, :price
%th.price_sum{colspan: 2, data: {value: total}}= number_to_currency(total)
- if group_order.transport
- total += group_order.transport
%tr{class: cycle('even', 'odd', :name => 'articles')}
%td{colspan: 7}= heading_helper GroupOrder, :transport
%td{colspan: 2}= number_to_currency(group_order.transport)
%tr{class: cycle('even', 'odd', :name => 'articles')}
%th{colspan: 7}= heading_helper GroupOrder, :total
%th.total{colspan: 2, data: {value: total}}= number_to_currency(total)
%tr
%th{colspan: 9}
- reset_cycle("articles")