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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue