apply highlighting and showing supplier name to invoice pdf

This commit is contained in:
viehlieb 2025-05-22 14:55:35 +02:00
parent 45db0575b1
commit a65120eefc
9 changed files with 96 additions and 72 deletions

View file

@ -118,7 +118,7 @@ class MultiOrdersController < ApplicationController
format.xml do
multi_group_orders.map(&:ordergroup_invoice).each(&:mark_sepa_downloaded)
collective_debit = OrderCollectiveDirectDebitXml.new(multi_group_orders)
send_data collective_debit.xml_string, filename: @multi_order.orders.first.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
send_data collective_debit.xml_string, filename: @multi_order.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
rescue SEPA::Error => e
multi_group_orders.map(&:ordergroup_invoice).each(&:unmark_sepa_downloaded)
render json: { error: e.message }

View file

@ -81,12 +81,22 @@ class GroupOrderInvoicePdf < RenderPdf
data = [I18n.t('documents.group_order_invoice_pdf.vat_exempt_rows')]
move_down 10
# no sinle group_order_id, capice? get all the articles.
group_order_articles = GroupOrderArticle.where(group_order_ids: @options.group_order_ids)
group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids])
separate_deposits = FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits)
supplier = ""
headlines = []
index = 0
group_order_articles.each do |goa|
# if no unit is received, nothing is to be charged
next if goa.result.to_i == 0
index +=1
if goa.group_order.order.supplier.name != supplier
headlines << index
supplier = goa.group_order.order.supplier.name
data << [supplier,"","",""]
index +=1
end
goa_total_price = separate_deposits ? goa.total_price_without_deposit : goa.total_price
data << [goa.order_article.article.name,
goa.result.to_i,
@ -108,9 +118,9 @@ class GroupOrderInvoicePdf < RenderPdf
table.position = :center
table.cells.border_width = 1
table.cells.border_color = '666666'
table.row(0).column(0..4).width = 80
table.row(0).column(0).width = 180
table.row(headlines).font_style= :bold
table.row(0).border_bottom_width = 2
table.columns(1).align = :right
table.columns(1..6).align = :right
@ -172,13 +182,21 @@ class GroupOrderInvoicePdf < RenderPdf
else
[I18n.t('documents.group_order_invoice_pdf.price_markup_rows', marge: marge)]
end
goa_tax_hash = GroupOrderArticle.where(group_order_id: @options[:group_order_ids]).find_each.group_by { |oat| oat.order_article.price.tax }
goa_tax_hash.each do |tax, group_order_articles|
group_order_articles.each do |goa|
# if no unit is received, nothing is to be charged
group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids]).includes(group_order: { order: :supplier })
index = 0
supplier_headlines = []
group_order_articles.group_by { |goa| goa.group_order.order.supplier.name }.each do |supplier_name, articles|
data << [supplier_name, "", "", "", "", ""]
index += 1
supplier_headlines << index
articles.each do |goa|
next if goa.result.to_i == 0
index += 1
order_article = goa.order_article
tax = order_article.price.tax
goa_total_net = goa.result * order_article.price.price
goa_total_fc = separate_deposits ? goa.total_price_without_deposit : goa.total_price
@ -236,6 +254,9 @@ class GroupOrderInvoicePdf < RenderPdf
table.row(0).border_bottom_width = 2
table.columns(1).align = :right
table.columns(1..6).align = :right
supplier_headlines.each do |row_index|
table.row(row_index).columns(0..6).style(font_style: :bold)
end
end
if marge > 0

View file

@ -19,6 +19,7 @@
%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= "Rechnungsnummer"
%th
%tbody
- order.group_orders.includes([:group_order_invoice, :ordergroup]).each do |go|
@ -52,6 +53,7 @@
%td
%td
%td
%td
- if order.group_orders.map(&:group_order_invoice).compact.present?
%tr.order-row
@ -68,5 +70,6 @@
%td
.div{id: "select_all_sepa_#{order.id}"}
= render :partial => 'group_order_invoices/collective_direct_debit', locals: { order: order }
%td
%td
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.download_all_zip'), download_all_group_order_invoices_path(order), class: 'btn btn-block'

View file

@ -75,6 +75,7 @@
= render :partial => 'ordergroup_invoices/collective_direct_debit', locals: { multi_order: multi_order }
%td
%td
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.download_all_zip'), download_all_ordergroup_invoices_path(multi_order), class: 'btn btn-block'
-# sends all ordergroup invoices to the ordergoups mail address via notifyjob
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.send_all_by_email'), send_all_ordergroup_invoices_path(multi_order), class: 'btn btn-block', method: :post, data: { confirm: I18n.t('activerecord.attributes.group_order_invoice.links.confirm_send_all', ordergroups: "#{multi_order.multi_group_orders.map(&:ordergroup).map(&:name).join(', ')}" ) }
- if multi_order.multi_group_orders.count == multi_order.multi_group_orders.map(&:ordergroup_invoice).compact&.count
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.download_all_zip'), download_all_ordergroup_invoices_path(multi_order), class: 'btn btn-block'
-# sends all ordergroup invoices to the ordergoups mail address via notifyjob
= link_to I18n.t('activerecord.attributes.group_order_invoice.links.send_all_by_email'), send_all_ordergroup_invoices_path(multi_order), class: 'btn btn-block', method: :post, data: { confirm: I18n.t('activerecord.attributes.group_order_invoice.links.confirm_send_all', ordergroups: "#{multi_order.multi_group_orders.map(&:ordergroup).map(&:name).join(', ')}" ) }