fix deposit is net value
This commit is contained in:
parent
b425d97876
commit
46e6bea49e
5 changed files with 14 additions and 5 deletions
|
@ -207,7 +207,7 @@ class Order < ApplicationRecord
|
|||
# :fc, guess what...
|
||||
def sum(type = :gross)
|
||||
total = 0
|
||||
if %i[net gross net_deposit gross_without_deposit fc_deposit deposit fc].include?(type)
|
||||
if %i[net gross net_deposit gross_without_deposit fc_without_deposit fc_deposit deposit fc].include?(type)
|
||||
for oa in order_articles.ordered.includes(:article, :article_price)
|
||||
quantity = oa.units * oa.price.unit_quantity
|
||||
case type
|
||||
|
@ -219,6 +219,8 @@ class Order < ApplicationRecord
|
|||
total += quantity * oa.price.gross_price_without_deposit
|
||||
when :fc
|
||||
total += quantity * oa.price.fc_price
|
||||
when :fc_without_deposit
|
||||
total += quantity * oa.price.fc_price_without_deposit
|
||||
when :net_deposit
|
||||
total += quantity * oa.price.net_deposit_price
|
||||
when :fc_deposit
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
%tr
|
||||
%td= t('.gross_amount')
|
||||
%td.numeric= number_to_currency(order.sum(:gross_without_deposit))
|
||||
%tr
|
||||
%td= t('.fc_amount')
|
||||
%td.numeric= number_to_currency(order.sum(:fc_without_deposit))
|
||||
%tr
|
||||
%td= t('.deposit')
|
||||
%td.numeric= number_to_currency(order.sum(:deposit))
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
= raw t '.description2',
|
||||
ordergroups: ordergroup_count(@order),
|
||||
article_count: @order.order_articles.ordered.count,
|
||||
net_sum: number_to_currency(@order.sum(:net)),
|
||||
gross_sum: number_to_currency(@order.sum(:gross))
|
||||
net_sum: number_to_currency(@order.sum(:net) + @order.sum(:net_deposit)),
|
||||
gross_sum: number_to_currency(@order.sum(:fc))
|
||||
|
||||
- unless @order.comments.blank?
|
||||
= link_to t('.comments_link'), '#comments'
|
||||
|
|
|
@ -934,6 +934,7 @@ de:
|
|||
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:'
|
||||
|
@ -1635,7 +1636,7 @@ de:
|
|||
pickup: und kann am %{pickup} abgeholt werden
|
||||
starts: läuft von %{starts}
|
||||
starts_ends: läuft von %{starts} bis %{ends}
|
||||
description2: "%{ordergroups} haben %{article_count} Artikel mit einem Gesamtwert von %{net_sum} / %{gross_sum} (netto / brutto) bestellt."
|
||||
description2: "%{ordergroups} haben %{article_count} Artikel mit einem Gesamtwert von %{net_sum} / %{gross_sum} (netto / brutto + fc + Pfand) bestellt."
|
||||
group_orders: 'Gruppenbestellungen:'
|
||||
search_placeholder:
|
||||
articles: Suche nach Artikeln ...
|
||||
|
|
|
@ -64,7 +64,10 @@ describe Article do
|
|||
article.tax = 12
|
||||
expect(article.gross_price).to eq((article.price * 1.12).round(2))
|
||||
article.deposit = 1.20
|
||||
expect(article.gross_price).to eq(((article.price + 1.20) * 1.12).round(2))
|
||||
if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits)
|
||||
expect(article.gross_price_without_deposit).to eq((article.price * 1.12 + 1.20).round(2))
|
||||
expect(article.gross_price).to eq(((article.price + 1.20) * 1.12).round(2))
|
||||
end
|
||||
end
|
||||
|
||||
it 'gross price >= net price' do
|
||||
|
|
Loading…
Reference in a new issue