This commit is contained in:
Nicolas Bally 2018-08-09 15:10:38 +02:00
parent 02075116a3
commit c5207c343c
26 changed files with 604 additions and 177 deletions

12
Gemfile
View File

@ -1,11 +1,8 @@
source 'https://rubygems.org'
gem 'rails', '4.2.6'
#gem 'activerecord-session_store'
gem 'rails', '4.2.0'
gem "mysql2", group: :mysql
gem 'sass-rails', '~> 5.0'
@ -81,4 +78,9 @@ gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
gem 'ogone-rails'
gem 'ogone-rails'
gem "mysql2"

View File

@ -1,36 +1,36 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
actionmailer (4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.0)
actionview (= 4.2.0)
activesupport (= 4.2.0)
rack (~> 1.6.0)
actionpack (4.2.6)
actionview (= 4.2.6)
activesupport (= 4.2.6)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.0)
activesupport (= 4.2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.0)
activesupport (= 4.2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.6)
activesupport (= 4.2.6)
globalid (>= 0.3.0)
activemodel (4.2.0)
activesupport (= 4.2.0)
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
activerecord (4.2.0)
activemodel (= 4.2.0)
activesupport (= 4.2.0)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
arel (~> 6.0)
activesupport (4.2.0)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
@ -39,11 +39,11 @@ GEM
acts_as_commentable (4.0.2)
acts_as_tree (2.1.0)
activerecord (>= 3.0.0)
arel (6.0.0)
arel (6.0.4)
bcrypt (3.1.10)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
builder (3.2.3)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
@ -67,19 +67,21 @@ GEM
execjs
coffee-script-source (1.9.1)
columnize (0.9.0)
concurrent-ruby (1.0.0)
concurrent-ruby (1.0.5)
connection_pool (2.2.0)
crass (1.0.4)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
erubis (2.7.0)
execjs (2.3.0)
ffi (1.9.25)
formtastic (2.3.0)
actionpack (>= 3.0)
formtastic-bootstrap (3.0.0)
formtastic (>= 2.2)
geocoder (1.2.9)
globalid (0.3.3)
activesupport (>= 4.1.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
gravatar_image_tag (1.2.0)
haml (4.0.6)
tilt
@ -90,13 +92,13 @@ GEM
html2haml (>= 1.0.1)
railties (>= 4.0.1)
highline (1.7.2)
hike (1.2.3)
html2haml (2.0.0)
erubis (~> 2.7.0)
haml (~> 4.0.0)
nokogiri (~> 1.6.0)
ruby_parser (~> 3.5)
i18n (0.7.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jbuilder (2.2.8)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
@ -104,7 +106,7 @@ GEM
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.2)
json (1.8.6)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
@ -112,15 +114,19 @@ GEM
kaminari (>= 0.13.0)
rails
kgio (2.9.3)
loofah (2.0.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
multi_json (1.10.1)
mysql2 (0.3.18)
mail (2.7.0)
mini_mime (>= 0.1.1)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0)
mini_portile2 (2.1.0)
minitest (5.11.3)
multi_json (1.13.1)
mysql2 (0.4.8)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
@ -128,42 +134,45 @@ GEM
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
ogone-rails (0.1.10)
activesupport
paranoia (2.1.4)
activerecord (~> 4.0)
posix-spawn (0.3.11)
rack (1.6.0)
rack (1.6.10)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.0)
actionmailer (= 4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
activemodel (= 4.2.0)
activerecord (= 4.2.0)
activesupport (= 4.2.0)
rails (4.2.6)
actionmailer (= 4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
activemodel (= 4.2.6)
activerecord (= 4.2.6)
activesupport (= 4.2.6)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0)
railties (= 4.2.6)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.5)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
loofah (~> 2.0)
railties (4.2.0)
actionpack (= 4.2.0)
activesupport (= 4.2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.4.2)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdoc (4.2.0)
json (~> 1.4)
redis (3.2.2)
@ -173,13 +182,17 @@ GEM
rubyzip (1.2.0)
rvm-capistrano (1.4.1)
capistrano (>= 2.0.0)
sass (3.4.12)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (3.5.7)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
@ -191,18 +204,16 @@ GEM
redis (~> 3.2, >= 3.2.1)
slop (3.6.0)
spring (1.3.2)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
turbolinks (2.5.3)
coffee-rails
twitter-bootstrap-rails (3.2.0)
@ -210,7 +221,7 @@ GEM
execjs (~> 2.2)
rails (~> 4.1)
railties (~> 4.1)
tzinfo (1.2.2)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (2.7.0)
execjs (>= 0.3.0)
@ -255,7 +266,7 @@ DEPENDENCIES
ogone-rails
paranoia (~> 2.0)
posix-spawn
rails (= 4.2.0)
rails (= 4.2.6)
rmagick
rubyzip (>= 1.0.0)
rvm-capistrano (= 1.4.1)
@ -274,4 +285,4 @@ DEPENDENCIES
zip-zip
BUNDLED WITH
1.16.1
1.16.2

View File

@ -2,7 +2,7 @@
/* pane_hover */
#qi_pane_hover{
position:fixed;
top:40px;
top:0px;
left:0px;
bottom:0px;
right:0px;
@ -26,9 +26,12 @@
#qi_pane_hover #qi_pane_hover_content{
margin:auto;
position:relative;
position:absolute;
max-width:100%;
max-height:90%;
right:0;
top:0;
bottom:0;
height:auto !important;
background:white;
background: #f8f8f8;
@ -47,7 +50,7 @@
top:0px;
right:0px;
left:0px;
bottom:37px;
bottom:44px;
overflow:auto;
padding:10px;

View File

@ -11,7 +11,7 @@ class Admin::ProductOrderDocumentsController < ApplicationController
@product_order_document = ProductOrderDocument.find_by_token(params[:id])
@product_order = @product_order_document.product_order
#params[:inline] = true
if true
if false
@temp_file = "#{Rails.root}/pdf/bl/DOC_#{@product_order_document.id}_temp.pdf"
@final_file = "#{Rails.root}/pdf/bl/DOC_#{@product_order_document.id}.pdf"

View File

@ -10,9 +10,32 @@ class Public::ProductOrderProductsController < ApplicationController
# Trying to retreive an existing pop in the current cart
existing_product_order_product = @product_order.product_order_products.where(:product_id => params[:product_order_product][:product_id], :product_size_id => params[:product_order_product][:product_size_id], :product_option_id => params[:product_order_product][:product_option_id]).first
if @product.constraint_qty
if @product.step_stop?
max = @product.step_stop
else
max = 500
end
if @product.step_start?
min = @product.step_start
else
min = 1
end
if @product.step_group?
group = @product.step_group
else
group = 10
end
end
# if the pop exists in the current cart, just increase the quantity
if existing_product_order_product
if [1,2].include?(@product.id)
if group
existing_product_order_product.qty += group
elsif [1,2].include?(@product.id)
existing_product_order_product.qty += 10
else
existing_product_order_product.qty += 1
@ -26,7 +49,12 @@ class Public::ProductOrderProductsController < ApplicationController
if [1,2].include?(@product.id)
@product_order_product.qty = 10
else
@product_order_product.qty = 1
if min
@product_order_product.qty = min
else
@product_order_product.qty = 1
end
end
@product_order_product.save

View File

@ -0,0 +1,3 @@
class ProductDegressif < ActiveRecord::Base
belongs_to :product_stock
end

View File

@ -13,6 +13,11 @@ class ProductOrderProduct < ActiveRecord::Base
has_many :sub_products
before_save do
self.price_ht = self.dyn_price_ht
end
def sage_reference
if self.product
self.product.sage_reference
@ -35,40 +40,69 @@ class ProductOrderProduct < ActiveRecord::Base
end
def final_price_ht_with_qty
qty.to_f * product.final_price_ht.to_f
qty.to_f * dyn_price_ht.to_f
end
def dyn_price_ht
if self.product_stock
if product_degressif = self.product_stock.product_degressifs.where("nbr <= ?", self.qty).order("nbr DESC").first
price = product_degressif.price
end
end
if !price
price = self.product.final_price_ht.to_f
end
return price
end
def dyn_price_ttc
dyn_price_ht * self.tva
end
def archived_price_ttc_with_qty
if archived_product
qty.to_f * archived_product.price_ttc.to_f
if self.price_ht?
qty.to_f * self.price_ht*self.tva_archived
else
0
if archived_product
qty.to_f * archived_product.price_ttc.to_f
else
0
end
end
end
def archived_final_price_ttc_with_qty
if archived_product
qty.to_f * archived_product.final_price_ttc.to_f
if self.price_ht?
qty.to_f * self.price_ht*self.tva_archived
else
0
if archived_product
qty.to_f * archived_product.final_price_ttc.to_f
else
0
end
end
end
def archived_final_price_ht_with_qty
if archived_product
qty.to_f * archived_product.final_price_ht.to_f
if self.price_ht?
qty.to_f * self.price_ht
else
0
if archived_product
qty.to_f * archived_product.final_price_ht.to_f
else
0
end
end
end
def verify_qty
product_stock_t = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
product_stock_t = product_stock = self.product_stock
if product_stock_t and self.qty > product_stock_t.stock_th
self.qty = product_stock_t.stock_th
@ -79,7 +113,7 @@ class ProductOrderProduct < ActiveRecord::Base
end
def update_stock_th
product_stock_t = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
product_stock_t = product_stock = self.product_stock
if product_stock_t
product_stock_t.stock_th = product_stock_t.stock_th - self.qty
@ -89,7 +123,7 @@ class ProductOrderProduct < ActiveRecord::Base
end
def update_stock
product_stock = self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
product_stock = self.product_stock
if product_stock
product_stock.stock = product_stock.stock - self.qty
@ -97,6 +131,9 @@ class ProductOrderProduct < ActiveRecord::Base
end
end
def product_stock
self.product.product_stocks.where(:product_option_id => self.product_option_id,:product_size_id => self.product_size_id).first
end
end

View File

@ -2,4 +2,10 @@ class ProductStock < ActiveRecord::Base
belongs_to :product
belongs_to :product_size
belongs_to :product_option
has_many :product_degressifs, :dependent => :destroy
accepts_nested_attributes_for :product_degressifs
end

View File

@ -4,7 +4,7 @@ class SubProduct < ActiveRecord::Base
belongs_to :product_order_product
def price_ht_with_qte
self.price_ht * self.qte
self.calculated_price.to_f * self.qte
end
def qte_tot
@ -16,7 +16,38 @@ class SubProduct < ActiveRecord::Base
end
def price_tot_with_qte
self.qte_tot * self.price_ht
self.qte_tot * self.calculated_price.to_f
end
def calculated_price
if self.product_order_product.price_ht
price_order_product = self.product_order_product.price_ht
end
if self.price_type == "reste"
if price_order_product
somme = 0.0
self.product_order_product.sub_products.where("price_type != ?", "reste" ).each do |sp|
somme += sp.calculated_price
end
(price_order_product - somme).round(2)
else
0.0
end
elsif self.price_type == "percent"
if price_order_product
(price_order_product * (self.price_ht/100)).round(2)
else
0.0
end
else
self.price_ht.round(2)
end
end
end

View File

@ -0,0 +1,11 @@
.field
.product_degressif_form
%hr
.product_degressif
=form.text_field :nbr, :placeholder => "Nombre mini"
=form.text_field :price, :placeholder => "Prix"
= link_to_remove_fields i(:"trash-o"), form

View File

@ -0,0 +1,185 @@
#main
%div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"}
=@product_order_document.label
=@product_order_document.d_number
%br
=l @product_order.created_at, :format => :date #@product_order_document.created_at
- if @product_order.reseaux_id != 19
%div{:style => "height:350px;"}
-else
%div{:style => "height:140px;"}
-if @product_order.reseaux_id != 19
%table.table{:style => "position:absolute;right:1cm;top:220px"}
%tr
%td{:style => "width:5.5cm;border:0"}
%h3 Adresse de facturation
%strong=@product_order.particular_bill.organisation
%br
=@product_order.particular_bill.firstname
=@product_order.particular_bill.name
%br
=@product_order.particular_bill.address_2
-if @product_order.particular_bill.address_3?
%br
=@product_order.particular_bill.address_3
%br
=@product_order.particular_bill.cp
=@product_order.particular_bill.city
%br
=@product_order.particular_bill.country
%br
%br
=@product_order.particular_bill.tel
%td{:style => "width:5.5cm;border:0"}
%h3 Adresse de livraison
%strong=@product_order.particular_bill.organisation
%br
=@product_order.particular_send.firstname
=@product_order.particular_send.name
%br
=@product_order.particular_send.address_2
-if @product_order.particular_send.address_3?
%br
=@product_order.particular_send.address_3
%br
=@product_order.particular_send.cp
=@product_order.particular_send.city
%br
=@product_order.particular_send.country
%br
%br
=@product_order.particular_bill.tel
%table.table{:style => "width:100%;margin:1cm 0;"}
%tr
-if @product_order.reseaux_id != 19
%th
%th
Description
%th{:style => "text-align:right;width:100px"}
Prix U. HT
%th{:style => "text-align:right;width:80px"}
Qté
%th{:style => "text-align:right;width:100px"}
Prix HT
-@product_order.product_order_products.order(:product_id).each do |product_order_product|
%tr
-if @product_order.reseaux_id != 19
%td{:style => "width:135px;padding:0;vertical-align:middle"}
=image_tag "http://negos.pro"+product_order_product.product.default_image.image_file.file.large.medium.small.thumb.url, :style => "width:130px;" if product_order_product.product.default_image
%td{:style => ""+("border-bottom: 0;padding-bottom:0;"if @product_order.reseaux_id == 19).to_s}
=simple_format product_order_product.archived_product.lang(:fr).bl_title
=# product_order_product.archived_product_size.name if product_order_product.archived_product_size
=# product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
= number_to_currency((product_order_product.price_ht? ? product_order_product.price_ht : product_order_product.archived_product.final_price_ht.to_f), locale: :fr) if product_order_product.archived_product
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
=product_order_product.qty
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
= number_to_currency(product_order_product.archived_final_price_ht_with_qty, locale: :fr) if product_order_product.archived_product
-if @product_order.reseaux_id == 19
%tr
%td{:colspan => 3, :style => "border-top:0;padding-top:0"}
%table.sub_products{:style => "width:100%;margin-bottom:20px;margin-top:5px;"}
%tr
%th Référence
%th Nom
%th Prix U.
%th Nbr
%th Prix HT
-product_order_product.sub_products.each do |sub_product|
%tr
%td
=sub_product.reference
%td
=sub_product.name
%td
=number_to_currency sub_product.price_ht_with_qte
%td
=sub_product.qte_tot
%td
=number_to_currency sub_product.price_tot_with_qte
%td
%tr
%td{:colspan => (@product_order.reseaux_id != 19 ? 3 : 2), :rowspan => 3, :style => "border:0;text-align:left;"}
-if @product_order.reseaux_id != 19
%p
%br
Mode de paiment :
-if @product_order.product_order_payment_type_ok_id == 3
CB
-elsif @product_order.product_order_payment_type_ok_id == 1
Chèque
-elsif @product_order.product_order_payment_type_ok_id == 2
Virement
-elsif @product_order.product_order_payment_type_ok_id == 4
Mandat administratif
%br
%br
Franco de port pour le Pays Voironnais
%td Total HT :
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ht, locale: :fr)
-if @product_order.reseaux_id != 19
%tr
%td TVA :
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_tva, locale: :fr)
%tr
%td Total TTC :
%td{:style => "text-align:right;"}= number_to_currency(@product_order.archived_total_ttc, locale: :fr)
%br
<!---
.fdp
%table.table
%tr
%td
=@product_order.product_fdp_archived.fdp_description
%td
=number_to_currency @product_order.product_fdp_archived.price
="--->"

View File

@ -98,7 +98,7 @@
=# product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
= number_to_currency(product_order_product.archived_product.final_price_ht.to_f, locale: :fr) if product_order_product.archived_product
= number_to_currency((product_order_product.price_ht? ? product_order_product.price_ht : product_order_product.archived_product.final_price_ht.to_f), locale: :fr) if product_order_product.archived_product
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
=product_order_product.qty

View File

@ -98,7 +98,7 @@
=# product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
= number_to_currency(product_order_product.archived_product.final_price_ht.to_f, locale: :fr) if product_order_product.archived_product
= number_to_currency((product_order_product.price_ht? ? product_order_product.price_ht : product_order_product.archived_product.final_price_ht.to_f), locale: :fr) if product_order_product.archived_product
%td{:style => "text-align:right;"+("border-bottom: 0;"if @product_order.reseaux_id == 19).to_s}
=product_order_product.qty

View File

@ -22,6 +22,11 @@
=form.input :price_ht, :label => "Prix (HT) :"
=form.input :price_reduced_ht, :label => "Prix (HT) avec réduction :"
=form.input :constraint_qty, :label => "Contraindre les quantités ?", :as => :boolean
=form.input :step_start, :label => "Quantité mini :"
=form.input :step_group, :label => "Valeur d'indentation :"
=form.input :step_stop, :label => "Quantité max :"
%hr

View File

@ -1,6 +1,7 @@
%table.table#products
%thead
%tr
%th Réseau
%th
%th
Catégorie

View File

@ -1,4 +1,7 @@
%tr#product_row.product_row{:id => product.id, :data => {:id => product.id}}
%td{:style => "width:130px;"}
=product.reseaux.name if product.reseaux
%td{:style => "width:200px;"}
=image_tag product.default_image.image_file.file.large.medium.small.thumb.url if product.default_image
%td

View File

@ -7,6 +7,7 @@
%td Taille
%td Stock théorique
%td Stock réél
%td Prix
=form.semantic_fields_for :product_stocks do |product_stock|
@ -20,6 +21,14 @@
%td=product_stock.text_field :stock_th
%td=product_stock.text_field :stock
%td
%p= link_to_add_fields "Ajouter une ligne", product_stock, :product_degressifs
.product_degressifs_form
=product_stock.semantic_fields_for :product_degressifs do |form|
=render :partial => "admin/product_degressifs/form", :locals => {:form => form}
.actions
= form.submit "Sauvegarder", :class => "btn btn-primary"

View File

@ -1 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "stock_form"))%>",550,600);
show_pane_hover("<%= escape_javascript(render(:partial => "stock_form"))%>",900,600);

View File

@ -6,6 +6,7 @@
=form.input :name
=form.input :qte
=form.input :price_type, :label => "Type de calcul :", :collection => [["Prix fixe", "price"],["Pourcentage du P.U.", "percent"], ["Reste de la somme", "reste"]], :include_blank => false
=form.input :price_ht
=form.input :reference
=form.input :fournisseur_id, :collection => Fournisseur.all, :as => :select

View File

@ -15,15 +15,43 @@
%td.boutique-right
= number_to_currency(product_order_product.product.final_price_ht.to_f, locale: :fr)
= number_to_currency(product_order_product.dyn_price_ht.to_f, locale: :fr)
%td{:style => "width:150px;text-align:center;"}
-if !@recap
.qty_form
= form_for [:public, product_order_product] do |f|
-if [1,2].include?(product_order_product.product_id)
= f.select :qty, [10,20,30,40,50,60,70,80,90,100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000], {:style => "width:30px;"}
-if product_order_product.product.constraint_qty
-if product_order_product.product.step_stop?
-max = product_order_product.product.step_stop
-else
-max = 500
-if product_order_product.product.step_start?
-min = product_order_product.product.step_start
-else
-min = 1
-if product_order_product.product.step_group?
-group = product_order_product.product.step_group
-else
-group = 10
-qte_table = [min.to_i]
-i = min
-while i < max do
-i += group
-qte_table << i.to_i
= f.select :qty, qte_table, {:style => "width:30px;"}
-else
= f.text_field :qty, :style => "width:30px;"
-if [1,2].include?(product_order_product.product_id)
= f.select :qty, [10,20,30,40,50,60,70,80,90,100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000], {:style => "width:30px;"}
-else
= f.text_field :qty, :style => "width:30px;"
= f.submit "Mettre à jour"
=link_to ic(:"trash-o"), public_product_order_product_path(:id => product_order_product.id, :product_order_product => {:qty => 0}), :method => :put
-else

View File

@ -0,0 +1,5 @@
class AddTypeToSubProducts < ActiveRecord::Migration
def change
add_column :sub_products, :price_type, :string
end
end

View File

@ -0,0 +1,12 @@
class CreateProductDegressifs < ActiveRecord::Migration
def change
create_table :product_degressifs do |t|
t.references :product_stock, index: true, foreign_key: true
t.decimal :price, precision: 10, scale: 2
t.decimal :price_remise, precision: 10, scale: 2
t.decimal :nbr, precision: 10, scale: 2
t.boolean :archived, :default => false
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,8 @@
class AddStepsToProducts < ActiveRecord::Migration
def change
add_column :products, :step_start, :decimal, precision: 10, scale: 2
add_column :products, :step_group, :decimal, precision: 10, scale: 2
add_column :products, :step_stop, :decimal, precision: 10, scale: 2
add_column :products, :constraint_qty, :boolean
end
end

View File

@ -11,15 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180417075800) do
ActiveRecord::Schema.define(version: 20180809120902) do
create_table "abonnements", force: :cascade do |t|
t.integer "abonnement_type_id", limit: 4
t.string "slug", limit: 255
t.datetime "start_at"
t.datetime "end_at"
t.boolean "paid", limit: 1
t.boolean "enabled", limit: 1
t.boolean "paid"
t.boolean "enabled"
t.decimal "price", precision: 10, scale: 2
t.integer "customer_id", limit: 4
t.datetime "created_at", null: false
@ -62,7 +62,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "albums", force: :cascade do |t|
t.string "name", limit: 255
t.boolean "super_admin", limit: 1
t.boolean "super_admin"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -85,9 +85,9 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "tag", limit: 255
t.text "description", limit: 65535
t.text "keywords", limit: 65535
t.boolean "enabled", limit: 1
t.boolean "enabled"
t.integer "image_file_id", limit: 4
t.boolean "title_cached", limit: 1
t.boolean "title_cached"
t.string "tags_cache", limit: 255
t.string "tags_cache_slug", limit: 255
t.integer "category_id", limit: 4
@ -116,7 +116,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
end
create_table "break_contents", force: :cascade do |t|
t.boolean "line", limit: 1
t.boolean "line"
t.integer "height", limit: 4
t.string "style", limit: 255
t.datetime "created_at"
@ -126,13 +126,13 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "categories", force: :cascade do |t|
t.string "name", limit: 255
t.string "slug", limit: 255
t.boolean "enabled", limit: 1
t.boolean "enabled"
t.text "description", limit: 65535
t.integer "image_file_id", limit: 4
t.integer "position", limit: 4
t.integer "parent_id", limit: 4
t.string "permalink", limit: 255
t.boolean "front_page", limit: 1
t.boolean "front_page"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -150,7 +150,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "pseudo", limit: 255, default: ""
t.string "email", limit: 255, default: ""
t.string "website", limit: 255, default: ""
t.boolean "enabled", limit: 1
t.boolean "enabled"
t.text "comment", limit: 65535
t.integer "commentable_id", limit: 4
t.string "commentable_type", limit: 255
@ -164,15 +164,15 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "admin_id", limit: 4
t.integer "contact_id", limit: 4
t.datetime "deleted_at"
t.boolean "read_by_admin", limit: 1, default: false
t.boolean "read_by_customer", limit: 1, default: false
t.boolean "read_by_admin", default: false
t.boolean "read_by_customer", default: false
t.text "content", limit: 65535
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "conversations", force: :cascade do |t|
t.boolean "oneone", limit: 1
t.boolean "oneone"
t.integer "first_customer_id", limit: 4
t.string "second_customer_id", limit: 255
t.datetime "created_at", null: false
@ -190,8 +190,8 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "parent_id", limit: 4
t.datetime "last_message_at"
t.string "remote_ip", limit: 255
t.boolean "enabled", limit: 1
t.boolean "readed", limit: 1
t.boolean "enabled"
t.boolean "readed"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "conversation_id", limit: 4
@ -213,8 +213,8 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "parent_id", limit: 4
t.string "parent_code", limit: 255
t.string "parent_at_create", limit: 255
t.boolean "archived", limit: 1
t.boolean "enabled", limit: 1
t.boolean "archived"
t.boolean "enabled"
t.string "username", limit: 255
t.string "name", limit: 255
t.string "firstname", limit: 255
@ -224,7 +224,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.text "bio", limit: 65535
t.string "avatar", limit: 255
t.string "localisation", limit: 255
t.boolean "pro", limit: 1, default: false
t.boolean "pro", default: false
t.string "token", limit: 255
t.string "mlm_token", limit: 255
t.string "address", limit: 255
@ -257,11 +257,11 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
t.boolean "lock", limit: 1
t.boolean "lock"
t.datetime "locked_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "account_validated", limit: 1
t.boolean "account_validated"
t.datetime "account_validated_at"
t.float "latitude", limit: 24
t.float "longitude", limit: 24
@ -269,10 +269,10 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.text "particulars_text", limit: 65535
t.float "capital", limit: 24
t.string "role_signataire", limit: 255
t.boolean "referent", limit: 1, default: false
t.boolean "chef_reseau", limit: 1, default: false
t.boolean "referent", default: false
t.boolean "chef_reseau", default: false
t.string "reseaux_token", limit: 255
t.boolean "particular_idem", limit: 1
t.boolean "particular_idem"
t.integer "particular_send_id", limit: 4
t.integer "particular_bill_id", limit: 4
end
@ -297,7 +297,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "returned_document", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "particulars", limit: 1
t.boolean "particulars"
t.string "download_token", limit: 255
end
@ -334,8 +334,8 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "domains", force: :cascade do |t|
t.string "name", limit: 255
t.string "slug", limit: 255
t.boolean "superadmin", limit: 1
t.boolean "enabled", limit: 1
t.boolean "superadmin"
t.boolean "enabled"
t.text "description", limit: 65535
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@ -366,7 +366,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "file_folders", force: :cascade do |t|
t.string "name", limit: 255
t.boolean "super_admin", limit: 1
t.boolean "super_admin"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -379,7 +379,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "email", limit: 255
t.boolean "send_email", limit: 1
t.boolean "send_email"
end
create_table "gallery_contents", force: :cascade do |t|
@ -415,13 +415,13 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "width", limit: 4
t.integer "height", limit: 4
t.string "alignement", limit: 255
t.boolean "expandable", limit: 1
t.boolean "expandable"
t.string "style", limit: 255
t.string "alt", limit: 255
t.integer "cible_id", limit: 4
t.string "cible_type", limit: 255
t.boolean "with_cible", limit: 1
t.boolean "popup", limit: 1
t.boolean "with_cible"
t.boolean "popup"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -443,7 +443,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "lang_sites", force: :cascade do |t|
t.string "name", limit: 255
t.string "slug", limit: 255
t.boolean "enabled", limit: 1
t.boolean "enabled"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
@ -452,7 +452,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "type", limit: 4
t.string "name", limit: 255
t.string "title", limit: 255
t.boolean "popup", limit: 1
t.boolean "popup"
t.string "url", limit: 255
t.string "style", limit: 255
t.integer "cible_id", limit: 4
@ -467,7 +467,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "email", limit: 255
t.integer "customer_id", limit: 4
t.string "token", limit: 255
t.boolean "readed", limit: 1
t.boolean "readed"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -480,7 +480,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "address", limit: 255
t.string "name", limit: 255
t.integer "view", limit: 4
t.boolean "info_bule", limit: 1
t.boolean "info_bule"
t.integer "zoom", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
@ -502,18 +502,18 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "repertoire_id", limit: 4
t.integer "parent_id", limit: 4
t.integer "position", limit: 4
t.boolean "super_admin", limit: 1
t.boolean "enabled", limit: 1
t.boolean "visible", limit: 1
t.boolean "deleted", limit: 1
t.boolean "super_admin"
t.boolean "enabled"
t.boolean "visible"
t.boolean "deleted"
t.integer "menu_id", limit: 4
t.integer "menu_content_id", limit: 4
t.string "menu_content_type", limit: 255
t.integer "archive_id", limit: 4
t.boolean "archived", limit: 1
t.boolean "archived"
t.datetime "archived_at"
t.boolean "password", limit: 1
t.boolean "comment", limit: 1
t.boolean "password"
t.boolean "comment"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -578,8 +578,8 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "newsgroups", force: :cascade do |t|
t.string "name", limit: 255
t.string "slug", limit: 255
t.boolean "default_checked", limit: 1
t.boolean "enabled", limit: 1
t.boolean "default_checked"
t.boolean "enabled"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
@ -588,7 +588,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "title", limit: 255
t.text "content", limit: 65535
t.datetime "sendmail"
t.boolean "archive", limit: 1
t.boolean "archive"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -627,7 +627,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
end
create_table "particulars", force: :cascade do |t|
t.boolean "pro", limit: 1
t.boolean "pro"
t.string "organisation", limit: 255
t.string "name", limit: 255
t.string "firstname", limit: 255
@ -647,7 +647,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "owner_type", limit: 255
t.integer "owner_id", limit: 4
t.string "particular_type", limit: 255
t.boolean "skip_validation", limit: 1
t.boolean "skip_validation"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "civilite", limit: 255
@ -658,7 +658,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "element_type", limit: 255
t.integer "element_id", limit: 4
t.datetime "paid_at"
t.boolean "paid", limit: 1
t.boolean "paid"
t.string "ogone_payid", limit: 255
t.string "ogone_pm", limit: 255
t.string "ogone_status", limit: 255
@ -752,17 +752,29 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
t.boolean "lock", limit: 1
t.boolean "lock"
t.datetime "locked_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "remote_ip", limit: 255
t.string "token", limit: 255
t.boolean "particular_idem", limit: 1, default: false
t.boolean "particular_idem", default: false
t.integer "particular_bill_id", limit: 4
t.integer "particular_send_id", limit: 4
end
create_table "product_degressifs", force: :cascade do |t|
t.integer "product_stock_id", limit: 4
t.decimal "price", precision: 10, scale: 2
t.decimal "price_remise", precision: 10, scale: 2
t.decimal "nbr", precision: 10, scale: 2
t.boolean "archived", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "product_degressifs", ["product_stock_id"], name: "index_product_degressifs_on_product_stock_id", using: :btree
create_table "product_fdps", force: :cascade do |t|
t.decimal "price", precision: 10, scale: 2
t.text "country", limit: 65535
@ -771,7 +783,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "delais", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.boolean "archived"
end
create_table "product_images", force: :cascade do |t|
@ -796,7 +808,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "product_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.boolean "archived"
t.text "bl_title", limit: 65535
end
@ -810,7 +822,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "name", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.boolean "archived"
end
add_index "product_option_langs", ["product_option_id"], name: "index_product_option_langs_on_product_option_id", using: :btree
@ -819,7 +831,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "product_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.boolean "archived"
end
add_index "product_options", ["product_id"], name: "index_product_options_on_product_id", using: :btree
@ -873,7 +885,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "payplug_card_last_number", limit: 255
t.datetime "paid_at"
t.datetime "tr_canceled_at"
t.boolean "tr_canceled", limit: 1, default: false
t.boolean "tr_canceled", default: false
t.string "token", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@ -913,30 +925,30 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "product_orders", force: :cascade do |t|
t.decimal "amount", precision: 10, scale: 2
t.boolean "particular_idem", limit: 1, default: false
t.boolean "paid", limit: 1, default: false
t.boolean "particular_idem", default: false
t.boolean "paid", default: false
t.integer "particular_bill_id", limit: 4
t.string "particular_send_id", limit: 255
t.string "token", limit: 255
t.boolean "completed_finish", limit: 1, default: false
t.boolean "completed_finish", default: false
t.integer "product_order_payment_ok_id", limit: 4
t.integer "product_order_payment_type_ok_id", limit: 4
t.integer "bill_index", limit: 4
t.string "bill_number", limit: 255
t.string "bill_year", limit: 255
t.boolean "bill_ok", limit: 1, default: false
t.boolean "bill_ok", default: false
t.integer "product_customer_id", limit: 4
t.datetime "paid_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "product_fdp_id", limit: 4
t.integer "product_fdp_archived_id", limit: 4
t.boolean "cgv", limit: 1
t.boolean "cgv"
t.integer "customer_id", limit: 4
t.string "bl_number", limit: 255
t.integer "bl_index", limit: 4
t.integer "bl_year", limit: 4
t.boolean "shiped", limit: 1
t.boolean "shiped"
t.integer "reseaux_id", limit: 4
end
@ -955,7 +967,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.integer "position", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "archived", limit: 1
t.boolean "archived"
end
create_table "product_stocks", force: :cascade do |t|
@ -973,17 +985,21 @@ ActiveRecord::Schema.define(version: 20180417075800) do
create_table "products", force: :cascade do |t|
t.decimal "price_ht", precision: 10, scale: 2
t.decimal "price_reduced_ht", precision: 10, scale: 2
t.boolean "enabled", limit: 1
t.boolean "enabled"
t.integer "default_image_id", limit: 4
t.integer "position", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "product_category_id", limit: 4
t.integer "product_collection_id", limit: 4
t.boolean "archived", limit: 1, default: false
t.boolean "archived", default: false
t.integer "reseaux_id", limit: 4
t.string "sage_reference", limit: 255
t.string "sage_tiers", limit: 255
t.decimal "step_start", precision: 10, scale: 2
t.decimal "step_group", precision: 10, scale: 2
t.decimal "step_stop", precision: 10, scale: 2
t.boolean "constraint_qty"
end
add_index "products", ["product_category_id"], name: "index_products_on_product_category_id", using: :btree
@ -1035,7 +1051,8 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "sub_product_reference_id", limit: 4
t.boolean "archived", limit: 1
t.boolean "archived"
t.string "price_type", limit: 255
end
create_table "table_contents", force: :cascade do |t|
@ -1066,7 +1083,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
t.string "name", limit: 255
t.string "slug", limit: 255
t.integer "parent_id", limit: 4
t.boolean "public", limit: 1
t.boolean "public"
t.string "taggable_type", limit: 255
t.integer "taggable_id", limit: 4
t.datetime "created_at"
@ -1122,6 +1139,7 @@ ActiveRecord::Schema.define(version: 20180417075800) do
add_foreign_key "product_category_langs", "product_categories"
add_foreign_key "product_collection_langs", "product_collections"
add_foreign_key "product_collections", "product_categories"
add_foreign_key "product_degressifs", "product_stocks"
add_foreign_key "product_images", "image_files"
add_foreign_key "product_langs", "product_categories"
add_foreign_key "product_langs", "product_collections"

13
test/fixtures/product_degressives.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
product_stock_id:
price: 9.99
price_remise: 9.99
nbr: 9.99
two:
product_stock_id:
price: 9.99
price_remise: 9.99
nbr: 9.99

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ProductDegressiveTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end