fix sum table is agnostic to percentage on goi pdf

add pickup to goi pdf

add seeds

tiny fixes
This commit is contained in:
viehlieb 2023-10-18 23:25:14 +02:00
parent 90e06a475f
commit c3d56cdf3b
7 changed files with 207 additions and 26 deletions

View file

@ -53,16 +53,18 @@ class GroupOrderInvoicePdf < RenderPdf
# invoice Date and nnvoice number
bounding_box [margin_box.right - 200, margin_box.top - 150], width: 200 do
text I18n.t('documents.group_order_invoice_pdf.invoice_date', invoice_date: @options[:invoice_date].strftime(I18n.t('date.formats.default'))), align: :left
move_down 5
text I18n.t('documents.group_order_invoice_pdf.invoice_number', invoice_number: @options[:invoice_number]), align: :left
move_down 5
text I18n.t('documents.group_order_invoice_pdf.invoice_date', invoice_date: @options[:invoice_date].strftime(I18n.t('date.formats.default'))), align: :left
if @options[:pickup]
move_down 5
text I18n.t('documents.group_order_invoice_pdf.pickup_date', invoice_date: @options[:pickup].strftime(I18n.t('date.formats.default')))
end
end
move_down 15
# kind of the "body" of the invoice
move_down 20
text I18n.t('documents.group_order_invoice_pdf.payment_method', payment_method: @options[:payment_method])
move_down 15
text I18n.t('documents.group_order_invoice_pdf.table_headline')
move_down 5
@ -151,6 +153,7 @@ 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) # same here with fc prices
if separate_deposits
total_deposit = 0
@ -158,6 +161,7 @@ class GroupOrderInvoicePdf < RenderPdf
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_fc = Hash.new(0) # same here with fc prices
end
marge = FoodsoftConfig[:price_markup]
@ -177,38 +181,42 @@ 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_gross = separate_deposits ? goa.result * order_article.price.gross_price_without_deposit : goa.result * order_article.price.gross_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
goa_net_deposit = goa.result * order_article.price.net_deposit_price
goa_deposit = goa.result * order_article.price.deposit
goa_total_deposit = goa.result * order_article.price.fc_deposit_price
data << ["zzgl. Pfand",
goa.result.to_i,
number_to_currency(order_article.price.net_deposit_price),
number_to_currency(goa_deposit),
number_to_currency(goa_net_deposit),
tax.to_s + '%',
number_to_currency(goa_total_deposit)]
total_deposit += goa_deposit
total_deposit_gross += goa_total_deposit
tax_hash_deposit_net[tax.to_i] += goa_deposit
tax_hash_deposit_gross[tax.to_i] += goa_total_deposit
tax_hash_deposit_net[tax.to_i] += goa_net_deposit
tax_hash_deposit_gross[tax.to_i] += goa_deposit
tax_hash_deposit_fc[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_fc
total_net += goa_total_net
total_gross += goa_total_gross
total_gross += goa_total_fc
end
end
@ -226,10 +234,34 @@ 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
if marge > 0
sum = [[nil, nil, "Netto", "MwSt", "FC-Marge", "Brutto"]]
else
sum = [[nil, nil, nil, "Netto", "MwSt", "Brutto"]]
end
tax_hash_gross.keys.each do |key|
tmp_sum = [nil, "Produkte mit #{key}%", number_to_currency(tax_hash_net[key])]
if marge <= 0
tmp_sum.unshift(nil)
end
tmp_sum << number_to_currency(tax_hash_gross[key] - tax_hash_net[key])
if marge > 0
tmp_sum << number_to_currency(tax_hash_fc[key] - tax_hash_gross[key])
end
tmp_sum << number_to_currency(tax_hash_fc[key])
sum << tmp_sum
tmp_sum = [nil, "Pfand mit #{key}%", number_to_currency(tax_hash_deposit_net[key])]
if marge <= 0
tmp_sum.unshift(nil)
end
tmp_sum << number_to_currency(tax_hash_deposit_gross[key] - tax_hash_deposit_net[key])
if marge > 0
tmp_sum << number_to_currency(tax_hash_deposit_fc[key] - tax_hash_deposit_gross[key])
end
tmp_sum << number_to_currency(tax_hash_deposit_fc[key])
sum << tmp_sum
end
total_deposit_gross ||= 0