fix one flaky test
This commit is contained in:
parent
03884e83a3
commit
8f05dd440e
10 changed files with 89 additions and 37 deletions
|
@ -8,6 +8,7 @@ class Finance::BalancingController < Finance::BaseController
|
||||||
flash.now.alert = t('.alert') if @order.closed?
|
flash.now.alert = t('.alert') if @order.closed?
|
||||||
@comments = @order.comments
|
@comments = @order.comments
|
||||||
|
|
||||||
|
|
||||||
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
|
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
|
||||||
group_order_articles: { group_order: :ordergroup })
|
group_order_articles: { group_order: :ordergroup })
|
||||||
|
|
||||||
|
@ -24,7 +25,6 @@ class Finance::BalancingController < Finance::BaseController
|
||||||
else
|
else
|
||||||
@articles
|
@articles
|
||||||
end
|
end
|
||||||
|
|
||||||
render layout: false if request.xhr?
|
render layout: false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
1
app/views/finance/balancing/_article_results.haml
Normal file
1
app/views/finance/balancing/_article_results.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render partial: 'finance/balancing/edit_results_by_articles', locals: {order: @order, articles: @articles, comments: @comments }
|
|
@ -36,28 +36,28 @@
|
||||||
%th= heading_helper Article, :tax
|
%th= heading_helper Article, :tax
|
||||||
%th= heading_helper Article, :deposit
|
%th= heading_helper Article, :deposit
|
||||||
%th{:colspan => "2"}
|
%th{:colspan => "2"}
|
||||||
- unless @order.closed?
|
- unless order.closed?
|
||||||
.btn-group
|
.btn-group
|
||||||
= link_to t('.add_article'), new_order_order_article_path(@order), remote: true,
|
= link_to t('.add_article'), new_order_order_article_path(order), remote: true,
|
||||||
class: 'btn btn-small'
|
class: 'btn btn-small'
|
||||||
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn btn-small dropdown-toggle' do
|
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn btn-small dropdown-toggle' do
|
||||||
%span.caret
|
%span.caret
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
%li= link_to t('.add_article'), new_order_order_article_path(@order), remote: true
|
%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
|
%li= link_to t('.edit_transport'), edit_transport_finance_order_path(order), remote: true
|
||||||
%tbody.list#result_table
|
%tbody.list#result_table
|
||||||
- for order_article in @articles.select { |oa| oa.units > 0 }
|
- for order_article in articles.select { |oa| oa.units > 0 }
|
||||||
= render :partial => "order_article_result", :locals => {:order_article => order_article}
|
= render :partial => "order_article_result", :locals => {:order_article => order_article}
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td{ colspan: 10 } The following were not ordered
|
%td{ colspan: 10 } The following were not ordered
|
||||||
|
|
||||||
- for order_article in @articles.select { |oa| oa.units == 0 }
|
- for order_article in articles.select { |oa| oa.units == 0 }
|
||||||
= render :partial => "order_article_result", :locals => {:order_article => order_article}
|
= render :partial => "order_article_result", :locals => {:order_article => order_article}
|
||||||
|
|
||||||
- if @order.transport
|
- if order.transport
|
||||||
%tr
|
%tr
|
||||||
%td{ colspan: 5 }= heading_helper Order, :transport
|
%td{ colspan: 5 }= heading_helper Order, :transport
|
||||||
%td{ colspan: 3, data: {value: @order.transport} }= number_to_currency(@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,
|
%td= link_to t('ui.edit'), edit_transport_finance_order_path(order), remote: true,
|
||||||
class: 'btn btn-mini' unless order_article.order.closed?
|
class: 'btn btn-mini' unless order_article.order.closed?
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
%section#results
|
|
||||||
= render 'edit_results_by_articles'
|
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
%li= link_to t('.articles_overview'), new_finance_order_path(order_id: @order.id, view: 'articles_overview'),
|
%li= link_to t('.articles_overview'), new_finance_order_path(order_id: @order.id, view: 'articles_overview'),
|
||||||
remote: true
|
remote: true
|
||||||
|
|
||||||
= render "results"
|
%section#results
|
||||||
|
= render partial: 'article_results', locals: { order: @order, articles: @articles, comments: @comments }
|
||||||
|
|
||||||
%p= link_to_top
|
%p= link_to_top
|
||||||
|
|
|
@ -93,6 +93,7 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
number_to_currency(goa.order_article.price.fc_price_without_deposit),
|
number_to_currency(goa.order_article.price.fc_price_without_deposit),
|
||||||
number_to_currency(goa_total_price)]
|
number_to_currency(goa_total_price)]
|
||||||
total_gross += goa_total_price
|
total_gross += goa_total_price
|
||||||
|
|
||||||
next unless separate_deposits && goa.order_article.price.deposit > 0.0
|
next unless separate_deposits && goa.order_article.price.deposit > 0.0
|
||||||
|
|
||||||
goa_total_deposit = goa.result * goa.order_article.price.fc_deposit_price
|
goa_total_deposit = goa.result * goa.order_article.price.fc_deposit_price
|
||||||
|
@ -151,13 +152,16 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
|
|
||||||
tax_hash_net = Hash.new(0) # for summing up article net prices grouped into vat percentage
|
tax_hash_net = Hash.new(0) # for summing up article net prices grouped into vat percentage
|
||||||
tax_hash_gross = Hash.new(0) # same here with gross prices
|
tax_hash_gross = Hash.new(0) # same here with gross prices
|
||||||
|
tax_hash_fc = Hash.new(0)
|
||||||
|
tax_hash_deposit_total = Hash.new(0) # for summing up deposit prices grouped into vat percentage
|
||||||
if separate_deposits
|
if separate_deposits
|
||||||
total_deposit = 0
|
total_deposit = 0
|
||||||
|
total_deposit_fc = 0
|
||||||
total_deposit_gross = 0
|
total_deposit_gross = 0
|
||||||
|
|
||||||
tax_hash_deposit_gross = Hash.new(0) # for summing up deposit gross prices grouped into vat percentage
|
|
||||||
tax_hash_deposit_net = Hash.new(0) # same here with gross prices
|
tax_hash_deposit_net = Hash.new(0) # same here with gross prices
|
||||||
|
tax_hash_deposit_gross = Hash.new(0) # for summing up deposit gross prices grouped into vat percentage
|
||||||
|
tax_hash_deposit_fc = Hash.new(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
marge = FoodsoftConfig[:price_markup]
|
marge = FoodsoftConfig[:price_markup]
|
||||||
|
@ -176,15 +180,15 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
|
|
||||||
order_article = goa.order_article
|
order_article = goa.order_article
|
||||||
goa_total_net = goa.result * order_article.price.price
|
goa_total_net = goa.result * order_article.price.price
|
||||||
|
goa_total_fc = separate_deposits ? goa.total_price_without_deposit : goa.total_price
|
||||||
goa_total_gross = separate_deposits ? goa.total_price_without_deposit : goa.total_price
|
goa_total = goa.total_price
|
||||||
|
|
||||||
data << [order_article.article.name,
|
data << [order_article.article.name,
|
||||||
goa.result.to_i,
|
goa.result.to_i,
|
||||||
number_to_currency(order_article.price.price),
|
number_to_currency(order_article.price.price),
|
||||||
number_to_currency(goa_total_net),
|
number_to_currency(goa_total_net),
|
||||||
tax.to_s + '%',
|
tax.to_s + '%',
|
||||||
number_to_currency(goa_total_gross)]
|
number_to_currency(goa_total_fc)]
|
||||||
|
|
||||||
if separate_deposits && order_article.price.deposit > 0.0
|
if separate_deposits && order_article.price.deposit > 0.0
|
||||||
goa_deposit = goa.result * order_article.price.net_deposit_price
|
goa_deposit = goa.result * order_article.price.net_deposit_price
|
||||||
|
@ -198,17 +202,20 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
number_to_currency(goa_total_deposit)]
|
number_to_currency(goa_total_deposit)]
|
||||||
|
|
||||||
total_deposit += goa_deposit
|
total_deposit += goa_deposit
|
||||||
total_deposit_gross += goa_total_deposit
|
total_deposit_fc += goa_total_deposit
|
||||||
|
total_deposit_gross += goa.result * order_article.price.gross_price
|
||||||
|
|
||||||
tax_hash_deposit_net[tax.to_i] += goa_deposit
|
tax_hash_deposit_net[tax.to_i] += goa_deposit
|
||||||
tax_hash_deposit_gross[tax.to_i] += goa_total_deposit
|
tax_hash_deposit_gross[tax.to_i] += goa.result * order_article.price.deposit
|
||||||
|
tax_hash_deposit_total[tax.to_i] += goa_total_deposit
|
||||||
end
|
end
|
||||||
|
|
||||||
tax_hash_net[tax.to_i] += goa_total_net
|
tax_hash_net[tax.to_i] += goa_total_net
|
||||||
tax_hash_gross[tax.to_i] += goa_total_gross
|
tax_hash_fc[tax.to_i] += goa_total
|
||||||
|
tax_hash_gross[tax.to_i] += goa.result * order_article.price.gross_price
|
||||||
|
|
||||||
total_net += goa_total_net
|
total_net += goa_total_net
|
||||||
total_gross += goa_total_gross
|
total_gross += goa_total_fc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -226,14 +233,42 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
table.columns(1..6).align = :right
|
table.columns(1..6).align = :right
|
||||||
end
|
end
|
||||||
|
|
||||||
sum = [[nil, nil, nil, "Netto", "MwSt", "Brutto"]]
|
sum = if marge > 0
|
||||||
[7, 19].each do |key|
|
[[nil, nil, "Netto", "MwSt", "FC marge", "Brutto"]]
|
||||||
sum << [nil, nil, "Produkte mit #{key}%", number_to_currency(tax_hash_net[key]), number_to_currency(tax_hash_gross[key] - tax_hash_net[key]), number_to_currency(tax_hash_gross[key])]
|
else
|
||||||
sum << [nil, nil, "Pfand mit #{key}%", number_to_currency(tax_hash_deposit_net[key]), number_to_currency(tax_hash_deposit_gross[key] - tax_hash_deposit_net[key]), number_to_currency(tax_hash_deposit_gross[key])] if separate_deposits
|
[[nil, nil, nil, "Netto", "MwSt", "Brutto"]]
|
||||||
|
end
|
||||||
|
|
||||||
|
tax_hash_net.each_key do |key|
|
||||||
|
if tax_hash_gross[key] > 0
|
||||||
|
tmp_sum_array = [nil, "Produkte mit #{key}%", number_to_currency(tax_hash_net[key]), number_to_currency(tax_hash_gross[key] - tax_hash_net[key])]
|
||||||
|
if marge > 0
|
||||||
|
tmp_sum_array << number_to_currency(tax_hash_fc[key] - tax_hash_gross[key])
|
||||||
|
else
|
||||||
|
tmp_sum_array.unshift(nil)
|
||||||
|
end
|
||||||
|
tmp_sum_array << number_to_currency(tax_hash_fc[key])
|
||||||
|
sum << tmp_sum_array
|
||||||
|
end
|
||||||
|
|
||||||
|
if separate_deposits && (tax_hash_deposit_total[key] > 0)
|
||||||
|
tmp_sum_array = [nil, "Pfand mit #{key}%", number_to_currency(tax_hash_deposit_net[key]), number_to_currency(tax_hash_deposit_gross[key] - tax_hash_deposit_net[key])]
|
||||||
|
if marge > 0
|
||||||
|
tmp_sum_array << number_to_currency(tax_hash_deposit_total[key] - tax_hash_deposit_gross[key])
|
||||||
|
else
|
||||||
|
tmp_sum_array.unshift(nil)
|
||||||
|
end
|
||||||
|
tmp_sum_array << number_to_currency(tax_hash_deposit_total[key])
|
||||||
|
sum << tmp_sum_array
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
total_deposit_gross ||= 0
|
total_deposit_fc ||= 0
|
||||||
sum << [nil, nil, nil, nil, I18n.t('documents.group_order_invoice_pdf.sum_to_pay_gross'), number_to_currency(total_gross + total_deposit_gross)]
|
tmp_total_sum = [nil, nil, nil, nil]
|
||||||
|
|
||||||
|
tmp_total_sum << I18n.t('documents.group_order_invoice_pdf.sum_to_pay_gross')
|
||||||
|
tmp_total_sum << number_to_currency(total_gross + total_deposit_fc)
|
||||||
|
sum << tmp_total_sum
|
||||||
|
|
||||||
move_down 10
|
move_down 10
|
||||||
table sum, cell_style: { size: fontsize(8), overflow: :shrink_to_fit } do |table|
|
table sum, cell_style: { size: fontsize(8), overflow: :shrink_to_fit } do |table|
|
||||||
|
@ -241,18 +276,20 @@ class GroupOrderInvoicePdf < RenderPdf
|
||||||
table.position = :center
|
table.position = :center
|
||||||
table.cells.border_width = 1
|
table.cells.border_width = 1
|
||||||
table.cells.border_color = '666666'
|
table.cells.border_color = '666666'
|
||||||
table.row(0).columns(2..6).style(align: :bottom)
|
table.row(0).columns(2..7).style(align: :bottom)
|
||||||
table.row(0).border_bottom_width = 2
|
table.row(0).border_bottom_width = 2
|
||||||
table.row(0..-1).columns(0..1).border_width = 0
|
table.row(0..-1).column(0).border_width = 0
|
||||||
|
|
||||||
|
table.rows(0..-1).columns(0..7).width = 80
|
||||||
|
|
||||||
|
|
||||||
table.rows(0..-1).columns(0..6).width = 80
|
|
||||||
table.row(-1).column(-1).style(font_style: :bold)
|
table.row(-1).column(-1).style(font_style: :bold)
|
||||||
table.row(-1).column(-2).style(font_style: :bold)
|
table.row(-1).column(-2).style(font_style: :bold)
|
||||||
table.row(-1).column(-1).size = fontsize(10)
|
table.row(-1).column(-1).size = fontsize(10)
|
||||||
table.row(-1).column(-2).size = fontsize(10)
|
table.row(-1).column(-2).size = fontsize(10)
|
||||||
|
|
||||||
table.columns(1).align = :right
|
table.columns(1).align = :right
|
||||||
table.columns(1..6).align = :right
|
table.columns(1..7).align = :right
|
||||||
end
|
end
|
||||||
|
|
||||||
if FoodsoftConfig[:group_order_invoices][:vat_exempt]
|
if FoodsoftConfig[:group_order_invoices][:vat_exempt]
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
/ replace_contents "section#results"
|
/ replace 'erb:contains("edit_results_by_articles")'
|
||||||
- if FoodsoftAutomaticInvoices.enabled?
|
- if FoodsoftAutomaticInvoices.enabled?
|
||||||
= render :partial => 'finance/balancing/edit_results_by_articles_override'
|
= render :partial => 'finance/balancing/edit_results_by_articles_override'
|
|
@ -14,25 +14,32 @@ feature 'settling an order', js: true do
|
||||||
let(:goa2) { create(:group_order_article, group_order: go2, order_article: oa) }
|
let(:goa2) { create(:group_order_article, group_order: go2, order_article: oa) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
Rails.cache.clear
|
||||||
|
login admin
|
||||||
goa1.update_quantities(3, 0)
|
goa1.update_quantities(3, 0)
|
||||||
goa2.update_quantities(1, 0)
|
goa2.update_quantities(1, 0)
|
||||||
oa.update_results!
|
oa.update_results!
|
||||||
|
oa.reload
|
||||||
|
order.reload
|
||||||
order.finish!(admin)
|
order.finish!(admin)
|
||||||
goa1.reload
|
goa1.reload
|
||||||
goa2.reload
|
goa2.reload
|
||||||
|
visit new_finance_order_path(order_id: order.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
before { visit new_finance_order_path(order_id: order.id) }
|
after do
|
||||||
before { login admin }
|
Rails.cache.clear
|
||||||
|
end
|
||||||
|
|
||||||
it 'has correct order result' do
|
it 'has correct order result' do
|
||||||
|
oa.reload
|
||||||
expect(oa.quantity).to eq(4)
|
expect(oa.quantity).to eq(4)
|
||||||
expect(oa.tolerance).to eq(0)
|
expect(oa.tolerance).to eq(0)
|
||||||
expect(goa1.result).to eq(3)
|
expect(goa1.result).to eq(3)
|
||||||
expect(goa2.result).to eq(1)
|
expect(goa2.result).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has product ordered visible' do
|
it 'has product ordered visible', js: true do
|
||||||
expect(page).to have_content(article.name)
|
expect(page).to have_content(article.name)
|
||||||
expect(page).to have_selector("#order_article_#{oa.id}")
|
expect(page).to have_selector("#order_article_#{oa.id}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -170,8 +170,10 @@ describe Order do
|
||||||
oa.update_results!
|
oa.update_results!
|
||||||
|
|
||||||
order.finish!(user)
|
order.finish!(user)
|
||||||
|
goa.reload
|
||||||
order.reload
|
order.reload
|
||||||
order.close!(user, ftt)
|
order.close!(user, ftt)
|
||||||
|
goa.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates financial transaction with correct amount' do
|
it 'creates financial transaction with correct amount' do
|
||||||
|
|
|
@ -40,6 +40,13 @@ RSpec.configure do |config|
|
||||||
FoodsoftConfig.init_mailing
|
FoodsoftConfig.init_mailing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.before(:each, type: :feature) do
|
||||||
|
Rails.cache.clear
|
||||||
|
end
|
||||||
|
config.after(:each, type: :feature) do
|
||||||
|
Rails.cache.clear
|
||||||
|
end
|
||||||
|
|
||||||
# If true, the base class of anonymous controllers will be inferred
|
# If true, the base class of anonymous controllers will be inferred
|
||||||
# automatically. This will be the default behavior in future versions of
|
# automatically. This will be the default behavior in future versions of
|
||||||
# rspec-rails.
|
# rspec-rails.
|
||||||
|
|
Loading…
Reference in a new issue