fix sum table is agnostic to percentage on goi pdf
add pickup to goi pdf add seeds tiny fixes
This commit is contained in:
parent
90e06a475f
commit
c3d56cdf3b
7 changed files with 207 additions and 26 deletions
|
@ -600,7 +600,6 @@ GEM
|
|||
zeitwerk (2.6.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -695,4 +694,4 @@ DEPENDENCIES
|
|||
whenever
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.5
|
||||
2.3.8
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,6 +33,7 @@ class GroupOrderInvoice < ApplicationRecord
|
|||
def load_data_for_invoice
|
||||
invoice_data = {}
|
||||
order = group_order.order
|
||||
invoice_data[:pickup] = order.pickup
|
||||
invoice_data[:supplier] = order.supplier.name
|
||||
invoice_data[:ordergroup] = group_order.ordergroup
|
||||
invoice_data[:group_order] = group_order
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
%td= t('.gross_amount')
|
||||
%td.numeric= number_to_currency(order.sum(:gross_without_deposit))
|
||||
%tr
|
||||
%td= t('.fc_amount')
|
||||
%td= t('.fc_amount_without_deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:fc_without_deposit))
|
||||
%tr
|
||||
%td= t('.deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:deposit))
|
||||
%tr
|
||||
%td= t('.net_deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:net_deposit))
|
||||
%tr
|
||||
%td= t('.deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:deposit))
|
||||
%tr
|
||||
%td= t('.fc_deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:fc_deposit))
|
||||
|
|
|
@ -782,6 +782,7 @@ de:
|
|||
customer_number: 'Kundennummer: %{customer_number}'
|
||||
name: Bestellgruppe %{ordergroup}
|
||||
payment_method: 'Zahlungsart: %{payment_method}'
|
||||
pickup_date: 'Lieferdatum: %{invoice_date}'
|
||||
sum_to_pay: Zu zahlen gesamt
|
||||
sum_to_pay_net: Zu zahlen gesamt (netto)
|
||||
sum_to_pay_gross: Gesamt
|
||||
|
@ -928,13 +929,13 @@ de:
|
|||
summary:
|
||||
changed: Daten wurden verändert!
|
||||
duration: von %{starts} bis %{ends}
|
||||
fc_amount: 'FC-Betrag:'
|
||||
fc_amount: 'FC-Gesamtbetrag:'
|
||||
fc_amount_without_deposit: 'FC-Betrag (ohne Pfand):'
|
||||
deposit: 'Pfand brutto:'
|
||||
gross_deposit: 'Pfand brutto:'
|
||||
net_deposit: 'Pfand netto:'
|
||||
fc_deposit: 'Pfand FC-Betrag:'
|
||||
fc_profit: FC Gewinn
|
||||
fc_amount: FC-Betrag (brutto)
|
||||
gross_amount: 'Bruttobetrag:'
|
||||
groups_amount: 'Gruppenbeträge:'
|
||||
net_amount: 'Nettobetrag:'
|
||||
|
|
147
db/seeds/demo.seeds.rb
Normal file
147
db/seeds/demo.seeds.rb
Normal file
|
@ -0,0 +1,147 @@
|
|||
require_relative 'seed_helper.rb'
|
||||
|
||||
FinancialTransactionClass.create!(:id => 1, :name => 'Standard')
|
||||
FinancialTransactionClass.create!(:id => 2, :name => 'Foodsoft')
|
||||
FinancialTransactionType.create!(:id => 1, :name => "Foodcoop", :financial_transaction_class_id => 1)
|
||||
|
||||
alice = User.create!(:id => 1, :nick => "alice", :password => "secret", :first_name => "Alice", :last_name => "Administrator", :email => "admin@foo.test", :phone => "+4421486548", :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00')
|
||||
bob = User.create!(:id => 2, :nick => "bob", :password => "secret", :first_name => "Bob", :last_name => "Doe", :email => "bob@doe.test", :created_on => 'Sun, 19 Jan 2014 17:38:22 UTC +00:00')
|
||||
|
||||
|
||||
Workgroup.create!(:id => 1, :name => "Administrators", :description => "System administrators.", :account_balance => 0.0, :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00', :role_admin => true, :role_suppliers => true, :role_article_meta => true, :role_finance => true, :role_orders => true, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 2, :name => "Finances", :account_balance => 0.0, :created_on => 'Sun, 19 Jan 2014 17:40:03 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => true, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Alice WG", :account_balance => 0.90E2, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => { :jobs_size => 0, :orders_sum => 1021.74 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 8, :name => "Bob's Family", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
FinancialTransaction.create!(:ordergroup_id => 5, :amount => 0.90E2, :note => "Bank transfer", :user_id => 2, :created_on => 'Mon, 17 Feb 2014 16:19:34 UTC +00:00', :financial_transaction_type_id => 1)
|
||||
FinancialTransaction.create!(:ordergroup_id => 8, :amount => 0.90E2, :note => "Bank transfer", :user_id => 2, :created_on => 'Mon, 17 Feb 2014 16:19:34 UTC +00:00', :financial_transaction_type_id => 1)
|
||||
|
||||
Membership.create!(:group_id => 1, :user_id => 1)
|
||||
Membership.create!(:group_id => 5, :user_id => 1)
|
||||
Membership.create!(:group_id => 2, :user_id => 2)
|
||||
Membership.create!(:group_id => 8, :user_id => 2)
|
||||
|
||||
supplier_category = SupplierCategory.create!(:id => 1, :name => "Other", :financial_transaction_class_id => 1)
|
||||
|
||||
chocolate_supplier = Supplier.create!(
|
||||
name: "Kollektiv CHOCK!",
|
||||
address: "Grabower Straße 1\n12345 Berlin",
|
||||
phone: "0123456789",
|
||||
email: "info@bbakery.test",
|
||||
supplier_category: supplier_category
|
||||
)
|
||||
|
||||
nkn_supplier = Supplier.create!(
|
||||
name: "Naturgut Süd",
|
||||
address: "Somewhere in Hamburg, maybe St. Pauli?",
|
||||
phone: "0123434789",
|
||||
email: "foodsoft@local-it.org",
|
||||
supplier_category: supplier_category
|
||||
)
|
||||
|
||||
chocolate_category = ArticleCategory.create!(name: "Schokolade")
|
||||
obst_category = ArticleCategory.create!(name: "Obst, Gemüse, Sprossen, Pilze")
|
||||
nudeln_category = ArticleCategory.create!(name: "Nudeln, Trockenfrüchte, Müsli")
|
||||
reis_category = ArticleCategory.create!(name: "Getreide, Ölsaaten. Nußkerne")
|
||||
|
||||
Article.create!(
|
||||
name: "Vollmilch-Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 3.0, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "1")
|
||||
|
||||
Article.create!(
|
||||
name: "Weiße Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 3.49, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "2")
|
||||
|
||||
dark_chocolate = Article.create!(
|
||||
name: "Dunkle Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "3")
|
||||
|
||||
Article.create!(
|
||||
name: "Himbeer-Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "170g", unit_quantity: 4,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "4")
|
||||
|
||||
previous_order = seed_order(supplier_id: chocolate_supplier.id, starts: 10.days.ago, ends: 7.days.ago)
|
||||
|
||||
GroupOrderArticle.create!(
|
||||
group_order: GroupOrder.create!(order_id: previous_order.id, ordergroup_id: 8),
|
||||
order_article: previous_order.order_articles.find_by(article_id: dark_chocolate.id),
|
||||
quantity: 5, tolerance: 0)
|
||||
|
||||
previous_order.close!(alice)
|
||||
|
||||
seed_order(supplier_id: chocolate_supplier.id, starts: 0.days.ago, ends: 7.days.from_now)
|
||||
|
||||
|
||||
apple = Article.create!(
|
||||
name: "Äpfel Elstar",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: obst_category.id,
|
||||
manufacturer: "Obsthof Bruno Brugger",
|
||||
origin: "D", price: 3.49, tax: 7.0,
|
||||
unit: "1kg", unit_quantity: 10,
|
||||
note: "lecker, fruchtig, demeter",
|
||||
availability: true, order_number: "5")
|
||||
|
||||
brokkoli = Article.create!(
|
||||
name: "Brokkoli",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: obst_category.id,
|
||||
manufacturer: "Fattoria degli Orsi",
|
||||
origin: "IT", price: 2.89, tax: 7.0,
|
||||
unit: "400g", unit_quantity: 6,
|
||||
note: "gesund und lecker",
|
||||
availability: true, order_number: "6")
|
||||
|
||||
tomatoes = Article.create!(
|
||||
name: "Tomaten",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: obst_category.id,
|
||||
manufacturer: "Terra di Puglia",
|
||||
origin: "IT", price: 2.89, tax: 7.0,
|
||||
unit: "500g", unit_quantity: 20,
|
||||
note: "pomodori italiani, demeter",
|
||||
availability: true, order_number: "7")
|
||||
|
||||
rice = Article.create!(
|
||||
name: "Reis",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: reis_category.id,
|
||||
manufacturer: "Finck",
|
||||
origin: "D", price: 3.29, tax: 7.0,
|
||||
unit: "3kg", unit_quantity: 10,
|
||||
note: "Reis im Vorratssack, demeter",
|
||||
availability: true, order_number: "8")
|
||||
|
||||
spaghetti = Article.create!(
|
||||
name: "Spaghetti",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: nudeln_category.id,
|
||||
manufacturer: "Pastificio Zanellini spa",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "500g", unit_quantity: 4,
|
||||
note: "100% italienisches Hartweizengrieß",
|
||||
availability: true, order_number: "9")
|
||||
|
|
@ -6,12 +6,13 @@ services:
|
|||
command: ./proc-start web
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- mariadb
|
||||
|
||||
foodsoft_worker:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-dev
|
||||
platform: linux/x86_64
|
||||
command: ./proc-start worker
|
||||
volumes:
|
||||
- bundle:/usr/local/bundle
|
||||
|
|
Loading…
Reference in a new issue