add price_per quantity unit to group order new
This commit is contained in:
parent
7ddb6ec0ef
commit
1106178e38
16 changed files with 40 additions and 8 deletions
|
|
@ -142,7 +142,14 @@ class Article < ApplicationRecord
|
|||
new_unit_quantity = new_article.unit_quantity
|
||||
new_unit = new_article.unit
|
||||
end
|
||||
|
||||
puts "
|
||||
" + "______________" + "
|
||||
" + "______________" + "
|
||||
" + "_____oha_________" + "
|
||||
" + "#{new_article.unit_symbol}" + "
|
||||
" + "______________"+ "
|
||||
" + "______________"+ "
|
||||
" + "______________"
|
||||
return Article.compare_attributes(
|
||||
{
|
||||
:name => [self.name, new_article.name],
|
||||
|
|
@ -153,6 +160,7 @@ class Article < ApplicationRecord
|
|||
:tax => [self.tax, new_article.tax],
|
||||
:deposit => [self.deposit.to_f.round(2), new_article.deposit.to_f.round(2)],
|
||||
:price_per => [self.price_per.to_f.round(2), new_article.price_per.to_f.round(2)],
|
||||
:unit_symbol => [self.unit_symbol, new_article.unit_symbol],
|
||||
# take care of different num-objects.
|
||||
:unit_quantity => [self.unit_quantity.to_s.to_f, new_unit_quantity.to_s.to_f],
|
||||
:note => [self.note.to_s, new_article.note.to_s]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ module PriceCalculation
|
|||
add_percent(gross_price, FoodsoftConfig[:price_markup])
|
||||
end
|
||||
|
||||
def fc_price_per
|
||||
if price_per > 0
|
||||
add_percent(add_percent(price_per, tax), FoodsoftConfig[:price_markup])
|
||||
else
|
||||
fc_price
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_percent(value, percent)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class GroupOrder < ApplicationRecord
|
|||
# Build hash with relevant data
|
||||
data[:order_articles][order_article.id] = {
|
||||
:price => order_article.article.fc_price,
|
||||
:price_per => order_article.article.fc_price_per,
|
||||
:unit_symbol => order_article.article.unit_symbol,
|
||||
:unit => order_article.article.unit_quantity,
|
||||
:quantity => (goa ? goa.quantity : 0),
|
||||
:others_quantity => order_article.quantity - (goa ? goa.quantity : 0),
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ class Supplier < ApplicationRecord
|
|||
if options[:outlist_absent]
|
||||
outlisted_articles += articles.undeleted.where.not(order_number: all_order_numbers + [nil])
|
||||
end
|
||||
# TODO: change price_per to scale factor
|
||||
return [updated_article_pairs, outlisted_articles, new_articles]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
= simple_form_for [@supplier, @article], :validate => true, :remote => true do |f|
|
||||
= f.hidden_field :shared_updated_on
|
||||
= f.hidden_field :unit_symbol
|
||||
= f.hidden_field :supplier_id
|
||||
.modal-header
|
||||
= close_button :modal
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
%i
|
||||
= t '.update.update_msg', count: @updated_article_pairs.size
|
||||
= t '.update.body'
|
||||
= render 'sync_table', articles: @updated_article_pairs, field: 'articles', hidden_fields: %w(shared_updated_on)
|
||||
= render 'sync_table', articles: @updated_article_pairs, field: 'articles', hidden_fields: %w(shared_updated_on unit_symbol)
|
||||
%hr/
|
||||
|
||||
- if @new_articles.any?
|
||||
%h2= t '.upnew.title'
|
||||
%p
|
||||
%i= t '.upnew.body_count', count: @new_articles.length
|
||||
= render 'sync_table', articles: @new_articles, field: 'new_articles', hidden_fields: %w(shared_updated_on order_number availability)
|
||||
= render 'sync_table', articles: @new_articles, field: 'new_articles', hidden_fields: %w(shared_updated_on order_number availability unit_symbol)
|
||||
%hr/
|
||||
|
||||
- if ignored_article_count > 0
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
%th= heading_helper Article, :unit
|
||||
%th= heading_helper Article, :unit_quantity, short: true
|
||||
%th= heading_helper Article, :price
|
||||
%th= heading_helper Article, :price_per
|
||||
%th= heading_helper Article, :tax
|
||||
%th= heading_helper Article, :deposit
|
||||
%th= heading_helper Article, :article_category
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
%td= article.unit
|
||||
%td= article.unit_quantity
|
||||
%td= number_to_currency article.price
|
||||
%td= number_to_currency article.price_per.round(2)
|
||||
%td= number_to_percentage article.tax
|
||||
%td= number_to_currency article.deposit
|
||||
%td= article.article_category.name if article.article_category
|
||||
|
|
@ -41,6 +43,10 @@
|
|||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= form.text_field 'price', class: 'input-mini', style: 'width: 45px'
|
||||
%td{:style => highlight_new(attrs, :price_per)}
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= form.text_field 'price_per', class: 'input-mini', style: 'width: 45px'
|
||||
%td{:style => highlight_new(attrs, :tax)}
|
||||
.input-append
|
||||
= form.text_field 'tax', class: 'input-mini', style: 'width: 45px'
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
%th{style: 'width:120px'}= heading_helper StockArticle, :supplier
|
||||
%th{style: "width:13px;"}
|
||||
%th{style: "width:4.5em;"}= t '.price'
|
||||
%th{style: "width:4.5em;"}= t '.price_per'
|
||||
%th{style: "width:4.5em;"}= heading_helper Article, :unit
|
||||
- unless @order.stockit?
|
||||
%th{style: "width:70px;"}= heading_helper OrderArticle, :missing_units, short: true
|
||||
|
|
@ -100,6 +101,7 @@
|
|||
%td= truncate order_article.article.supplier.name, length: 15
|
||||
%td= h order_article.article.origin
|
||||
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
|
||||
%td= "#{number_to_currency(@ordering_data[:order_articles][order_article.id][:price_per])}/#{@ordering_data[:order_articles][order_article.id][:unit_symbol]||@ordering_data[:order_articles][order_article.id][:unit]}"
|
||||
%td= order_article.article.unit
|
||||
%td
|
||||
- if @order.stockit?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue