diff --git a/app/controllers/admin/p_spec_values_controller.rb b/app/controllers/admin/p_spec_values_controller.rb index 2dfd736..4ddb464 100644 --- a/app/controllers/admin/p_spec_values_controller.rb +++ b/app/controllers/admin/p_spec_values_controller.rb @@ -13,7 +13,7 @@ class Admin::PSpecValuesController < ApplicationController def index @p_spec_values = PSpecValue.all - @p_spec_values = sort_by_sorting(@p_spec_values, "id DESC") + @p_spec_values = sort_by_sorting(@p_spec_values, "value + 0 ASC") respond_to do |format| format.html{ diff --git a/app/controllers/admin/sorecop_cats_controller.rb b/app/controllers/admin/sorecop_cats_controller.rb new file mode 100644 index 0000000..9a0803e --- /dev/null +++ b/app/controllers/admin/sorecop_cats_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::SorecopCatsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @sorecop_cats = SorecopCat.all + + @sorecop_cats = sort_by_sorting(@sorecop_cats, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @sorecop_cats = @sorecop_cats.page(page).per(per_page) + + } + end + end + + def show + @sorecop_cat = SorecopCat.find(params[:id]) + + end + + def new + @sorecop_cat = SorecopCat.new + + end + + def edit + @sorecop_cat = SorecopCat.find(params[:id]) + + end + + def create + @sorecop_cat = SorecopCat.new(params.require(:sorecop_cat).permit!) + + if @sorecop_cat.save + + else + render action: "new" + + end + + end + + + def update + @sorecop_cat = SorecopCat.find(params[:id]) + + + if @sorecop_cat.update_attributes(params.require(:sorecop_cat).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @sorecop_cat = SorecopCat.find(params[:id]) + @sorecop_cat.destroy + + end +end diff --git a/app/controllers/admin/sorecop_taxes_controller.rb b/app/controllers/admin/sorecop_taxes_controller.rb new file mode 100644 index 0000000..a67105b --- /dev/null +++ b/app/controllers/admin/sorecop_taxes_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::SorecopTaxesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @sorecop_taxes = SorecopTax.all + + @sorecop_taxes = sort_by_sorting(@sorecop_taxes, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @sorecop_taxes = @sorecop_taxes.page(page).per(per_page) + + } + end + end + + def show + @sorecop_tax = SorecopTax.find(params[:id]) + + end + + def new + @sorecop_tax = SorecopTax.new + + end + + def edit + @sorecop_tax = SorecopTax.find(params[:id]) + + end + + def create + @sorecop_tax = SorecopTax.new(params.require(:sorecop_tax).permit!) + + if @sorecop_tax.save + + else + render action: "new" + + end + + end + + + def update + @sorecop_tax = SorecopTax.find(params[:id]) + + + if @sorecop_tax.update_attributes(params.require(:sorecop_tax).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @sorecop_tax = SorecopTax.find(params[:id]) + @sorecop_tax.destroy + + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0b3022..dab1fa6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,6 +128,10 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csvs, "Import Excel" set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csv_match_refs, "Rapprochement références", match_refs_admin_import_csvs_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_cats, "Catégories SORECOP" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_taxes, "taxe SORECOP" + + end diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 793b3c0..19088a9 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -28,7 +28,7 @@ class PProduct < ApplicationRecord has_many :p_product_images belongs_to :p_customer - + belongs_to :sorecop_cat belongs_to :p_product_cat belongs_to :s_brand diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 3203fc1..fce57e9 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -1,6 +1,7 @@ class PProductRef < ApplicationRecord belongs_to :p_product - + belongs_to :sorecop_cat + has_many :sorecop_taxes, through: :sorecop_cat has_many :p_customer_cats, :through => :p_product has_many :p_product_features @@ -45,9 +46,9 @@ class PProductRef < ApplicationRecord :ct_sub_name => {:name => "Nom référence"}, :ct_price_ht => {:name => "Prix de vente", :as => :currency}, :ean => {:name => "EAN"}, - :ca_deee => {:name => "DEEE", :as => :currency}, - :ca_sorecop => {:name => "Sorecop", :as => :currency}, - :sorecop_comment => {:name => "Type de Sorecop"}, + :deee => {:name => "DEEE", :as => :currency}, + :sorecop => {:name => "Sorecop", :as => :currency}, + :sorecop_comment => {:name => "Commentaire Sorecop"}, :actions => {:name => "Actions", :reorder => false} } @@ -102,11 +103,10 @@ class PProductRef < ApplicationRecord end # QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name) - QI_DYNAMICS = %w(name code p_product_cat_id cat_name) #sub_cat_names removed - eval(QI_DYNAMICS_CORE) + # eval(QI_DYNAMICS_CORE) - before_validation :qi_dynamics_cache + # before_validation :qi_dynamics_cache def get_price(options) p_customer = PCustomer.find(options[:p_customer_id]) if options[:p_customer_id] @@ -169,18 +169,42 @@ class PProductRef < ApplicationRecord end def ca_sorecop + return ct_sorecop if ct_sorecop + return "Pas de catégorie Sorecop" if self.p_product.sorecop_cat.blank? + if self.cc_sorecop return self.cc_sorecop else - "TODO Calcul sorecop" + find_sorecop_tax + end + end + + def find_sorecop_tax + p_product_ref_spec = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first + return "Pas de stockage" if p_product_ref_spec.blank? + + storage_capacity = p_product_ref_spec.p_spec_value.value.to_f + if p_product_ref_spec.p_spec_value.unit.casecmp?("Go") + tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first + elsif p_product_ref_spec.p_spec_value.unit.casecmp?("To") + tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity * 1000, storage_capacity * 1000).first + end + + if tax.fixed_price + tax.price + else + tax.price * storage_capacity end end def ca_deee + if ct_deee + return ct_deee + end if self.cc_deee return self.cc_deee else - "TODO Calcul DEEE" + "DEEE à renseigner" end end diff --git a/app/models/sorecop_cat.rb b/app/models/sorecop_cat.rb new file mode 100644 index 0000000..ebb0575 --- /dev/null +++ b/app/models/sorecop_cat.rb @@ -0,0 +1,10 @@ +class SorecopCat < ApplicationRecord + has_many :p_products + has_many :sorecop_taxes, dependent: :destroy + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :name => {:name => "Catégorie", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } +end diff --git a/app/models/sorecop_tax.rb b/app/models/sorecop_tax.rb new file mode 100644 index 0000000..061dd00 --- /dev/null +++ b/app/models/sorecop_tax.rb @@ -0,0 +1,15 @@ +class SorecopTax < ApplicationRecord + belongs_to :sorecop_cat + + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :title => {:name => "Désignation", :reorder => true}, + :critere_min => {:name => "Critère mini (Go)", :reorder => true}, + :critere_max => {:name => "Critère maxi (Go)", :reorder => true}, + :fixed_price => {:name => "Prix forfaitaire", :reorder => true, :format => :boolean}, + :sorecop_cat => {:name => "Catégorie SORECOP",member_label: :name, :reorder => false}, + :price => {:name => "Prix", :reorder => false, as: :currency}, + :actions => {:name => "Actions", :reorder => true} + } +end diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index f89bf35..aa46f8e 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -22,14 +22,15 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"} + %td + =form.input :ean + %tr %td =form.input :ct_sorecop, :label => "Sorecop personalisée :" %td - =form.input :sorecop_comment, :label => "Type de Sorecop :" + =form.input :sorecop_comment, :label => "Commentaire de Sorecop :" %td =form.input :ct_deee, :label => "DEEE personalisée :" - %td - =form.input :ean diff --git a/app/views/admin/p_products/_form.html.haml b/app/views/admin/p_products/_form.html.haml index dcc5078..d298195 100755 --- a/app/views/admin/p_products/_form.html.haml +++ b/app/views/admin/p_products/_form.html.haml @@ -19,7 +19,8 @@ =# f.input :stocked, :label => "Suivi de stock ?" - + .col-sm-2 + =f.input :sorecop_cat, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true @@ -112,4 +113,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/sorecop_cats/_form.html.haml b/app/views/admin/sorecop_cats/_form.html.haml new file mode 100644 index 0000000..92adc9a --- /dev/null +++ b/app/views/admin/sorecop_cats/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @sorecop_cat], :remote => true do |f| + + .content + =f.inputs do + = f.input :name, :label => f.object.label_for(:name) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/_sorecop_cat.html.haml b/app/views/admin/sorecop_cats/_sorecop_cat.html.haml new file mode 100644 index 0000000..f7c3aa2 --- /dev/null +++ b/app/views/admin/sorecop_cats/_sorecop_cat.html.haml @@ -0,0 +1,16 @@ +%tr#sorecop_cat_row{:id => sorecop_cat.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, sorecop_cat], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_sorecop_cat_path(sorecop_cat), :remote => true + = link_to i(:eye), admin_sorecop_cat_path(sorecop_cat), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => sorecop_cat} + + + + \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/create.js.erb b/app/views/admin/sorecop_cats/create.js.erb new file mode 100644 index 0000000..5b32752 --- /dev/null +++ b/app/views/admin/sorecop_cats/create.js.erb @@ -0,0 +1,2 @@ +$('#sorecop_cats_rows').prepend("<%= escape_javascript(render(@sorecop_cat))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/destroy.js.erb b/app/views/admin/sorecop_cats/destroy.js.erb new file mode 100644 index 0000000..53582e6 --- /dev/null +++ b/app/views/admin/sorecop_cats/destroy.js.erb @@ -0,0 +1 @@ +$('#sorecop_cat_row_<%= @sorecop_cat.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/edit.js.erb b/app/views/admin/sorecop_cats/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/sorecop_cats/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/index.html.haml b/app/views/admin/sorecop_cats/index.html.haml new file mode 100644 index 0000000..635f57b --- /dev/null +++ b/app/views/admin/sorecop_cats/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_sorecop_cat_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =SorecopCat.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @sorecop_cats} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @sorecop_cats} + + + diff --git a/app/views/admin/sorecop_cats/new.js.erb b/app/views/admin/sorecop_cats/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/sorecop_cats/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/show.html.haml b/app/views/admin/sorecop_cats/show.html.haml new file mode 100644 index 0000000..764b0b5 --- /dev/null +++ b/app/views/admin/sorecop_cats/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @sorecop_cat \ No newline at end of file diff --git a/app/views/admin/sorecop_cats/update.js.erb b/app/views/admin/sorecop_cats/update.js.erb new file mode 100644 index 0000000..3fe7cb0 --- /dev/null +++ b/app/views/admin/sorecop_cats/update.js.erb @@ -0,0 +1,2 @@ +$('#sorecop_cat_row_<%= @sorecop_cat.id %>').replaceWith("<%= escape_javascript(render(@sorecop_cat))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/_form.html.haml b/app/views/admin/sorecop_taxes/_form.html.haml new file mode 100644 index 0000000..38654b8 --- /dev/null +++ b/app/views/admin/sorecop_taxes/_form.html.haml @@ -0,0 +1,18 @@ +=semantic_form_for [:admin, @sorecop_tax], :remote => true do |f| + + .content + =f.inputs do + = f.input :sorecop_cat_id, as: :select, collection: SorecopCat.pluck(:name, :id) ,:label => f.object.label_for(:sorecop_cat) + = f.input :title, :label => f.object.label_for(:title) + = f.input :critere_min, :label => f.object.label_for(:critere_min) + = f.input :critere_max, :label => f.object.label_for(:critere_max) + = f.input :price, :label => f.object.label_for(:price) + = f.input :fixed_price, :label => f.object.label_for(:fixed_price) + + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml new file mode 100644 index 0000000..684f550 --- /dev/null +++ b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml @@ -0,0 +1,35 @@ +%tr#sorecop_tax_row{:id => sorecop_tax.id} + -tr = {} + + -tr[:critere_min] = capture do + %td + = sorecop_tax.critere_min + Go + + -tr[:critere_max] = capture do + %td + = sorecop_tax.critere_max + Go + + -tr[:fixed_price] = capture do + %td.text-center + -if sorecop_tax.fixed_price + =ic("check-square-o") + -else + =ic("square-o") + + + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, sorecop_tax], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_sorecop_tax_path(sorecop_tax), :remote => true + = link_to i(:eye), admin_sorecop_tax_path(sorecop_tax), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => sorecop_tax} + + + + diff --git a/app/views/admin/sorecop_taxes/create.js.erb b/app/views/admin/sorecop_taxes/create.js.erb new file mode 100644 index 0000000..a917ef3 --- /dev/null +++ b/app/views/admin/sorecop_taxes/create.js.erb @@ -0,0 +1,2 @@ +$('#sorecop_taxes_rows').prepend("<%= escape_javascript(render(@sorecop_tax))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/destroy.js.erb b/app/views/admin/sorecop_taxes/destroy.js.erb new file mode 100644 index 0000000..527b1f6 --- /dev/null +++ b/app/views/admin/sorecop_taxes/destroy.js.erb @@ -0,0 +1 @@ +$('#sorecop_tax_row_<%= @sorecop_tax.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/edit.js.erb b/app/views/admin/sorecop_taxes/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/sorecop_taxes/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/index.html.haml b/app/views/admin/sorecop_taxes/index.html.haml new file mode 100644 index 0000000..90d80c4 --- /dev/null +++ b/app/views/admin/sorecop_taxes/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_sorecop_tax_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =SorecopTax.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @sorecop_taxes} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @sorecop_taxes} + + + diff --git a/app/views/admin/sorecop_taxes/new.js.erb b/app/views/admin/sorecop_taxes/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/sorecop_taxes/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/show.html.haml b/app/views/admin/sorecop_taxes/show.html.haml new file mode 100644 index 0000000..cb114cd --- /dev/null +++ b/app/views/admin/sorecop_taxes/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @sorecop_tax \ No newline at end of file diff --git a/app/views/admin/sorecop_taxes/update.js.erb b/app/views/admin/sorecop_taxes/update.js.erb new file mode 100644 index 0000000..0d6db14 --- /dev/null +++ b/app/views/admin/sorecop_taxes/update.js.erb @@ -0,0 +1,2 @@ +$('#sorecop_tax_row_<%= @sorecop_tax.id %>').replaceWith("<%= escape_javascript(render(@sorecop_tax))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 59be0a4..ab30648 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,27 @@ Rails.application.routes.draw do + namespace :admin do + resources :sorecop_taxes do + member do + + end + collection do + + end + end + end + + namespace :admin do + resources :sorecop_cats do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_fournisseur_refs do member do diff --git a/db/migrate/20210923161914_create_sorecop_cats.rb b/db/migrate/20210923161914_create_sorecop_cats.rb new file mode 100644 index 0000000..4679ff6 --- /dev/null +++ b/db/migrate/20210923161914_create_sorecop_cats.rb @@ -0,0 +1,9 @@ +class CreateSorecopCats < ActiveRecord::Migration[6.0] + def change + create_table :sorecop_cats do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20210923165046_create_sorecop_taxes.rb b/db/migrate/20210923165046_create_sorecop_taxes.rb new file mode 100644 index 0000000..1bf6e8b --- /dev/null +++ b/db/migrate/20210923165046_create_sorecop_taxes.rb @@ -0,0 +1,14 @@ +class CreateSorecopTaxes < ActiveRecord::Migration[6.0] + def change + create_table :sorecop_taxes do |t| + t.decimal :critere_min, precision: 10, scale: 2 + t.decimal :critere_max, precision: 10, scale: 2 + t.string :title + t.boolean :fixed_price, default: true + t.decimal :price, precision: 10, scale: 2 + t.references :sorecop_cat, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20210924145644_add_sorecop_cat_id_to_p_products.rb b/db/migrate/20210924145644_add_sorecop_cat_id_to_p_products.rb new file mode 100644 index 0000000..6091257 --- /dev/null +++ b/db/migrate/20210924145644_add_sorecop_cat_id_to_p_products.rb @@ -0,0 +1,5 @@ +class AddSorecopCatIdToPProducts < ActiveRecord::Migration[6.0] + def change + add_column :p_products, :sorecop_cat_id, :integer + end +end diff --git a/db/migrate/20210924153716_rename_ca_to_ac_for_product_refs.rb b/db/migrate/20210924153716_rename_ca_to_ac_for_product_refs.rb new file mode 100644 index 0000000..304762e --- /dev/null +++ b/db/migrate/20210924153716_rename_ca_to_ac_for_product_refs.rb @@ -0,0 +1,6 @@ +class RenameCaToAcForProductRefs < ActiveRecord::Migration[6.0] + def change + rename_column :p_product_refs, :ca_deee, :ac_deee + rename_column :p_product_refs, :ca_sorecop, :ac_sorecop + end +end diff --git a/db/schema.rb b/db/schema.rb index 83454f6..5c1a20a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1810,10 +1810,10 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do t.boolean "stocked", default: true t.text "description" t.integer "p_product_color_id" - t.decimal "ca_sorecop", precision: 10, scale: 2 + t.decimal "ac_sorecop", precision: 10, scale: 2 t.decimal "cc_sorecop", precision: 10, scale: 2 t.decimal "ct_sorecop", precision: 10, scale: 2 - t.decimal "ca_deee", precision: 10, scale: 2 + t.decimal "ac_deee", precision: 10, scale: 2 t.decimal "cc_deee", precision: 10, scale: 2 t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" @@ -1907,6 +1907,7 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do t.decimal "finesse_max", precision: 6, scale: 2 t.boolean "conserve_proportion", default: false t.boolean "frontpage", default: true + t.integer "sorecop_cat_id" t.index ["p_product_cat_id"], name: "index_p_products_on_p_product_cat_id" t.index ["s_brand_id"], name: "index_p_products_on_s_brand_id" end @@ -2771,6 +2772,24 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do t.decimal "ac_remise", precision: 14, scale: 2 end + create_table "sorecop_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "name" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "sorecop_taxes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.decimal "critere_min", precision: 10, scale: 2 + t.decimal "critere_max", precision: 10, scale: 2 + t.string "title" + t.boolean "fixed_price", default: true + t.decimal "price", precision: 10, scale: 2 + t.bigint "sorecop_cat_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["sorecop_cat_id"], name: "index_sorecop_taxes_on_sorecop_cat_id" + end + create_table "specific_preferences", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "key" t.string "value" @@ -3195,6 +3214,7 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do add_foreign_key "partition_lines", "partitions" add_foreign_key "partitions", "admins" add_foreign_key "s_modules", "s_modules_states" + add_foreign_key "sorecop_taxes", "sorecop_cats" add_foreign_key "stat_lines", "p_commercials" add_foreign_key "stat_lines", "p_customers" add_foreign_key "stat_lines", "p_product_refs" diff --git a/test/fixtures/sorecop_cats.yml b/test/fixtures/sorecop_cats.yml new file mode 100644 index 0000000..7d41224 --- /dev/null +++ b/test/fixtures/sorecop_cats.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/fixtures/sorecop_taxes.yml b/test/fixtures/sorecop_taxes.yml new file mode 100644 index 0000000..f3c9843 --- /dev/null +++ b/test/fixtures/sorecop_taxes.yml @@ -0,0 +1,15 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + critere_min: 9.99 + critere_max: 9.99 + title: MyString + fixed_price: false + sorecop_cat_id: one + +two: + critere_min: 9.99 + critere_max: 9.99 + title: MyString + fixed_price: false + sorecop_cat_id: two diff --git a/test/models/sorecop_cat_test.rb b/test/models/sorecop_cat_test.rb new file mode 100644 index 0000000..2daceaa --- /dev/null +++ b/test/models/sorecop_cat_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SorecopCatTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/sorecop_tax_test.rb b/test/models/sorecop_tax_test.rb new file mode 100644 index 0000000..afb017b --- /dev/null +++ b/test/models/sorecop_tax_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SorecopTaxTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end