fix deposit is net value
This commit is contained in:
parent
f29ab603b6
commit
90e06a475f
10 changed files with 75 additions and 34 deletions
|
|
@ -207,7 +207,7 @@ class Order < ApplicationRecord
|
|||
# :fc, guess what...
|
||||
def sum(type = :gross)
|
||||
total = 0
|
||||
if %i[net gross gross_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
|
||||
|
|
@ -215,10 +215,14 @@ class Order < ApplicationRecord
|
|||
total += quantity * oa.price.price
|
||||
when :gross
|
||||
total += quantity * oa.price.gross_price
|
||||
when :gross_without_deposit
|
||||
total += quantity * oa.price.gross_price_without_deposit
|
||||
when :fc
|
||||
total += quantity * oa.price.fc_price
|
||||
when :gross_deposit
|
||||
total += quantity * oa.price.gross_deposit_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
|
||||
total += quantity * oa.price.fc_deposit_price
|
||||
when :deposit
|
||||
|
|
@ -230,11 +234,7 @@ class Order < ApplicationRecord
|
|||
for goa in go.group_order_articles
|
||||
case type
|
||||
when :groups
|
||||
total += if FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits)
|
||||
goa.result * (goa.order_article.price.fc_price + goa.order_article.price.fc_deposit_price)
|
||||
else
|
||||
goa.result * goa.order_article.price.fc_price
|
||||
end
|
||||
total += goa.result * goa.order_article.price.fc_price
|
||||
when :groups_without_markup
|
||||
total += goa.result * goa.order_article.price.gross_price
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue