fix one flaky test

This commit is contained in:
viehlieb 2023-10-13 19:03:55 +02:00
parent 03884e83a3
commit 8f05dd440e
10 changed files with 89 additions and 37 deletions

View file

@ -93,6 +93,7 @@ class GroupOrderInvoicePdf < RenderPdf
number_to_currency(goa.order_article.price.fc_price_without_deposit),
number_to_currency(goa_total_price)]
total_gross += goa_total_price
next unless separate_deposits && goa.order_article.price.deposit > 0.0
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_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
total_deposit = 0
total_deposit_fc = 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_gross = Hash.new(0) # for summing up deposit gross prices grouped into vat percentage
tax_hash_deposit_fc = Hash.new(0)
end
marge = FoodsoftConfig[:price_markup]
@ -176,15 +180,15 @@ class GroupOrderInvoicePdf < RenderPdf
order_article = goa.order_article
goa_total_net = goa.result * order_article.price.price
goa_total_gross = separate_deposits ? goa.total_price_without_deposit : goa.total_price
goa_total_fc = separate_deposits ? goa.total_price_without_deposit : goa.total_price
goa_total = goa.total_price
data << [order_article.article.name,
goa.result.to_i,
number_to_currency(order_article.price.price),
number_to_currency(goa_total_net),
tax.to_s + '%',
number_to_currency(goa_total_gross)]
number_to_currency(goa_total_fc)]
if separate_deposits && order_article.price.deposit > 0.0
goa_deposit = goa.result * order_article.price.net_deposit_price
@ -198,17 +202,20 @@ class GroupOrderInvoicePdf < RenderPdf
number_to_currency(goa_total_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_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
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_gross += goa_total_gross
total_gross += goa_total_fc
end
end
@ -226,14 +233,42 @@ class GroupOrderInvoicePdf < RenderPdf
table.columns(1..6).align = :right
end
sum = [[nil, nil, nil, "Netto", "MwSt", "Brutto"]]
[7, 19].each do |key|
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])]
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
sum = if marge > 0
[[nil, nil, "Netto", "MwSt", "FC marge", "Brutto"]]
else
[[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
total_deposit_gross ||= 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)]
total_deposit_fc ||= 0
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
table sum, cell_style: { size: fontsize(8), overflow: :shrink_to_fit } do |table|
@ -241,18 +276,20 @@ class GroupOrderInvoicePdf < RenderPdf
table.position = :center
table.cells.border_width = 1
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..-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(-2).style(font_style: :bold)
table.row(-1).column(-1).size = fontsize(10)
table.row(-1).column(-2).size = fontsize(10)
table.columns(1).align = :right
table.columns(1..6).align = :right
table.columns(1..7).align = :right
end
if FoodsoftConfig[:group_order_invoices][:vat_exempt]

View file

@ -1,3 +1,3 @@
/ replace_contents "section#results"
/ replace 'erb:contains("edit_results_by_articles")'
- if FoodsoftAutomaticInvoices.enabled?
= render :partial => 'finance/balancing/edit_results_by_articles_override'