Remove number_display.rb
This commit is contained in:
parent
5f2e319469
commit
67ab647eb0
9 changed files with 18 additions and 35 deletions
|
@ -27,7 +27,7 @@ class OrderByGroups < OrderPdf
|
||||||
rows << [goa.order_article.article.name,
|
rows << [goa.order_article.article.name,
|
||||||
goa.order_article.article.supplier.name,
|
goa.order_article.article.supplier.name,
|
||||||
group_order_article_quantity_with_tolerance(goa),
|
group_order_article_quantity_with_tolerance(goa),
|
||||||
goa.result,
|
group_order_article_result(goa),
|
||||||
order_article_price_per_unit(goa.order_article),
|
order_article_price_per_unit(goa.order_article),
|
||||||
number_to_currency(goa.total_price)]
|
number_to_currency(goa.total_price)]
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,11 +2,12 @@ module GroupOrderArticlesHelper
|
||||||
|
|
||||||
# return an edit field for a GroupOrderArticle result
|
# return an edit field for a GroupOrderArticle result
|
||||||
def group_order_article_edit_result(goa)
|
def group_order_article_edit_result(goa)
|
||||||
|
result = number_with_precision goa.result, strip_insignificant_zeros: true
|
||||||
unless goa.group_order.order.finished? && current_user.role_finance?
|
unless goa.group_order.order.finished? && current_user.role_finance?
|
||||||
goa.result
|
result
|
||||||
else
|
else
|
||||||
simple_form_for goa, remote: true, html: {'data-submit-onchange' => 'changed', class: 'delta-input'} do |f|
|
simple_form_for goa, remote: true, html: {'data-submit-onchange' => 'changed', class: 'delta-input'} do |f|
|
||||||
f.input_field :result, as: :delta, class: 'input-nano', data: {min: 0}, id: "r_#{goa.id}"
|
f.input_field :result, as: :delta, class: 'input-nano', data: {min: 0}, id: "r_#{goa.id}", value: result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
%td{:colspan => "3",:style => "width:14em"}
|
%td{:colspan => "3",:style => "width:14em"}
|
||||||
- unless order_article.order.closed?
|
- unless order_article.order.closed?
|
||||||
= link_to t('.add_group'), new_group_order_article_path(order_article_id: order_article.id),
|
= link_to t('.add_group'), new_group_order_article_path(order_article_id: order_article.id),
|
||||||
remote: true, class: 'btn btn-mini'
|
remote: true, class: 'btn btn-mini'
|
||||||
%tbody
|
%tbody
|
||||||
- totals = {result: 0}
|
- totals = {result: 0}
|
||||||
- for group_order_article in order_article.group_order_articles.select { |goa| goa.result > 0 }
|
- for group_order_article in order_article.group_order_articles.select { |goa| goa.result > 0 }
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
%td.numeric= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result)
|
%td.numeric= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result)
|
||||||
%td.actions{:style=>"width:1em"}
|
%td.actions{:style=>"width:1em"}
|
||||||
- unless order_article.order.closed?
|
- unless order_article.order.closed?
|
||||||
= link_to t('ui.delete'), group_order_article_path(group_order_article),
|
= link_to t('ui.delete'), group_order_article_path(group_order_article),
|
||||||
method: :delete, remote: true, class: 'btn btn-mini btn-danger'
|
method: :delete, remote: true, class: 'btn btn-mini btn-danger'
|
||||||
%td
|
%td
|
||||||
- totals[:result] += group_order_article.result
|
- totals[:result] += group_order_article.result
|
||||||
|
@ -31,6 +31,6 @@
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%td{:style => "width:8em"}= t('.total_fc')
|
%td{:style => "width:8em"}= t('.total_fc')
|
||||||
%td.center= totals[:result]
|
%td.center= number_with_precision totals[:result], strip_insignificant_zeros: true
|
||||||
%td.numeric= number_to_currency(order_article.group_orders_sum[:price])
|
%td.numeric= number_to_currency(order_article.group_orders_sum[:price])
|
||||||
%td{:colspan => "3"}
|
%td{:colspan => "3"}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
:plain
|
:plain
|
||||||
/
|
/
|
||||||
= number_to_currency(order_article.total_gross_price, :unit => "")
|
= number_to_currency(order_article.total_gross_price, :unit => "")
|
||||||
%td #{order_article.price.tax}%
|
%td= number_to_percentage(order_article.price.tax) unless order_article.price.tax.zero?
|
||||||
%td= order_article.price.deposit
|
%td= number_to_currency(order_article.price.deposit, :unit => "") unless order_article.price.deposit.zero?
|
||||||
%td
|
%td
|
||||||
= link_to t('ui.edit'), edit_order_order_article_path(order_article.order, order_article), remote: true,
|
= link_to t('ui.edit'), edit_order_order_article_path(order_article.order, order_article), remote: true,
|
||||||
class: 'btn btn-mini' unless order_article.order.closed?
|
class: 'btn btn-mini' unless order_article.order.closed?
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# we'd like to show "0.0" as "0"
|
|
||||||
|
|
||||||
class Float
|
|
||||||
alias :foodsoft_to_s :to_s
|
|
||||||
def to_s
|
|
||||||
foodsoft_to_s.gsub /(\.0*|(\.[0-9]+?)0+)$/, '\2'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# allow +to_s+ on bigdecimal without argument too
|
|
||||||
if defined? BigDecimal
|
|
||||||
class BigDecimal
|
|
||||||
alias :foodsoft_to_s :to_s
|
|
||||||
def to_s(*args)
|
|
||||||
if args.present?
|
|
||||||
foodsoft_to_s(*args)
|
|
||||||
else
|
|
||||||
foodsoft_to_s(*args).gsub /(\.0*|(\.[0-9]+?)0+)$/, '\2'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -50,6 +50,10 @@ class OrderPdf < RenderPDF
|
||||||
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : "#{goa.quantity}"
|
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : "#{goa.quantity}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def group_order_article_result(goa)
|
||||||
|
number_with_precision goa.result, strip_insignificant_zeros: true
|
||||||
|
end
|
||||||
|
|
||||||
def group_order_articles(ordergroup)
|
def group_order_articles(ordergroup)
|
||||||
GroupOrderArticle.
|
GroupOrderArticle.
|
||||||
includes(:group_order).
|
includes(:group_order).
|
||||||
|
@ -107,7 +111,7 @@ class OrderPdf < RenderPDF
|
||||||
results = goa_records.group_by(&:first).transform_values do |value|
|
results = goa_records.group_by(&:first).transform_values do |value|
|
||||||
grouped_value = value.group_by(&:second)
|
grouped_value = value.group_by(&:second)
|
||||||
group_ids.map do |group_id|
|
group_ids.map do |group_id|
|
||||||
grouped_value[group_id].try(:first).try(:third)
|
number_with_precision grouped_value[group_id].try(:first).try(:third), strip_insignificant_zeros: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class MultipleOrdersByArticles < OrderPdf
|
||||||
each_group_order_article_for(order_article) do |goa|
|
each_group_order_article_for(order_article) do |goa|
|
||||||
rows << [goa.group_order.ordergroup_name,
|
rows << [goa.group_order.ordergroup_name,
|
||||||
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : goa.quantity,
|
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : goa.quantity,
|
||||||
goa.result,
|
group_order_article_result(goa),
|
||||||
number_to_currency(goa.total_price(order_article))]
|
number_to_currency(goa.total_price(order_article))]
|
||||||
dimrows << rows.length if goa.result == 0
|
dimrows << rows.length if goa.result == 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ class MultipleOrdersByGroups < OrderPdf
|
||||||
number_to_currency(price),
|
number_to_currency(price),
|
||||||
goa.order_article.article.unit,
|
goa.order_article.article.unit,
|
||||||
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : goa.quantity,
|
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : goa.quantity,
|
||||||
goa.result,
|
group_order_article_result(goa),
|
||||||
number_to_currency(sub_total),
|
number_to_currency(sub_total),
|
||||||
goa.order_article.price.unit_quantity]
|
goa.order_article.price.unit_quantity]
|
||||||
dimrows << rows.length if goa.result == 0
|
dimrows << rows.length if goa.result == 0
|
||||||
|
|
|
@ -53,9 +53,9 @@
|
||||||
%td
|
%td
|
||||||
- best_sum = @poll.resistance_points? ? sums.min : sums.max
|
- best_sum = @poll.resistance_points? ? sums.min : sums.max
|
||||||
- if sum == best_sum
|
- if sum == best_sum
|
||||||
%strong= sum
|
%strong= number_with_precision sum, strip_insignificant_zeros: true
|
||||||
- else
|
- else
|
||||||
= sum
|
= number_with_precision sum, strip_insignificant_zeros: true
|
||||||
%td
|
%td
|
||||||
|
|
||||||
- for vote in @poll.poll_votes
|
- for vote in @poll.poll_votes
|
||||||
|
|
Loading…
Reference in a new issue