From 216ef1afe80163b7e9977053548f7645020007e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 12:38:17 +0200 Subject: [PATCH 01/91] add Postgres --- Gemfile | 2 ++ Gemfile.lock | 4 ++++ config/database.yml | 7 ++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index f4aa40b..00ea1f3 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,8 @@ gem 'rails', '6.0.3.4' gem 'mysql2' # Use Puma as the app server +gem "postgresql" + # Use SCSS for stylesheets gem 'sass-rails', '~> 5' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker diff --git a/Gemfile.lock b/Gemfile.lock index a758dba..cb4387b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -229,7 +229,10 @@ GEM nio4r (2.5.4) nokogiri (1.10.10) mini_portile2 (~> 2.4.0) + pg (1.2.3) posix-spawn (0.3.13) + postgresql (1.0.0) + pg public_suffix (4.0.1) puma (3.12.1) rack (2.2.3) @@ -386,6 +389,7 @@ DEPENDENCIES mysql2 nokogiri posix-spawn + postgresql puma (~> 3.11) rails (= 6.0.3.4) rails_autolink diff --git a/config/database.yml b/config/database.yml index b7f85f0..a3fb5bf 100644 --- a/config/database.yml +++ b/config/database.yml @@ -14,9 +14,10 @@ default: &default sql_mode: TRADITIONAL development: - <<: *default - username: root - socket: /tmp/mysql.sock + adapter: postgresql + database: presta_app + pool: 5 + username: postgres # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". From 3bec5568eb21658c34330458c2039949744bf4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 12:38:38 +0200 Subject: [PATCH 02/91] debug group --- app/views/admin/p_customer_sheets/index.html.haml | 2 +- app/views/admin/p_customers/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index 8657d2a..2ba4b79 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -23,7 +23,7 @@ %td Statut : - =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) + =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.select(:state).group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) %td Numéro d'offre : diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index c7ddc07..af02f16 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -34,7 +34,7 @@ %td Raison de blocage : - =select_tag "search[disabled_raison]", options_for_select(PCustomer.group("disabled_raison").map{|p| [p.disabled_raison]}, params[:search][:disabled_raison]) + =select_tag "search[disabled_raison]", options_for_select(PCustomer.select("disabled_raison").group("disabled_raison").map{|p| [p.disabled_raison]}, params[:search][:disabled_raison]) -if false From 7567ffbd343e10625c03e8c23ebe2b3cac1914a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 15:32:27 +0200 Subject: [PATCH 03/91] wip debug --- app/controllers/admin/buy_lists_controller.rb | 4 ++-- app/controllers/admin/edit_watchers_controller.rb | 2 +- .../admin/price_documents_controller.rb | 7 +++++-- app/controllers/admin/timer_watchers_controller.rb | 2 +- app/models/p_customer.rb | 6 ++++-- app/models/p_sheet_line.rb | 2 +- app/models/v_contact.rb | 2 +- app/views/admin/admins/show.html.haml | 4 ++-- app/views/admin/buy_lists/index.html.haml | 14 +++++++------- 9 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index 662c25d..e555dcc 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -12,7 +12,7 @@ class Admin::BuyListsController < ApplicationController @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) - @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids).unscoped if params[:search][:s_brand].present? && params[:search][:s_brand] != "" @price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand]) @@ -61,7 +61,7 @@ class Admin::BuyListsController < ApplicationController @price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @start) if @start @price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @stop.end_of_day) if @stop - + @price_lines = @price_lines.where(:cc_block_type => "Demande de commande") respond_to do |format| format.html{ diff --git a/app/controllers/admin/edit_watchers_controller.rb b/app/controllers/admin/edit_watchers_controller.rb index 11ec4f4..5e464a0 100644 --- a/app/controllers/admin/edit_watchers_controller.rb +++ b/app/controllers/admin/edit_watchers_controller.rb @@ -15,7 +15,7 @@ class Admin::EditWatchersController < ApplicationController @edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all - @edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all + @edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all else render :action => :new diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index b480168..c839a72 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -278,8 +278,8 @@ class Admin::PriceDocumentsController < ApplicationController @ref_price_lines = @demande.price_line_block.price_lines - @ref_price_lines.group(:p_product_ref_id).each do |plr| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + @ref_price_lines.unscoped.select(:p_product_ref_id).group(:p_product_ref_id).each do |plr| + @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) end @@ -294,6 +294,8 @@ class Admin::PriceDocumentsController < ApplicationController if @price_document.save redirect_to consult_edit_admin_price_document_path(:id => @price_document.token) else + @demande = PriceDocument.where(:id => @price_document.doc_ref_id).first + render action: "consult" end @@ -330,6 +332,7 @@ class Admin::PriceDocumentsController < ApplicationController def update + raise @price_document = PriceDocument.find(params[:id]) @avoir = true if @price_document.label == "Avoir" diff --git a/app/controllers/admin/timer_watchers_controller.rb b/app/controllers/admin/timer_watchers_controller.rb index 35d689c..7d37b85 100644 --- a/app/controllers/admin/timer_watchers_controller.rb +++ b/app/controllers/admin/timer_watchers_controller.rb @@ -50,7 +50,7 @@ class Admin::TimerWatchersController < ApplicationController @edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all - @edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all + @edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index e1ee85d..a9decf8 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -123,8 +123,10 @@ class PCustomer < ApplicationRecord end after_initialize do - self.p_payment_type_id = 41 if !self.p_payment_type_id? - + begin + self.p_payment_type_id = 41 if !self.p_payment_type_id? + rescue + end end diff --git a/app/models/p_sheet_line.rb b/app/models/p_sheet_line.rb index 926c7dd..140e231 100644 --- a/app/models/p_sheet_line.rb +++ b/app/models/p_sheet_line.rb @@ -172,7 +172,7 @@ class PSheetLine < ApplicationRecord def stock_is_ok if !self.stock_done - if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.group(:p_brut_product_id).length + if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.select(:p_brut_product_id).group(:p_brut_product_id).length self.stock_done = true self.save diff --git a/app/models/v_contact.rb b/app/models/v_contact.rb index 195c00f..3d15cb3 100644 --- a/app/models/v_contact.rb +++ b/app/models/v_contact.rb @@ -203,7 +203,7 @@ class VContact < ApplicationRecord # Mettre nbr_mvt à 0 pour toutes les cartes actives qui n'ont pas eu de mouvement - vc_ids = VolumePeriodique.group(:codemanaginn).map{|a| a.codemanaginn} + vc_ids = VolumePeriodique.select(:codemanaginn).group(:codemanaginn).map{|a| a.codemanaginn} VContact.where(:enabled => true).where("codemanaginn not in(?)", vc_ids).update_all(:nbr_mvt => 0, :cc_cagnotte => 0, :cc_total => 0, :cc_remise => 0) diff --git a/app/views/admin/admins/show.html.haml b/app/views/admin/admins/show.html.haml index 8d8f6eb..dc200a3 100644 --- a/app/views/admin/admins/show.html.haml +++ b/app/views/admin/admins/show.html.haml @@ -47,7 +47,7 @@ %th Client %th Temps passé %th - -@timer_watchers.group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp| + -@timer_watchers.select(:p_customer_id).group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp| %tbody %tr %td @@ -86,4 +86,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 37beefd..b84b535 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -30,7 +30,7 @@ =ic(:times) %td Statut : - =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select" + =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.select(:state).group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select" %td Marque : @@ -113,8 +113,8 @@ %tbody -p_product_id = nil - -@price_lines.where.not(:p_product_ref_id => nil).group(:p_product_ref_id).order("p_product_id ASC").each do |plr| - + -@price_lines.select("DISTINCT ON (price_lines.p_product_ref_id) price_lines.*").where.not(:p_product_ref_id => nil).order("price_lines.p_product_ref_id, p_product_id ASC").each do |plr| + -if p_product_id != plr.p_product_id -p_product_id = plr.p_product_id %tr.prdct_tr @@ -190,15 +190,15 @@ %td.col-detail =link_to [:admin, price_line.price_line_block.price_lineable] do =price_line.price_line_block.price_lineable.id - =price_line.price_line_block.price_lineable.past_id + =#price_line.price_line_block.price_lineable.past_id %td.col-detail - =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] + =#link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] %td - =state_helper price_line.price_line_block.price_lineable.state + =#state_helper price_line.price_line_block.price_lineable.state %td =price_line.comment @@ -209,7 +209,7 @@ = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date %td - = l price_line.cc_wish_date, :format => "semaine %V (%Y)" + = #l price_line.cc_wish_date, :format => "semaine %V (%Y)" %td =price_line.qte.to_i From 2cf5b53cba9401921935afaec68273b5739a5dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 13 Sep 2021 15:15:08 +0200 Subject: [PATCH 04/91] payment fix & commercial --- app/controllers/admin/p_payments_controller.rb | 13 +++++++------ app/views/admin/dashboards/commercial.html.haml | 13 ++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/p_payments_controller.rb b/app/controllers/admin/p_payments_controller.rb index 31ac52c..e5366ea 100644 --- a/app/controllers/admin/p_payments_controller.rb +++ b/app/controllers/admin/p_payments_controller.rb @@ -108,12 +108,13 @@ class Admin::PPaymentsController < ApplicationController @p_payments = @p_payments.where("affected = ?", params[:affected].to_i) end - if params[:remise].to_s != "" - @p_payments = @p_payments.where("remise = ?", params[:remise].to_i) - if params[:remise].to_s == "0" - @p_payments = @p_payments.where(:imported => false) - end - end + # PROBLEME AVEC POSTGRES. Attend un booléen mais le where envoi 1/0 + # if params[:remise].to_s != "" + # @p_payments = @p_payments.where("remise = ?", params[:remise].to_i) + # if params[:remise].to_s == "0" + # @p_payments = @p_payments.where(:imported => false) + # end + # end if params[:p_customer_id].to_s != "" @p_payments = @p_payments.where(:p_customer_id => params[:p_customer_id]) diff --git a/app/views/admin/dashboards/commercial.html.haml b/app/views/admin/dashboards/commercial.html.haml index 047efd4..36a15bd 100644 --- a/app/views/admin/dashboards/commercial.html.haml +++ b/app/views/admin/dashboards/commercial.html.haml @@ -293,7 +293,7 @@ .check_box_search_index .check_box_search_index_inner.clientsCheck - -st = StatLine.group(:p_customer_id).order(:p_customer_name) + -st = StatLine.select(:p_customer_id, :p_customer_name).group(:p_customer_id, :p_customer_name).order('stat_lines.p_customer_name') -if current_admin.p_commercial -st = st.where(:p_customer_id => current_admin.p_commercial.p_customers.ids) -st.all.each do |pdt| @@ -675,6 +675,8 @@ %span.text-success %i.mdi.mdi-arrow-bottom-right =number_to_currency(((@periode_tot_weight.to_f != 0.0 ? @periode_avg_price_per_kg = @ca_produits_degrade / @periode_tot_weight : 0.0)), :precision => 2) + / DEBUG POUR AFFICHER LA PAGE SANS DATA + - @periode_avg_price_per_kg = 1 ="/ Kg" ca moyen / kilo @@ -748,10 +750,10 @@ -@tot_clients_inactifs = (@tot_customs - @periode_lines.group(:p_customer_id).map{|p| p.p_customer_id}.uniq) -@all_customers_rows = @all_customers_rows.where(id: params[:p_customer_ids]) -else - -@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq ) + -@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq ) - -@periode_nbr_clients_actifs = (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length + -@periode_nbr_clients_actifs = (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length / -@clients_inactifs = [] / -@periode_nbr_clients_inactifs = params[:p_customer_ids].each do |a| / -@clients_inactifs << PCustomer.where(id: a, enabled: false) @@ -759,7 +761,7 @@ / -@tot_clients_inactifs = (@clients_inactifs.length - @periode_nbr_clients_actifs) %div{:style => "font-size:0.7em;float:right"} - =link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do + =link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do =@tot_clients_inactifs.length inactifs @@ -810,7 +812,8 @@ %span.text-success %i.mdi.mdi-arrow-bottom-right =number_to_currency((@periode_avg_ca_per_customer = @ca_produits_degrade / @periode_nbr_clients_actifs.to_f), :precision => 0) - + / DEBUG POUR AFFICHER LA PAGE SANS DATA + -@periode_avg_ca_per_customer = 1 ca moyen / clients .mb-0 From fc9a97fe3f48f8d01cac9e247dad63a33475a321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 17:53:01 +0200 Subject: [PATCH 05/91] WIP remote change p_customer_sheet state --- .../admin/p_customer_sheets_controller.rb | 12 ++++++----- app/views/admin/buy_lists/index.html.haml | 21 +++++++++++++++++-- app/views/admin/buy_lists/index.js.erb | 2 ++ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 app/views/admin/buy_lists/index.js.erb diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index fbc5058..8040166 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -196,10 +196,13 @@ class Admin::PCustomerSheetsController < ApplicationController if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) - @p_customer = @p_customer_sheet.price_line_block.p_customer - - - redirect_to admin_p_customer_sheet_path(@p_customer_sheet) + @p_customer = @p_customer_sheet.price_line_block.p_customer + if params[:no_redirect] == "true" + @price_line_id = params[:price_line_id] + render "admin/buy_lists/index" + else + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) + end else render action: "edit" @@ -207,7 +210,6 @@ class Admin::PCustomerSheetsController < ApplicationController end - def destroy @p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet.destroy diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index de9fbbb..8999cff 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -216,7 +216,7 @@ %tbody.detail -ppr_lines.each do |price_line| - %tr + %tr{id: "price_line_row_#{price_line.id}"} - if checkbox %td =check_box_tag :"price_line_ids[]", price_line.id @@ -235,7 +235,23 @@ =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] %td - =state_helper price_line.price_line_block.price_lineable.state + -@p_customer_sheet = price_line.price_line_block.price_lineable + -if true + %form + =semantic_form_for [:admin, @p_customer_sheet], remote: true, authenticity_token: true do |f| + =f.inputs class: "form-inline d-flex flex-nowrap" do + =f.input :state, collection: ["AV BPA", "PAS BPA","BPA", "Traitée"], as: :select, :include_blank => false, label: false, selected: f.object.state, input_html: {class: "custom-select"}, remote: true + =hidden_field_tag :no_redirect, "true" + =hidden_field_tag :price_line_id, price_line.id + =f.button ic(:check), type: :submit, class: "btn btn-primary ml-1" + -if false + =f.actions class: "btn btn-primary ml-1" do + =f.action :submit, label: "#{ic(:check).html_safe}" + -if false + =form_with url: update_state_admin_p_customer_sheet_path(@p_customer_sheet), method: :get do |f| + =f.select :state, ["AV BPA", "PAS BPA","BPA", "Traitée"] + =f.submit + =#state_helper price_line.price_line_block.price_lineable.state %td =price_line.comment @@ -364,6 +380,7 @@ checkbox.prop("checked", false) } }) + $('.plus-all').click() diff --git a/app/views/admin/buy_lists/index.js.erb b/app/views/admin/buy_lists/index.js.erb new file mode 100644 index 0000000..9eef406 --- /dev/null +++ b/app/views/admin/buy_lists/index.js.erb @@ -0,0 +1,2 @@ +console.log('coucou') +$('#price_line_row_<%= @price_line_id %>').replaceWith("<%= escape_javascript(render(@p_customer_sheet))%>"); From a9a5e222513c46236d77b2aed0bb3301c6cee330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 18:19:47 +0200 Subject: [PATCH 06/91] g qis sorecop_cats --- .../admin/sorecop_cats_controller.rb | 76 +++++++++++++++++++ app/models/sorecop_cat.rb | 2 + app/views/admin/sorecop_cats/_form.html.haml | 12 +++ .../admin/sorecop_cats/_sorecop_cat.html.haml | 16 ++++ app/views/admin/sorecop_cats/create.js.erb | 2 + app/views/admin/sorecop_cats/destroy.js.erb | 1 + app/views/admin/sorecop_cats/edit.js.erb | 1 + app/views/admin/sorecop_cats/index.html.haml | 16 ++++ app/views/admin/sorecop_cats/new.js.erb | 1 + app/views/admin/sorecop_cats/show.html.haml | 10 +++ app/views/admin/sorecop_cats/update.js.erb | 2 + config/routes.rb | 11 +++ .../20210923161914_create_sorecop_cats.rb | 9 +++ test/fixtures/sorecop_cats.yml | 7 ++ test/models/sorecop_cat_test.rb | 7 ++ 15 files changed, 173 insertions(+) create mode 100644 app/controllers/admin/sorecop_cats_controller.rb create mode 100644 app/models/sorecop_cat.rb create mode 100644 app/views/admin/sorecop_cats/_form.html.haml create mode 100644 app/views/admin/sorecop_cats/_sorecop_cat.html.haml create mode 100644 app/views/admin/sorecop_cats/create.js.erb create mode 100644 app/views/admin/sorecop_cats/destroy.js.erb create mode 100644 app/views/admin/sorecop_cats/edit.js.erb create mode 100644 app/views/admin/sorecop_cats/index.html.haml create mode 100644 app/views/admin/sorecop_cats/new.js.erb create mode 100644 app/views/admin/sorecop_cats/show.html.haml create mode 100644 app/views/admin/sorecop_cats/update.js.erb create mode 100644 db/migrate/20210923161914_create_sorecop_cats.rb create mode 100644 test/fixtures/sorecop_cats.yml create mode 100644 test/models/sorecop_cat_test.rb 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/models/sorecop_cat.rb b/app/models/sorecop_cat.rb new file mode 100644 index 0000000..be69dba --- /dev/null +++ b/app/models/sorecop_cat.rb @@ -0,0 +1,2 @@ +class SorecopCat < ApplicationRecord +end 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/config/routes.rb b/config/routes.rb index a5835ca..bb3e0c3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :sorecop_cats do + member do + + end + collection do + + end + end + end + namespace :admin do resources :price_line_resp_selects 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/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/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 From 91dc7a86317643fd6314cab9290506855052149d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 18:52:52 +0200 Subject: [PATCH 07/91] g qis sorecop_taxes --- .../admin/sorecop_taxes_controller.rb | 76 +++++++++++++++++++ app/models/sorecop_tax.rb | 3 + app/views/admin/sorecop_taxes/_form.html.haml | 16 ++++ .../sorecop_taxes/_sorecop_tax.html.haml | 16 ++++ app/views/admin/sorecop_taxes/create.js.erb | 2 + app/views/admin/sorecop_taxes/destroy.js.erb | 1 + app/views/admin/sorecop_taxes/edit.js.erb | 1 + app/views/admin/sorecop_taxes/index.html.haml | 16 ++++ app/views/admin/sorecop_taxes/new.js.erb | 1 + app/views/admin/sorecop_taxes/show.html.haml | 10 +++ app/views/admin/sorecop_taxes/update.js.erb | 2 + config/routes.rb | 11 +++ .../20210923165046_create_sorecop_taxes.rb | 13 ++++ test/fixtures/sorecop_taxes.yml | 15 ++++ test/models/sorecop_tax_test.rb | 7 ++ 15 files changed, 190 insertions(+) create mode 100644 app/controllers/admin/sorecop_taxes_controller.rb create mode 100644 app/models/sorecop_tax.rb create mode 100644 app/views/admin/sorecop_taxes/_form.html.haml create mode 100644 app/views/admin/sorecop_taxes/_sorecop_tax.html.haml create mode 100644 app/views/admin/sorecop_taxes/create.js.erb create mode 100644 app/views/admin/sorecop_taxes/destroy.js.erb create mode 100644 app/views/admin/sorecop_taxes/edit.js.erb create mode 100644 app/views/admin/sorecop_taxes/index.html.haml create mode 100644 app/views/admin/sorecop_taxes/new.js.erb create mode 100644 app/views/admin/sorecop_taxes/show.html.haml create mode 100644 app/views/admin/sorecop_taxes/update.js.erb create mode 100644 db/migrate/20210923165046_create_sorecop_taxes.rb create mode 100644 test/fixtures/sorecop_taxes.yml create mode 100644 test/models/sorecop_tax_test.rb 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/models/sorecop_tax.rb b/app/models/sorecop_tax.rb new file mode 100644 index 0000000..9fb2cd7 --- /dev/null +++ b/app/models/sorecop_tax.rb @@ -0,0 +1,3 @@ +class SorecopTax < ApplicationRecord + belongs_to :sorecop_cat_id +end 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..389bbe6 --- /dev/null +++ b/app/views/admin/sorecop_taxes/_form.html.haml @@ -0,0 +1,16 @@ +=semantic_form_for [:admin, @sorecop_tax], :remote => true do |f| + + .content + =f.inputs do + = f.input :critere_min, :label => f.object.label_for(:critere_min) + = f.input :critere_max, :label => f.object.label_for(:critere_max) + = f.input :title, :label => f.object.label_for(:title) + = f.input :fixed_price, :label => f.object.label_for(:fixed_price) + = f.input :sorecop_cat_id, :label => f.object.label_for(:sorecop_cat_id) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file 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..4a318ec --- /dev/null +++ b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml @@ -0,0 +1,16 @@ +%tr#sorecop_tax_row{:id => sorecop_tax.id} + -tr = {} + + -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} + + + + \ No newline at end of file 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 bb3e0c3..3543334 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ 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 diff --git a/db/migrate/20210923165046_create_sorecop_taxes.rb b/db/migrate/20210923165046_create_sorecop_taxes.rb new file mode 100644 index 0000000..c272193 --- /dev/null +++ b/db/migrate/20210923165046_create_sorecop_taxes.rb @@ -0,0 +1,13 @@ +class CreateSorecopTaxes < ActiveRecord::Migration[6.0] + def change + create_table :sorecop_taxes do |t| + t.decimal :critere_min + t.decimal :critere_max + t.string :title + t.boolean :fixed_price + t.references :sorecop_cat_id, foreign_key: true + + t.timestamps + end + end +end 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_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 From 07014ae159ac78012296e3bedcbd2a081c2aace2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 18:58:09 +0200 Subject: [PATCH 08/91] typo fix --- .../20210923165046_create_sorecop_taxes.rb | 8 ++++---- db/schema.rb | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/db/migrate/20210923165046_create_sorecop_taxes.rb b/db/migrate/20210923165046_create_sorecop_taxes.rb index c272193..bbeeaff 100644 --- a/db/migrate/20210923165046_create_sorecop_taxes.rb +++ b/db/migrate/20210923165046_create_sorecop_taxes.rb @@ -1,11 +1,11 @@ class CreateSorecopTaxes < ActiveRecord::Migration[6.0] def change create_table :sorecop_taxes do |t| - t.decimal :critere_min - t.decimal :critere_max + t.decimal :critere_min, :precision => 10, :scale => 2 + t.decimal :critere_max, :precision => 10, :scale => 2 t.string :title - t.boolean :fixed_price - t.references :sorecop_cat_id, foreign_key: true + t.boolean :fixed_price, default: true + t.references :sorecop_cats, foreign_key: true t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 5baae52..abb4522 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_17_124338) do +ActiveRecord::Schema.define(version: 2021_09_23_165046) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -2754,6 +2754,23 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) 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.bigint "sorecop_cats_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["sorecop_cats_id"], name: "index_sorecop_taxes_on_sorecop_cats_id" + end + create_table "specific_preferences", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "key" t.string "value" @@ -3176,6 +3193,7 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) 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", column: "sorecop_cats_id" add_foreign_key "stat_lines", "p_commercials" add_foreign_key "stat_lines", "p_customers" add_foreign_key "stat_lines", "p_product_refs" From 7a5e27685caa173b57769396a59e517b2b51dcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 19:55:56 +0200 Subject: [PATCH 09/91] update migration --- db/migrate/20210923165046_create_sorecop_taxes.rb | 7 ++++--- ...10923170130_add_sorecop_cat_id_to_p_product_refs.rb | 5 +++++ db/schema.rb | 10 ++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb diff --git a/db/migrate/20210923165046_create_sorecop_taxes.rb b/db/migrate/20210923165046_create_sorecop_taxes.rb index bbeeaff..1bf6e8b 100644 --- a/db/migrate/20210923165046_create_sorecop_taxes.rb +++ b/db/migrate/20210923165046_create_sorecop_taxes.rb @@ -1,11 +1,12 @@ 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.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.references :sorecop_cats, foreign_key: true + t.decimal :price, precision: 10, scale: 2 + t.references :sorecop_cat, foreign_key: true t.timestamps end diff --git a/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb b/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb new file mode 100644 index 0000000..b4d65a9 --- /dev/null +++ b/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb @@ -0,0 +1,5 @@ +class AddSorecopCatIdToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :sorecop_cat_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index abb4522..5e36bad 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_23_165046) do +ActiveRecord::Schema.define(version: 2021_09_23_170130) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1801,6 +1801,7 @@ ActiveRecord::Schema.define(version: 2021_09_23_165046) do t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" + t.integer "sorecop_cat_id" end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| @@ -2765,10 +2766,11 @@ ActiveRecord::Schema.define(version: 2021_09_23_165046) do t.decimal "critere_max", precision: 10, scale: 2 t.string "title" t.boolean "fixed_price", default: true - t.bigint "sorecop_cats_id" + 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_cats_id"], name: "index_sorecop_taxes_on_sorecop_cats_id" + 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| @@ -3193,7 +3195,7 @@ ActiveRecord::Schema.define(version: 2021_09_23_165046) 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", column: "sorecop_cats_id" + 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" From 0246cf966e66fc154c0f5098d01ecc5c476a97f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 19:56:51 +0200 Subject: [PATCH 10/91] menu & forms --- app/controllers/application_controller.rb | 4 +++- app/models/p_product_ref.rb | 3 ++- app/models/sorecop_cat.rb | 8 ++++++++ app/models/sorecop_tax.rb | 14 +++++++++++++- app/views/admin/sorecop_taxes/_form.html.haml | 16 +++++++++------- .../admin/sorecop_taxes/_sorecop_tax.html.haml | 7 ++++++- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce02913..6441a74 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,7 +126,9 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" - + 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_ref.rb b/app/models/p_product_ref.rb index 9a7fccf..49d5d80 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 diff --git a/app/models/sorecop_cat.rb b/app/models/sorecop_cat.rb index be69dba..a0af0d4 100644 --- a/app/models/sorecop_cat.rb +++ b/app/models/sorecop_cat.rb @@ -1,2 +1,10 @@ class SorecopCat < ApplicationRecord + has_many :p_product_refs + 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 index 9fb2cd7..518bb01 100644 --- a/app/models/sorecop_tax.rb +++ b/app/models/sorecop_tax.rb @@ -1,3 +1,15 @@ class SorecopTax < ApplicationRecord - belongs_to :sorecop_cat_id + 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", :reorder => false}, + :price => {:name => "Prix", :reorder => false}, + :actions => {:name => "Actions", :reorder => true} + } end diff --git a/app/views/admin/sorecop_taxes/_form.html.haml b/app/views/admin/sorecop_taxes/_form.html.haml index 389bbe6..38654b8 100644 --- a/app/views/admin/sorecop_taxes/_form.html.haml +++ b/app/views/admin/sorecop_taxes/_form.html.haml @@ -2,15 +2,17 @@ .content =f.inputs do - = f.input :critere_min, :label => f.object.label_for(:critere_min) - = f.input :critere_max, :label => f.object.label_for(:critere_max) - = f.input :title, :label => f.object.label_for(:title) - = f.input :fixed_price, :label => f.object.label_for(:fixed_price) - = f.input :sorecop_cat_id, :label => f.object.label_for(:sorecop_cat_id) - + = 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" - \ No newline at end of file + diff --git a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml index 4a318ec..c35450f 100644 --- a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml +++ b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml @@ -1,5 +1,10 @@ %tr#sorecop_tax_row{:id => sorecop_tax.id} -tr = {} + + -tr[:sorecop_cat] = capture do + %td + = sorecop_tax.sorecop_cat.name + -tr[:actions] = capture do %td.actions @@ -13,4 +18,4 @@ - \ No newline at end of file + From 2e83114c3f1f3ff463f8715fe531e829c76bedd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 12:30:19 +0200 Subject: [PATCH 11/91] Update sorecop text table --- app/models/sorecop_tax.rb | 4 ++-- .../sorecop_taxes/_sorecop_tax.html.haml | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/models/sorecop_tax.rb b/app/models/sorecop_tax.rb index 518bb01..061dd00 100644 --- a/app/models/sorecop_tax.rb +++ b/app/models/sorecop_tax.rb @@ -8,8 +8,8 @@ class SorecopTax < ApplicationRecord :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", :reorder => false}, - :price => {:name => "Prix", :reorder => false}, + :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/sorecop_taxes/_sorecop_tax.html.haml b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml index c35450f..684f550 100644 --- a/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml +++ b/app/views/admin/sorecop_taxes/_sorecop_tax.html.haml @@ -1,11 +1,25 @@ %tr#sorecop_tax_row{:id => sorecop_tax.id} -tr = {} - -tr[:sorecop_cat] = capture do + -tr[:critere_min] = capture do %td - = sorecop_tax.sorecop_cat.name + = 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 From 91754a6192447358fee3c11a584d5315a3e4ea51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 15:11:43 +0200 Subject: [PATCH 12/91] Spec value default order --- app/controllers/admin/p_spec_values_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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{ From e8ebce23edc9588ccbd555cd09266bc3d5127165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 15:12:17 +0200 Subject: [PATCH 13/91] ca_sorecop for p_product_ref --- app/models/p_product_ref.rb | 22 +++++++++++++++---- .../admin/p_product_refs/_form.html.haml | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 49d5d80..f8cf488 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -10,6 +10,7 @@ class PProductRef < ApplicationRecord has_many :p_product_ref_price_histories belongs_to :p_product_color + belongs_to :sorecop_cat has_many :p_articles has_many :p_article_serial_nums, through: :p_articles @@ -46,7 +47,7 @@ class PProductRef < ApplicationRecord :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 => {:name => "Sorecop", :as => :currency}, :sorecop_comment => {:name => "Type de Sorecop"}, :actions => {:name => "Actions", :reorder => false} } @@ -155,13 +156,26 @@ class PProductRef < ApplicationRecord end def ca_sorecop - if self.cc_sorecop - return self.cc_sorecop + if self.sorecop_cat + if self.cc_sorecop + return self.cc_sorecop + else + if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")) + find_sorecop_tax.price + else + "Pas de spec de Stockage" + end + end else - "TODO Calcul sorecop" + "Pas de catégorie Sorecop" end end + def find_sorecop_tax + storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value + self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first + end + def ca_deee if self.cc_deee return self.cc_deee diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index 4b0b755..f55ec17 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -20,10 +20,12 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true + %td + =form.input :sorecop_cat_id, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true %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 From 72cee7f797bc7925d02ea7cf30f00da8d39389a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 15:59:38 +0200 Subject: [PATCH 14/91] update sorecop calcul --- app/models/p_product_ref.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index f8cf488..2588ad3 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -48,7 +48,7 @@ class PProductRef < ApplicationRecord :ean => {:name => "EAN"}, :ca_deee => {:name => "DEEE", :as => :currency}, :sorecop => {:name => "Sorecop", :as => :currency}, - :sorecop_comment => {:name => "Type de Sorecop"}, + :sorecop_comment => {:name => "Commentaire Sorecop"}, :actions => {:name => "Actions", :reorder => false} } @@ -156,14 +156,17 @@ class PProductRef < ApplicationRecord end def ca_sorecop + if ct_sorecop + return ct_sorecop + end if self.sorecop_cat if self.cc_sorecop return self.cc_sorecop else - if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")) - find_sorecop_tax.price + if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).empty? + "Pas de stockage" else - "Pas de spec de Stockage" + find_sorecop_tax end end else @@ -172,8 +175,13 @@ class PProductRef < ApplicationRecord end def find_sorecop_tax - storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value - self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first + storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value.to_f + tax = self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first + if tax.fixed_price + tax.price + else + tax.price * storage_capacity + end end def ca_deee From 82fdb06254c4134f18a699dbb18eac05d748b384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 15:59:56 +0200 Subject: [PATCH 15/91] fomr in 2 lines --- app/views/admin/p_product_refs/_form.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index f55ec17..7ce89d3 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -20,6 +20,9 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true + %td + =form.input :ean + %tr %td =form.input :sorecop_cat_id, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true %td @@ -28,8 +31,6 @@ =form.input :sorecop_comment, :label => "Commentaire de Sorecop :" %td =form.input :ct_deee, :label => "DEEE personalisée :" - %td - =form.input :ean From 60ee0d819761bd33be3c7d48a082f257aa141d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 17:19:44 +0200 Subject: [PATCH 16/91] move sorecop_cat to p_product --- app/models/p_product.rb | 2 +- app/models/p_product_ref.rb | 40 ++++++++++--------- app/models/sorecop_cat.rb | 2 +- .../admin/p_product_refs/_form.html.haml | 2 - app/views/admin/p_products/_form.html.haml | 5 ++- ...30_add_sorecop_cat_id_to_p_product_refs.rb | 5 --- ...145644_add_sorecop_cat_id_to_p_products.rb | 5 +++ db/schema.rb | 4 +- 8 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb create mode 100644 db/migrate/20210924145644_add_sorecop_cat_id_to_p_products.rb diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 893a83c..43bab07 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 2588ad3..5e2992c 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -10,7 +10,6 @@ class PProductRef < ApplicationRecord has_many :p_product_ref_price_histories belongs_to :p_product_color - belongs_to :sorecop_cat has_many :p_articles has_many :p_article_serial_nums, through: :p_articles @@ -46,7 +45,7 @@ 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}, + :deee => {:name => "DEEE", :as => :currency}, :sorecop => {:name => "Sorecop", :as => :currency}, :sorecop_comment => {:name => "Commentaire Sorecop"}, :actions => {:name => "Actions", :reorder => false} @@ -156,27 +155,27 @@ class PProductRef < ApplicationRecord end def ca_sorecop - if ct_sorecop - return ct_sorecop - end - if self.sorecop_cat - if self.cc_sorecop - return self.cc_sorecop - else - if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).empty? - "Pas de stockage" - else - find_sorecop_tax - end - end + 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 - "Pas de catégorie Sorecop" + find_sorecop_tax end end def find_sorecop_tax - storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value.to_f - tax = self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first + 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 @@ -185,10 +184,13 @@ class PProductRef < ApplicationRecord 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 index a0af0d4..ebb0575 100644 --- a/app/models/sorecop_cat.rb +++ b/app/models/sorecop_cat.rb @@ -1,5 +1,5 @@ class SorecopCat < ApplicationRecord - has_many :p_product_refs + has_many :p_products has_many :sorecop_taxes, dependent: :destroy acts_as_sorting :fields => { diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index 7ce89d3..89561b6 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -23,8 +23,6 @@ %td =form.input :ean %tr - %td - =form.input :sorecop_cat_id, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true %td =form.input :ct_sorecop, :label => "Sorecop personalisée :" %td 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/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb b/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb deleted file mode 100644 index b4d65a9..0000000 --- a/db/migrate/20210923170130_add_sorecop_cat_id_to_p_product_refs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddSorecopCatIdToPProductRefs < ActiveRecord::Migration[6.0] - def change - add_column :p_product_refs, :sorecop_cat_id, :integer - 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/schema.rb b/db/schema.rb index 5e36bad..0c04f68 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_23_170130) do +ActiveRecord::Schema.define(version: 2021_09_24_145644) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1801,7 +1801,6 @@ ActiveRecord::Schema.define(version: 2021_09_23_170130) do t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" - t.integer "sorecop_cat_id" end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| @@ -1891,6 +1890,7 @@ ActiveRecord::Schema.define(version: 2021_09_23_170130) 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 From 4ad0ac7db520f5d6fd0be8be56e202184a0cd55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 17:52:23 +0200 Subject: [PATCH 17/91] remove qi_cache --- app/models/p_product_ref.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 5e2992c..9141d45 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -88,11 +88,11 @@ class PProductRef < ApplicationRecord self.p_product.p_product_cat_id end - QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name) + # QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name) - 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] From d43fd65822b2ce86271d8b0b7d45bbf5fa140f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 17:52:37 +0200 Subject: [PATCH 18/91] rename ac_ column --- .../20210924153716_rename_ca_to_ac_for_product_refs.rb | 6 ++++++ db/schema.rb | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20210924153716_rename_ca_to_ac_for_product_refs.rb 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 0c04f68..016eb45 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_24_145644) do +ActiveRecord::Schema.define(version: 2021_09_24_153716) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1793,10 +1793,10 @@ ActiveRecord::Schema.define(version: 2021_09_24_145644) 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" From 0199f0e520d555aa5aaa7a8d808f00e04c63caa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 24 Sep 2021 18:55:00 +0200 Subject: [PATCH 19/91] WIP doesn't work.... --- app/controllers/admin/buy_lists_controller.rb | 13 ++++++------- app/views/admin/buy_lists/index.html.haml | 11 +++++++---- .../admin/buy_lists/{index.js.erb => update.js.erb} | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) rename app/views/admin/buy_lists/{index.js.erb => update.js.erb} (82%) diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index 0fb842d..277832a 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -149,12 +149,13 @@ class Admin::BuyListsController < ApplicationController @p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer = @p_customer_sheet.p_customer - - if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) + @price_line_id = params[:price_line_id] + + if @p_customer_sheet.update(state: params[:state]) - @p_customer_sheets = PCustomerSheet.order(:id).all - - redirect_to admin_p_customer_sheet_path(@p_customer_sheet) + @p_customer_sheets = PCustomerSheet.where(:state => ["AV BPA", "PAS BPA", "BPA"]) + return @p_customer_sheet + # redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else render action: "edit" @@ -235,6 +236,4 @@ class Admin::BuyListsController < ApplicationController end - - end diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 8999cff..36b8236 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -236,7 +236,8 @@ %td -@p_customer_sheet = price_line.price_line_block.price_lineable - -if true + -form = false + -if form %form =semantic_form_for [:admin, @p_customer_sheet], remote: true, authenticity_token: true do |f| =f.inputs class: "form-inline d-flex flex-nowrap" do @@ -247,10 +248,12 @@ -if false =f.actions class: "btn btn-primary ml-1" do =f.action :submit, label: "#{ic(:check).html_safe}" - -if false - =form_with url: update_state_admin_p_customer_sheet_path(@p_customer_sheet), method: :get do |f| + -if !form + %form + =form_with url: admin_buy_list_path(@p_customer_sheet), method: :patch, remote: true, authenticity_token: true, id: "p_customer_sheet_state_#{@p_customer_sheet.id}" do |f| + =hidden_field_tag :price_line_id, price_line.id =f.select :state, ["AV BPA", "PAS BPA","BPA", "Traitée"] - =f.submit + =f.submit for: "p_customer_sheet_state_#{@p_customer_sheet.id}" =#state_helper price_line.price_line_block.price_lineable.state %td diff --git a/app/views/admin/buy_lists/index.js.erb b/app/views/admin/buy_lists/update.js.erb similarity index 82% rename from app/views/admin/buy_lists/index.js.erb rename to app/views/admin/buy_lists/update.js.erb index 9eef406..85ca3d0 100644 --- a/app/views/admin/buy_lists/index.js.erb +++ b/app/views/admin/buy_lists/update.js.erb @@ -1,2 +1,2 @@ -console.log('coucou') +console.log('coucou'); $('#price_line_row_<%= @price_line_id %>').replaceWith("<%= escape_javascript(render(@p_customer_sheet))%>"); From 48898840d3796df76c918ff1723a9cf8521bc64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 11:20:37 +0200 Subject: [PATCH 20/91] set breadcrump helper --- app/controllers/application_controller.rb | 11 +++++++ app/helpers/breadcrumb_helper.rb | 35 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 app/helpers/breadcrumb_helper.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce02913..76cf36c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -49,6 +49,7 @@ class ApplicationController < ActionController::Base end end + set_breadcrumb end @@ -539,5 +540,15 @@ class ApplicationController < ActionController::Base @dropdown_title = "Parametrage" end + def set_breadcrumb + @result = {} + if @qi_menu_active.present? + current_menu = @qi_menus[@qi_menu_active] + current_controller = controller_name.to_sym + @result[:first] = {name: current_menu[:name], link: current_menu[:link]} + @result[:second] = current_menu[:elements][current_controller] + @title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s + end + end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb new file mode 100644 index 0000000..84b4c0b --- /dev/null +++ b/app/helpers/breadcrumb_helper.rb @@ -0,0 +1,35 @@ +module BreadcrumbHelper + def breadcrumb(*custom_last_item) + if custom_last_item.present? + first_title_length = @result[:first][:name].to_s.length + 1 + @title.slice!(0, first_title_length) + @title << "/" + custom_last_item[0] + end + if @result.present? + capture_haml do + haml_tag :h1 do + haml_concat(link_to @result[:first][:name], @result[:first][:link]) + haml_tag :span do + haml_concat(link_to @result[:second][:name], @result[:second][:link]) + if custom_last_item.present? + haml_tag :span do + haml_concat(custom_last_item[0]) + end + end + end + end + end + else + capture_haml do + haml_tag :h1 do + haml_concat "Erreur dans le BreadcrumbHelper" + end + end + end + end + + def breadcrumb_title + @result[:first][:name] + "/" + result[:second][:name] + end + +end From 5d1d1ee1631d2712c57a4fc70beb178a4508251f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 16:56:10 +0200 Subject: [PATCH 21/91] refacto breadcrump --- app/controllers/application_controller.rb | 6 ++- app/helpers/breadcrumb_helper.rb | 50 ++++++++++----------- app/views/admin/p_customers/index.html.haml | 3 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 76cf36c..517c5a8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -545,9 +545,13 @@ class ApplicationController < ActionController::Base if @qi_menu_active.present? current_menu = @qi_menus[@qi_menu_active] current_controller = controller_name.to_sym + @action = action_name.to_sym + @result[:first] = {name: current_menu[:name], link: current_menu[:link]} @result[:second] = current_menu[:elements][current_controller] - @title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s + if @result[:first][:name] == @result[:second][:name] + @result[:second] = nil + end end end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 84b4c0b..84bac8c 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -1,35 +1,31 @@ module BreadcrumbHelper - def breadcrumb(*custom_last_item) - if custom_last_item.present? - first_title_length = @result[:first][:name].to_s.length + 1 - @title.slice!(0, first_title_length) - @title << "/" + custom_last_item[0] - end - if @result.present? - capture_haml do - haml_tag :h1 do - haml_concat(link_to @result[:first][:name], @result[:first][:link]) - haml_tag :span do - haml_concat(link_to @result[:second][:name], @result[:second][:link]) - if custom_last_item.present? - haml_tag :span do - haml_concat(custom_last_item[0]) - end + def breadcrumb(options = {}) + options = {action: @action}.merge options + + capture_haml do + haml_tag :h1 do + unless @result.present? + haml_concat "Erreur dans le BreadcrumbHelper" + else + if options[:custom_last_item].present? + haml_concat(link_to @result[:first][:name], @result[:first][:link]) + haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present? + case options[:action] + when :new + haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")} + when :edit + haml_tag(:span) {haml_concat('Modification')} + when :index + haml_tag(:span) {haml_concat('Liste')} end + + haml_tag(:span) {haml_concat(options[:custom_last_item])} + else + @result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name]) + haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present? end end end - else - capture_haml do - haml_tag :h1 do - haml_concat "Erreur dans le BreadcrumbHelper" - end - end end end - - def breadcrumb_title - @result[:first][:name] + "/" + result[:second][:name] - end - end diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index c7ddc07..8c34c18 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -9,7 +9,8 @@ =link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path %h1 - Clients + =breadcrumb + =hello From 57c3da9789a56e0b81b481f548610d47532e47c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 16:56:42 +0200 Subject: [PATCH 22/91] wip p_ ustomer breadcrumb --- app/views/admin/p_customer_cats/index.html.haml | 7 ++----- app/views/admin/p_customers/edit.html.haml | 1 + app/views/admin/p_customers/index.html.haml | 6 ++---- app/views/admin/p_customers/new.html.haml | 7 +------ app/views/admin/p_customers/show.html.haml | 13 +++---------- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/app/views/admin/p_customer_cats/index.html.haml b/app/views/admin/p_customer_cats/index.html.haml index a447feb..ae53751 100644 --- a/app/views/admin/p_customer_cats/index.html.haml +++ b/app/views/admin/p_customer_cats/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to 'Ajouter une catégorie', new_admin_p_customer_cat_path(), :class => "btn btn-primary", :remote => true - %h1 - Produits - %span - Catégories + =breadcrumb .qi_row @@ -18,4 +15,4 @@ %tbody#p_customer_cats_rows =render @p_customer_cats - \ No newline at end of file + diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 4f29362..0981487 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,4 +1,5 @@ .qi_header + =breadcrumb("Modifier un client") %h1 Ventes %span diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index 8c34c18..6d34ced 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -7,11 +7,9 @@ -else .right =link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path + =breadcrumb - %h1 - =breadcrumb - =hello - + diff --git a/app/views/admin/p_customers/new.html.haml b/app/views/admin/p_customers/new.html.haml index a3ca07d..99210cb 100644 --- a/app/views/admin/p_customers/new.html.haml +++ b/app/views/admin/p_customers/new.html.haml @@ -1,10 +1,5 @@ .qi_header - %h1 - Ventes - %span - =link_to "Clients", admin_p_customers_path - %span - Créer un nouveau client + =breadcrumb = render 'form' diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index deab7df..6eedb53 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,15 +3,8 @@ = link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false - - %h1 - Clients - %span - Détail d'un client - %span - =link_to [:admin, @p_customer] do - =@p_customer.code - =@p_customer.show_name + =breadcrumb("Détail client / #{@p_customer.code} - #{@p_customer.show_name}") + @@ -294,4 +287,4 @@ - \ No newline at end of file + From af1de12b1eeeefcc87c4b678946003b66d82bbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 19:09:05 +0200 Subject: [PATCH 23/91] Upgrade breadcrumb --- app/controllers/application_controller.rb | 10 +++- app/helpers/breadcrumb_helper.rb | 69 ++++++++++++++++++----- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 517c5a8..c7db3bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -548,10 +548,16 @@ class ApplicationController < ActionController::Base @action = action_name.to_sym @result[:first] = {name: current_menu[:name], link: current_menu[:link]} - @result[:second] = current_menu[:elements][current_controller] - if @result[:first][:name] == @result[:second][:name] + if current_menu[:elements][current_controller] + @result[:second] = current_menu[:elements][current_controller] + else @result[:second] = nil end + if @result[:second] + if @result[:first][:name] == @result[:second][:name] + @result[:second] = nil + end + end end end end diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 84bac8c..2cce85a 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -1,29 +1,72 @@ +# DOC : +# ajouter =breadcrumb dans une vue +# pour personaliser le breadcrumb, il y a plusieurs options : +# passer un ou plusieurs parametre piur overrider l'existant par défaut +# :first_title premier element du breadcrumb +# :first_link premier path du breadcrumb +# +# :second_title second element du breadcrumb +# :second_link second path du breadcrumb +# +# :last_element le tout dernier element du breadcrumb +# +# :record est le nom du record pour un show ou un edit par exemple :record => @p_product.name +# +# :default_crud booléen qui active/neutralise la création du titre "Détail de .." ou "Modification .." + + module BreadcrumbHelper - def breadcrumb(options = {}) - options = {action: @action}.merge options + def breadcrumb(opts = {}) + default_opts = { + action: @action, + first_title: @result[:first][:name], + first_link: @result[:first][:link], + default_crud: true + } + + if @result[:second] + default_opts[:second_title] = @result[:second][:name] + default_opts[:second_link] = @result[:second][:link] + end + + options = default_opts.merge opts + capture_haml do haml_tag :h1 do unless @result.present? haml_concat "Erreur dans le BreadcrumbHelper" else - if options[:custom_last_item].present? - haml_concat(link_to @result[:first][:name], @result[:first][:link]) - haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present? + if options[:record].present? || options[:last_element].present? + haml_concat(link_to options[:first_title], options[:first_link]) + if options[:second_title].present? && options[:second_link].present? + haml_tag(:span) { haml_concat(link_to options[:second_title], options[:second_title]) } + elsif options[:second_title].present? + haml_tag(:span) {haml_concat( options[:second_title])} + end + else + if options[:second_title].present? + haml_concat(link_to options[:first_title], options[:first_link]) + haml_tag(:span) { haml_concat( options[:second_title]) } + else + haml_concat( options[:first_title]) + end + end + if options[:default_crud] case options[:action] when :new - haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")} + haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")} when :edit - haml_tag(:span) {haml_concat('Modification')} + haml_tag(:span) {haml_concat("Modification #{options[:record]}")} when :index - haml_tag(:span) {haml_concat('Liste')} + haml_tag(:span) {haml_concat("Liste")} + when :show + options[:record].present? ? haml_tag(:span) {haml_concat("Détail de #{options[:record]}")} : haml_tag(:span) {haml_concat("Détail")} + else + haml_tag(:span) {haml_concat(options[:record])} if options[:record].present? end - - haml_tag(:span) {haml_concat(options[:custom_last_item])} - else - @result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name]) - haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present? end + haml_tag(:span) { haml_concat( options[:last_element]) } if options[:last_element].present? end end end From 48e81e45249713d81558dac5e4c5782d74305dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 27 Sep 2021 19:14:39 +0200 Subject: [PATCH 24/91] WIP deploy breadcrumb on views --- app/views/admin/p_customers/edit.html.haml | 8 +------- app/views/admin/p_customers/show.html.haml | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 0981487..22d6097 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,11 +1,5 @@ .qi_header - =breadcrumb("Modifier un client") - %h1 - Ventes - %span - =link_to "Clients", admin_p_customers_path - %span - Modifier un client + =breadcrumb(record: @p_customer.name) = render 'form' diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index 6eedb53..6a5e837 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,8 +3,7 @@ = link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false - =breadcrumb("Détail client / #{@p_customer.code} - #{@p_customer.show_name}") - + =breadcrumb(record: "#{@p_customer.code} - #{@p_customer.show_name}") From f1ed7e4ff5d6849897238d326e6aa1f8f1d9dd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 11:22:49 +0200 Subject: [PATCH 25/91] add sub_sub_menu to breadcrumb --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c7db3bf..3a67bd5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -546,10 +546,11 @@ class ApplicationController < ActionController::Base current_menu = @qi_menus[@qi_menu_active] current_controller = controller_name.to_sym @action = action_name.to_sym - @result[:first] = {name: current_menu[:name], link: current_menu[:link]} if current_menu[:elements][current_controller] @result[:second] = current_menu[:elements][current_controller] + elsif current_menu[:elements][:p_preferences_products_menu] && current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller] + @result[:second] = current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller] else @result[:second] = nil end From 973182221e611e85ef6ae500cdc480a377245e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 11:23:02 +0200 Subject: [PATCH 26/91] bugfix breadcrumn --- app/helpers/breadcrumb_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 2cce85a..2e2800d 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -40,7 +40,7 @@ module BreadcrumbHelper if options[:record].present? || options[:last_element].present? haml_concat(link_to options[:first_title], options[:first_link]) if options[:second_title].present? && options[:second_link].present? - haml_tag(:span) { haml_concat(link_to options[:second_title], options[:second_title]) } + haml_tag(:span) { haml_concat(link_to options[:second_title], options[:second_link]) } elsif options[:second_title].present? haml_tag(:span) {haml_concat( options[:second_title])} end @@ -57,11 +57,11 @@ module BreadcrumbHelper when :new haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")} when :edit - haml_tag(:span) {haml_concat("Modification #{options[:record]}")} + options[:record].present? ? haml_tag(:span) {haml_concat("Modification de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Modification")} when :index haml_tag(:span) {haml_concat("Liste")} when :show - options[:record].present? ? haml_tag(:span) {haml_concat("Détail de #{options[:record]}")} : haml_tag(:span) {haml_concat("Détail")} + options[:record].present? ? haml_tag(:span) {haml_concat("Détail de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Détail")} else haml_tag(:span) {haml_concat(options[:record])} if options[:record].present? end From 4d3ccfd221fefced0843ce0afad5c13fc4198789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 12:29:38 +0200 Subject: [PATCH 27/91] add breadcrumb to views --- app/views/admin/buy_lists/index.html.haml | 4 +- app/views/admin/line_stocks/index.html.haml | 3 +- .../p_article_serial_nums/index.html.haml | 3 +- .../admin/p_articles/_p_article.html.haml | 2 +- app/views/admin/p_articles/index.html.haml | 3 +- .../admin/p_compta_exports/index.html.haml | 7 +- .../admin/p_customer_sheets/edit.html.haml | 7 +- .../admin/p_customer_sheets/index.html.haml | 5 +- .../admin/p_customer_sheets/show.html.haml | 9 +- app/views/admin/p_customers/edit.html.haml | 2 +- app/views/admin/p_customers/index.html.haml | 5 +- app/views/admin/p_customers/show.html.haml | 2 +- .../admin/p_fournisseurs/index.html.haml | 7 +- .../admin/p_payment_types/index.html.haml | 7 +- app/views/admin/p_payments/index.html.haml | 7 +- .../admin/p_product_cats/index.html.haml | 7 +- .../admin/p_product_colors/index.html.haml | 3 +- .../admin/p_product_powers/index.html.haml | 3 +- .../admin/p_product_ref_specs/index.html.haml | 3 +- .../admin/p_product_refs/index.html.haml | 7 +- app/views/admin/p_product_refs/show.html.haml | 130 +++++++++--------- .../admin/p_product_zones/index.html.haml | 3 +- app/views/admin/p_products/edit.html.haml | 8 +- app/views/admin/p_products/index.html.haml | 5 +- app/views/admin/p_products/new.html.haml | 8 +- .../admin/p_serial_num_types/index.html.haml | 3 +- app/views/admin/p_spec_types/index.html.haml | 3 +- app/views/admin/p_spec_values/index.html.haml | 3 +- .../analyse_reponses.html.haml | 8 +- .../admin/price_documents/edit.html.haml | 11 +- .../admin/price_documents/index.html.haml | 19 +-- .../admin/price_documents/show.html.haml | 10 +- app/views/admin/s_brands/index.html.haml | 7 +- .../admin/stock_movements/index.html.haml | 2 +- .../admin/stock_movements/show.html.haml | 7 +- 35 files changed, 114 insertions(+), 209 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index de9fbbb..b5b831a 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -2,9 +2,7 @@ .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" - - %h1 - Tableaux de bord achats + = breadcrumb .qi_search_row diff --git a/app/views/admin/line_stocks/index.html.haml b/app/views/admin/line_stocks/index.html.haml index 0658b45..7360c8e 100644 --- a/app/views/admin/line_stocks/index.html.haml +++ b/app/views/admin/line_stocks/index.html.haml @@ -4,8 +4,7 @@ = link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true = link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true - %h1 - Mouvements de stocks + = breadcrumb diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml index 0c3ea96..e5f732a 100644 --- a/app/views/admin/p_article_serial_nums/index.html.haml +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PArticleSerialNum.human rescue "" + =breadcrumb diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 32497fc..c713ea0 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -33,7 +33,7 @@ %td.actions = link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:pencil), edit_admin_p_article_path(p_article), :remote => true - = link_to i(:eye), admin_p_article_path(p_article), :remote => true + =# link_to i(:eye), admin_p_article_path(p_article), :remote => true diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 0064c5c..cfe9452 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PArticle.human rescue "" + =breadcrumb diff --git a/app/views/admin/p_compta_exports/index.html.haml b/app/views/admin/p_compta_exports/index.html.haml index 381dcf9..0371115 100644 --- a/app/views/admin/p_compta_exports/index.html.haml +++ b/app/views/admin/p_compta_exports/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to 'Ajouter un export', new_admin_p_compta_export_path(), :class => "btn btn-primary", :remote => true - %h1 - Stats - %span - Exports comptable + = breadcrumb @@ -30,4 +27,4 @@ %tbody#p_compta_exports_rows =render @p_compta_exports - \ No newline at end of file + diff --git a/app/views/admin/p_customer_sheets/edit.html.haml b/app/views/admin/p_customer_sheets/edit.html.haml index 604e1fa..0f8df99 100644 --- a/app/views/admin/p_customer_sheets/edit.html.haml +++ b/app/views/admin/p_customer_sheets/edit.html.haml @@ -1,10 +1,5 @@ .qi_header - %h1 - Ventes - %span - =link_to "Demandes de commande", admin_p_customer_sheets_path() - %span - Modifier une demande + = breadcrumb diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index f61d281..b0db10f 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -1,10 +1,7 @@ .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" - %h1 - Ventes - %span - Demandes de commande + = breadcrumb .qi_search_row diff --git a/app/views/admin/p_customer_sheets/show.html.haml b/app/views/admin/p_customer_sheets/show.html.haml index 57031b4..1b37292 100644 --- a/app/views/admin/p_customer_sheets/show.html.haml +++ b/app/views/admin/p_customer_sheets/show.html.haml @@ -12,12 +12,7 @@ = link_to i(:pencil), edit_admin_p_customer_sheet_path(@p_customer_sheet), :remote => false - %h1 - Ventes - %span - =link_to "Demande de commandes",admin_p_customer_sheets_path - %span - ="#{@p_customer_sheet.com_counter}" + = breadcrumb .qi_row @@ -114,4 +109,4 @@ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents} - \ No newline at end of file + diff --git a/app/views/admin/p_customers/edit.html.haml b/app/views/admin/p_customers/edit.html.haml index 22d6097..d2c283d 100644 --- a/app/views/admin/p_customers/edit.html.haml +++ b/app/views/admin/p_customers/edit.html.haml @@ -1,5 +1,5 @@ .qi_header - =breadcrumb(record: @p_customer.name) + =breadcrumb record: @p_customer.name = render 'form' diff --git a/app/views/admin/p_customers/index.html.haml b/app/views/admin/p_customers/index.html.haml index 6d34ced..ea441a2 100644 --- a/app/views/admin/p_customers/index.html.haml +++ b/app/views/admin/p_customers/index.html.haml @@ -4,10 +4,11 @@ -if current_admin.has_permission?("customers-c") .right= link_to ic(:plus)+' Ajouter un client', new_admin_p_customer_path(), :class => "btn btn-primary btn-ap-add", :remote => false + =breadcrumb -else .right - =link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path - =breadcrumb + =link_to "< Retour aux commandes", admin_p_customer_sheets_path + =breadcrumb first_title: "Commandes" , first_link: admin_p_customer_sheets_path ,second_title: "Demande de commande", last_element: 'Selectioner un client', default_crud: false diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index 6a5e837..ea0dbf2 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -3,7 +3,7 @@ = link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false - =breadcrumb(record: "#{@p_customer.code} - #{@p_customer.show_name}") + =breadcrumb record: @p_customer.name diff --git a/app/views/admin/p_fournisseurs/index.html.haml b/app/views/admin/p_fournisseurs/index.html.haml index f77d543..ef18615 100644 --- a/app/views/admin/p_fournisseurs/index.html.haml +++ b/app/views/admin/p_fournisseurs/index.html.haml @@ -2,10 +2,7 @@ .right = link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true - %h1 - Achats - %span - Fournisseurs + =breadcrumb .qi_row @@ -28,4 +25,4 @@ %tbody#p_fournisseurs_rows =render @p_fournisseurs - \ No newline at end of file + diff --git a/app/views/admin/p_payment_types/index.html.haml b/app/views/admin/p_payment_types/index.html.haml index 08213cf..f9e4779 100644 --- a/app/views/admin/p_payment_types/index.html.haml +++ b/app/views/admin/p_payment_types/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to 'Ajouter un type de paiement', new_admin_p_payment_type_path(), :class => "btn btn-primary", :remote => true - %h1 - Paiements - %span - Types de paiement + = breadcrumb .qi_row @@ -19,4 +16,4 @@ %tbody#p_payment_types_rows =render @p_payment_types - \ No newline at end of file + diff --git a/app/views/admin/p_payments/index.html.haml b/app/views/admin/p_payments/index.html.haml index 9d5500c..f586b10 100644 --- a/app/views/admin/p_payments/index.html.haml +++ b/app/views/admin/p_payments/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter un paiement', new_admin_p_payment_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - Paiements - %span - Liste des paiements + = breadcrumb .qi_search_row =form_tag "", :method => "get", :onsubmit => "" do @@ -117,4 +114,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/p_product_cats/index.html.haml b/app/views/admin/p_product_cats/index.html.haml index 4df21f9..3ab0b4e 100644 --- a/app/views/admin/p_product_cats/index.html.haml +++ b/app/views/admin/p_product_cats/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to 'Ajouter une catégorie', new_admin_p_product_cat_path(), :class => "btn btn-primary", :remote => true - %h1 - Achats - %span - Catégories produit + =breadcrumb .qi_row @@ -21,4 +18,4 @@ %tbody#p_product_cats_rows =render @p_product_cats - \ No newline at end of file + diff --git a/app/views/admin/p_product_colors/index.html.haml b/app/views/admin/p_product_colors/index.html.haml index 4da1f8e..68a3daa 100644 --- a/app/views/admin/p_product_colors/index.html.haml +++ b/app/views/admin/p_product_colors/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_color_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PProductColor.human + =breadcrumb diff --git a/app/views/admin/p_product_powers/index.html.haml b/app/views/admin/p_product_powers/index.html.haml index 5a129d6..14211e1 100644 --- a/app/views/admin/p_product_powers/index.html.haml +++ b/app/views/admin/p_product_powers/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_power_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PProductPower.human rescue "" + = breadcrumb diff --git a/app/views/admin/p_product_ref_specs/index.html.haml b/app/views/admin/p_product_ref_specs/index.html.haml index f486839..043b6c0 100644 --- a/app/views/admin/p_product_ref_specs/index.html.haml +++ b/app/views/admin/p_product_ref_specs/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PProductRefSpec.human rescue "" + = breadcrumb diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 3a3aeaf..df20346 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -1,10 +1,7 @@ -if !@manager .qi_header .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false - %h1 - Achats - %span - Références + =breadcrumb @@ -57,4 +54,4 @@ :coffeescript $(".qi_search_row form").on "submit", -> - $("#p_product_refs_index_wrapper").html('recherche en cours ...') \ No newline at end of file + $("#p_product_refs_index_wrapper").html('recherche en cours ...') diff --git a/app/views/admin/p_product_refs/show.html.haml b/app/views/admin/p_product_refs/show.html.haml index 309a88d..800f758 100644 --- a/app/views/admin/p_product_refs/show.html.haml +++ b/app/views/admin/p_product_refs/show.html.haml @@ -1,15 +1,7 @@ .qi_header .right = link_to i(:pencil), edit_admin_p_product_path(@p_product_ref.p_product), :remote => false if @p_product_ref.p_product - %h1 - Références produits - %span - Détail d'une référence - - %span - =@p_product_ref.p_product.name - ="-" - =@p_product_ref.ct_sub_name + =breadcrumb record: @p_product_ref.p_product.name + " - " + @p_product_ref.ct_sub_name .qi_row @@ -20,9 +12,10 @@ %td Produit %td=@p_product_ref.p_product.name #link_to @p_product_ref.p_product.name, [:admin, @p_product_ref.p_product] - %tr - %td Actif ? - %td=@p_product_ref.enabled ? "Oui" : "Non" + -if false + %tr + %td Actif ? + %td=@p_product_ref.enabled ? "Oui" : "Non" %tr @@ -45,30 +38,31 @@ %td Unité de vente (archive) : %td= @p_product_ref.uv - %tr - %td Conditionnement de référence : - %td - -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning - = @p_product_ref.p_product.p_product_conditioning.name + -if false + %tr + %td Conditionnement de référence : + %td + -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning + = @p_product_ref.p_product.p_product_conditioning.name + + %tr + %td Conditionnement : + %td + -if @p_product_ref.p_product_conditioning + = @p_product_ref.p_product_conditioning.name - %tr - %td Conditionnement : - %td - -if @p_product_ref.p_product_conditioning - = @p_product_ref.p_product_conditioning.name + %tr + %td Quantité par rapport au conditionnement de référence : + %td + = @p_product_ref.conditioning_ref_qte - %tr - %td Quantité par rapport au conditionnement de référence : - %td - = @p_product_ref.conditioning_ref_qte - - %tr - %td Prix de vente à l'unité de référence - %td - =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? - ="/" - = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning + %tr + %td Prix de vente à l'unité de référence + %td + =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? + ="/" + = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning -if @p_product_ref @@ -132,41 +126,41 @@ sortis .clear +-if false + .qi_row + .qi_pannel + %h3 Historique des prix d'achat -.qi_row - .qi_pannel - %h3 Historique des prix d'achat - - %table.table.table-striped.table-hover.table-bordered - %tr - %th - Date - %th Fournisseur - %th Document - %th Total - %th Qté - %th P.U. - - -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| - + %table.table.table-striped.table-hover.table-bordered %tr - %td - =l price_line.price_line_block.price_lineable.date, :format => :date + %th + Date + %th Fournisseur + %th Document + %th Total + %th Qté + %th P.U. + + -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| + + %tr + %td + =l price_line.price_line_block.price_lineable.date, :format => :date + + %td + =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur + + %td + =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] + + %td + =number_to_currency price_line.tot_amount_ht + + + %td + =price_line.qte + + %td + =number_to_currency price_line.price_u_ht - %td - =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur - - %td - =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] - - %td - =number_to_currency price_line.tot_amount_ht - - - %td - =price_line.qte - - %td - =number_to_currency price_line.price_u_ht - - \ No newline at end of file + diff --git a/app/views/admin/p_product_zones/index.html.haml b/app/views/admin/p_product_zones/index.html.haml index cf5e70a..8651c8d 100644 --- a/app/views/admin/p_product_zones/index.html.haml +++ b/app/views/admin/p_product_zones/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_zone_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PProductZone.human + = breadcrumb diff --git a/app/views/admin/p_products/edit.html.haml b/app/views/admin/p_products/edit.html.haml index e0d5b2b..a70a9dc 100644 --- a/app/views/admin/p_products/edit.html.haml +++ b/app/views/admin/p_products/edit.html.haml @@ -1,11 +1,5 @@ .qi_header - %h1 - Achats - %span - =link_to "Produits", admin_p_products_path() - - %span - Modifier un produit + =breadcrumb record: @p_product.code + ' - ' + @p_product.name = render 'form' diff --git a/app/views/admin/p_products/index.html.haml b/app/views/admin/p_products/index.html.haml index ec874e5..3ff55ee 100644 --- a/app/views/admin/p_products/index.html.haml +++ b/app/views/admin/p_products/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false - %h1 - Produits & Stocks - %span - Produits + =breadcrumb .qi_search_row diff --git a/app/views/admin/p_products/new.html.haml b/app/views/admin/p_products/new.html.haml index c9ff653..45f9916 100644 --- a/app/views/admin/p_products/new.html.haml +++ b/app/views/admin/p_products/new.html.haml @@ -1,11 +1,5 @@ .qi_header - %h1 - Achats - %span - =link_to "Produits", admin_p_products_path() - - %span - Ajouter un produit + =breadcrumb diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml index 80034b4..456211f 100644 --- a/app/views/admin/p_serial_num_types/index.html.haml +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PSerialNumType.human rescue "" + = breadcrumb diff --git a/app/views/admin/p_spec_types/index.html.haml b/app/views/admin/p_spec_types/index.html.haml index 46d02ec..fb1e681 100644 --- a/app/views/admin/p_spec_types/index.html.haml +++ b/app/views/admin/p_spec_types/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PSpecType.human rescue "" + = breadcrumb diff --git a/app/views/admin/p_spec_values/index.html.haml b/app/views/admin/p_spec_values/index.html.haml index 8f34bd1..d629379 100644 --- a/app/views/admin/p_spec_values/index.html.haml +++ b/app/views/admin/p_spec_values/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 - =PSpecValue.human rescue "" + = breadcrumb diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 8627aca..3766d31 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -1,11 +1,5 @@ .qi_header - %h1 - Achats - %span - Analyse des réponces à la demande de prix n° - = link_to @price_document.d_number, admin_price_document_path(@price_document) - \- - = @price_document.list_designaton + =breadcrumb second_title: "Demande de prix #{@price_document.d_number} - #{@price_document.list_designaton}", second_link: admin_price_document_path(@price_document) , last_element: "Analyse de des réponses" -unmatched_fournisseur = 0 =semantic_form_for [:admin, @price_document],url: analyse_reponses_save_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form| diff --git a/app/views/admin/price_documents/edit.html.haml b/app/views/admin/price_documents/edit.html.haml index f652735..2193d72 100644 --- a/app/views/admin/price_documents/edit.html.haml +++ b/app/views/admin/price_documents/edit.html.haml @@ -1,13 +1,6 @@ .qi_header - - %h1 - Documents comptables - %span - Modifier un document - %span - =@price_document.label - ="-" - =@price_document.d_number + =breadcrumb second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number + .qi_row=render :partial => "form" diff --git a/app/views/admin/price_documents/index.html.haml b/app/views/admin/price_documents/index.html.haml index 014b9eb..ca45910 100644 --- a/app/views/admin/price_documents/index.html.haml +++ b/app/views/admin/price_documents/index.html.haml @@ -1,21 +1,16 @@ .qi_header .right - -if false # params[:price_document_type_id].to_s == "5" - =link_to ic(:plus)+" Ajouter un avoir", new_admin_price_document_path, :class => "btn btn-primary bgbd-ventes" - -elsif params[:price_document_type_id].to_i == 6 + -if params[:price_document_type_id].to_i == 6 # Facture Achat = link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture d'achat"), :class => "btn btn-primary bgbd-documents", :remote => false - - -elsif params[:price_document_type_id].to_i == 7 + -elsif params[:price_document_type_id].to_i == 4 # Commande Achat = link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false - - - + -elsif params[:price_document_type_id].to_i == 7 -else =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes" - %h1 - Documents - %span - Liste + + -if params[:price_document_type_id] + =breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label + .qi_search_row diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 1f7bc6a..c474220 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -13,16 +13,8 @@ = link_to i(:download), print_admin_price_document_path(@price_document.token), :remote => false, :target => "_blank" if !PriceLineBlock::PURCHASE_BLOCKS.include?(@price_document.block_type) - %h1 - Documents + =breadcrumb second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number - %span - =@price_document.price_document_type.label - - %span - ="##{@price_document.id}" - %span - =@price_document.d_number .qi_row diff --git a/app/views/admin/s_brands/index.html.haml b/app/views/admin/s_brands/index.html.haml index 164cd26..d74bcd7 100644 --- a/app/views/admin/s_brands/index.html.haml +++ b/app/views/admin/s_brands/index.html.haml @@ -1,9 +1,6 @@ .qi_header .right= link_to 'Ajouter une marque', new_admin_s_brand_path(), :class => "btn btn-primary", :remote => true - %h1 - Marques - %span - Liste + =breadcrumb .qi_row @@ -18,4 +15,4 @@ %tbody#s_brands_rows =render @s_brands - \ No newline at end of file + diff --git a/app/views/admin/stock_movements/index.html.haml b/app/views/admin/stock_movements/index.html.haml index 3dec3e9..6d44fd9 100644 --- a/app/views/admin/stock_movements/index.html.haml +++ b/app/views/admin/stock_movements/index.html.haml @@ -3,7 +3,7 @@ = link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true = link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true - %h1 Mouvements de stock manuels + = breadcrumb diff --git a/app/views/admin/stock_movements/show.html.haml b/app/views/admin/stock_movements/show.html.haml index d8210be..0c8b675 100644 --- a/app/views/admin/stock_movements/show.html.haml +++ b/app/views/admin/stock_movements/show.html.haml @@ -1,9 +1,6 @@ .qi_header - %h1 - Mouvements de stock manuels - %span - Détail du mouvement - ="##{@stock_movement.id}" + = breadcrumb record: "mouvement ##{@stock_movement.id}" + From 05c832eb5291abcb6203512ca22c9efc21c0cc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 12:29:55 +0200 Subject: [PATCH 28/91] bugfix p_product_refs --- app/models/p_product_ref.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 9a7fccf..8e08f51 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -10,6 +10,8 @@ class PProductRef < ApplicationRecord belongs_to :p_product_color + has_many :line_stocks + has_many :p_articles has_many :p_article_serial_nums, through: :p_articles accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true From 5b71fff2d6e92f1c51986fdbec8141b062197089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 14:29:38 +0200 Subject: [PATCH 29/91] install pg_search --- Gemfile | 1 + Gemfile.lock | 4 + ...210928122901_create_pg_search_documents.rb | 17 + db/schema.rb | 3460 +++++++++-------- 4 files changed, 1758 insertions(+), 1724 deletions(-) create mode 100644 db/migrate/20210928122901_create_pg_search_documents.rb diff --git a/Gemfile b/Gemfile index 00ea1f3..92d980f 100644 --- a/Gemfile +++ b/Gemfile @@ -98,6 +98,7 @@ gem "country_select" gem 'haml-rails' gem 'rails_autolink' +gem 'pg_search' group :development do gem "capistrano", "~> 3.10", require: false diff --git a/Gemfile.lock b/Gemfile.lock index cb4387b..207dffb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -230,6 +230,9 @@ GEM nokogiri (1.10.10) mini_portile2 (~> 2.4.0) pg (1.2.3) + pg_search (2.3.5) + activerecord (>= 5.2) + activesupport (>= 5.2) posix-spawn (0.3.13) postgresql (1.0.0) pg @@ -388,6 +391,7 @@ DEPENDENCIES mimemagic (= 0.3.10) mysql2 nokogiri + pg_search posix-spawn postgresql puma (~> 3.11) diff --git a/db/migrate/20210928122901_create_pg_search_documents.rb b/db/migrate/20210928122901_create_pg_search_documents.rb new file mode 100644 index 0000000..a234851 --- /dev/null +++ b/db/migrate/20210928122901_create_pg_search_documents.rb @@ -0,0 +1,17 @@ +class CreatePgSearchDocuments < ActiveRecord::Migration[6.0] + def up + say_with_time("Creating table for pg_search multisearch") do + create_table :pg_search_documents do |t| + t.text :content + t.belongs_to :searchable, polymorphic: true, index: true + t.timestamps null: false + end + end + end + + def down + say_with_time("Dropping table for pg_search multisearch") do + drop_table :pg_search_documents + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3107c6a..8412ef2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,252 +10,255 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_07_083709) do +ActiveRecord::Schema.define(version: 2021_09_28_122901) do - create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "accounting_zones", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.boolean "enabled", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "admin_admin_roles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "admin_admin_roles", force: :cascade do |t| t.bigint "admin_id" t.bigint "admin_role_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_admin_admin_roles_on_admin_id" - t.index ["admin_role_id"], name: "index_admin_admin_roles_on_admin_role_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_53785_index_admin_admin_roles_on_admin_id" + t.index ["admin_role_id"], name: "idx_53785_index_admin_admin_roles_on_admin_role_id" end - create_table "admin_permission_admin_roles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "admin_permission_admin_roles", force: :cascade do |t| t.bigint "admin_permission_id" t.bigint "admin_role_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_permission_id"], name: "index_admin_permission_admin_roles_on_admin_permission_id" - t.index ["admin_role_id"], name: "index_admin_permission_admin_roles_on_admin_role_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_permission_id"], name: "idx_53803_index_admin_permission_admin_roles_on_admin_permissio" + t.index ["admin_role_id"], name: "idx_53803_index_admin_permission_admin_roles_on_admin_role_id" end - create_table "admin_permissions", 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 - t.string "code" - t.string "slug" - t.integer "parent_id" - t.integer "position" + create_table "admin_permissions", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "code", limit: 255 + t.string "slug", limit: 255 + t.bigint "parent_id" + t.bigint "position" end - create_table "admin_preferences", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "admin_preferences", force: :cascade do |t| t.bigint "admin_id" - t.string "key" + t.string "key", limit: 255 t.text "value" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_admin_preferences_on_admin_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_53809_index_admin_preferences_on_admin_id" end - create_table "admin_roles", 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 + create_table "admin_roles", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "firstname" - t.string "avatar" - t.string "username", default: "" - t.string "email", default: "" - t.string "password_digest", default: "" - t.string "reset_password_token" + create_table "admins", force: :cascade do |t| + t.string "name", limit: 255 + t.string "firstname", limit: 255 + t.string "avatar", limit: 255 + t.string "username", limit: 255, default: "" + t.string "email", limit: 255, default: "" + t.string "password_digest", limit: 255, default: "" + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 + t.bigint "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "remember_token" - t.integer "p_commercial_id" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "remember_token", limit: 255 + t.bigint "p_commercial_id" t.boolean "super_admin", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "societe_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "societe_id" end - create_table "albums", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "albums", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "super_admin", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "block_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "style" - t.integer "nbr_columns" - t.integer "row1" - t.integer "row2" - t.integer "row3" - t.integer "row4" + create_table "block_contents", force: :cascade do |t| + t.bigint "style" + t.bigint "nbr_columns" + t.bigint "row1" + t.bigint "row2" + t.bigint "row3" + t.bigint "row4" t.bigint "image_file_id" - t.integer "margin_top" - t.integer "margin_bottom" - t.integer "margin_left" - t.integer "margin_right" - t.integer "padding_top" - t.integer "padding_bottom" - t.integer "padding_left" - t.integer "padding_right" + t.bigint "margin_top" + t.bigint "margin_bottom" + t.bigint "margin_left" + t.bigint "margin_right" + t.bigint "padding_top" + t.bigint "padding_bottom" + t.bigint "padding_left" + t.bigint "padding_right" t.boolean "parallax", default: false t.boolean "center", default: false - t.integer "center_width" - t.string "background_color" - t.string "gradient_start" - t.string "gradient_stop" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["image_file_id"], name: "index_block_contents_on_image_file_id" + t.bigint "center_width" + t.string "background_color", limit: 255 + t.string "gradient_start", limit: 255 + t.string "gradient_stop", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["image_file_id"], name: "idx_53852_index_block_contents_on_image_file_id" end - create_table "blocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "blocks", force: :cascade do |t| t.bigint "lang_site_id" - t.string "block_name" - t.string "blockable_type" + t.string "block_name", limit: 255 + t.string "blockable_type", limit: 255 t.bigint "blockable_id" t.text "content" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["blockable_id"], name: "index_blocks_on_blockable_id" - t.index ["lang_site_id"], name: "index_blocks_on_lang_site_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["blockable_id"], name: "idx_53841_index_blocks_on_blockable_id" + t.index ["lang_site_id"], name: "idx_53841_index_blocks_on_lang_site_id" end - create_table "break_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "break_contents", force: :cascade do |t| t.boolean "line", default: false - t.integer "height" - t.string "style" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "height" + t.string "style", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "categories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" + create_table "categories", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 t.boolean "enabled", default: false t.text "description" - t.integer "image_file_id" - t.integer "position" + t.bigint "image_file_id" + t.bigint "position" t.bigint "parent_id" - t.string "permalink" + t.string "permalink", limit: 255 t.boolean "front_page", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["parent_id"], name: "index_categories_on_parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "idx_53874_index_categories_on_parent_id" end - create_table "category_categoryables", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "category_categoryables", force: :cascade do |t| t.bigint "category_id" - t.string "categoryable_type" - t.integer "categoryable_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["category_id"], name: "index_category_categoryables_on_category_id" + t.string "categoryable_type", limit: 255 + t.bigint "categoryable_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["category_id"], name: "idx_53888_index_category_categoryables_on_category_id" end - create_table "category_langs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" + create_table "category_langs", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 t.text "description" - t.integer "image_file_id" + t.bigint "image_file_id" t.bigint "lang_site_id" t.bigint "category_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["category_id"], name: "index_category_langs_on_category_id" - t.index ["lang_site_id"], name: "index_category_langs_on_lang_site_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["category_id"], name: "idx_53895_index_category_langs_on_category_id" + t.index ["lang_site_id"], name: "idx_53895_index_category_langs_on_lang_site_id" end - create_table "cel_tables", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "position" - t.integer "style" + create_table "cel_tables", force: :cascade do |t| + t.bigint "position" + t.bigint "style" t.bigint "table_row_id" - t.integer "table_content_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["table_row_id"], name: "index_cel_tables_on_table_row_id" + t.bigint "table_content_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["table_row_id"], name: "idx_53906_index_cel_tables_on_table_row_id" end - create_table "comments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "pseudo", default: "" - t.string "email", default: "" - t.string "website", default: "" + create_table "comments", force: :cascade do |t| + t.string "pseudo", limit: 255, default: "" + t.string "email", limit: 255, default: "" + t.string "website", limit: 255, default: "" t.boolean "enabled", default: false t.text "comment" - t.string "commentable_type" + t.string "commentable_type", limit: 255 t.bigint "commentable_id" - t.integer "user_id" + t.bigint "user_id" t.bigint "parent_id" t.boolean "notified", default: false t.datetime "notified_at" t.bigint "lang_site_id", default: 1 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["commentable_id"], name: "index_comments_on_commentable_id" - t.index ["lang_site_id"], name: "index_comments_on_lang_site_id" - t.index ["parent_id"], name: "index_comments_on_parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["commentable_id"], name: "idx_53912_index_comments_on_commentable_id" + t.index ["lang_site_id"], name: "idx_53912_index_comments_on_lang_site_id" + t.index ["parent_id"], name: "idx_53912_index_comments_on_parent_id" end - create_table "contacts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "civilite" - t.string "firstname" - t.string "name" - t.string "address" - t.string "address2" - t.string "cp" - t.string "city" - t.string "country" - t.string "phone" - t.string "token" - t.string "email" - t.string "website" - t.integer "raison_id" + create_table "contacts", force: :cascade do |t| + t.string "civilite", limit: 255 + t.string "firstname", limit: 255 + t.string "name", limit: 255 + t.string "address", limit: 255 + t.string "address2", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "phone", limit: 255 + t.string "token", limit: 255 + t.string "email", limit: 255 + t.string "website", limit: 255 + t.bigint "raison_id" t.text "message" t.text "notes" - t.integer "survey_set_id" - t.string "raison_text" + t.bigint "survey_set_id" + t.string "raison_text", limit: 255 t.text "objet" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "data_file_categories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" - t.integer "parent_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "data_file_categories", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.bigint "parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "data_file_passwords", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "data_file_passwords", force: :cascade do |t| t.bigint "data_file_id" - t.string "token" + t.string "token", limit: 255 t.text "description" - t.integer "nbr_downloads" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["data_file_id"], name: "index_data_file_passwords_on_data_file_id" + t.bigint "nbr_downloads" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_file_id"], name: "idx_53980_index_data_file_passwords_on_data_file_id" end - create_table "data_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "file" - t.string "name" - t.string "slug" - t.string "token" - t.string "description" + create_table "data_files", force: :cascade do |t| + t.string "file", limit: 255 + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.string "token", limit: 255 + t.string "description", limit: 255 t.bigint "file_folder_id" - t.string "title" + t.string "title", limit: 255 t.text "long_desc" t.boolean "boutique", default: false t.bigint "data_file_category_id" @@ -265,317 +268,317 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.bigint "square_image_file_id" t.boolean "order_link", default: false t.boolean "download_link", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["data_file_category_id"], name: "index_data_files_on_data_file_category_id" - t.index ["file_folder_id"], name: "index_data_files_on_file_folder_id" - t.index ["image_file_id"], name: "index_data_files_on_image_file_id" - t.index ["square_image_file_id"], name: "index_data_files_on_square_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_file_category_id"], name: "idx_53950_index_data_files_on_data_file_category_id" + t.index ["file_folder_id"], name: "idx_53950_index_data_files_on_file_folder_id" + t.index ["image_file_id"], name: "idx_53950_index_data_files_on_image_file_id" + t.index ["square_image_file_id"], name: "idx_53950_index_data_files_on_square_image_file_id" end - create_table "download_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" - t.string "style" + create_table "download_contents", force: :cascade do |t| + t.string "title", limit: 255 + t.string "style", limit: 255 t.text "description" t.bigint "data_file_id" t.boolean "boutique", default: false t.boolean "show_yumpu", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["data_file_id"], name: "index_download_contents_on_data_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_file_id"], name: "idx_53990_index_download_contents_on_data_file_id" end - create_table "dynamic_contents", 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 + create_table "dynamic_contents", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "edit_watchers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "element_type" - t.integer "element_id" - t.string "key" + create_table "edit_watchers", force: :cascade do |t| + t.string "element_type", limit: 255 + t.bigint "element_id" + t.string "key", limit: 255 t.bigint "admin_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_edit_watchers_on_admin_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_54010_index_edit_watchers_on_admin_id" end - create_table "export_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "piece" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "export_hists", force: :cascade do |t| + t.string "piece", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "external_links", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" + create_table "external_links", force: :cascade do |t| + t.string "title", limit: 255 t.text "description" - t.string "url" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "url", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "file_folders", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "file_folders", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "super_admin", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "gallery_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "gallery_contents", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" - t.integer "style" - t.integer "nbr_img" + t.bigint "style" + t.bigint "nbr_img" t.boolean "with_legend", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "gallery_images", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" + create_table "gallery_images", force: :cascade do |t| + t.string "title", limit: 255 t.text "description" - t.string "tags" - t.integer "position" + t.string "tags", limit: 255 + t.bigint "position" t.bigint "image_file_id" t.bigint "gallery_content_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["gallery_content_id"], name: "index_gallery_images_on_gallery_content_id" - t.index ["image_file_id"], name: "index_gallery_images_on_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["gallery_content_id"], name: "idx_54058_index_gallery_images_on_gallery_content_id" + t.index ["image_file_id"], name: "idx_54058_index_gallery_images_on_image_file_id" end - create_table "hashtaggings", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "hashtaggings", force: :cascade do |t| t.bigint "hashtag_id" - t.string "hashtaggable_type" + t.string "hashtaggable_type", limit: 255 t.bigint "hashtaggable_id" - t.integer "lang_site_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["hashtag_id"], name: "index_hashtaggings_on_hashtag_id" - t.index ["hashtaggable_id"], name: "index_hashtaggings_on_hashtaggable_id" + t.bigint "lang_site_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["hashtag_id"], name: "idx_54069_index_hashtaggings_on_hashtag_id" + t.index ["hashtaggable_id"], name: "idx_54069_index_hashtaggings_on_hashtaggable_id" end - create_table "hashtags", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "hashtags", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "enabled", default: false - t.integer "lang_site_id" - t.string "slug" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "lang_site_id" + t.string "slug", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "html_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "html_contents", force: :cascade do |t| t.text "content" - t.string "style" - t.string "content_type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "style", limit: 255 + t.string "content_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "i_task_projects", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" + create_table "i_task_projects", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 t.bigint "admin_id" t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_i_task_projects_on_admin_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_54203_index_i_task_projects_on_admin_id" end - create_table "i_tasks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "i_tasks", force: :cascade do |t| t.bigint "i_task_project_id" - t.string "name" + t.string "name", limit: 255 t.text "descritpion" t.date "end_at" - t.integer "image_file_id" + t.bigint "image_file_id" t.boolean "done", default: false - t.integer "minutes" + t.bigint "minutes" t.bigint "admin_id" t.date "done_at" t.boolean "urgent", default: false - t.integer "i_previ_id" - t.integer "i_task_type_id" + t.bigint "i_previ_id" + t.bigint "i_task_type_id" t.boolean "from_customer", default: false - t.integer "i_task_bill_state_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_i_tasks_on_admin_id" - t.index ["i_task_project_id"], name: "index_i_tasks_on_i_task_project_id" + t.bigint "i_task_bill_state_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_54190_index_i_tasks_on_admin_id" + t.index ["i_task_project_id"], name: "idx_54190_index_i_tasks_on_i_task_project_id" end - create_table "image_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "image_contents", force: :cascade do |t| t.bigint "image_file_id" - t.integer "width" - t.integer "height" - t.string "alignement" + t.bigint "width" + t.bigint "height" + t.string "alignement", limit: 255 t.boolean "expandable", default: false - t.string "style" - t.string "alt" + t.string "style", limit: 255 + t.string "alt", limit: 255 t.bigint "cible_id" - t.string "cible_type" + t.string "cible_type", limit: 255 t.boolean "with_cible", default: false t.boolean "popup", default: false - t.integer "margin_top" - t.integer "margin_left" - t.integer "margin_right" - t.integer "margin_bottom" + t.bigint "margin_top" + t.bigint "margin_left" + t.bigint "margin_right" + t.bigint "margin_bottom" t.boolean "with_legend", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["cible_id"], name: "index_image_contents_on_cible_id" - t.index ["image_file_id"], name: "index_image_contents_on_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["cible_id"], name: "idx_54099_index_image_contents_on_cible_id" + t.index ["image_file_id"], name: "idx_54099_index_image_contents_on_image_file_id" end - create_table "image_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "file" - t.string "name" - t.string "slug" + create_table "image_files", force: :cascade do |t| + t.string "file", limit: 255 + t.string "name", limit: 255 + t.string "slug", limit: 255 t.text "description" - t.string "tags" - t.integer "album_id" - t.string "photograph" - t.string "cible_type" - t.integer "cible_id" - t.string "origin_name" - t.string "token_s" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "tags", limit: 255 + t.bigint "album_id" + t.string "photograph", limit: 255 + t.string "cible_type", limit: 255 + t.bigint "cible_id" + t.string "origin_name", limit: 255 + t.string "token_s", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "import_csv_champs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "champ" - t.string "header" - t.string "value" + create_table "import_csv_champs", force: :cascade do |t| + t.string "champ", limit: 255 + t.string "header", limit: 255 + t.string "value", limit: 255 t.bigint "import_csv_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["import_csv_id"], name: "index_import_csv_champs_on_import_csv_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["import_csv_id"], name: "idx_54147_index_import_csv_champs_on_import_csv_id" end - create_table "import_csv_elements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "import_csv_elements", force: :cascade do |t| t.bigint "import_csv_id" - t.string "element_type" - t.integer "element_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["import_csv_id"], name: "index_import_csv_elements_on_import_csv_id" + t.string "element_type", limit: 255 + t.bigint "element_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["import_csv_id"], name: "idx_54159_index_import_csv_elements_on_import_csv_id" end - create_table "import_csv_headers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "import_csv_headers", force: :cascade do |t| t.bigint "import_csv_id" - t.string "name" - t.string "champ" + t.string "name", limit: 255 + t.string "champ", limit: 255 t.boolean "custom", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["import_csv_id"], name: "index_import_csv_headers_on_import_csv_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["import_csv_id"], name: "idx_54166_index_import_csv_headers_on_import_csv_id" end - create_table "import_csvs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "file" + create_table "import_csvs", force: :cascade do |t| + t.string "file", limit: 255 t.text "notes" t.boolean "imported", default: false - t.string "table_name" + t.string "table_name", limit: 255 t.datetime "imported_at" - t.string "token" - t.integer "parent_id" - t.string "name" + t.string "token", limit: 255 + t.bigint "parent_id" + t.string "name", limit: 255 t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "ingredients", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "i_type" + create_table "ingredients", force: :cascade do |t| + t.string "name", limit: 255 + t.string "i_type", limit: 255 t.boolean "public", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "lang_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "lang_articles", force: :cascade do |t| t.datetime "published_at" - t.string "title" - t.string "slug" + t.string "title", limit: 255 + t.string "slug", limit: 255 t.text "description" t.text "keywords" t.boolean "enabled", default: false t.bigint "image_file_id" t.boolean "title_cached", default: false - t.string "tags_cache" - t.string "tags_cache_slug" + t.string "tags_cache", limit: 255 + t.string "tags_cache_slug", limit: 255 t.bigint "lang_site_id" t.bigint "article_id" - t.string "html_title" - t.string "fb_title" - t.string "twitter_title" + t.string "html_title", limit: 255 + t.string "fb_title", limit: 255 + t.string "twitter_title", limit: 255 t.text "twitter_description" - t.integer "without_text_image_file_id" + t.bigint "without_text_image_file_id" t.bigint "slider_image_file_id" t.text "chapeau" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["article_id"], name: "index_lang_articles_on_article_id" - t.index ["image_file_id"], name: "index_lang_articles_on_image_file_id" - t.index ["lang_site_id"], name: "index_lang_articles_on_lang_site_id" - t.index ["slider_image_file_id"], name: "index_lang_articles_on_slider_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["article_id"], name: "idx_54214_index_lang_articles_on_article_id" + t.index ["image_file_id"], name: "idx_54214_index_lang_articles_on_image_file_id" + t.index ["lang_site_id"], name: "idx_54214_index_lang_articles_on_lang_site_id" + t.index ["slider_image_file_id"], name: "idx_54214_index_lang_articles_on_slider_image_file_id" end - create_table "lang_pages", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "lang_pages", force: :cascade do |t| t.bigint "lang_site_id" t.bigint "page_id" t.text "title" t.text "description" t.text "keywords" - t.string "twitter_title" + t.string "twitter_title", limit: 255 t.text "twitter_description" t.bigint "without_text_image_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["lang_site_id"], name: "index_lang_pages_on_lang_site_id" - t.index ["page_id"], name: "index_lang_pages_on_page_id" - t.index ["without_text_image_file_id"], name: "index_lang_pages_on_without_text_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["lang_site_id"], name: "idx_54232_index_lang_pages_on_lang_site_id" + t.index ["page_id"], name: "idx_54232_index_lang_pages_on_page_id" + t.index ["without_text_image_file_id"], name: "idx_54232_index_lang_pages_on_without_text_image_file_id" end - create_table "lang_sites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" + create_table "lang_sites", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 t.boolean "enabled", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "line_stock_usages", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "line_stock_usages", force: :cascade do |t| t.bigint "line_stock_id" t.decimal "qte", precision: 14, scale: 2 t.decimal "cc_price_u_ht", precision: 14, scale: 2 t.decimal "ac_price_u_ht", precision: 14, scale: 2 t.decimal "cc_price_ht", precision: 14, scale: 2 t.decimal "ac_price_ht", precision: 14, scale: 2 - t.integer "dest_line_stock_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["line_stock_id"], name: "index_line_stock_usages_on_line_stock_id" + t.bigint "dest_line_stock_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["line_stock_id"], name: "idx_54286_index_line_stock_usages_on_line_stock_id" end - create_table "line_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "line_stocks", force: :cascade do |t| t.bigint "p_product_ref_id" t.text "description" t.decimal "qte", precision: 14, scale: 2 t.decimal "qte_available", precision: 14, scale: 2 t.decimal "qte_used", precision: 14, scale: 2 t.decimal "price_ht", precision: 14, scale: 2 - t.integer "price_line_block_id" - t.integer "price_line_id" - t.string "stockable_type" - t.integer "stockable_id" + t.bigint "price_line_block_id" + t.bigint "price_line_id" + t.string "stockable_type", limit: 255 + t.bigint "stockable_id" t.datetime "date" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "ac_line_type" - t.string "cc_line_type" - t.integer "stock_movement_line_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "ac_line_type", limit: 255 + t.string "cc_line_type", limit: 255 + t.bigint "stock_movement_line_id" t.decimal "cc_price_ht_available", precision: 14, scale: 2 t.decimal "cc_price_ht_used", precision: 14, scale: 2 t.decimal "cc_price_u_ht", precision: 14, scale: 2 @@ -593,279 +596,279 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "ac_qte_kg_available", precision: 14, scale: 2 t.decimal "ac_qte_kg_used", precision: 14, scale: 2 t.date "dluo" - t.integer "partition_line_id" - t.index ["p_product_ref_id"], name: "index_line_stocks_on_p_product_ref_id" + t.bigint "partition_line_id" + t.index ["p_product_ref_id"], name: "idx_54254_index_line_stocks_on_p_product_ref_id" end - create_table "link_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "type" - t.string "name" - t.string "title" + create_table "link_contents", force: :cascade do |t| + t.bigint "type" + t.string "name", limit: 255 + t.string "title", limit: 255 t.boolean "popup", default: false - t.string "url" - t.string "style" + t.string "url", limit: 255 + t.string "style", limit: 255 t.bigint "cible_id" - t.string "cible_type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["cible_id"], name: "index_link_contents_on_cible_id" + t.string "cible_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["cible_id"], name: "idx_54297_index_link_contents_on_cible_id" end - create_table "mail_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "mail_contents", force: :cascade do |t| t.bigint "lang_site_id" t.bigint "mail_type_id" - t.string "subject" + t.string "subject", limit: 255 t.text "message" t.boolean "enabled", default: false - t.string "content_type" + t.string "content_type", limit: 255 t.text "tags" t.bigint "mail_template_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["lang_site_id"], name: "index_mail_contents_on_lang_site_id" - t.index ["mail_template_id"], name: "index_mail_contents_on_mail_template_id" - t.index ["mail_type_id"], name: "index_mail_contents_on_mail_type_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["lang_site_id"], name: "idx_54312_index_mail_contents_on_lang_site_id" + t.index ["mail_template_id"], name: "idx_54312_index_mail_contents_on_mail_template_id" + t.index ["mail_type_id"], name: "idx_54312_index_mail_contents_on_mail_type_id" end - create_table "mail_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "mail_hists", force: :cascade do |t| t.bigint "lang_site_id" - t.string "from_email" - t.string "to_email" - t.string "subject" + t.string "from_email", limit: 255 + t.string "to_email", limit: 255 + t.string "subject", limit: 255 t.text "body" - t.string "subject_send" + t.string "subject_send", limit: 255 t.text "body_send" t.bigint "mail_content_id" t.bigint "mail_type_id" - t.string "element_type" - t.integer "element_id" - t.integer "w_biker_id" + t.string "element_type", limit: 255 + t.bigint "element_id" + t.bigint "w_biker_id" t.boolean "mj_read" - t.string "mj_token" - t.integer "nbr_send" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "v_bda_id" - t.integer "v_contact_id" - t.integer "societe_id" - t.index ["lang_site_id"], name: "index_mail_hists_on_lang_site_id" - t.index ["mail_content_id"], name: "index_mail_hists_on_mail_content_id" - t.index ["mail_type_id"], name: "index_mail_hists_on_mail_type_id" + t.string "mj_token", limit: 255 + t.bigint "nbr_send" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "v_bda_id" + t.bigint "v_contact_id" + t.bigint "societe_id" + t.index ["lang_site_id"], name: "idx_54324_index_mail_hists_on_lang_site_id" + t.index ["mail_content_id"], name: "idx_54324_index_mail_hists_on_mail_content_id" + t.index ["mail_type_id"], name: "idx_54324_index_mail_hists_on_mail_type_id" end - create_table "mail_profiles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "civilite" - t.string "firstname" - t.string "name" - t.string "address" - t.string "address2" - t.string "cp" - t.string "city" - t.string "country" - t.string "email" - t.string "phone" - t.string "token" - t.string "provider" - t.string "uid" - t.string "facebook_token" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "mail_profiles", force: :cascade do |t| + t.string "civilite", limit: 255 + t.string "firstname", limit: 255 + t.string "name", limit: 255 + t.string "address", limit: 255 + t.string "address2", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "email", limit: 255 + t.string "phone", limit: 255 + t.string "token", limit: 255 + t.string "provider", limit: 255 + t.string "uid", limit: 255 + t.string "facebook_token", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "mail_templates", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" + create_table "mail_templates", force: :cascade do |t| + t.string "title", limit: 255 t.text "template_html" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "mail_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "slug" - t.string "default_title" + create_table "mail_types", force: :cascade do |t| + t.string "slug", limit: 255 + t.string "default_title", limit: 255 t.text "default_message" t.bigint "mail_type_reference_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["mail_type_reference_id"], name: "index_mail_types_on_mail_type_reference_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["mail_type_reference_id"], name: "idx_54372_index_mail_types_on_mail_type_reference_id" end - create_table "map_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "address" - t.string "name" - t.integer "view" + create_table "map_contents", force: :cascade do |t| + t.string "address", limit: 255 + t.string "name", limit: 255 + t.bigint "view" t.boolean "info_bule", default: false - t.integer "zoom" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "zoom" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "market_discounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "market_discounts", force: :cascade do |t| t.decimal "min", precision: 10 t.decimal "max", precision: 10 t.decimal "percent", precision: 10 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "p_customer_cat_id", default: 1 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "p_customer_cat_id", default: 1 end - create_table "menu_aliases", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_aliases", force: :cascade do |t| t.bigint "menu_item_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["menu_item_id"], name: "index_menu_aliases_on_menu_item_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["menu_item_id"], name: "idx_54417_index_menu_aliases_on_menu_item_id" end - create_table "menu_item_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_item_articles", force: :cascade do |t| t.bigint "menu_item_id" t.bigint "article_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["article_id"], name: "index_menu_item_articles_on_article_id" - t.index ["menu_item_id"], name: "index_menu_item_articles_on_menu_item_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["article_id"], name: "idx_54449_index_menu_item_articles_on_article_id" + t.index ["menu_item_id"], name: "idx_54449_index_menu_item_articles_on_menu_item_id" end - create_table "menu_item_categories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_item_categories", force: :cascade do |t| t.bigint "menu_item_id" t.bigint "category_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["category_id"], name: "index_menu_item_categories_on_category_id" - t.index ["menu_item_id"], name: "index_menu_item_categories_on_menu_item_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["category_id"], name: "idx_54455_index_menu_item_categories_on_category_id" + t.index ["menu_item_id"], name: "idx_54455_index_menu_item_categories_on_menu_item_id" end - create_table "menu_item_langs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_item_langs", force: :cascade do |t| t.bigint "lang_site_id" - t.string "name" - t.string "slug" - t.string "permalink" + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.string "permalink", limit: 255 t.boolean "enabled", default: false t.boolean "visible", default: false t.bigint "menu_item_id" t.bigint "image_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["image_file_id"], name: "index_menu_item_langs_on_image_file_id" - t.index ["lang_site_id"], name: "index_menu_item_langs_on_lang_site_id" - t.index ["menu_item_id"], name: "index_menu_item_langs_on_menu_item_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["image_file_id"], name: "idx_54461_index_menu_item_langs_on_image_file_id" + t.index ["lang_site_id"], name: "idx_54461_index_menu_item_langs_on_lang_site_id" + t.index ["menu_item_id"], name: "idx_54461_index_menu_item_langs_on_menu_item_id" end - create_table "menu_item_link_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_item_link_contents", force: :cascade do |t| t.bigint "menu_item_id" t.bigint "image_file_id" - t.string "title" + t.string "title", limit: 255 t.text "description" - t.string "url" + t.string "url", limit: 255 t.boolean "popup", default: false - t.string "style" - t.string "block_type" + t.string "style", limit: 255 + t.string "block_type", limit: 255 t.bigint "cible_id" - t.string "cible_type" + t.string "cible_type", limit: 255 t.decimal "proportion", precision: 14, scale: 2 - t.integer "level" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["cible_id"], name: "index_menu_item_link_contents_on_cible_id" - t.index ["image_file_id"], name: "index_menu_item_link_contents_on_image_file_id" - t.index ["menu_item_id"], name: "index_menu_item_link_contents_on_menu_item_id" + t.bigint "level" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["cible_id"], name: "idx_54475_index_menu_item_link_contents_on_cible_id" + t.index ["image_file_id"], name: "idx_54475_index_menu_item_link_contents_on_image_file_id" + t.index ["menu_item_id"], name: "idx_54475_index_menu_item_link_contents_on_menu_item_id" end - create_table "menu_item_slug_histories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "permalink" - t.string "locale" - t.integer "menu_item_id" + create_table "menu_item_slug_histories", force: :cascade do |t| + t.string "permalink", limit: 255 + t.string "locale", limit: 255 + t.bigint "menu_item_id" t.bigint "menu_item_lang_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["menu_item_lang_id"], name: "index_menu_item_slug_histories_on_menu_item_lang_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["menu_item_lang_id"], name: "idx_54491_index_menu_item_slug_histories_on_menu_item_lang_id" end - create_table "menu_item_tags", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "menu_item_tags", force: :cascade do |t| t.bigint "menu_item_id" t.bigint "tag_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["menu_item_id"], name: "index_menu_item_tags_on_menu_item_id" - t.index ["tag_id"], name: "index_menu_item_tags_on_tag_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["menu_item_id"], name: "idx_54502_index_menu_item_tags_on_menu_item_id" + t.index ["tag_id"], name: "idx_54502_index_menu_item_tags_on_tag_id" end - create_table "menu_items", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" - t.string "permalink" + create_table "menu_items", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.string "permalink", limit: 255 t.bigint "image_file_id" - t.string "section_name" - t.integer "section_id" - t.string "repertoire_name" - t.integer "repertoire_id" + t.string "section_name", limit: 255 + t.bigint "section_id" + t.string "repertoire_name", limit: 255 + t.bigint "repertoire_id" t.bigint "parent_id" - t.integer "position" + t.bigint "position" t.boolean "super_admin", default: false t.boolean "enabled", default: false t.boolean "visible", default: false t.boolean "deleted", default: false t.bigint "menu_id" t.bigint "menu_content_id" - t.string "menu_content_type" - t.integer "archive_id" + t.string "menu_content_type", limit: 255 + t.bigint "archive_id" t.boolean "archived", default: false t.datetime "archived_at" t.boolean "password", default: false t.boolean "comment", default: false t.boolean "sidebar", default: false t.boolean "title_image", default: false - t.string "title_image_style" + t.string "title_image_style", limit: 255 t.boolean "title_cached", default: false t.bigint "icon_image_file_id" t.bigint "icon_b_image_file_id" t.text "primary_description" t.bigint "icon_v_image_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["icon_b_image_file_id"], name: "index_menu_items_on_icon_b_image_file_id" - t.index ["icon_image_file_id"], name: "index_menu_items_on_icon_image_file_id" - t.index ["icon_v_image_file_id"], name: "index_menu_items_on_icon_v_image_file_id" - t.index ["image_file_id"], name: "index_menu_items_on_image_file_id" - t.index ["menu_content_id"], name: "index_menu_items_on_menu_content_id" - t.index ["menu_id"], name: "index_menu_items_on_menu_id" - t.index ["parent_id"], name: "index_menu_items_on_parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["icon_b_image_file_id"], name: "idx_54423_index_menu_items_on_icon_b_image_file_id" + t.index ["icon_image_file_id"], name: "idx_54423_index_menu_items_on_icon_image_file_id" + t.index ["icon_v_image_file_id"], name: "idx_54423_index_menu_items_on_icon_v_image_file_id" + t.index ["image_file_id"], name: "idx_54423_index_menu_items_on_image_file_id" + t.index ["menu_content_id"], name: "idx_54423_index_menu_items_on_menu_content_id" + t.index ["menu_id"], name: "idx_54423_index_menu_items_on_menu_id" + t.index ["parent_id"], name: "idx_54423_index_menu_items_on_parent_id" end - create_table "menu_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "url" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "menu_urls", force: :cascade do |t| + t.string "url", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "menus", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "max_levels" - t.string "slug" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "menus", force: :cascade do |t| + t.string "name", limit: 255 + t.string "max_levels", limit: 255 + t.string "slug", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "open_range_elements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "open_range_id" - t.string "element_type" - t.integer "element_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "open_range_elements", force: :cascade do |t| + t.bigint "open_range_id" + t.string "element_type", limit: 255 + t.bigint "element_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "open_ranges", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "open_ranges", force: :cascade do |t| + t.string "name", limit: 255 + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "order_hist_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "past_code_client" - t.string "numero_piece" - t.string "numerofacture" - t.string "d_number" - t.integer "position" - t.string "code_article" + create_table "order_hist_lines", force: :cascade do |t| + t.string "past_code_client", limit: 255 + t.string "numero_piece", limit: 255 + t.string "numerofacture", limit: 255 + t.string "d_number", limit: 255 + t.bigint "position" + t.string "code_article", limit: 255 t.bigint "p_product_ref_id" t.decimal "qte", precision: 14, scale: 2 t.decimal "prix_u", precision: 14, scale: 2 @@ -875,7 +878,7 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "remise_2", precision: 14, scale: 2 t.datetime "date_creation" t.datetime "date_modification" - t.string "compte_vente" + t.string "compte_vente", limit: 255 t.date "date_piece" t.date "date_facture" t.decimal "colisage", precision: 14, scale: 2 @@ -886,27 +889,27 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "quantite_origine", precision: 14, scale: 2 t.decimal "pu_tarif_origine", precision: 14, scale: 2 t.decimal "taux_tva_article_2", precision: 14, scale: 2 - t.string "compte_ventil_vente" - t.integer "num_ligne_avancement" - t.integer "etat" - t.string "reference_1" - t.string "reference_2" - t.string "reference_3" - t.string "reference_4" - t.string "code_mode_reglement" + t.string "compte_ventil_vente", limit: 255 + t.bigint "num_ligne_avancement" + t.bigint "etat" + t.string "reference_1", limit: 255 + t.string "reference_2", limit: 255 + t.string "reference_3", limit: 255 + t.string "reference_4", limit: 255 + t.string "code_mode_reglement", limit: 255 t.bigint "p_payment_type_id" - t.integer "echeance_nbr_jour" + t.bigint "echeance_nbr_jour" t.date "date_echeance" - t.string "code_commercial" + t.string "code_commercial", limit: 255 t.bigint "p_commercial_id" t.decimal "taux_escompte", precision: 14, scale: 2 t.decimal "taux_remise", precision: 14, scale: 2 - t.string "fichier_archive" - t.string "interlocuteur" - t.string "new_code_client" + t.string "fichier_archive", limit: 255 + t.string "interlocuteur", limit: 255 + t.string "new_code_client", limit: 255 t.bigint "p_customer_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.decimal "cc_montant_ht", precision: 14, scale: 2 t.decimal "cc_montant_ht_remise", precision: 14, scale: 2 t.decimal "cc_montant_ht_com", precision: 14, scale: 2 @@ -930,25 +933,25 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.bigint "order_hist_id" t.decimal "montant_ht", precision: 14, scale: 3 t.decimal "montant_ht_remise", precision: 14, scale: 3 - t.index ["order_hist_id"], name: "index_order_hist_lines_on_order_hist_id" - t.index ["p_commercial_id"], name: "index_order_hist_lines_on_p_commercial_id" - t.index ["p_customer_id"], name: "index_order_hist_lines_on_p_customer_id" - t.index ["p_payment_type_id"], name: "index_order_hist_lines_on_p_payment_type_id" - t.index ["p_product_ref_id"], name: "index_order_hist_lines_on_p_product_ref_id" + t.index ["order_hist_id"], name: "idx_54552_index_order_hist_lines_on_order_hist_id" + t.index ["p_commercial_id"], name: "idx_54552_index_order_hist_lines_on_p_commercial_id" + t.index ["p_customer_id"], name: "idx_54552_index_order_hist_lines_on_p_customer_id" + t.index ["p_payment_type_id"], name: "idx_54552_index_order_hist_lines_on_p_payment_type_id" + t.index ["p_product_ref_id"], name: "idx_54552_index_order_hist_lines_on_p_product_ref_id" end - create_table "order_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "past_code_client" - t.string "numero_piece" - t.string "numerofacture" - t.string "d_number" + create_table "order_hists", force: :cascade do |t| + t.string "past_code_client", limit: 255 + t.string "numero_piece", limit: 255 + t.string "numerofacture", limit: 255 + t.string "d_number", limit: 255 t.date "date_creation" t.date "date_modification" t.date "date_piece" t.date "date_facture" - t.integer "p_payment_type_id" - t.integer "p_commercial_id" - t.integer "p_customer_id" + t.bigint "p_payment_type_id" + t.bigint "p_commercial_id" + t.bigint "p_customer_id" t.decimal "montant_ht", precision: 14, scale: 2 t.decimal "montant_ht_remise", precision: 14, scale: 2 t.decimal "montant_ht_com", precision: 14, scale: 2 @@ -959,437 +962,437 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "marge_brut_hors_remise_pa", precision: 14, scale: 2 t.decimal "marge_brut_remise_pa", precision: 14, scale: 2 t.decimal "marge_net_ht_pa", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_aromes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_aromes", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "public", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_article_serial_nums", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_article_serial_nums", force: :cascade do |t| t.bigint "p_article_id" t.bigint "p_serial_num_type_id" t.bigint "p_serial_num_value_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "value" - t.index ["p_article_id"], name: "index_p_article_serial_nums_on_p_article_id" - t.index ["p_serial_num_type_id"], name: "index_p_article_serial_nums_on_p_serial_num_type_id" - t.index ["p_serial_num_value_id"], name: "index_p_article_serial_nums_on_p_serial_num_value_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "value", limit: 255 + t.index ["p_article_id"], name: "idx_54961_index_p_article_serial_nums_on_p_article_id" + t.index ["p_serial_num_type_id"], name: "idx_54961_index_p_article_serial_nums_on_p_serial_num_type_id" + t.index ["p_serial_num_value_id"], name: "idx_54961_index_p_article_serial_nums_on_p_serial_num_value_id" end - create_table "p_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_articles", force: :cascade do |t| t.bigint "p_product_ref_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.bigint "p_grade_id" - t.index ["p_grade_id"], name: "index_p_articles_on_p_grade_id" - t.index ["p_product_ref_id"], name: "index_p_articles_on_p_product_ref_id" + t.index ["p_grade_id"], name: "idx_54955_index_p_articles_on_p_grade_id" + t.index ["p_product_ref_id"], name: "idx_54955_index_p_articles_on_p_product_ref_id" end - create_table "p_bank_accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_bank_accounts", force: :cascade do |t| t.bigint "p_bank_id" - t.string "iban" - t.string "bic" - t.string "compta_cpt" - t.string "compta_journ" - t.string "compta_aux" + t.string "iban", limit: 255 + t.string "bic", limit: 255 + t.string "compta_cpt", limit: 255 + t.string "compta_journ", limit: 255 + t.string "compta_aux", limit: 255 t.bigint "p_fournisseur_id" t.bigint "p_customer_id" t.boolean "owner", default: false t.bigint "data_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["data_file_id"], name: "index_p_bank_accounts_on_data_file_id" - t.index ["p_bank_id"], name: "index_p_bank_accounts_on_p_bank_id" - t.index ["p_customer_id"], name: "index_p_bank_accounts_on_p_customer_id" - t.index ["p_fournisseur_id"], name: "index_p_bank_accounts_on_p_fournisseur_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_file_id"], name: "idx_54979_index_p_bank_accounts_on_data_file_id" + t.index ["p_bank_id"], name: "idx_54979_index_p_bank_accounts_on_p_bank_id" + t.index ["p_customer_id"], name: "idx_54979_index_p_bank_accounts_on_p_customer_id" + t.index ["p_fournisseur_id"], name: "idx_54979_index_p_bank_accounts_on_p_fournisseur_id" end - create_table "p_banks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "bic" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_banks", force: :cascade do |t| + t.string "name", limit: 255 + t.string "bic", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_brut_products", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_brut_products", force: :cascade do |t| + t.string "name", limit: 255 t.decimal "price", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_commercial_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "description" - t.string "type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_commercial_cats", force: :cascade do |t| + t.string "name", limit: 255 + t.string "description", limit: 255 + t.string "type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_commercial_object_brands", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_commercial_object_brands", force: :cascade do |t| t.bigint "p_commercial_id" t.bigint "p_commercial_objective_id" t.bigint "s_brand_id" t.decimal "objective_percent", precision: 10 t.decimal "weight_objective", precision: 10 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "commercial_show", default: true - t.index ["p_commercial_id"], name: "index_p_commercial_object_brands_on_p_commercial_id" - t.index ["p_commercial_objective_id"], name: "index_p_commercial_object_brands_on_p_commercial_objective_id" - t.index ["s_brand_id"], name: "index_p_commercial_object_brands_on_s_brand_id" + t.index ["p_commercial_id"], name: "idx_55049_index_p_commercial_object_brands_on_p_commercial_id" + t.index ["p_commercial_objective_id"], name: "idx_55049_index_p_commercial_object_brands_on_p_commercial_obje" + t.index ["s_brand_id"], name: "idx_55049_index_p_commercial_object_brands_on_s_brand_id" end - create_table "p_commercial_object_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_commercial_object_cats", force: :cascade do |t| t.bigint "p_commercial_id" t.bigint "p_product_cats_id" t.decimal "objective_percent", precision: 10 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.bigint "p_commercial_objective_id" t.decimal "weight_objective", precision: 10 - t.index ["p_commercial_id"], name: "index_p_commercial_object_cats_on_p_commercial_id" - t.index ["p_commercial_objective_id"], name: "index_p_commercial_object_cats_on_p_commercial_objective_id" - t.index ["p_product_cats_id"], name: "index_p_commercial_object_cats_on_p_product_cats_id" + t.index ["p_commercial_id"], name: "idx_55058_index_p_commercial_object_cats_on_p_commercial_id" + t.index ["p_commercial_objective_id"], name: "idx_55058_index_p_commercial_object_cats_on_p_commercial_object" + t.index ["p_product_cats_id"], name: "idx_55058_index_p_commercial_object_cats_on_p_product_cats_id" end - create_table "p_commercial_object_months", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_commercial_object_months", force: :cascade do |t| t.bigint "p_commercial_id" t.date "start_at" t.date "end_at" t.decimal "objective_percent", precision: 10 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.bigint "p_commercial_objective_id" t.decimal "weight_objective", precision: 10 - t.index ["p_commercial_id"], name: "index_p_commercial_object_months_on_p_commercial_id" - t.index ["p_commercial_objective_id"], name: "index_p_commercial_object_months_on_p_commercial_objective_id" + t.index ["p_commercial_id"], name: "idx_55066_index_p_commercial_object_months_on_p_commercial_id" + t.index ["p_commercial_objective_id"], name: "idx_55066_index_p_commercial_object_months_on_p_commercial_obje" end - create_table "p_commercial_objectives", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_commercial_objectives", force: :cascade do |t| t.bigint "p_commercial_id" - t.integer "total_ca" + t.bigint "total_ca" t.date "start_at" t.date "end_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.decimal "total_weight", precision: 10 - t.index ["p_commercial_id"], name: "index_p_commercial_objectives_on_p_commercial_id" + t.index ["p_commercial_id"], name: "idx_55042_index_p_commercial_objectives_on_p_commercial_id" end - create_table "p_commercials", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_commercials", force: :cascade do |t| t.boolean "enabled", default: true - t.string "code" - t.string "organisation" - t.string "civilite" - t.string "name" - t.string "firstname" - t.string "address_number" - t.string "address_1" - t.string "address_2" - t.string "address_3" - t.string "cp" - t.string "city" - t.string "country" - t.string "phone" - t.string "email" - t.string "token" - t.integer "p_commercial_cat_id" - t.string "ac_display_name" - t.string "cc_display_name" + t.string "code", limit: 255 + t.string "organisation", limit: 255 + t.string "civilite", limit: 255 + t.string "name", limit: 255 + t.string "firstname", limit: 255 + t.string "address_number", limit: 255 + t.string "address_1", limit: 255 + t.string "address_2", limit: 255 + t.string "address_3", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "phone", limit: 255 + t.string "email", limit: 255 + t.string "token", limit: 255 + t.bigint "p_commercial_cat_id" + t.string "ac_display_name", limit: 255 + t.string "cc_display_name", limit: 255 t.date "start_at" t.date "stop_at" t.text "secteur" t.boolean "avenant" t.date "birth" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.decimal "objectif_ht", precision: 14, scale: 2 end - create_table "p_compta_elements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "element_type" + create_table "p_compta_elements", force: :cascade do |t| + t.string "element_type", limit: 255 t.bigint "element_id" t.bigint "p_customer_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.date "cc_element_date" t.date "ac_element_date" t.boolean "cc_solde" t.boolean "ac_solde" t.decimal "ac_amount", precision: 14, scale: 2 t.decimal "cc_amount", precision: 14, scale: 2 - t.index ["element_id"], name: "index_p_compta_elements_on_element_id" - t.index ["p_customer_id"], name: "index_p_compta_elements_on_p_customer_id" + t.index ["element_id"], name: "idx_55074_index_p_compta_elements_on_element_id" + t.index ["p_customer_id"], name: "idx_55074_index_p_compta_elements_on_p_customer_id" end - create_table "p_compta_exports", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_compta_exports", force: :cascade do |t| t.date "start_at" t.date "end_at" t.text "comment" t.boolean "validated", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_contact_contact_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_contact_contact_types", force: :cascade do |t| t.bigint "p_contact_id" t.bigint "p_contact_type_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_contact_id"], name: "index_p_contact_contact_types_on_p_contact_id" - t.index ["p_contact_type_id"], name: "index_p_contact_contact_types_on_p_contact_type_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_contact_id"], name: "idx_55108_index_p_contact_contact_types_on_p_contact_id" + t.index ["p_contact_type_id"], name: "idx_55108_index_p_contact_contact_types_on_p_contact_type_id" end - create_table "p_contact_types", 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 + create_table "p_contact_types", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_contacts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_contacts", force: :cascade do |t| + t.string "name", limit: 255 t.text "comment" - t.string "tel" - t.string "email" + t.string "tel", limit: 255 + t.string "email", limit: 255 t.boolean "bc", default: false t.boolean "boolean", default: false t.bigint "contactable_id" - t.string "contactable_type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["contactable_id"], name: "index_p_contacts_on_contactable_id" + t.string "contactable_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["contactable_id"], name: "idx_55093_index_p_contacts_on_contactable_id" end - create_table "p_customer_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "code" - t.integer "payment_days" + create_table "p_customer_cats", force: :cascade do |t| + t.string "name", limit: 255 + t.string "code", limit: 255 + t.bigint "payment_days" t.decimal "encourt_max", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_customer_product_prices", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_customer_product_prices", force: :cascade do |t| t.decimal "price", precision: 14, scale: 2 t.boolean "no_remise" t.bigint "p_customer_id" t.bigint "p_product_ref_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_customer_id"], name: "index_p_customer_product_prices_on_p_customer_id" - t.index ["p_product_ref_id"], name: "index_p_customer_product_prices_on_p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_customer_id"], name: "idx_55183_index_p_customer_product_prices_on_p_customer_id" + t.index ["p_product_ref_id"], name: "idx_55183_index_p_customer_product_prices_on_p_product_ref_id" end - create_table "p_customer_ribs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "nbr_use" - t.string "iban" - t.string "bic" - t.string "bank" - t.string "num_compte" - t.string "intitule" - t.string "address1" - t.string "cp" - t.string "city" - t.string "country" - t.string "rum" + create_table "p_customer_ribs", force: :cascade do |t| + t.bigint "nbr_use" + t.string "iban", limit: 255 + t.string "bic", limit: 255 + t.string "bank", limit: 255 + t.string "num_compte", limit: 255 + t.string "intitule", limit: 255 + t.string "address1", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "rum", limit: 255 t.boolean "import", default: false t.boolean "archived", default: false - t.integer "price_document_id" - t.integer "p_mandat_id" + t.bigint "price_document_id" + t.bigint "p_mandat_id" t.date "sign_date" t.boolean "pres_sepa", default: false t.bigint "p_customer_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_customer_id"], name: "index_p_customer_ribs_on_p_customer_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_customer_id"], name: "idx_55190_index_p_customer_ribs_on_p_customer_id" end - create_table "p_customer_sheets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "state" - t.string "comments" + create_table "p_customer_sheets", force: :cascade do |t| + t.string "state", limit: 255 + t.string "comments", limit: 255 t.bigint "p_customer_id" - t.integer "p_commercial_id" - t.integer "particular_bill_id" - t.integer "particular_send_id" - t.integer "ref_particular_bill_id" - t.integer "ref_particular_send_id" - t.integer "ac_accounting_zone_id" - t.integer "cc_accounting_zone_id" - t.string "ac_accounting_zone_name" - t.string "cc_accounting_zone_name" + t.bigint "p_commercial_id" + t.bigint "particular_bill_id" + t.bigint "particular_send_id" + t.bigint "ref_particular_bill_id" + t.bigint "ref_particular_send_id" + t.bigint "ac_accounting_zone_id" + t.bigint "cc_accounting_zone_id" + t.string "ac_accounting_zone_name", limit: 255 + t.string "cc_accounting_zone_name", limit: 255 t.decimal "ac_tot_amount_ht", precision: 14, scale: 2 t.decimal "cc_tot_amount_ht", precision: 14, scale: 2 t.decimal "ac_tot_amount_ttc", precision: 14, scale: 2 t.decimal "cc_tot_amount_ttc", precision: 14, scale: 2 t.decimal "ac_tot_amount_tva", precision: 14, scale: 2 t.decimal "cc_tot_amount_tva", precision: 14, scale: 2 - t.string "token" - t.integer "p_payment_type_id" + t.string "token", limit: 255 + t.bigint "p_payment_type_id" t.boolean "ac_payment_comptant" t.boolean "cc_payment_comptant" - t.integer "ac_payment_delais" - t.integer "cc_payment_delais" + t.bigint "ac_payment_delais" + t.bigint "cc_payment_delais" t.boolean "ac_payment_month_end" t.boolean "cc_payment_month_end" t.date "ac_payment_end_at" t.date "cc_payment_end_at" - t.integer "ac_payment_days" - t.integer "cc_payment_days" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "ac_payment_days" + t.bigint "cc_payment_days" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "archived" - t.string "demande_type" - t.integer "com_counter_index" - t.string "cc_com_counter" - t.string "ac_com_counter" + t.string "demande_type", limit: 255 + t.bigint "com_counter_index" + t.string "cc_com_counter", limit: 255 + t.string "ac_com_counter", limit: 255 t.decimal "ac_weight_tot", precision: 14, scale: 2 t.decimal "cc_weight_tot", precision: 14, scale: 2 - t.integer "admin_id" + t.bigint "admin_id" t.boolean "price_blocked", default: false t.datetime "customer_validation_at" t.boolean "web_order", default: false - t.string "past_id" - t.index ["p_customer_id"], name: "index_p_customer_sheets_on_p_customer_id" + t.string "past_id", limit: 255 + t.index ["p_customer_id"], name: "idx_55212_index_p_customer_sheets_on_p_customer_id" end - create_table "p_customer_sites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_customer_sites", force: :cascade do |t| t.bigint "p_customer_id" - t.string "name" + t.string "name", limit: 255 t.bigint "particular_id" - t.string "comments" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_customer_id"], name: "index_p_customer_sites_on_p_customer_id" - t.index ["particular_id"], name: "index_p_customer_sites_on_particular_id" + t.string "comments", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_customer_id"], name: "idx_55240_index_p_customer_sites_on_p_customer_id" + t.index ["particular_id"], name: "idx_55240_index_p_customer_sites_on_particular_id" end - create_table "p_customers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_customers", force: :cascade do |t| t.decimal "encourt_max", precision: 14, scale: 2 t.bigint "p_customer_cat_id" t.bigint "particular_id" - t.string "name" - t.string "code" + t.string "name", limit: 255 + t.string "code", limit: 255 t.boolean "fav", default: false t.boolean "facture_email", default: false t.boolean "risque", default: false - t.integer "admin_id" + t.bigint "admin_id" t.decimal "cache_ca", precision: 14, scale: 2 t.decimal "cache_encours", precision: 14, scale: 2 - t.integer "cache_moyenne_paiement" - t.integer "payment_days" - t.integer "parent_id" - t.string "mlm_token" - t.string "parent_code" + t.bigint "cache_moyenne_paiement" + t.bigint "payment_days" + t.bigint "parent_id" + t.string "mlm_token", limit: 255 + t.string "parent_code", limit: 255 t.boolean "parent_at_create", default: false t.boolean "imported", default: false t.boolean "facture_mail", default: false t.boolean "comptant", default: true t.boolean "acompte", default: false t.decimal "acompte_percent", precision: 14, scale: 2 - t.integer "payment_delais" + t.bigint "payment_delais" t.boolean "payment_fin_de_mois", default: false t.decimal "cache_encours_th", precision: 14, scale: 2 t.decimal "cache_payments_th", precision: 14, scale: 2 t.decimal "cache_payments", precision: 14, scale: 2 t.decimal "cache_payments_tot", precision: 14, scale: 2 - t.integer "p_payment_type_id" - t.string "i_actif" + t.bigint "p_payment_type_id" + t.string "i_actif", limit: 255 t.boolean "i_cat", default: false t.decimal "cache_ca_ttc", precision: 14, scale: 2 - t.integer "p_commercial_id" - t.integer "accounting_zone_id" + t.bigint "p_commercial_id" + t.bigint "accounting_zone_id" t.bigint "market_discount_id" - t.string "siret" - t.string "tva_intra" + t.string "siret", limit: 255 + t.string "tva_intra", limit: 255 t.text "closed_day" t.boolean "discount_enrobage", default: false t.boolean "discount_comptant", default: false t.boolean "discount_ecole", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "enabled", default: true t.text "disabled_raison" - t.string "siren" + t.string "siren", limit: 255 t.datetime "import_created_at" - t.string "website" - t.string "soumis_tva" + t.string "website", limit: 255 + t.string "soumis_tva", limit: 255 t.text "p_customer_sheet_note" - t.string "past_code" - t.integer "particular_bill_id" - t.integer "particular_send_id" - t.string "email" - t.string "password_digest" - t.string "reset_password_token" + t.string "past_code", limit: 255 + t.bigint "particular_bill_id" + t.bigint "particular_send_id" + t.string "email", limit: 255 + t.string "password_digest", limit: 255 + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count" + t.bigint "sign_in_count" t.datetime "current_sign_at" t.datetime "last_sign_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "auth_token" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "auth_token", limit: 255 t.boolean "online_shop", default: false - t.index ["market_discount_id"], name: "index_p_customers_on_market_discount_id" - t.index ["p_customer_cat_id"], name: "index_p_customers_on_p_customer_cat_id" - t.index ["particular_id"], name: "index_p_customers_on_particular_id" + t.index ["market_discount_id"], name: "idx_55121_index_p_customers_on_market_discount_id" + t.index ["p_customer_cat_id"], name: "idx_55121_index_p_customers_on_p_customer_cat_id" + t.index ["particular_id"], name: "idx_55121_index_p_customers_on_particular_id" end - create_table "p_devises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "symbol" + create_table "p_devises", force: :cascade do |t| + t.string "name", limit: 255 + t.string "symbol", limit: 255 t.decimal "rate", precision: 14, scale: 7 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_document_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "prefix" - t.string "label" - t.string "affix" + create_table "p_document_types", force: :cascade do |t| + t.string "prefix", limit: 255 + t.string "label", limit: 255 + t.string "affix", limit: 255 t.text "header" t.text "footer" - t.integer "image_file_id" + t.bigint "image_file_id" t.bigint "data_file_id" - t.string "class_type" - t.string "sub_type" - t.string "name" + t.string "class_type", limit: 255 + t.string "sub_type", limit: 255 + t.string "name", limit: 255 t.boolean "enabled", default: false - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["data_file_id"], name: "index_p_document_types_on_data_file_id" + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_file_id"], name: "idx_55300_index_p_document_types_on_data_file_id" end - create_table "p_documents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "element_type" + create_table "p_documents", force: :cascade do |t| + t.string "element_type", limit: 255 t.bigint "element_id" t.bigint "p_document_type_id" t.bigint "particular_bill_id" t.bigint "particular_send_id" - t.string "name" - t.string "d_number" - t.integer "d_index" - t.integer "d_year" - t.string "d_prefix" - t.string "label" + t.string "name", limit: 255 + t.string "d_number", limit: 255 + t.bigint "d_index" + t.bigint "d_year" + t.string "d_prefix", limit: 255 + t.string "label", limit: 255 t.text "header" t.text "footer" - t.integer "image_file_id" - t.integer "data_file_id" - t.string "token" + t.bigint "image_file_id" + t.bigint "data_file_id" + t.string "token", limit: 255 t.bigint "p_sheet_line_id" - t.string "bl_type" + t.string "bl_type", limit: 255 t.decimal "cache_total_ht", precision: 14, scale: 2 t.decimal "cache_total_ttc", precision: 14, scale: 2 t.decimal "cache_tva", precision: 14, scale: 2 - t.integer "payment_days" + t.bigint "payment_days" t.datetime "cache_exp_date" t.bigint "p_customer_id" t.boolean "theo_paid", default: false @@ -1404,36 +1407,36 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cache_total_tva", precision: 14, scale: 2 t.boolean "comptant", default: true t.boolean "acompte", default: false - t.integer "payment_delais" + t.bigint "payment_delais" t.boolean "payment_fin_de_mois", default: false t.bigint "p_payment_type_id" t.bigint "p_ship_tour_truck_id" t.boolean "canceled", default: false t.boolean "i_archive", default: false - t.string "cust_ref" - t.integer "doc_ref_id" + t.string "cust_ref", limit: 255 + t.bigint "doc_ref_id" t.date "echeance_date" t.text "avoir_text" - t.string "doc_ref_number" + t.string "doc_ref_number", limit: 255 t.boolean "i_ajust", default: false t.boolean "i_ajust_result", default: false - t.integer "p_commercial_id" - t.integer "p_compta_export_id" + t.bigint "p_commercial_id" + t.bigint "p_compta_export_id" t.boolean "compta_locked", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["element_id"], name: "index_p_documents_on_element_id" - t.index ["p_customer_id"], name: "index_p_documents_on_p_customer_id" - t.index ["p_document_type_id"], name: "index_p_documents_on_p_document_type_id" - t.index ["p_payment_type_id"], name: "index_p_documents_on_p_payment_type_id" - t.index ["p_sheet_line_id"], name: "index_p_documents_on_p_sheet_line_id" - t.index ["p_ship_tour_truck_id"], name: "index_p_documents_on_p_ship_tour_truck_id" - t.index ["particular_bill_id"], name: "index_p_documents_on_particular_bill_id" - t.index ["particular_send_id"], name: "index_p_documents_on_particular_send_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["element_id"], name: "idx_55263_index_p_documents_on_element_id" + t.index ["p_customer_id"], name: "idx_55263_index_p_documents_on_p_customer_id" + t.index ["p_document_type_id"], name: "idx_55263_index_p_documents_on_p_document_type_id" + t.index ["p_payment_type_id"], name: "idx_55263_index_p_documents_on_p_payment_type_id" + t.index ["p_sheet_line_id"], name: "idx_55263_index_p_documents_on_p_sheet_line_id" + t.index ["p_ship_tour_truck_id"], name: "idx_55263_index_p_documents_on_p_ship_tour_truck_id" + t.index ["particular_bill_id"], name: "idx_55263_index_p_documents_on_particular_bill_id" + t.index ["particular_send_id"], name: "idx_55263_index_p_documents_on_particular_send_id" end - create_table "p_fournisseur_orders", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "ref" + create_table "p_fournisseur_orders", force: :cascade do |t| + t.string "ref", limit: 255 t.decimal "amount", precision: 14, scale: 2 t.datetime "enter_date" t.bigint "p_fournisseur_id" @@ -1443,79 +1446,79 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "a_total_ttc", precision: 14, scale: 2 t.decimal "a_total_ht", precision: 14, scale: 2 t.decimal "a_tva", precision: 14, scale: 2 - t.integer "p_compta_export_id" + t.bigint "p_compta_export_id" t.boolean "compta_locked", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_fournisseur_id"], name: "index_p_fournisseur_orders_on_p_fournisseur_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_fournisseur_id"], name: "idx_55335_index_p_fournisseur_orders_on_p_fournisseur_id" end - create_table "p_fournisseurs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "code" - t.string "address1" - t.string "address2" - t.string "cp" - t.string "city" - t.string "country" - t.string "email" - t.string "tel" - t.string "compta_account" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_fournisseurs", force: :cascade do |t| + t.string "name", limit: 255 + t.string "code", limit: 255 + t.string "address1", limit: 255 + t.string "address2", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "email", limit: 255 + t.string "tel", limit: 255 + t.string "compta_account", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_grades", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "grade" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_grades", force: :cascade do |t| + t.string "grade", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_nutris", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_nutris", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "public", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_origines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_origines", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "public", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_payment_documents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_payment_documents", force: :cascade do |t| t.bigint "p_payment_id" t.bigint "p_document_id" t.decimal "amount", precision: 14, scale: 2 t.boolean "paid", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "price_document_id" - t.integer "avoir_id" - t.index ["p_document_id"], name: "index_p_payment_documents_on_p_document_id" - t.index ["p_payment_id"], name: "index_p_payment_documents_on_p_payment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "price_document_id" + t.bigint "avoir_id" + t.index ["p_document_id"], name: "idx_55402_index_p_payment_documents_on_p_document_id" + t.index ["p_payment_id"], name: "idx_55402_index_p_payment_documents_on_p_payment_id" end - create_table "p_payment_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "code" + create_table "p_payment_types", force: :cascade do |t| + t.string "name", limit: 255 + t.string "code", limit: 255 t.boolean "enabled", default: false t.boolean "comptant", default: false - t.integer "signe" + t.bigint "signe" t.bigint "p_bank_account_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_bank_account_id"], name: "index_p_payment_types_on_p_bank_account_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_bank_account_id"], name: "idx_55410_index_p_payment_types_on_p_bank_account_id" end - create_table "p_payments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_payments", force: :cascade do |t| t.datetime "paid_at" t.datetime "theo_date" t.bigint "p_payment_type_id" t.decimal "amount", precision: 14, scale: 2 - t.string "number" + t.string "number", limit: 255 t.bigint "p_customer_id" t.boolean "paid", default: false t.boolean "canceled", default: false @@ -1523,8 +1526,8 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.bigint "p_ship_tour_truck_sheet_line_id" t.bigint "p_sheet_line_id" t.boolean "imported", default: false - t.string "label" - t.string "piece" + t.string "label", limit: 255 + t.string "piece", limit: 255 t.boolean "i_archive", default: false t.boolean "remise", default: false t.bigint "p_remise_id" @@ -1535,62 +1538,62 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.date "past_theo_date" t.boolean "past_diff", default: false t.bigint "p_bank_account_id" - t.integer "p_compta_export_id" + t.bigint "p_compta_export_id" t.boolean "compta_locked", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.decimal "cc_total_affected", precision: 14, scale: 2 t.decimal "ac_total_affected", precision: 14, scale: 2 t.decimal "cc_reste_to_affect", precision: 14, scale: 2 t.decimal "ac_reste_to_affect", precision: 14, scale: 2 t.boolean "cc_affected", default: false t.boolean "ac_affected", default: false - t.integer "price_document_id" - t.index ["p_bank_account_id"], name: "index_p_payments_on_p_bank_account_id" - t.index ["p_customer_id"], name: "index_p_payments_on_p_customer_id" - t.index ["p_payment_type_id"], name: "index_p_payments_on_p_payment_type_id" - t.index ["p_remise_id"], name: "index_p_payments_on_p_remise_id" - t.index ["p_sheet_line_id"], name: "index_p_payments_on_p_sheet_line_id" - t.index ["p_ship_tour_truck_sheet_line_id"], name: "index_p_payments_on_p_ship_tour_truck_sheet_line_id" + t.bigint "price_document_id" + t.index ["p_bank_account_id"], name: "idx_55373_index_p_payments_on_p_bank_account_id" + t.index ["p_customer_id"], name: "idx_55373_index_p_payments_on_p_customer_id" + t.index ["p_payment_type_id"], name: "idx_55373_index_p_payments_on_p_payment_type_id" + t.index ["p_remise_id"], name: "idx_55373_index_p_payments_on_p_remise_id" + t.index ["p_sheet_line_id"], name: "idx_55373_index_p_payments_on_p_sheet_line_id" + t.index ["p_ship_tour_truck_sheet_line_id"], name: "idx_55373_index_p_payments_on_p_ship_tour_truck_sheet_line_id" end - create_table "p_price_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_price_cats", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "enabled", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_aromes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_aromes", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_arome_id" t.decimal "qte", precision: 6, scale: 2 - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_arome_id"], name: "index_p_product_aromes_on_p_arome_id" - t.index ["p_product_id"], name: "index_p_product_aromes_on_p_product_id" + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_arome_id"], name: "idx_55478_index_p_product_aromes_on_p_arome_id" + t.index ["p_product_id"], name: "idx_55478_index_p_product_aromes_on_p_product_id" end - create_table "p_product_assembleds", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "parent_product_ref_id" - t.integer "p_product_ref_id" + create_table "p_product_assembleds", force: :cascade do |t| + t.bigint "parent_product_ref_id" + t.bigint "p_product_ref_id" t.decimal "qte", precision: 10 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_brut_products", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_brut_products", force: :cascade do |t| t.bigint "p_brut_product_id" t.bigint "p_product_id" t.decimal "qte", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_brut_product_id"], name: "index_p_product_brut_products_on_p_brut_product_id" - t.index ["p_product_id"], name: "index_p_product_brut_products_on_p_product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_brut_product_id"], name: "idx_55492_index_p_product_brut_products_on_p_brut_product_id" + t.index ["p_product_id"], name: "idx_55492_index_p_product_brut_products_on_p_product_id" end - create_table "p_product_brut_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_brut_stocks", force: :cascade do |t| t.bigint "p_brut_product_id" t.bigint "p_fournisseur_order_id" t.bigint "p_tank_id" @@ -1604,312 +1607,312 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.boolean "ok", default: false t.decimal "qte_restant", precision: 14, scale: 2, default: "0.0" t.boolean "lock", default: false - t.string "stock_type" + t.string "stock_type", limit: 255 t.boolean "externe", default: false t.boolean "comptabilised", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_brut_product_id"], name: "index_p_product_brut_stocks_on_p_brut_product_id" - t.index ["p_fournisseur_order_id"], name: "index_p_product_brut_stocks_on_p_fournisseur_order_id" - t.index ["p_tank_id"], name: "index_p_product_brut_stocks_on_p_tank_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_brut_product_id"], name: "idx_55499_index_p_product_brut_stocks_on_p_brut_product_id" + t.index ["p_fournisseur_order_id"], name: "idx_55499_index_p_product_brut_stocks_on_p_fournisseur_order_id" + t.index ["p_tank_id"], name: "idx_55499_index_p_product_brut_stocks_on_p_tank_id" end - create_table "p_product_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "code" - t.string "purchase_account" - t.string "sale_account" - t.integer "parent_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_product_cats", force: :cascade do |t| + t.string "name", limit: 255 + t.string "code", limit: 255 + t.string "purchase_account", limit: 255 + t.string "sale_account", limit: 255 + t.bigint "parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "stocked", default: true t.boolean "commercial_show", default: true end - create_table "p_product_colors", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "color" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_product_colors", force: :cascade do |t| + t.string "name", limit: 255 + t.string "color", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_feature_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_product_feature_cats", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.boolean "enabled" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_features", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "p_product_feature_cat_id" - t.string "ac_name" - t.string "cc_name" - t.string "value" - t.integer "p_product_ref_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_product_features", force: :cascade do |t| + t.bigint "p_product_feature_cat_id" + t.string "ac_name", limit: 255 + t.string "cc_name", limit: 255 + t.string "value", limit: 255 + t.bigint "p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_images", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "description" + create_table "p_product_images", force: :cascade do |t| + t.string "name", limit: 255 + t.string "description", limit: 255 t.bigint "p_product_id" t.bigint "p_product_ref_id" t.boolean "enabled", default: true - t.integer "position" + t.bigint "position" t.bigint "image_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["image_file_id"], name: "index_p_product_images_on_image_file_id" - t.index ["p_product_id"], name: "index_p_product_images_on_p_product_id" - t.index ["p_product_ref_id"], name: "index_p_product_images_on_p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["image_file_id"], name: "idx_55565_index_p_product_images_on_image_file_id" + t.index ["p_product_id"], name: "idx_55565_index_p_product_images_on_p_product_id" + t.index ["p_product_ref_id"], name: "idx_55565_index_p_product_images_on_p_product_ref_id" end - create_table "p_product_ingredients", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "p_product_id" - t.integer "ingredient_id" + create_table "p_product_ingredients", force: :cascade do |t| + t.bigint "p_product_id" + t.bigint "ingredient_id" t.decimal "qte", precision: 6, scale: 2 - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_nutris", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_nutris", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_nutri_id" t.decimal "qte", precision: 6, scale: 2 t.decimal "ar", precision: 6, scale: 2 - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_nutri_id"], name: "index_p_product_nutris_on_p_nutri_id" - t.index ["p_product_id"], name: "index_p_product_nutris_on_p_product_id" + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_nutri_id"], name: "idx_55584_index_p_product_nutris_on_p_nutri_id" + t.index ["p_product_id"], name: "idx_55584_index_p_product_nutris_on_p_product_id" end - create_table "p_product_origines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_origines", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_origine_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_origine_id"], name: "index_p_product_origines_on_p_origine_id" - t.index ["p_product_id"], name: "index_p_product_origines_on_p_product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_origine_id"], name: "idx_55592_index_p_product_origines_on_p_origine_id" + t.index ["p_product_id"], name: "idx_55592_index_p_product_origines_on_p_product_id" end - create_table "p_product_p_customer_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_p_customer_cats", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_customer_cat_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_customer_cat_id"], name: "index_p_product_p_customer_cats_on_p_customer_cat_id" - t.index ["p_product_id"], name: "index_p_product_p_customer_cats_on_p_product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_customer_cat_id"], name: "idx_55613_index_p_product_p_customer_cats_on_p_customer_cat_id" + t.index ["p_product_id"], name: "idx_55613_index_p_product_p_customer_cats_on_p_product_id" end - create_table "p_product_p_normes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_p_normes", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_product_spec_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_product_id"], name: "index_p_product_p_normes_on_p_product_id" - t.index ["p_product_spec_id"], name: "index_p_product_p_normes_on_p_product_spec_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_product_id"], name: "idx_55619_index_p_product_p_normes_on_p_product_id" + t.index ["p_product_spec_id"], name: "idx_55619_index_p_product_p_normes_on_p_product_spec_id" end - create_table "p_product_p_product_sub_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_p_product_sub_cats", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_product_sub_cat_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_product_id"], name: "index_p_product_p_product_sub_cats_on_p_product_id" - t.index ["p_product_sub_cat_id"], name: "index_p_product_p_product_sub_cats_on_p_product_sub_cat_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_product_id"], name: "idx_55625_index_p_product_p_product_sub_cats_on_p_product_id" + t.index ["p_product_sub_cat_id"], name: "idx_55625_index_p_product_p_product_sub_cats_on_p_product_sub_c" end - create_table "p_product_powers", 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 + create_table "p_product_powers", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_product_prices", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_prices", force: :cascade do |t| t.boolean "enabled", default: true t.bigint "p_product_ref_id" t.bigint "p_price_cat_id" - t.integer "min" - t.integer "max" + t.bigint "min" + t.bigint "max" t.decimal "ct_price_ht", precision: 14, scale: 2 - t.integer "past_p_product_price" + t.bigint "past_p_product_price" t.datetime "remove_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_price_cat_id"], name: "index_p_product_prices_on_p_price_cat_id" - t.index ["p_product_ref_id"], name: "index_p_product_prices_on_p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_price_cat_id"], name: "idx_55605_index_p_product_prices_on_p_price_cat_id" + t.index ["p_product_ref_id"], name: "idx_55605_index_p_product_prices_on_p_product_ref_id" end - create_table "p_product_ref_price_histories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_ref_price_histories", force: :cascade do |t| t.bigint "p_product_ref_id" t.decimal "price", precision: 14, scale: 2 t.bigint "admin_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_p_product_ref_price_histories_on_admin_id" - t.index ["p_product_ref_id"], name: "index_p_product_ref_price_histories_on_p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_55658_index_p_product_ref_price_histories_on_admin_id" + t.index ["p_product_ref_id"], name: "idx_55658_index_p_product_ref_price_histories_on_p_product_ref_" end - create_table "p_product_ref_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_ref_specs", force: :cascade do |t| t.bigint "p_product_ref_id" t.bigint "p_spec_type_id" t.bigint "p_spec_value_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_product_ref_id"], name: "index_p_product_ref_specs_on_p_product_ref_id" - t.index ["p_spec_type_id"], name: "index_p_product_ref_specs_on_p_spec_type_id" - t.index ["p_spec_value_id"], name: "index_p_product_ref_specs_on_p_spec_value_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_product_ref_id"], name: "idx_55665_index_p_product_ref_specs_on_p_product_ref_id" + t.index ["p_spec_type_id"], name: "idx_55665_index_p_product_ref_specs_on_p_spec_type_id" + t.index ["p_spec_value_id"], name: "idx_55665_index_p_product_ref_specs_on_p_spec_value_id" end - create_table "p_product_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "ref" - t.integer "p_product_id" + create_table "p_product_refs", force: :cascade do |t| + t.string "ref", limit: 255 + t.bigint "p_product_id" t.decimal "ct_price_ht", precision: 14, scale: 2 - t.string "cc_name" - t.string "ac_name" + t.string "cc_name", limit: 255 + t.string "ac_name", limit: 255 t.decimal "weight", precision: 14, scale: 2 - t.string "ct_sub_name" - t.integer "cc_p_product_cat_id" - t.integer "ac_p_product_cat_id" - t.string "uv" - t.string "capacite" - t.string "cc_sub_cat_names" - t.string "ac_sub_cat_names" - t.string "cc_cat_name" - t.string "ac_cat_name" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "ct_sub_name", limit: 255 + t.bigint "cc_p_product_cat_id" + t.bigint "ac_p_product_cat_id" + t.string "uv", limit: 255 + t.string "capacite", limit: 255 + t.string "cc_sub_cat_names", limit: 255 + t.string "ac_sub_cat_names", limit: 255 + t.string "cc_cat_name", limit: 255 + t.string "ac_cat_name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "no_remise", default: false t.boolean "assembled", default: false t.boolean "promo", default: false t.date "start_at" t.date "end_at" - t.string "cc_code" - t.string "ac_code" + t.string "cc_code", limit: 255 + t.string "ac_code", limit: 255 t.boolean "stocked", default: true t.text "description" - t.integer "p_product_color_id" + t.bigint "p_product_color_id" end - create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_specs", force: :cascade do |t| t.bigint "p_product_id" - t.string "code" + t.string "code", limit: 255 t.text "description" t.boolean "un", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_product_id"], name: "index_p_product_specs_on_p_product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_product_id"], name: "idx_55671_index_p_product_specs_on_p_product_id" end - create_table "p_product_sub_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "parent_id" - t.string "code" - t.string "name" - t.integer "position" + create_table "p_product_sub_cats", force: :cascade do |t| + t.bigint "parent_id" + t.string "code", limit: 255 + t.string "name", limit: 255 + t.bigint "position" t.boolean "enabled" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "menu", default: false end - create_table "p_product_utilisations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_product_utilisations", force: :cascade do |t| t.bigint "p_product_id" t.bigint "p_utilisation_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_product_id"], name: "index_p_product_utilisations_on_p_product_id" - t.index ["p_utilisation_id"], name: "index_p_product_utilisations_on_p_utilisation_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_product_id"], name: "idx_55694_index_p_product_utilisations_on_p_product_id" + t.index ["p_utilisation_id"], name: "idx_55694_index_p_product_utilisations_on_p_utilisation_id" end - create_table "p_product_zones", 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 + create_table "p_product_zones", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_products", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_products", force: :cascade do |t| + t.string "name", limit: 255 t.decimal "ct_price_ht", precision: 14, scale: 2 t.decimal "ct_purchase_price_ht", precision: 14, scale: 2 t.bigint "p_product_cat_id" - t.string "code" - t.string "sub_code" - t.string "conditionnement" - t.string "uv" + t.string "code", limit: 255 + t.string "sub_code", limit: 255 + t.string "conditionnement", limit: 255 + t.string "uv", limit: 255 t.boolean "tgap", default: false t.boolean "fisc", default: false - t.string "un" + t.string "un", limit: 255 t.decimal "capacite", precision: 14, scale: 2 t.boolean "enabled", default: true t.bigint "s_brand_id" t.boolean "discount_enrobage", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "p_customer_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "p_customer_id" t.boolean "imported", default: false t.text "note" - t.integer "a_code_tva" - t.string "price_calc", default: "Kg" - t.string "country" - t.string "sub_country" - t.string "domaine" - t.string "imp_sale_account" + t.bigint "a_code_tva" + t.string "price_calc", limit: 255, default: "Kg" + t.string "country", limit: 255 + t.string "sub_country", limit: 255 + t.string "domaine", limit: 255 + t.string "imp_sale_account", limit: 255 t.text "description" - t.integer "image_file_id" + t.bigint "image_file_id" t.decimal "fonte_min", precision: 6, scale: 2 t.decimal "fonte_max", precision: 6, scale: 2 t.decimal "cristal_min", precision: 6, scale: 2 t.decimal "cristal_max", precision: 6, scale: 2 t.decimal "travail_min", precision: 6, scale: 2 t.decimal "travail_max", precision: 6, scale: 2 - t.integer "intensite_cacao" - t.string "country_fabrication" + t.bigint "intensite_cacao" + t.string "country_fabrication", limit: 255 t.decimal "viscosite", precision: 6, scale: 2 t.text "utilisation_text" t.text "chapeau" t.boolean "grand_cru", default: false t.boolean "vegan", default: false t.boolean "public", default: false - t.string "visco_text" - t.string "finesse_text" + t.string "visco_text", limit: 255 + t.string "finesse_text", limit: 255 t.decimal "viscosite_min", precision: 6, scale: 2 t.decimal "viscosite_max", precision: 6, scale: 2 t.decimal "finesse_min", precision: 6, scale: 2 t.decimal "finesse_max", precision: 6, scale: 2 t.boolean "conserve_proportion", default: false t.boolean "frontpage", default: true - 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" + t.index ["p_product_cat_id"], name: "idx_55431_index_p_products_on_p_product_cat_id" + t.index ["s_brand_id"], name: "idx_55431_index_p_products_on_s_brand_id" end - create_table "p_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_remises", force: :cascade do |t| t.date "date" t.boolean "validated", default: false t.bigint "p_payment_type_id" t.bigint "p_bank_account_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_bank_account_id"], name: "index_p_remises_on_p_bank_account_id" - t.index ["p_payment_type_id"], name: "index_p_remises_on_p_payment_type_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_bank_account_id"], name: "idx_55707_index_p_remises_on_p_bank_account_id" + t.index ["p_payment_type_id"], name: "idx_55707_index_p_remises_on_p_payment_type_id" end - create_table "p_serial_num_types", 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 + create_table "p_serial_num_types", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_serial_num_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "value" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_serial_num_values", force: :cascade do |t| + t.string "value", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_sheet_line_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_sheet_line_stocks", force: :cascade do |t| t.bigint "p_sheet_line_id" t.bigint "p_brut_product_id" t.bigint "p_product_brut_stock_id" @@ -1921,14 +1924,14 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "price_ok", precision: 14, scale: 2 t.boolean "lock", default: false t.boolean "decr", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_brut_product_id"], name: "index_p_sheet_line_stocks_on_p_brut_product_id" - t.index ["p_product_brut_stock_id"], name: "index_p_sheet_line_stocks_on_p_product_brut_stock_id" - t.index ["p_sheet_line_id"], name: "index_p_sheet_line_stocks_on_p_sheet_line_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_brut_product_id"], name: "idx_55764_index_p_sheet_line_stocks_on_p_brut_product_id" + t.index ["p_product_brut_stock_id"], name: "idx_55764_index_p_sheet_line_stocks_on_p_product_brut_stock_id" + t.index ["p_sheet_line_id"], name: "idx_55764_index_p_sheet_line_stocks_on_p_sheet_line_id" end - create_table "p_sheet_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_sheet_lines", force: :cascade do |t| t.bigint "p_customer_sheet_id" t.bigint "p_product_id" t.bigint "p_tank_id" @@ -1941,333 +1944,342 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.boolean "ok", default: false t.boolean "lock", default: false t.boolean "externe", default: false - t.integer "externe_stock_id" + t.bigint "externe_stock_id" t.bigint "p_document_id" t.boolean "shiped", default: false t.boolean "bl", default: false t.boolean "ship", default: false - t.integer "p_ship_tour_truck_sheet_line_id" + t.bigint "p_ship_tour_truck_sheet_line_id" t.boolean "stock_done", default: false t.decimal "a_total_cost_ok", precision: 14, scale: 2 - t.string "ref" + t.string "ref", limit: 255 t.decimal "price_tot", precision: 14, scale: 2 t.decimal "price_tot_ttc", precision: 14, scale: 2 t.decimal "ok_price_tot", precision: 14, scale: 2 t.decimal "ok_price_tot_ttc", precision: 14, scale: 2 t.boolean "imported", default: false - t.string "piece" + t.string "piece", limit: 255 t.boolean "arrondi", default: false t.boolean "decr", default: false - t.string "custom_title" + t.string "custom_title", limit: 255 t.text "custom_desc" t.boolean "no_stock", default: false t.boolean "custom", default: false - t.string "element_label" + t.string "element_label", limit: 255 t.boolean "cancel", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_customer_sheet_id"], name: "index_p_sheet_lines_on_p_customer_sheet_id" - t.index ["p_document_id"], name: "index_p_sheet_lines_on_p_document_id" - t.index ["p_product_id"], name: "index_p_sheet_lines_on_p_product_id" - t.index ["p_tank_id"], name: "index_p_sheet_lines_on_p_tank_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_customer_sheet_id"], name: "idx_55728_index_p_sheet_lines_on_p_customer_sheet_id" + t.index ["p_document_id"], name: "idx_55728_index_p_sheet_lines_on_p_document_id" + t.index ["p_product_id"], name: "idx_55728_index_p_sheet_lines_on_p_product_id" + t.index ["p_tank_id"], name: "idx_55728_index_p_sheet_lines_on_p_tank_id" end - create_table "p_ship_bill_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_ship_bill_lines", force: :cascade do |t| t.bigint "p_ship_bill_id" - t.string "name" + t.string "name", limit: 255 t.text "description" t.decimal "qte", precision: 14, scale: 2 t.decimal "price", precision: 14, scale: 2 t.decimal "a_ok_total", precision: 14, scale: 2 t.boolean "paid", default: false t.date "paid_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_ship_bill_id"], name: "index_p_ship_bill_lines_on_p_ship_bill_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_ship_bill_id"], name: "idx_55788_index_p_ship_bill_lines_on_p_ship_bill_id" end - create_table "p_ship_bills", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_ship_bills", force: :cascade do |t| t.date "count_date" t.date "bill_at" - t.string "ref" + t.string "ref", limit: 255 t.bigint "p_fournisseur_id" t.text "comment" t.decimal "a_ok_total", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_fournisseur_id"], name: "index_p_ship_bills_on_p_fournisseur_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_fournisseur_id"], name: "idx_55777_index_p_ship_bills_on_p_fournisseur_id" end - create_table "p_spec_types", 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 + create_table "p_spec_types", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_spec_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "value" - t.string "unit" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "p_spec_values", force: :cascade do |t| + t.string "value", limit: 255 + t.string "unit", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "p_tank_stocks", force: :cascade do |t| t.datetime "ok_at" t.boolean "enabled", default: false t.bigint "p_brut_product_id" t.decimal "volume", precision: 14, scale: 2 t.decimal "price", precision: 14, scale: 2 t.bigint "p_tank_id" - t.string "stock_type" + t.string "stock_type", limit: 255 t.decimal "volume_abs", precision: 14, scale: 2 t.decimal "volume_restant", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_brut_product_id"], name: "index_p_tank_stocks_on_p_brut_product_id" - t.index ["p_tank_id"], name: "index_p_tank_stocks_on_p_tank_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_brut_product_id"], name: "idx_55828_index_p_tank_stocks_on_p_brut_product_id" + t.index ["p_tank_id"], name: "idx_55828_index_p_tank_stocks_on_p_tank_id" end - create_table "p_tanks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_tanks", force: :cascade do |t| + t.string "name", limit: 255 t.decimal "volume", precision: 14, scale: 2 t.bigint "p_brut_product_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_brut_product_id"], name: "index_p_tanks_on_p_brut_product_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_brut_product_id"], name: "idx_55820_index_p_tanks_on_p_brut_product_id" end - create_table "p_truck_spaces", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_truck_spaces", force: :cascade do |t| + t.string "name", limit: 255 t.decimal "volume", precision: 14, scale: 2 t.bigint "p_truck_id" - t.integer "default_p_tank_id" - t.string "code" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["p_truck_id"], name: "index_p_truck_spaces_on_p_truck_id" + t.bigint "default_p_tank_id" + t.string "code", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["p_truck_id"], name: "idx_55840_index_p_truck_spaces_on_p_truck_id" end - create_table "p_utilisations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "p_utilisations", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "public", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "pages", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "pages", force: :cascade do |t| t.text "title" t.text "description" t.text "keywords" - t.integer "lang_site_id" - t.integer "page_type_id", default: 1 + t.bigint "lang_site_id" + t.bigint "page_type_id", default: 1 t.boolean "clikable", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "particulars", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "particulars", force: :cascade do |t| t.boolean "pro", default: false - t.string "organisation" - t.string "name" - t.string "firstname" - t.string "address_1" - t.string "address_2" - t.string "address_3" - t.string "address_4" - t.string "address_5" - t.string "cp" - t.string "city" - t.string "country" - t.string "tel" - t.string "email" - t.string "tel2" - t.string "tel3" - t.string "fax" - t.string "owner_type" + t.string "organisation", limit: 255 + t.string "name", limit: 255 + t.string "firstname", limit: 255 + t.string "address_1", limit: 255 + t.string "address_2", limit: 255 + t.string "address_3", limit: 255 + t.string "address_4", limit: 255 + t.string "address_5", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "country", limit: 255 + t.string "tel", limit: 255 + t.string "email", limit: 255 + t.string "tel2", limit: 255 + t.string "tel3", limit: 255 + t.string "fax", limit: 255 + t.string "owner_type", limit: 255 t.bigint "owner_id" - t.string "particular_type" + t.string "particular_type", limit: 255 t.boolean "skip_validation", default: false - t.string "civilite" + t.string "civilite", limit: 255 t.boolean "archived", default: false - t.integer "particular_ref_id" + t.bigint "particular_ref_id" t.boolean "price_in_bl", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "com_name" - t.index ["owner_id"], name: "index_particulars_on_owner_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "com_name", limit: 255 + t.index ["owner_id"], name: "idx_54626_index_particulars_on_owner_id" end - create_table "partition_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "p_product_ref_from_id" - t.integer "p_product_ref_to_id" + create_table "partition_lines", force: :cascade do |t| + t.bigint "p_product_ref_from_id" + t.bigint "p_product_ref_to_id" t.bigint "partition_id" - t.integer "qte_from" - t.integer "qte_to" + t.bigint "qte_from" + t.bigint "qte_to" t.text "description" t.boolean "stock_ok", default: false t.decimal "amount", precision: 15, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["partition_id"], name: "index_partition_lines_on_partition_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["partition_id"], name: "idx_54670_index_partition_lines_on_partition_id" end - create_table "partitions", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "partitions", force: :cascade do |t| t.bigint "admin_id" t.date "date" t.text "description" t.boolean "stock_ok", default: false t.decimal "amount", precision: 15, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_partitions_on_admin_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_54659_index_partitions_on_admin_id" end - create_table "portlets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "pg_search_documents", force: :cascade do |t| + t.text "content" + t.string "searchable_type" + t.bigint "searchable_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["searchable_type", "searchable_id"], name: "index_pg_search_documents_on_searchable_type_and_searchable_id" + end + + create_table "portlets", force: :cascade do |t| t.bigint "block_id" t.bigint "content_id" - t.string "content_type" - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["block_id"], name: "index_portlets_on_block_id" - t.index ["content_id"], name: "index_portlets_on_content_id" + t.string "content_type", limit: 255 + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["block_id"], name: "idx_54681_index_portlets_on_block_id" + t.index ["content_id"], name: "idx_54681_index_portlets_on_content_id" end - create_table "price_document_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "prefix" - t.string "label" - t.string "affix" + create_table "price_document_types", force: :cascade do |t| + t.string "prefix", limit: 255 + t.string "label", limit: 255 + t.string "affix", limit: 255 t.text "header" t.text "footer" - t.integer "image_file_id" - t.integer "data_file_id" - t.string "class_type" - t.string "sub_type" + t.bigint "image_file_id" + t.bigint "data_file_id" + t.string "class_type", limit: 255 + t.string "sub_type", limit: 255 t.boolean "enabled", default: true - t.string "movement_type", default: "cred" + t.string "movement_type", limit: 255, default: "cred" t.boolean "accounting", default: false - t.integer "poisition" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "poisition" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "price_documents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "price_documents", force: :cascade do |t| t.boolean "archived" t.bigint "p_customer_id" - t.integer "p_commercial_id" - t.string "movement_type" + t.bigint "p_commercial_id" + t.string "movement_type", limit: 255 t.boolean "accounting", default: false t.boolean "soldable", default: false t.datetime "date" - t.integer "ac_accounting_zone_id" - t.integer "cc_accounting_zone_id" - t.string "ac_accounting_zone_name" - t.string "cc_accounting_zone_name" + t.bigint "ac_accounting_zone_id" + t.bigint "cc_accounting_zone_id" + t.string "ac_accounting_zone_name", limit: 255 + t.string "cc_accounting_zone_name", limit: 255 t.decimal "ac_tot_amount_ht", precision: 14, scale: 2 t.decimal "cc_tot_amount_ht", precision: 14, scale: 2 t.decimal "ac_tot_amount_ttc", precision: 14, scale: 2 t.decimal "cc_tot_amount_ttc", precision: 14, scale: 2 t.decimal "ac_tot_amount_tva", precision: 14, scale: 2 t.decimal "cc_tot_amount_tva", precision: 14, scale: 2 - t.string "d_number" - t.integer "d_index" - t.integer "d_year" - t.integer "d_month" - t.integer "d_day" - t.string "d_prefix" + t.string "d_number", limit: 255 + t.bigint "d_index" + t.bigint "d_year" + t.bigint "d_month" + t.bigint "d_day" + t.string "d_prefix", limit: 255 t.boolean "solded", default: false t.boolean "imported", default: false - t.string "ref_element_type" - t.integer "ref_element_id" - t.integer "price_document_type_id" - t.string "ac_label" - t.string "cc_label" - t.string "token" + t.string "ref_element_type", limit: 255 + t.bigint "ref_element_id" + t.bigint "price_document_type_id" + t.string "ac_label", limit: 255 + t.string "cc_label", limit: 255 + t.string "token", limit: 255 t.text "ct_header" t.text "ac_header" t.text "cc_header" t.text "ct_footer" t.text "ac_footer" t.text "cc_footer" - t.integer "ac_payment_days" - t.integer "cc_payment_days" + t.bigint "ac_payment_days" + t.bigint "cc_payment_days" t.datetime "paid_at" - t.integer "ct_payment_delais" - t.integer "ac_payment_delais" - t.integer "cc_payment_delais" + t.bigint "ct_payment_delais" + t.bigint "ac_payment_delais" + t.bigint "cc_payment_delais" t.boolean "ct_payment_month_end" t.boolean "ac_payment_month_end" t.boolean "cc_payment_month_end" t.date "ac_payment_end_at" t.date "cc_payment_end_at" - t.integer "doc_ref_id" + t.bigint "doc_ref_id" t.boolean "accounting_locked", default: false - t.integer "particular_bill_id" - t.integer "particular_send_id" - t.integer "ac_particular_bill_id" - t.integer "ac_particular_send_id" + t.bigint "particular_bill_id" + t.bigint "particular_send_id" + t.bigint "ac_particular_bill_id" + t.bigint "ac_particular_send_id" t.decimal "ac_to_paid_ht", precision: 14, scale: 2 t.decimal "cc_to_paid_ht", precision: 14, scale: 2 t.decimal "ac_to_paid_ttc", precision: 14, scale: 2 t.decimal "cc_to_paid_ttc", precision: 14, scale: 2 t.decimal "ac_to_paid_tva", precision: 14, scale: 2 t.decimal "cc_to_paid_tva", precision: 14, scale: 2 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "cc_solded" t.boolean "ac_solded" - t.integer "p_payment_type_id" + t.bigint "p_payment_type_id" t.boolean "compta_export", default: false t.boolean "compta_locked", default: false - t.integer "p_compta_export_id" + t.bigint "p_compta_export_id" t.decimal "ac_weight_tot", precision: 14, scale: 2 t.decimal "cc_weight_tot", precision: 14, scale: 2 t.boolean "price_blocked", default: false - t.integer "bon_de_commande_id" - t.integer "bon_de_livraison_id" - t.integer "facture_id" + t.bigint "bon_de_commande_id" + t.bigint "bon_de_livraison_id" + t.bigint "facture_id" t.boolean "reliquat" - t.integer "p_fournisseur_id" + t.bigint "p_fournisseur_id" t.boolean "cost_ok", default: false t.boolean "stock_ok", default: false - t.integer "p_devise_id", default: 1 + t.bigint "p_devise_id", default: 1 t.decimal "cc_cost_ht", precision: 14, scale: 2 t.decimal "cc_marge_ht", precision: 14, scale: 2 t.decimal "ac_cost_ht", precision: 14, scale: 2 t.decimal "ac_marge_ht", precision: 14, scale: 2 t.boolean "cancelled", default: false t.datetime "cc_solded_at" - t.integer "cc_solded_nbr_days" + t.bigint "cc_solded_nbr_days" t.datetime "ac_solded_at" - t.integer "ac_solded_nbr_days" - t.integer "order_hist_id" - t.string "statut" + t.bigint "ac_solded_nbr_days" + t.bigint "order_hist_id" + t.string "statut", limit: 255 t.decimal "avancement", precision: 10, scale: 2 t.boolean "ended", default: false t.text "list_designaton" t.date "end_date" t.text "dp_comment" t.date "eta_min" - t.string "f_token" + t.string "f_token", limit: 255 t.text "acheteur_text" - t.string "public_fournisseur_name" - t.index ["p_customer_id"], name: "index_price_documents_on_p_customer_id" + t.string "public_fournisseur_name", limit: 255 + t.index ["p_customer_id"], name: "idx_54688_index_price_documents_on_p_customer_id" end - create_table "price_line_blocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "price_line_blocks", force: :cascade do |t| t.bigint "p_customer_id" - t.integer "p_commercial_id" - t.integer "ac_p_customer_cat_id" - t.integer "cc_p_customer_cat_id" - t.integer "particular_bill_id" - t.integer "particular_send_id" - t.integer "ref_particular_bill_id" - t.integer "ref_particular_send_id" + t.bigint "p_commercial_id" + t.bigint "ac_p_customer_cat_id" + t.bigint "cc_p_customer_cat_id" + t.bigint "particular_bill_id" + t.bigint "particular_send_id" + t.bigint "ref_particular_bill_id" + t.bigint "ref_particular_send_id" t.boolean "archived" - t.string "movement_type", default: "cred" + t.string "movement_type", limit: 255, default: "cred" t.boolean "accounting", default: false - t.integer "price_lineable_id" - t.string "price_lineable_type" + t.bigint "price_lineable_id" + t.string "price_lineable_type", limit: 255 t.date "ct_creation_date" t.date "cc_creation_date" t.date "ac_creation_date" @@ -2277,14 +2289,14 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.boolean "cc_remise_ecole_ok" t.boolean "ac_remise_enrobage_ok" t.boolean "ac_remise_ecole_ok" - t.string "customer_ref" - t.integer "ct_nbr_ship" - t.integer "ac_nbr_ship" - t.integer "cc_nbr_ship" - t.integer "ac_accounting_zone_id" - t.integer "cc_accounting_zone_id" - t.string "ac_accounting_zone_name" - t.string "cc_accounting_zone_name" + t.string "customer_ref", limit: 255 + t.bigint "ct_nbr_ship" + t.bigint "ac_nbr_ship" + t.bigint "cc_nbr_ship" + t.bigint "ac_accounting_zone_id" + t.bigint "cc_accounting_zone_id" + t.string "ac_accounting_zone_name", limit: 255 + t.string "cc_accounting_zone_name", limit: 255 t.decimal "ac_tot_lines_ht", precision: 14, scale: 2 t.decimal "cc_tot_lines_ht", precision: 14, scale: 2 t.decimal "ac_tot_lines_tva", precision: 14, scale: 2 @@ -2332,13 +2344,13 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cc_tot_amount_ttc", precision: 14, scale: 2 t.decimal "ac_weight_tot", precision: 14, scale: 2 t.decimal "cc_weight_tot", precision: 14, scale: 2 - t.integer "p_payment_type_id" + t.bigint "p_payment_type_id" t.boolean "ct_payment_comptant" t.boolean "ac_payment_comptant" t.boolean "cc_payment_comptant" - t.integer "ct_payment_delais" - t.integer "ac_payment_delais" - t.integer "cc_payment_delais" + t.bigint "ct_payment_delais" + t.bigint "ac_payment_delais" + t.bigint "cc_payment_delais" t.boolean "ct_payment_month_end" t.boolean "ac_payment_month_end" t.boolean "cc_payment_month_end" @@ -2350,10 +2362,10 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "ct_acompte_percent", precision: 14, scale: 2 t.decimal "ac_acompte_percent", precision: 14, scale: 2 t.decimal "cc_acompte_percent", precision: 14, scale: 2 - t.integer "ac_payment_days" - t.integer "cc_payment_days" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "ac_payment_days" + t.bigint "cc_payment_days" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "bl_comment" t.text "f_comment" t.text "bc_comment" @@ -2366,25 +2378,25 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.boolean "cc_discount_comptant" t.boolean "ac_discount_comptant" t.boolean "price_blocked", default: false - t.string "ac_block_type" - t.string "cc_block_type" + t.string "ac_block_type", limit: 255 + t.string "cc_block_type", limit: 255 t.decimal "cc_customer_market_discount_percent", precision: 14, scale: 2 t.decimal "ac_customer_market_discount_percent", precision: 14, scale: 2 - t.integer "ac_bon_de_commande_id" - t.integer "cc_bon_de_commande_id" - t.integer "ac_bon_de_livraison_id" - t.integer "cc_bon_de_livraison_id" - t.integer "ac_facture_id" - t.integer "cc_facture_id" + t.bigint "ac_bon_de_commande_id" + t.bigint "cc_bon_de_commande_id" + t.bigint "ac_bon_de_livraison_id" + t.bigint "cc_bon_de_livraison_id" + t.bigint "ac_facture_id" + t.bigint "cc_facture_id" t.boolean "ac_reliquat" t.boolean "cc_reliquat" t.decimal "bk_tot_fdp_ht", precision: 14, scale: 2 t.decimal "reliquat_fdp_ht", precision: 14, scale: 2 - t.integer "p_devise_id", default: 1 + t.bigint "p_devise_id", default: 1 t.decimal "cc_devise_rate", precision: 14, scale: 7, default: "1.0" t.decimal "ac_devise_rate", precision: 14, scale: 7 - t.integer "local_amount_ttc" - t.integer "p_fournisseur_id" + t.bigint "local_amount_ttc" + t.bigint "p_fournisseur_id" t.boolean "cost_ok", default: false t.boolean "stock_ok", default: false t.decimal "cc_cost_ht", precision: 14, scale: 2 @@ -2393,45 +2405,45 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "ac_marge_ht", precision: 14, scale: 2 t.boolean "cancelled", default: false t.datetime "cc_solded_at" - t.integer "cc_solded_nbr_days" + t.bigint "cc_solded_nbr_days" t.datetime "ac_solded_at" - t.integer "ac_solded_nbr_days" - t.integer "order_hist_id" + t.bigint "ac_solded_nbr_days" + t.bigint "order_hist_id" t.boolean "imported", default: false t.date "validation_date" - t.string "cc_state" - t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id" + t.string "cc_state", limit: 255 + t.index ["p_customer_id"], name: "idx_54863_index_price_line_blocks_on_p_customer_id" end - create_table "price_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "price_lines", force: :cascade do |t| t.boolean "archived" - t.integer "price_line_block_id" - t.integer "position" - t.string "line_type" - t.integer "ac_accounting_zone_id" - t.integer "cc_accounting_zone_id" - t.string "ac_accounting_zone_name" - t.string "cc_accounting_zone_name" - t.integer "ac_tva_account_id" - t.integer "cc_tva_account_id" + t.bigint "price_line_block_id" + t.bigint "position" + t.string "line_type", limit: 255 + t.bigint "ac_accounting_zone_id" + t.bigint "cc_accounting_zone_id" + t.string "ac_accounting_zone_name", limit: 255 + t.string "cc_accounting_zone_name", limit: 255 + t.bigint "ac_tva_account_id" + t.bigint "cc_tva_account_id" t.decimal "ac_tva_account_value", precision: 5, scale: 2 t.decimal "cc_tva_account_value", precision: 5, scale: 2 - t.integer "p_product_id" - t.integer "p_product_variante_id" - t.integer "p_product_alt_id" - t.integer "p_product_alt_variante_id" - t.integer "p_product_ref_id" - t.integer "p_product_ref_variante_id" - t.string "ct_ref" - t.string "ac_ref" - t.string "cc_ref" - t.string "ct_title" - t.string "ac_title" - t.string "cc_title" + t.bigint "p_product_id" + t.bigint "p_product_variante_id" + t.bigint "p_product_alt_id" + t.bigint "p_product_alt_variante_id" + t.bigint "p_product_ref_id" + t.bigint "p_product_ref_variante_id" + t.string "ct_ref", limit: 255 + t.string "ac_ref", limit: 255 + t.string "cc_ref", limit: 255 + t.string "ct_title", limit: 255 + t.string "ac_title", limit: 255 + t.string "cc_title", limit: 255 t.boolean "ac_product_remise_enrobage_ok" t.boolean "cc_product_remise_enrobage_ok" - t.string "ac_uv" - t.string "cc_uv" + t.string "ac_uv", limit: 255 + t.string "cc_uv", limit: 255 t.text "ct_description" t.text "ac_description" t.text "cc_description" @@ -2485,27 +2497,27 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cc_tot_amount_tva", precision: 15, scale: 3 t.decimal "ac_tot_amount_ttc", precision: 15, scale: 3 t.decimal "cc_tot_amount_ttc", precision: 15, scale: 3 - t.integer "p_cter_id" + t.bigint "p_cter_id" t.decimal "ct_weight_u", precision: 15, scale: 3 t.decimal "ac_weight_u", precision: 15, scale: 3 t.decimal "cc_weight_u", precision: 15, scale: 3 t.decimal "ac_weight_tot", precision: 15, scale: 3 t.decimal "cc_weight_tot", precision: 15, scale: 3 - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "cc_p_product_specific_customer_id" - t.integer "ac_p_product_specific_customer_id" - t.string "ac_price_calc" - t.string "cc_price_calc" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "cc_p_product_specific_customer_id" + t.bigint "ac_p_product_specific_customer_id" + t.string "ac_price_calc", limit: 255 + t.string "cc_price_calc", limit: 255 t.boolean "cc_product_no_remise", default: false t.boolean "ac_product_no_remise" - t.integer "ct_tva_account_id" + t.bigint "ct_tva_account_id" t.decimal "bk_price_ht", precision: 14, scale: 4 - t.string "ac_block_type" - t.string "cc_block_type" - t.integer "price_line_ref_id" - t.integer "cc_p_devise_id" - t.integer "ac_p_devise_id" + t.string "ac_block_type", limit: 255 + t.string "cc_block_type", limit: 255 + t.bigint "price_line_ref_id" + t.bigint "cc_p_devise_id" + t.bigint "ac_p_devise_id" t.decimal "cc_devise_rate", precision: 14, scale: 7, default: "1.0" t.decimal "ac_devise_rate", precision: 14, scale: 7 t.decimal "cc_local_tot_amount_ht", precision: 15, scale: 3 @@ -2521,198 +2533,198 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "ct_tot_amount_ht", precision: 16, scale: 4 t.boolean "cancelled", default: false t.date "dluo" - t.string "lot" - t.integer "ac_p_product_cat_id" - t.integer "ac_p_customer_id" - t.integer "cc_p_product_cat_id" - t.integer "cc_p_customer_id" - t.integer "order_hist_id" + t.string "lot", limit: 255 + t.bigint "ac_p_product_cat_id" + t.bigint "ac_p_customer_id" + t.bigint "cc_p_product_cat_id" + t.bigint "cc_p_customer_id" + t.bigint "order_hist_id" t.boolean "imported", default: false t.decimal "ct_cost_ht", precision: 15, scale: 3 t.text "comment" t.date "cc_validation_date" t.date "cc_creation_date" t.date "cc_wish_date" - t.string "cc_state" + t.string "cc_state", limit: 255 t.decimal "qte_available", precision: 10 - t.string "ref_fournisseur" - t.integer "p_product_power_id" - t.integer "p_product_zone_id" + t.string "ref_fournisseur", limit: 255 + t.bigint "p_product_power_id" + t.bigint "p_product_zone_id" t.boolean "ready_stock" - t.string "ram" - t.string "ram_unit" + t.string "ram", limit: 255 + t.string "ram_unit", limit: 255 t.boolean "eu" t.boolean "fullkit" t.boolean "lang_start" - t.integer "selected_price_line_id" + t.bigint "selected_price_line_id" end - create_table "quote_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "quote_contents", force: :cascade do |t| t.text "quote" - t.string "author" - t.string "color" - t.string "background" - t.string "style" + t.string "author", limit: 255 + t.string "color", limit: 255 + t.string "background", limit: 255 + t.string "style", limit: 255 t.bigint "image_file_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["image_file_id"], name: "index_quote_contents_on_image_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["image_file_id"], name: "idx_55860_index_quote_contents_on_image_file_id" end - create_table "s_brands", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "s_brands", force: :cascade do |t| t.boolean "enabled", default: true - t.string "code" - t.string "name" + t.string "code", limit: 255 + t.string "name", limit: 255 t.text "description" - t.string "url" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "url", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_compta_accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "code" - t.string "name" - t.string "i_account" - t.string "i_sale_account" - t.string "i_account_ps" - t.string "zone" - t.string "purchase_account" - t.string "sale_account" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "s_compta_accounts", force: :cascade do |t| + t.string "code", limit: 255 + t.string "name", limit: 255 + t.string "i_account", limit: 255 + t.string "i_sale_account", limit: 255 + t.string "i_account_ps", limit: 255 + t.string "zone", limit: 255 + t.string "purchase_account", limit: 255 + t.string "sale_account", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_module_configurations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "s_module_configurations", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_modules", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "serial_nbr" - t.string "cache_long_serial_number" + create_table "s_modules", force: :cascade do |t| + t.bigint "serial_nbr" + t.string "cache_long_serial_number", limit: 255 t.bigint "s_modules_state_id" t.date "order_date" t.date "production_start_date" t.date "production_end_date" t.bigint "s_module_configuration_id" t.bigint "s_site_id" - t.string "name" + t.string "name", limit: 255 t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["s_module_configuration_id"], name: "index_s_modules_on_s_module_configuration_id" - t.index ["s_modules_state_id"], name: "index_s_modules_on_s_modules_state_id" - t.index ["s_site_id"], name: "index_s_modules_on_s_site_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["s_module_configuration_id"], name: "idx_56073_index_s_modules_on_s_module_configuration_id" + t.index ["s_modules_state_id"], name: "idx_56073_index_s_modules_on_s_modules_state_id" + t.index ["s_site_id"], name: "idx_56073_index_s_modules_on_s_site_id" end - create_table "s_modules_states", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "s_modules_states", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_organisations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "address1" - t.string "address2" - t.string "address3" - t.string "tel" - t.string "fax" - t.string "email" - t.string "website" - t.string "siret" - t.string "siren" - t.string "rcs" - t.string "ape" - t.string "capital" - t.string "forme" + create_table "s_organisations", force: :cascade do |t| + t.string "name", limit: 255 + t.string "address1", limit: 255 + t.string "address2", limit: 255 + t.string "address3", limit: 255 + t.string "tel", limit: 255 + t.string "fax", limit: 255 + t.string "email", limit: 255 + t.string "website", limit: 255 + t.string "siret", limit: 255 + t.string "siren", limit: 255 + t.string "rcs", limit: 255 + t.string "ape", limit: 255 + t.string "capital", limit: 255 + t.string "forme", limit: 255 t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_site_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "s_site_types", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "s_sites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "s_sites", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.boolean "externe" t.bigint "s_site_type_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["s_site_type_id"], name: "index_s_sites_on_s_site_type_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["s_site_type_id"], name: "idx_56128_index_s_sites_on_s_site_type_id" end - create_table "share_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "url" - t.string "facebook_url" + create_table "share_contents", force: :cascade do |t| + t.string "url", limit: 255 + t.string "facebook_url", limit: 255 t.boolean "facebook", default: false - t.string "twitter_url" - t.string "twitter_title" + t.string "twitter_url", limit: 255 + t.string "twitter_title", limit: 255 t.boolean "twitter", default: false - t.string "mail_subject" - t.string "mail_url" + t.string "mail_subject", limit: 255 + t.string "mail_url", limit: 255 t.text "mail_content" t.boolean "mail", default: false - t.string "print_url" + t.string "print_url", limit: 255 t.boolean "print", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "societes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "socmanaginn" - t.string "nom" - t.string "adresse1" - t.string "adresse2" - t.string "codepostal" - t.string "ville" - t.string "pays" - t.string "numtel" - t.string "numfax" - t.string "mobile" - t.string "mail" - t.string "mailcc" - t.string "mailbcc" - t.string "siteweb" - t.string "statut" - t.string "rc" - t.string "naf" - t.string "soc_type" - t.string "enseigne" + create_table "societes", force: :cascade do |t| + t.string "socmanaginn", limit: 255 + t.string "nom", limit: 255 + t.string "adresse1", limit: 255 + t.string "adresse2", limit: 255 + t.string "codepostal", limit: 255 + t.string "ville", limit: 255 + t.string "pays", limit: 255 + t.string "numtel", limit: 255 + t.string "numfax", limit: 255 + t.string "mobile", limit: 255 + t.string "mail", limit: 255 + t.string "mailcc", limit: 255 + t.string "mailbcc", limit: 255 + t.string "siteweb", limit: 255 + t.string "statut", limit: 255 + t.string "rc", limit: 255 + t.string "naf", limit: 255 + t.string "soc_type", limit: 255 + t.string "enseigne", limit: 255 t.datetime "datecreation" - t.string "activite1" - t.string "activite2" - t.string "activite3" - t.string "activite4" - t.string "activite5" - t.string "login" - t.string "password" - t.string "photo" - t.string "typeuser" - t.string "codeproprietaire" - t.string "typepartage" - t.string "libre1" - t.string "libre2" - t.string "libre3" - t.string "libre4" - t.string "libre5" - t.string "accesbloque" - t.string "corbeille" - t.string "codetpe" - t.string "codecreateur" - t.string "partagedefaut" - t.string "npai" - t.string "npaimail" - t.string "npaisms" + t.string "activite1", limit: 255 + t.string "activite2", limit: 255 + t.string "activite3", limit: 255 + t.string "activite4", limit: 255 + t.string "activite5", limit: 255 + t.string "login", limit: 255 + t.string "password", limit: 255 + t.string "photo", limit: 255 + t.string "typeuser", limit: 255 + t.string "codeproprietaire", limit: 255 + t.string "typepartage", limit: 255 + t.string "libre1", limit: 255 + t.string "libre2", limit: 255 + t.string "libre3", limit: 255 + t.string "libre4", limit: 255 + t.string "libre5", limit: 255 + t.string "accesbloque", limit: 255 + t.string "corbeille", limit: 255 + t.string "codetpe", limit: 255 + t.string "codecreateur", limit: 255 + t.string "partagedefaut", limit: 255 + t.string "npai", limit: 255 + t.string "npaimail", limit: 255 + t.string "npaisms", limit: 255 t.decimal "ac_rate", precision: 14, scale: 2 t.decimal "cc_rate", precision: 14, scale: 2 t.decimal "ac_cagnotte", precision: 14, scale: 2 @@ -2721,35 +2733,35 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cc_cumul", precision: 14, scale: 2 t.boolean "enabled", default: false t.date "last_volume_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "bon_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "bon_type", limit: 255 t.decimal "seuil", precision: 14, scale: 2 t.decimal "remise_percent", precision: 14, scale: 2 t.decimal "bon_amount", precision: 14, scale: 2 - t.string "send_via" + t.string "send_via", limit: 255 t.decimal "cc_total", precision: 14, scale: 2 t.decimal "ac_total", precision: 14, scale: 2 t.decimal "cc_remise", precision: 14, scale: 2 t.decimal "ac_remise", precision: 14, scale: 2 end - create_table "specific_preferences", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "key" - t.string "value" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "specific_preferences", force: :cascade do |t| + t.string "key", limit: 255 + t.string "value", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "stat_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "stat_lines", force: :cascade do |t| t.bigint "p_product_id" - t.string "product_name" - t.string "product_code" + t.string "product_name", limit: 255 + t.string "product_code", limit: 255 t.bigint "p_product_ref_id" - t.string "p_product_ref_name" + t.string "p_product_ref_name", limit: 255 t.decimal "tva_rate", precision: 10, scale: 2 - t.integer "tva_account_id" - t.string "title" + t.bigint "tva_account_id" + t.string "title", limit: 255 t.decimal "price_u_ht", precision: 15, scale: 3 t.decimal "price_u_tva", precision: 15, scale: 3 t.decimal "price_u_ttc", precision: 15, scale: 3 @@ -2772,30 +2784,30 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cost_u_w_ht", precision: 15, scale: 3 t.decimal "marge_u_w_ht", precision: 15, scale: 3 t.bigint "p_commercial_id" - t.string "p_commercial_name" - t.string "p_commercial_code" + t.string "p_commercial_name", limit: 255 + t.string "p_commercial_code", limit: 255 t.bigint "p_product_cat_id" - t.string "p_product_cat_name" + t.string "p_product_cat_name", limit: 255 t.bigint "p_customer_id" - t.string "p_customer_name" - t.string "p_customer_code" + t.string "p_customer_name", limit: 255 + t.string "p_customer_code", limit: 255 t.date "date" - t.integer "price_document_id" - t.string "price_document_number" - t.integer "price_line_block_id" - t.integer "price_line_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "s_brand_id" - t.string "s_brand_name" - t.index ["p_commercial_id"], name: "index_stat_lines_on_p_commercial_id" - t.index ["p_customer_id"], name: "index_stat_lines_on_p_customer_id" - t.index ["p_product_cat_id"], name: "index_stat_lines_on_p_product_cat_id" - t.index ["p_product_id"], name: "index_stat_lines_on_p_product_id" - t.index ["p_product_ref_id"], name: "index_stat_lines_on_p_product_ref_id" + t.bigint "price_document_id" + t.string "price_document_number", limit: 255 + t.bigint "price_line_block_id" + t.bigint "price_line_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "s_brand_id" + t.string "s_brand_name", limit: 255 + t.index ["p_commercial_id"], name: "idx_55975_index_stat_lines_on_p_commercial_id" + t.index ["p_customer_id"], name: "idx_55975_index_stat_lines_on_p_customer_id" + t.index ["p_product_cat_id"], name: "idx_55975_index_stat_lines_on_p_product_cat_id" + t.index ["p_product_id"], name: "idx_55975_index_stat_lines_on_p_product_id" + t.index ["p_product_ref_id"], name: "idx_55975_index_stat_lines_on_p_product_ref_id" end - create_table "stock_movement_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "stock_movement_lines", force: :cascade do |t| t.bigint "stock_movement_id" t.decimal "ct_price_u_ht", precision: 14, scale: 2 t.decimal "cc_price_u_ht", precision: 14, scale: 2 @@ -2804,364 +2816,364 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.decimal "cc_tot_amount_ht", precision: 14, scale: 2 t.decimal "ac_tot_amount_ht", precision: 14, scale: 2 t.decimal "qte", precision: 14, scale: 2 - t.integer "p_product_ref_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "p_product_ref_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.date "dluo" - t.index ["stock_movement_id"], name: "index_stock_movement_lines_on_stock_movement_id" + t.index ["stock_movement_id"], name: "idx_56030_index_stock_movement_lines_on_stock_movement_id" end - create_table "stock_movements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "movement_type", default: "deb" + create_table "stock_movements", force: :cascade do |t| + t.string "movement_type", limit: 255, default: "deb" t.text "description" - t.integer "admin_id" + t.bigint "admin_id" t.date "date" t.decimal "cc_tot_amount_ht", precision: 14, scale: 2 t.decimal "ac_tot_amount_ht", precision: 14, scale: 2 t.boolean "stock_done", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "table_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "style" - t.integer "nbr_rows" - t.integer "nbr_cols" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "table_contents", force: :cascade do |t| + t.bigint "style" + t.bigint "nbr_rows" + t.bigint "nbr_cols" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "table_rows", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "position" - t.integer "style" + create_table "table_rows", force: :cascade do |t| + t.bigint "position" + t.bigint "style" t.bigint "table_content_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["table_content_id"], name: "index_table_rows_on_table_content_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["table_content_id"], name: "idx_56154_index_table_rows_on_table_content_id" end - create_table "tag_taggables", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "taggable_type" + create_table "tag_taggables", force: :cascade do |t| + t.string "taggable_type", limit: 255 t.bigint "taggable_id" t.bigint "tag_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["tag_id"], name: "index_tag_taggables_on_tag_id" - t.index ["taggable_id"], name: "index_tag_taggables_on_taggable_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["tag_id"], name: "idx_56173_index_tag_taggables_on_tag_id" + t.index ["taggable_id"], name: "idx_56173_index_tag_taggables_on_taggable_id" end - create_table "tags", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" - t.string "slug" - t.integer "parent_id" + create_table "tags", force: :cascade do |t| + t.string "name", limit: 255 + t.string "slug", limit: 255 + t.bigint "parent_id" t.boolean "public", default: false - t.string "taggable_type" + t.string "taggable_type", limit: 255 t.bigint "taggable_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["taggable_id"], name: "index_tags_on_taggable_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["taggable_id"], name: "idx_56160_index_tags_on_taggable_id" end - create_table "text_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "style" + create_table "text_contents", force: :cascade do |t| + t.string "style", limit: 255 t.text "content" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "timer_watchers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "element_type" - t.integer "element_id" - t.string "key" + create_table "timer_watchers", force: :cascade do |t| + t.string "element_type", limit: 255 + t.bigint "element_id" + t.string "key", limit: 255 t.bigint "admin_id" t.bigint "p_customer_id" - t.string "admin_space" + t.string "admin_space", limit: 255 t.datetime "end_at" - t.integer "time_ok" + t.bigint "time_ok" t.boolean "write_action" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["admin_id"], name: "index_timer_watchers_on_admin_id" - t.index ["p_customer_id"], name: "index_timer_watchers_on_p_customer_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["admin_id"], name: "idx_56190_index_timer_watchers_on_admin_id" + t.index ["p_customer_id"], name: "idx_56190_index_timer_watchers_on_p_customer_id" end - create_table "tiny_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "url" - t.string "slug" + create_table "tiny_urls", force: :cascade do |t| + t.string "url", limit: 255 + t.string "slug", limit: 255 t.text "description" t.datetime "start_at" t.datetime "stop_at" - t.integer "nbr_views" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "nbr_views" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "title_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "title_contents", force: :cascade do |t| t.text "content" - t.integer "level" - t.string "style" - t.string "alignement" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "level" + t.string "style", limit: 255 + t.string "alignement", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "translations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "locale" - t.string "key" + create_table "translations", force: :cascade do |t| + t.string "locale", limit: 255 + t.string "key", limit: 255 t.text "value" t.text "interpolations" t.boolean "is_proc", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "tva_rates", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "tva_rates", force: :cascade do |t| + t.string "name", limit: 255 t.text "description" t.bigint "accounting_zone_id" t.boolean "enabled", default: true t.decimal "rate", precision: 5, scale: 2 - t.string "purchase_account" - t.string "sale_account" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "sale_product_account" - t.index ["accounting_zone_id"], name: "index_tva_rates_on_accounting_zone_id" + t.string "purchase_account", limit: 255 + t.string "sale_account", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "sale_product_account", limit: 255 + t.index ["accounting_zone_id"], name: "idx_56243_index_tva_rates_on_accounting_zone_id" end - create_table "tvable_tva_rates", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.integer "tvable_id" - t.string "tvable_type" - t.integer "tva_rate_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + create_table "tvable_tva_rates", force: :cascade do |t| + t.bigint "tvable_id" + t.string "tvable_type", limit: 255 + t.bigint "tva_rate_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "v_bdas", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "token" + create_table "v_bdas", force: :cascade do |t| + t.string "token", limit: 255 t.date "date" t.decimal "amount", precision: 14, scale: 2 t.decimal "seuil", precision: 14, scale: 2 t.boolean "used", default: false t.date "end_at" t.bigint "volume_periodique_id" - t.integer "v_contact_id" - t.integer "societe_id" - t.integer "societe_use_id" + t.bigint "v_contact_id" + t.bigint "societe_id" + t.bigint "societe_use_id" t.text "comment" - t.string "bda_type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "send_via" + t.string "bda_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "send_via", limit: 255 t.boolean "sended" - t.string "email" - t.index ["volume_periodique_id"], name: "index_v_bdas_on_volume_periodique_id" + t.string "email", limit: 255 + t.index ["volume_periodique_id"], name: "idx_56332_index_v_bdas_on_volume_periodique_id" end - create_table "v_contacts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "codemanaginn" - t.string "nomgroupe" - t.string "societe" - t.string "civilite" - t.string "nom" - t.string "prenom" - t.string "titre" - t.string "mailto" - t.string "mailcc" - t.string "mailbcc" - t.string "numportable" - t.string "numtel" - t.string "numfax" - t.string "adresse1" - t.string "adresse2" - t.string "codepostal" - t.string "ville" - t.string "anniversaire" - t.string "pays" - t.string "photo" - t.string "login" - t.string "password" - t.string "typeuser" - t.string "commentaire" - t.string "codeproprietaire" - t.string "typepartage" - t.string "libre1" - t.string "libre2" - t.string "libre3" - t.string "libre4" - t.string "libre5" - t.string "accesbloque" - t.string "corbeille" - t.string "codecreateur" - t.string "partagedefaut" - t.string "npai" - t.string "npaimail" - t.string "npaisms" - t.string "rate" + create_table "v_contacts", force: :cascade do |t| + t.string "codemanaginn", limit: 255 + t.string "nomgroupe", limit: 255 + t.string "societe", limit: 255 + t.string "civilite", limit: 255 + t.string "nom", limit: 255 + t.string "prenom", limit: 255 + t.string "titre", limit: 255 + t.string "mailto", limit: 255 + t.string "mailcc", limit: 255 + t.string "mailbcc", limit: 255 + t.string "numportable", limit: 255 + t.string "numtel", limit: 255 + t.string "numfax", limit: 255 + t.string "adresse1", limit: 255 + t.string "adresse2", limit: 255 + t.string "codepostal", limit: 255 + t.string "ville", limit: 255 + t.string "anniversaire", limit: 255 + t.string "pays", limit: 255 + t.string "photo", limit: 255 + t.string "login", limit: 255 + t.string "password", limit: 255 + t.string "typeuser", limit: 255 + t.string "commentaire", limit: 255 + t.string "codeproprietaire", limit: 255 + t.string "typepartage", limit: 255 + t.string "libre1", limit: 255 + t.string "libre2", limit: 255 + t.string "libre3", limit: 255 + t.string "libre4", limit: 255 + t.string "libre5", limit: 255 + t.string "accesbloque", limit: 255 + t.string "corbeille", limit: 255 + t.string "codecreateur", limit: 255 + t.string "partagedefaut", limit: 255 + t.string "npai", limit: 255 + t.string "npaimail", limit: 255 + t.string "npaisms", limit: 255 + t.string "rate", limit: 255 t.decimal "cumul", precision: 14, scale: 2 t.decimal "cagnotte", precision: 14, scale: 2 t.decimal "prime", precision: 14, scale: 2 - t.integer "nbr_vidanges" - t.integer "vidanges_seuil" - t.integer "vidanges_offerte" + t.bigint "nbr_vidanges" + t.bigint "vidanges_seuil" + t.bigint "vidanges_offerte" t.date "datecreation" t.date "last_volume_at" t.decimal "ac_rate", precision: 14, scale: 2 t.boolean "enabled", default: false - t.integer "nbr_mvt" - t.string "cc_centre" - t.string "ac_centre" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "nbr_mvt" + t.string "cc_centre", limit: 255 + t.string "ac_centre", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.decimal "cc_cagnotte", precision: 14, scale: 2 t.decimal "cc_total", precision: 14, scale: 2 t.decimal "cc_remise", precision: 14, scale: 2 t.decimal "ac_cagnotte", precision: 14, scale: 2 t.decimal "ac_total", precision: 14, scale: 2 t.decimal "ac_remise", precision: 14, scale: 2 - t.integer "societe_id" - t.string "a_codeproprietaire" + t.bigint "societe_id" + t.string "a_codeproprietaire", limit: 255 end - create_table "video_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "video_contents", force: :cascade do |t| t.bigint "video_file_id" - t.string "title" + t.string "title", limit: 255 t.boolean "download", default: false t.boolean "autoplay", default: false t.boolean "fullscreen", default: false t.boolean "controls", default: false - t.string "legend" - t.string "style" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["video_file_id"], name: "index_video_contents_on_video_file_id" + t.string "legend", limit: 255 + t.string "style", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["video_file_id"], name: "idx_56258_index_video_contents_on_video_file_id" end - create_table "video_file_langs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" + create_table "video_file_langs", force: :cascade do |t| + t.string "title", limit: 255 t.text "description" - t.string "slug" + t.string "slug", limit: 255 t.bigint "video_file_id" t.bigint "lang_site_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["lang_site_id"], name: "index_video_file_langs_on_lang_site_id" - t.index ["video_file_id"], name: "index_video_file_langs_on_video_file_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["lang_site_id"], name: "idx_56296_index_video_file_langs_on_lang_site_id" + t.index ["video_file_id"], name: "idx_56296_index_video_file_langs_on_video_file_id" end - create_table "video_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "title" + create_table "video_files", force: :cascade do |t| + t.string "title", limit: 255 t.text "description" - t.string "token" - t.string "poster" - t.string "mpg" - t.string "ogg" - t.string "webm" - t.string "youtube_link" - t.string "youtube_code" + t.string "token", limit: 255 + t.string "poster", limit: 255 + t.string "mpg", limit: 255 + t.string "ogg", limit: 255 + t.string "webm", limit: 255 + t.string "youtube_link", limit: 255 + t.string "youtube_code", limit: 255 t.bigint "video_folder_id" - t.string "slug" + t.string "slug", limit: 255 t.bigint "image_file_id" - t.string "vimeo_code" + t.string "vimeo_code", limit: 255 t.boolean "public", default: false t.datetime "published_at" - t.integer "position" + t.bigint "position" t.boolean "fr", default: true t.boolean "en", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["image_file_id"], name: "index_video_files_on_image_file_id" - t.index ["video_folder_id"], name: "index_video_files_on_video_folder_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["image_file_id"], name: "idx_56274_index_video_files_on_image_file_id" + t.index ["video_folder_id"], name: "idx_56274_index_video_files_on_video_folder_id" end - create_table "video_folders", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "name" + create_table "video_folders", force: :cascade do |t| + t.string "name", limit: 255 t.boolean "super_admin", default: false t.text "description" t.boolean "public", default: false - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.bigint "position" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "volume_periodiques", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "codemanaginn" - t.string "codeindicateur" + create_table "volume_periodiques", force: :cascade do |t| + t.string "codemanaginn", limit: 255 + t.string "codeindicateur", limit: 255 t.datetime "datedebut" t.datetime "datefin" t.decimal "valeur", precision: 12, scale: 2 t.datetime "datereception" t.text "commentaire" - t.string "codesociete" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "codesociete", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_foreign_key "admin_preferences", "admins" - add_foreign_key "i_task_projects", "admins" - add_foreign_key "i_tasks", "admins" - add_foreign_key "i_tasks", "i_task_projects" - add_foreign_key "import_csv_champs", "import_csvs" - add_foreign_key "import_csv_elements", "import_csvs" - add_foreign_key "import_csv_headers", "import_csvs" - add_foreign_key "line_stock_usages", "line_stocks" - add_foreign_key "line_stocks", "p_product_refs" - add_foreign_key "mail_hists", "mail_contents" - add_foreign_key "mail_hists", "mail_types" - add_foreign_key "order_hist_lines", "order_hists" - add_foreign_key "order_hist_lines", "p_commercials" - add_foreign_key "order_hist_lines", "p_customers" - add_foreign_key "order_hist_lines", "p_payment_types" - add_foreign_key "order_hist_lines", "p_product_refs" - add_foreign_key "p_article_serial_nums", "p_articles" - add_foreign_key "p_article_serial_nums", "p_serial_num_types" - add_foreign_key "p_article_serial_nums", "p_serial_num_values" - add_foreign_key "p_articles", "p_grades" - add_foreign_key "p_articles", "p_product_refs" - add_foreign_key "p_commercial_object_brands", "p_commercial_objectives" - add_foreign_key "p_commercial_object_brands", "p_commercials" - add_foreign_key "p_commercial_object_brands", "s_brands" - add_foreign_key "p_commercial_object_cats", "p_commercial_objectives" - add_foreign_key "p_commercial_object_cats", "p_commercials" - add_foreign_key "p_commercial_object_cats", "p_product_cats", column: "p_product_cats_id" - add_foreign_key "p_commercial_object_months", "p_commercial_objectives" - add_foreign_key "p_commercial_object_months", "p_commercials" - add_foreign_key "p_commercial_objectives", "p_commercials" - add_foreign_key "p_contact_contact_types", "p_contact_types" - add_foreign_key "p_contact_contact_types", "p_contacts" - add_foreign_key "p_customer_product_prices", "p_customers" - add_foreign_key "p_customer_product_prices", "p_product_refs" - add_foreign_key "p_customer_ribs", "p_customers" - add_foreign_key "p_product_aromes", "p_aromes" - add_foreign_key "p_product_aromes", "p_products" - add_foreign_key "p_product_images", "image_files" - add_foreign_key "p_product_images", "p_product_refs" - add_foreign_key "p_product_images", "p_products" - add_foreign_key "p_product_nutris", "p_nutris" - add_foreign_key "p_product_nutris", "p_products" - add_foreign_key "p_product_origines", "p_origines" - add_foreign_key "p_product_origines", "p_products" - add_foreign_key "p_product_p_customer_cats", "p_customer_cats" - add_foreign_key "p_product_p_customer_cats", "p_products" - add_foreign_key "p_product_p_product_sub_cats", "p_product_sub_cats" - add_foreign_key "p_product_p_product_sub_cats", "p_products" - add_foreign_key "p_product_prices", "p_price_cats" - add_foreign_key "p_product_prices", "p_product_refs" - add_foreign_key "p_product_ref_price_histories", "p_product_refs" - add_foreign_key "p_product_ref_specs", "p_product_refs" - add_foreign_key "p_product_ref_specs", "p_spec_types" - add_foreign_key "p_product_ref_specs", "p_spec_values" - add_foreign_key "p_product_utilisations", "p_products" - add_foreign_key "p_product_utilisations", "p_utilisations" - add_foreign_key "partition_lines", "partitions" - add_foreign_key "partitions", "admins" - add_foreign_key "s_modules", "s_modules_states" - add_foreign_key "stat_lines", "p_commercials" - add_foreign_key "stat_lines", "p_customers" - add_foreign_key "stat_lines", "p_product_refs" - add_foreign_key "stat_lines", "p_products" - add_foreign_key "stock_movement_lines", "stock_movements" - add_foreign_key "timer_watchers", "admins" - add_foreign_key "tva_rates", "accounting_zones" - add_foreign_key "v_bdas", "volume_periodiques" + add_foreign_key "admin_preferences", "admins", on_update: :restrict, on_delete: :restrict + add_foreign_key "i_task_projects", "admins", on_update: :restrict, on_delete: :restrict + add_foreign_key "i_tasks", "admins", on_update: :restrict, on_delete: :restrict + add_foreign_key "i_tasks", "i_task_projects", on_update: :restrict, on_delete: :restrict + add_foreign_key "import_csv_champs", "import_csvs", on_update: :restrict, on_delete: :restrict + add_foreign_key "import_csv_elements", "import_csvs", on_update: :restrict, on_delete: :restrict + add_foreign_key "import_csv_headers", "import_csvs", on_update: :restrict, on_delete: :restrict + add_foreign_key "line_stock_usages", "line_stocks", on_update: :restrict, on_delete: :restrict + add_foreign_key "line_stocks", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "mail_hists", "mail_contents", on_update: :restrict, on_delete: :restrict + add_foreign_key "mail_hists", "mail_types", on_update: :restrict, on_delete: :restrict + add_foreign_key "order_hist_lines", "order_hists", on_update: :restrict, on_delete: :restrict + add_foreign_key "order_hist_lines", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "order_hist_lines", "p_customers", on_update: :restrict, on_delete: :restrict + add_foreign_key "order_hist_lines", "p_payment_types", on_update: :restrict, on_delete: :restrict + add_foreign_key "order_hist_lines", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_article_serial_nums", "p_articles", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_article_serial_nums", "p_serial_num_types", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_article_serial_nums", "p_serial_num_values", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_articles", "p_grades", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_articles", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_brands", "p_commercial_objectives", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_brands", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_brands", "s_brands", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_cats", "p_commercial_objectives", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_cats", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_cats", "p_product_cats", column: "p_product_cats_id", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_months", "p_commercial_objectives", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_object_months", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_commercial_objectives", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_contact_contact_types", "p_contact_types", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_contact_contact_types", "p_contacts", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_customer_product_prices", "p_customers", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_customer_product_prices", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_customer_ribs", "p_customers", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_aromes", "p_aromes", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_aromes", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_images", "image_files", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_images", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_images", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_nutris", "p_nutris", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_nutris", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_origines", "p_origines", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_origines", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_p_customer_cats", "p_customer_cats", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_p_customer_cats", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_p_product_sub_cats", "p_product_sub_cats", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_p_product_sub_cats", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_prices", "p_price_cats", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_prices", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_ref_price_histories", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_ref_specs", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_ref_specs", "p_spec_types", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_ref_specs", "p_spec_values", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_utilisations", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_product_utilisations", "p_utilisations", on_update: :restrict, on_delete: :restrict + add_foreign_key "partition_lines", "partitions", on_update: :restrict, on_delete: :restrict + add_foreign_key "partitions", "admins", on_update: :restrict, on_delete: :restrict + add_foreign_key "s_modules", "s_modules_states", on_update: :restrict, on_delete: :restrict + add_foreign_key "stat_lines", "p_commercials", on_update: :restrict, on_delete: :restrict + add_foreign_key "stat_lines", "p_customers", on_update: :restrict, on_delete: :restrict + add_foreign_key "stat_lines", "p_product_refs", on_update: :restrict, on_delete: :restrict + add_foreign_key "stat_lines", "p_products", on_update: :restrict, on_delete: :restrict + add_foreign_key "stock_movement_lines", "stock_movements", on_update: :restrict, on_delete: :restrict + add_foreign_key "timer_watchers", "admins", on_update: :restrict, on_delete: :restrict + add_foreign_key "tva_rates", "accounting_zones", on_update: :restrict, on_delete: :restrict + add_foreign_key "v_bdas", "volume_periodiques", on_update: :restrict, on_delete: :restrict end From fc143d26fd8d8191e6d6a7a2d6fe45d31df9154e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 17:02:28 +0200 Subject: [PATCH 30/91] Replace multiserache by scope search --- app/models/p_product_ref.rb | 14 +++++++++++++- ...20210928122901_create_pg_search_documents.rb | 17 ----------------- db/schema.rb | 11 +---------- 3 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 db/migrate/20210928122901_create_pg_search_documents.rb diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 07926e6..47855ec 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 :p_product + has_one :s_brand, through: :p_product has_many :p_customer_cats, :through => :p_product has_many :p_product_features @@ -48,6 +49,17 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } + include PgSearch::Model + pg_search_scope :global_search, + against: :cc_name, + associated_against: { + s_brand: [ :code, :name ], + p_product: [:code], + p_product_color: [:name, :color] + }, + using: { + tsearch: { prefix: true } + } def not_imported? if !self.p_product or !self.p_product.imported diff --git a/db/migrate/20210928122901_create_pg_search_documents.rb b/db/migrate/20210928122901_create_pg_search_documents.rb deleted file mode 100644 index a234851..0000000 --- a/db/migrate/20210928122901_create_pg_search_documents.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreatePgSearchDocuments < ActiveRecord::Migration[6.0] - def up - say_with_time("Creating table for pg_search multisearch") do - create_table :pg_search_documents do |t| - t.text :content - t.belongs_to :searchable, polymorphic: true, index: true - t.timestamps null: false - end - end - end - - def down - say_with_time("Dropping table for pg_search multisearch") do - drop_table :pg_search_documents - end - end -end diff --git a/db/schema.rb b/db/schema.rb index 8412ef2..33a7cb9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_28_122901) do +ActiveRecord::Schema.define(version: 2021_09_07_083709) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -2125,15 +2125,6 @@ ActiveRecord::Schema.define(version: 2021_09_28_122901) do t.index ["admin_id"], name: "idx_54659_index_partitions_on_admin_id" end - create_table "pg_search_documents", force: :cascade do |t| - t.text "content" - t.string "searchable_type" - t.bigint "searchable_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["searchable_type", "searchable_id"], name: "index_pg_search_documents_on_searchable_type_and_searchable_id" - end - create_table "portlets", force: :cascade do |t| t.bigint "block_id" t.bigint "content_id" From 6cc9d167f5bbadd187338873c7f88861384968e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 17:02:53 +0200 Subject: [PATCH 31/91] global search ok / WIP for select filters --- .../admin/p_product_refs_controller.rb | 12 +++++-- .../admin/p_product_refs/index.html.haml | 34 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 5648846..564d597 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -28,8 +28,8 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%") end - if params[:search][:name].to_s != "" - @p_product_refs = @p_product_refs.where("p_product_refs.ct_sub_name LIKE ? or p_product_refs.cc_name LIKE ?","%#{params[:search][:name]}%", "%#{params[:search][:name]}%") + if params[:search][:global].to_s != "" + @p_product_refs = PProductRef.global_search(params[:search][:global]) end if params[:search][:p_product_ref_cat_id].to_s != "" @@ -42,7 +42,13 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" - @p_product_refs = @p_product_refs.where(:s_brand_id => params[:search][:s_brand_id]) + + @p_product_refs = @p_product_refs.where(:s_brand => params[:search][:s_brand_id]) + puts "£££££££££££££££££££££££££££££££££££££" + puts "£££££££££££££££££££££££££££££££££££££" + puts SBrand.find(params[:search][:s_brand_id]).id.to_s + ' ' +SBrand.find(params[:search][:s_brand_id]).name + puts "£££££££££££££££££££££££££££££££££££££" + puts "£££££££££££££££££££££££££££££££££££££" end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 9e77e44..e4564ec 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -14,27 +14,35 @@ %table %tr - %td - Actif : - =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]) + + -if false + %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" + %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" - - %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - - - %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom" - + + %td{style: "min-width: 500px;"} + .input-group + =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..." + .input-group-append{:onclick => "$(this).prev('input').val('');"} + .btn.btn-outline-primary + =ic(:times) + %table %tr + %td + Actif : + %td + =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" %td Catégorie : - =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]) + %td + =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]), class: "custom-select" %td Marque : - =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]) + %td + =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select" @@ -52,4 +60,4 @@ }); - \ No newline at end of file + From 6b98b8f03cbe8ecb0730bdf4967ccba0e5761854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 18:55:06 +0200 Subject: [PATCH 32/91] WIP filters works, but without global search --- .../admin/p_product_refs_controller.rb | 13 ++++-------- app/models/s_brand.rb | 3 ++- .../admin/p_product_refs/index.html.haml | 21 +++++++++---------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 564d597..1ee4dde 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -28,9 +28,6 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%") end - if params[:search][:global].to_s != "" - @p_product_refs = PProductRef.global_search(params[:search][:global]) - end if params[:search][:p_product_ref_cat_id].to_s != "" if params[:search][:p_product_ref_cat_id].to_s == "null" @@ -42,13 +39,11 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" + @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) + end - @p_product_refs = @p_product_refs.where(:s_brand => params[:search][:s_brand_id]) - puts "£££££££££££££££££££££££££££££££££££££" - puts "£££££££££££££££££££££££££££££££££££££" - puts SBrand.find(params[:search][:s_brand_id]).id.to_s + ' ' +SBrand.find(params[:search][:s_brand_id]).name - puts "£££££££££££££££££££££££££££££££££££££" - puts "£££££££££££££££££££££££££££££££££££££" + if params[:search][:global].to_s != "" + @p_product_refs = PProductRef.global_search(params[:search][:global]) end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") diff --git a/app/models/s_brand.rb b/app/models/s_brand.rb index c5db009..10fa791 100644 --- a/app/models/s_brand.rb +++ b/app/models/s_brand.rb @@ -1,4 +1,5 @@ class SBrand < ApplicationRecord - + has_many :p_products + has_many :p_product_refs, through: :p_products validates :name, :presence => true, :uniqueness => true end diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index e4564ec..bc2bd0f 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -15,25 +15,24 @@ %table %tr - -if false - %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" - - %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - - %td{style: "min-width: 500px;"} .input-group =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..." .input-group-append{:onclick => "$(this).prev('input').val('');"} - .btn.btn-outline-primary + .btn.btn-outline-dark =ic(:times) %table %tr - %td - Actif : - %td - =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" + -if false + %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" + + %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" + + %td + Actif : + %td + =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" %td Catégorie : %td From 7b223648b809795e980ff3c5c94f588d983a016a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 29 Sep 2021 15:45:28 +0200 Subject: [PATCH 33/91] p_product_ref search + filter ok --- .../admin/p_product_refs_controller.rb | 31 ++++++++++++++----- .../admin/p_product_refs/index.html.haml | 15 ++++++--- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 1ee4dde..641f43b 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -16,9 +16,15 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = PProductRef.joins(:p_product) - @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all + # @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all + global_search_ids = @p_product_refs.ids + p_product_ref_cat_id_ids = @p_product_refs.ids + s_brand_id_ids = @p_product_refs.ids + if params[:search][:global].to_s != "" + global_search_ids = PProductRef.global_search(params[:search][:global]).ids + end if params[:search][:code].to_s != "" @p_product_refs = @p_product_refs.where("p_product_refs.ref LIKE ?","#{params[:search][:code]}%") @@ -31,19 +37,27 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:p_product_ref_cat_id].to_s != "" if params[:search][:p_product_ref_cat_id].to_s == "null" - @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => nil) + # @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => nil) + p_product_ref_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => nil).ids else - @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id]) + # @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id]) + p_product_ref_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id]).ids end end if params[:search][:s_brand_id].to_s != "" - @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) + # @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) + # @p_product_refs = @p_product_refs.select { |ref| ref.p_product.s_brand_id == params[:search][:s_brand_id]} + s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids end - if params[:search][:global].to_s != "" - @p_product_refs = PProductRef.global_search(params[:search][:global]) + final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids + + if params[:search].present? + @p_product_refs = PProductRef.where(id: final_ids) + else + @p_product_refs = PProductRef.joins(:p_product) end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") @@ -110,7 +124,8 @@ class Admin::PProductRefsController < ApplicationController end def autocomplete - @p_product_refs = PProductRef.for_search(params[:search]).limit(50) + @p_product_refs = PProductRef.joins(:p_product).all + # @p_product_refs = PProductRef.for_search(params[:search]).limit(50) if params[:p_customer_id] @p_customer = PCustomer.where(:id => params[:p_customer_id]).first @@ -196,5 +211,5 @@ class Admin::PProductRefsController < ApplicationController @p_product_ref = PProductRef.find(params[:id]) end - + end diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index bc2bd0f..f301f4e 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -36,13 +36,20 @@ %td Catégorie : %td - =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]), class: "custom-select" - + .input-group + =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]), class: "custom-select" + .input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"} + .btn.btn-outline-dark + =ic(:times) + %td Marque : %td - =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select" - + .input-group + =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select" + .input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"} + .btn.btn-outline-dark + =ic(:times) =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_refs} From 9f23908f7f5ba7985cd9604e150eda19295127cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 29 Sep 2021 16:56:13 +0200 Subject: [PATCH 34/91] p_product search + filter ok --- .../admin/p_products_controller.rb | 19 ++++++++--- app/models/p_product.rb | 10 ++++++ app/views/admin/p_products/index.html.haml | 34 ++++++++++++++----- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index 9cb4915..ff04834 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -18,9 +18,13 @@ class Admin::PProductsController < ApplicationController params[:search] = params[:search] || {} + global_search_ids = p_product_cat_id_ids = s_brand_id_ids = @p_products.ids + + if params[:search][:global].to_s != "" + global_search_ids = PProduct.global_search(params[:search][:global]).ids + end params[:search][:enabled] = "Oui" if !params[:search][:enabled] - if params[:search][:enabled].to_s == "Oui" @p_products = @p_products.where(:enabled => true) elsif params[:search][:enabled].to_s == "Non" @@ -37,17 +41,23 @@ class Admin::PProductsController < ApplicationController if params[:search][:p_product_cat_id].to_s != "" if params[:search][:p_product_cat_id].to_s == "null" - @p_products = @p_products.where(:p_product_cat_id => nil) + # @p_products = @p_products.where(:p_product_cat_id => nil) + p_product_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => nil).ids else - @p_products = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id]) + # @p_products = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id]) + p_product_cat_id_ids = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id]).ids end end if params[:search][:s_brand_id].to_s != "" @p_products = @p_products.where(:s_brand_id => params[:search][:s_brand_id]) + s_brand_id_ids = @p_products.where(:s_brand_id => params[:search][:s_brand_id]).ids end - + + final_ids = global_search_ids & p_product_cat_id_ids & s_brand_id_ids + @p_products = PProduct.where(id: final_ids) + @p_products = sort_by_sorting(@p_products, "id DESC") respond_to do |format| format.html{ @@ -60,7 +70,6 @@ class Admin::PProductsController < ApplicationController } end - end def show diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 893a83c..78ee662 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -70,6 +70,16 @@ class PProduct < ApplicationRecord } + include PgSearch::Model + pg_search_scope :global_search, + against: [:name, :code], + associated_against: { + p_product_refs: [:cc_name, :ref], + s_brand: [ :code, :name ], + }, + using: { + tsearch: { prefix: true } + } diff --git a/app/views/admin/p_products/index.html.haml b/app/views/admin/p_products/index.html.haml index ec874e5..2c89729 100644 --- a/app/views/admin/p_products/index.html.haml +++ b/app/views/admin/p_products/index.html.haml @@ -14,25 +14,41 @@ %table %tr - %td - Actif : - =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]) + %td{style: "min-width: 500px;"} + .input-group + =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..." + .input-group-append{:onclick => "$(this).prev('input').val('');"} + .btn.btn-outline-dark + =ic(:times) + %tr + -if false + %td + Actif : + =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]) - %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" + %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" - %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom" + %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom" %table %tr %td Catégorie : - =select_tag "search[p_product_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_cat_id]) - + %td + .input-group + =select_tag "search[p_product_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_cat_id]), class: "custom-select" + .input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"} + .btn.btn-outline-dark + =ic(:times) %td Marque : - =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]) - + %td + .input-group + =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select" + .input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"} + .btn.btn-outline-dark + =ic(:times) =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_products} From e45208a394c4960f54dfd2ea81edf184d6c252d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 29 Sep 2021 16:56:49 +0200 Subject: [PATCH 35/91] refacto --- app/controllers/admin/p_product_refs_controller.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 641f43b..c187e7f 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -18,9 +18,7 @@ class Admin::PProductRefsController < ApplicationController # @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all - global_search_ids = @p_product_refs.ids - p_product_ref_cat_id_ids = @p_product_refs.ids - s_brand_id_ids = @p_product_refs.ids + global_search_ids = p_product_ref_cat_id_ids = s_brand_id_ids = @p_product_refs.ids if params[:search][:global].to_s != "" global_search_ids = PProductRef.global_search(params[:search][:global]).ids @@ -52,13 +50,11 @@ class Admin::PProductRefsController < ApplicationController s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids end + final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids - if params[:search].present? - @p_product_refs = PProductRef.where(id: final_ids) - else - @p_product_refs = PProductRef.joins(:p_product) - end + @p_product_refs = PProductRef.where(id: final_ids) + @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") respond_to do |format| From 7e65e3374e4ab641dd2de25050f0280160f65e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 29 Sep 2021 16:56:58 +0200 Subject: [PATCH 36/91] add ref to search --- app/models/p_product_ref.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 47855ec..348ef3e 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -51,7 +51,7 @@ class PProductRef < ApplicationRecord include PgSearch::Model pg_search_scope :global_search, - against: :cc_name, + against: [:ref, :cc_name], associated_against: { s_brand: [ :code, :name ], p_product: [:code], From bf92abf5a04042e29ad8a0264c12e2b534efc1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 29 Sep 2021 17:42:59 +0200 Subject: [PATCH 37/91] search to p_article --- .../admin/p_articles_controller.rb | 10 +++++++ app/models/p_article.rb | 20 +++++++++++--- app/models/p_serial_num_value.rb | 1 + .../admin/p_articles/_p_article.html.haml | 4 +-- app/views/admin/p_articles/index.html.haml | 27 +++++++++++++------ 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index 0e40f7a..613b0de 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -12,6 +12,11 @@ class Admin::PArticlesController < ApplicationController def index @p_articles = PArticle.all + global_search_ids = @p_articles.ids + + if params[:search][:global].to_s != "" + global_search_ids = PArticle.global_search(params[:search][:global]).ids + end if params[:search][:p_product_color].to_s != "" if params[:search][:p_product_color].to_s == "null" @@ -38,6 +43,11 @@ class Admin::PArticlesController < ApplicationController end + + final_ids = global_search_ids + + @p_articles = PArticle.where(id: final_ids) + @p_articles = sort_by_sorting(@p_articles, "id DESC") respond_to do |format| format.html{ diff --git a/app/models/p_article.rb b/app/models/p_article.rb index 187741f..db8556c 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -3,9 +3,10 @@ class PArticle < ApplicationRecord belongs_to :p_product_ref has_one :p_product, through: :p_product_ref has_one :p_product_color, through: :p_product_ref + has_one :s_brand, through: :p_product_ref has_many :p_article_serial_nums, dependent: :destroy - has_many :p_serial_num_values, through: :p_article_serial_nums + # has_many :p_serial_num_values, through: :p_article_serial_nums accepts_nested_attributes_for :p_article_serial_nums validates_presence_of :p_product_ref @@ -15,7 +16,7 @@ class PArticle < ApplicationRecord if PGrade::ACTIVATED acts_as_sorting :fields => { :id => {:name => "id", :reorder => true}, - :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref_ref => {:name => "Code ref", :reorder => true}, :p_product_ref => {:name => "Désignation", :reorder => true}, :p_grade => {:name => "Grade", :reorder => true}, :color => {:name => "Couleur"}, @@ -25,13 +26,26 @@ class PArticle < ApplicationRecord else acts_as_sorting :fields => { :id => {:name => "id", :reorder => true}, - :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref_ref => {:name => "Code ref", :reorder => true}, :p_product_ref => {:name => "Désignation", :reorder => true}, :color => {:name => "Couleur"}, :p_article_serial_nums => {:name => "N° identifiants"}, :actions => {:name => "Actions", :reorder => false}, } end + + include PgSearch::Model + pg_search_scope :global_search, + associated_against: { + p_product_ref: [:cc_name, :ref], + s_brand: [ :code, :name ], + p_product_color: [:name, :color], + p_article_serial_nums: [:value] + }, + using: { + tsearch: { prefix: true } + } + def member_label "#{p_product_ref.cc_name}" end diff --git a/app/models/p_serial_num_value.rb b/app/models/p_serial_num_value.rb index c8a476f..c6716a3 100644 --- a/app/models/p_serial_num_value.rb +++ b/app/models/p_serial_num_value.rb @@ -1,4 +1,5 @@ class PSerialNumValue < ApplicationRecord + # USELESS MODEL : VALUES A ON p_article_serial_nums TABLE has_many :p_article_serial_nums, inverse_of: :p_serial_num_value has_many :p_articles, through: :p_article_serial_nums end diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 32497fc..be0c6ca 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -1,9 +1,9 @@ %tr#p_article_row{:id => p_article.id} -tr = {} - -tr[:p_product_ref_code] = capture do + -tr[:p_product_ref_ref] = capture do %td - = p_article.p_product_ref.code + = p_article.p_product_ref.ref -tr[:p_grade] = capture do %td diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 0064c5c..f889055 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -12,18 +12,29 @@ %table %tr - %td=text_field_tag "search[p_product_ref_cc_code]", params[:search][:p_product_ref_cc_code],:class => "form-control", :placeholder => "Code" + %td{style: "min-width: 500px;"} + .input-group + =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code, IMEI, SN..." + .input-group-append{:onclick => "$(this).prev('input').val('');"} + .btn.btn-outline-dark + =ic(:times) - %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" + %tr + -if false + %td=text_field_tag "search[p_product_ref_cc_code]", params[:search][:p_product_ref_cc_code],:class => "form-control", :placeholder => "Code" - %td=text_field_tag "search[p_article_serial_num]", params[:search][:p_article_serial_num],:class => "form-control", :placeholder => "N° de serie" + %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" - %td.pl-2 Grade : - %td=select_tag "search[p_grade_id]", options_for_select([["",""],["Aucune","null"]]+PGrade.pluck(:grade, :id), params[:search][:p_grade_id]), class: "custom-select" + %td=text_field_tag "search[p_article_serial_num]", params[:search][:p_article_serial_num],:class => "form-control", :placeholder => "N° de serie" + + %td.pl-2 Couleur : + %td + =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select" + + -if PGrade::ACTIVATED + %td.pl-2 Grade : + %td=select_tag "search[p_grade_id]", options_for_select([["",""],["Aucune","null"]]+PGrade.pluck(:grade, :id), params[:search][:p_grade_id]), class: "custom-select" - %td.pl-2 Couleur : - %td - =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select" =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles} From 4c49e4d3faa566bbad744947a43d84de0f37aa61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 30 Sep 2021 12:46:27 +0200 Subject: [PATCH 38/91] WIP import client --- .../admin/p_fournisseurs_controller.rb | 14 +++++++++++++- app/views/admin/p_fournisseurs/import.html.haml | 17 +++++++++-------- .../import_fournisseurs.html.haml | 16 ++++++++++++++++ app/views/admin/p_fournisseurs/index.html.haml | 4 ++-- config/routes.rb | 2 ++ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 app/views/admin/p_fournisseurs/import_fournisseurs.html.haml diff --git a/app/controllers/admin/p_fournisseurs_controller.rb b/app/controllers/admin/p_fournisseurs_controller.rb index 3b8b041..e406eed 100644 --- a/app/controllers/admin/p_fournisseurs_controller.rb +++ b/app/controllers/admin/p_fournisseurs_controller.rb @@ -23,7 +23,19 @@ class Admin::PFournisseursController < ApplicationController end - + def import_fournisseurs + # @file = params[:csv_file] + # require 'csv' + + # csv_text = File.read("#{Rails.root}/import_csv/fournisseurs.csv") #.force_encoding('ISO-8859-1') + # @csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") + + end + + def import_fournisseurs_xls + raise + end + def index @p_fournisseurs = PFournisseur.order(:name).all diff --git a/app/views/admin/p_fournisseurs/import.html.haml b/app/views/admin/p_fournisseurs/import.html.haml index 276b6d1..41199bd 100644 --- a/app/views/admin/p_fournisseurs/import.html.haml +++ b/app/views/admin/p_fournisseurs/import.html.haml @@ -1,13 +1,14 @@ --@import= true +-if false + -@import= true --i = 0 --@csv.each do |csv| - -i += 1 + -i = 0 + -@csv.each do |csv| + -i += 1 - =csv["code"] - -if csv["code"].to_s != "" - sfsd - -PFournisseur.create(:code => csv["code"],:name => csv["nom"],:address1 => csv["adresse 1"],:address2 => csv["adresse 2"],:cp => csv["code postal"],:city => csv["city"],:country => csv["country"],:email => csv["email"],:tel => csv["tel"]) + =csv["code"] + -if csv["code"].to_s != "" + sfsd + -PFournisseur.create(:code => csv["code"],:name => csv["nom"],:address1 => csv["adresse 1"],:address2 => csv["adresse 2"],:cp => csv["code postal"],:city => csv["city"],:country => csv["country"],:email => csv["email"],:tel => csv["tel"]) diff --git a/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml b/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml new file mode 100644 index 0000000..1010d73 --- /dev/null +++ b/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right + %h1 + Import + %span + Fournisseurs + + +.qi_row + .qi_pannel.qi_plain.padding + %table.table + %tr + %td + =form_with url: import_fournisseurs_xls_admin_p_fournisseurs_path() do |form| + =form.file_field_tag 'Base client', accept: '.xls, .xlsx' + =form.submit_tag 'importer' diff --git a/app/views/admin/p_fournisseurs/index.html.haml b/app/views/admin/p_fournisseurs/index.html.haml index f77d543..22fa1ce 100644 --- a/app/views/admin/p_fournisseurs/index.html.haml +++ b/app/views/admin/p_fournisseurs/index.html.haml @@ -1,7 +1,7 @@ .qi_header .right = link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true - + =link_to 'import base fournisseurs', import_fournisseurs_admin_p_fournisseurs_path(), :class => "btn btn-primary" %h1 Achats %span @@ -28,4 +28,4 @@ %tbody#p_fournisseurs_rows =render @p_fournisseurs - \ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index a5835ca..355ebde 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -967,6 +967,8 @@ Rails.application.routes.draw do resources :p_fournisseurs do collection do get :import + get :import_fournisseurs + post :import_fournisseurs_xls end From aa3dbed95b35983076cf45af5775399a1ef059d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:28:44 +0200 Subject: [PATCH 39/91] import csv work with xlsx files --- app/models/import_csv.rb | 89 +++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/app/models/import_csv.rb b/app/models/import_csv.rb index 7414d1b..d0d1dd1 100644 --- a/app/models/import_csv.rb +++ b/app/models/import_csv.rb @@ -10,7 +10,7 @@ class ImportCsv < ApplicationRecord validates :file, :presence => true validates :table_name, :presence => true - + has_many :import_csv_champs, :dependent => :destroy accepts_nested_attributes_for :import_csv_champs, :allow_destroy => true @@ -21,72 +21,97 @@ class ImportCsv < ApplicationRecord :name => {:name => "Nom", :reorder => true}, :file => {:name => "Fichier", :reorder => true}, :table_name => {:name => "Table", :reorder => true}, - + :nbr_headers => {:name => "Nbr champs", :reorder => true}, :nbr_elements => {:name => "Nbr elements", :reorder => true}, - - - + + + :actions => {:name => "Actions", :reorder => false} } after_create do - - csv_text = File.read(self.file.path, :encoding => 'UTF-8') - @csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") - - @csv.headers.each do |header| + if file_is_csv? + csv_text = File.read(self.file.path, :encoding => 'UTF-8') + csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") + headers = csv.headers + else + xlsx = Roo::Spreadsheet.open(self.file.path, extension: :xlsx) # open spreadsheet + headers = xlsx.row(1) + end + headers.each do |header| self.import_csv_headers << ImportCsvHeader.new(:name => header) end self.table_name.classify.constantize.import_csv_fields.each do |h| if self.parent and c = self.parent.import_csv_champs.where(:champ => h.to_s).first - self.import_csv_champs.new(:champ => h.to_s, :header => c.header) + self.import_csv_champs.new(:champ => h.to_s, :header => c.header) else - self.import_csv_champs.new(:champ => h.to_s) + self.import_csv_champs.new(:champ => h.to_s) end end - self.save - - end + + def file_is_csv? + File.read(self.file.path, :encoding => 'utf-8').valid_encoding? + end + + def charge - + self.import_csv_elements.each do |e| e.element.destroy if e.element e.destroy end - csv_text = File.read(self.file.path, :encoding => 'UTF-8') - @csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") r = [] - @csv.each do |row| - line = {} - self.import_csv_champs.each do |import_csv_champ| - if import_csv_champ.header? - eval "line['#{import_csv_champ.champ}'] = row[\"#{import_csv_champ.header}\"]" - elsif import_csv_champ.value? - eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\"" + + if file_is_csv? + csv_text = File.read(self.file.path, :encoding => 'UTF-8') + csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") + csv.each do |row| + line = {} + self.import_csv_champs.each do |import_csv_champ| + if import_csv_champ.header? + eval "line['#{import_csv_champ.champ}'] = row[\"#{import_csv_champ.header}\"]" + elsif import_csv_champ.value? + eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\"" + end end - + r << line end - - r << line - + return r + else + xlsx = Roo::Spreadsheet.open(self.file.path, extension: :xlsx) # open spreadsheet + headers = xlsx.row(1) # get header row + xlsx.each_with_index do |row, idx| + line = {} + next if idx == 0 # skip header + # create hash from headers and cells + data = Hash[[headers, row].transpose] + self.import_csv_champs.each do |import_csv_champ| + # raise + if import_csv_champ.header? + eval "line['#{import_csv_champ.champ}'] = data[\"#{import_csv_champ.header}\"]" + elsif import_csv_champ.value? + eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\"" + end + end + r << line + end + return r end - - return r end def load self.table_name.classify.constantize.import_csv(self.charge, self) - + end From e6ddcfe1835928b23e07640d04a88847937359eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:29:05 +0200 Subject: [PATCH 40/91] add import xls to menu --- app/controllers/application_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce02913..06d193f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,8 +126,7 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" 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" end From 0e33efd61ab5a72bcc26d101d67ea1128fde748c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:37:31 +0200 Subject: [PATCH 41/91] p_fournisseur CSV+EXCEL import ok --- app/models/p_contact.rb | 2 +- app/models/p_fournisseur.rb | 79 +++++++++++++++++++ app/models/p_payment_type.rb | 3 +- app/views/admin/import_csvs/_form.html.haml | 4 +- app/views/admin/import_csvs/index.html.haml | 4 +- .../20211004161651_add_skype_to_p_contacts.rb | 5 ++ ...004161753_add_details_to_p_fournisseurs.rb | 9 +++ db/schema.rb | 8 +- lib/acts_as_csv_import/hook.rb | 2 +- 9 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20211004161651_add_skype_to_p_contacts.rb create mode 100644 db/migrate/20211004161753_add_details_to_p_fournisseurs.rb diff --git a/app/models/p_contact.rb b/app/models/p_contact.rb index 28706f5..6da354d 100644 --- a/app/models/p_contact.rb +++ b/app/models/p_contact.rb @@ -5,5 +5,5 @@ class PContact < ApplicationRecord has_many :p_contact_contact_types, :dependent => :destroy has_many :p_contact_types, :through => :p_contact_contact_types - + belongs_to :p_payment_type end diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index b24d696..e585732 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -1,2 +1,81 @@ class PFournisseur < ApplicationRecord + # has_many :particulars, :as => :owner, :dependent => :destroy + has_many :p_contacts, :as => :contactable, :dependent => :destroy + + acts_as_csv_import :fields => [ + :name, + :address1, + :cp, + :city, + :country, + :email, + :tel, + :p_contact_name, + :p_contact_comment, + :p_contact_tel, + :p_contact_skype, + :p_contact_email_1, + :p_contact_email_2, + :p_contact_email_3, + :bic, + :iban, + :payment_delais, + :tva_num, + :p_payment_type + ] + + def self.custom_csv_import(list, import_csv) + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap list + # ap list.class + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap import_csv + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + + list.each do |row| + + n = self.new + # particular = Particular.new(pro: true) + contact_1 = PContact.new + contact_2 = nil + contact_3 = nil + row.each do |key, value| + + if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal + eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" + elsif key == "p_contact_name" + contact_1.name = value + elsif key == "p_contact_comment" + contact_1.p_contact_types << PContactType.find_or_create_by(name: value) + elsif key == "p_contact_tel" + contact_1.tel = value + elsif key == "p_contact_skype" + contact_1.skype = value + elsif key == "p_contact_email_1" + contact_1.email = value + elsif key == "p_contact_email_2" + contact_2 = PContact.new(email: value) + elsif key == "p_contact_email_3" + contact_3 = PContact.new(email: value) + elsif key == "p_payment_type" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + else + eval "n.#{key} = value" + end + + end + # particular.organisation = self.name + n.save + n.p_contacts << contact_1 if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) + n.p_contacts << contact_2 if contact_2 + n.p_contacts << contact_3 if contact_3 + # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + end + end end diff --git a/app/models/p_payment_type.rb b/app/models/p_payment_type.rb index a6cfaa8..fbd2f02 100644 --- a/app/models/p_payment_type.rb +++ b/app/models/p_payment_type.rb @@ -1,7 +1,8 @@ class PPaymentType < ApplicationRecord belongs_to :p_bank_account has_many :p_payments - + has_many :p_fournisseurs + after_save do if self.p_bank_account self.p_payments.where(:remise => false).update_all(:p_bank_account_id => self.p_bank_account_id) diff --git a/app/views/admin/import_csvs/_form.html.haml b/app/views/admin/import_csvs/_form.html.haml index f115a9c..ede671b 100644 --- a/app/views/admin/import_csvs/_form.html.haml +++ b/app/views/admin/import_csvs/_form.html.haml @@ -6,7 +6,7 @@ = f.input :name, :label => "Nom de l'import :" = f.input :file, :label => "file :" - = f.input :table_name, :label => "Table :" , :as => :select, :collection => ["order_hist_lines"] + = f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Base fournisseurs", "p_fournisseur"], ["Mise à jour catalogue prix","price_document"]] -if f.object.id %table.import_csv_champs_form @@ -23,4 +23,4 @@ .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/import_csvs/index.html.haml b/app/views/admin/import_csvs/index.html.haml index 78aa6d9..54de32a 100644 --- a/app/views/admin/import_csvs/index.html.haml +++ b/app/views/admin/import_csvs/index.html.haml @@ -1,6 +1,6 @@ .qi_header .right= link_to ic(:plus)+' Ajouter', new_admin_import_csv_path(), :class => "btn btn-primary btn-ap-add", :remote => true - %h1 + %h1 Import xls @@ -12,4 +12,4 @@ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs} -=debug OrderHistLine.new.class.type_for_attribute("ff") \ No newline at end of file +=debug OrderHistLine.new.class.type_for_attribute("ff") diff --git a/db/migrate/20211004161651_add_skype_to_p_contacts.rb b/db/migrate/20211004161651_add_skype_to_p_contacts.rb new file mode 100644 index 0000000..2560a30 --- /dev/null +++ b/db/migrate/20211004161651_add_skype_to_p_contacts.rb @@ -0,0 +1,5 @@ +class AddSkypeToPContacts < ActiveRecord::Migration[6.0] + def change + add_column :p_contacts, :skype, :string + end +end diff --git a/db/migrate/20211004161753_add_details_to_p_fournisseurs.rb b/db/migrate/20211004161753_add_details_to_p_fournisseurs.rb new file mode 100644 index 0000000..345ce24 --- /dev/null +++ b/db/migrate/20211004161753_add_details_to_p_fournisseurs.rb @@ -0,0 +1,9 @@ +class AddDetailsToPFournisseurs < ActiveRecord::Migration[6.0] + def change + add_column :p_fournisseurs, :payment_delais, :integer + add_column :p_fournisseurs, :tva_num, :string + add_column :p_fournisseurs, :p_payment_type_id, :integer + add_column :p_fournisseurs, :iban, :string + add_column :p_fournisseurs, :bic, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 5baae52..dc64e8d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_17_124338) do +ActiveRecord::Schema.define(version: 2021_10_04_161753) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1164,6 +1164,7 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) do t.string "contactable_type" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "skype" t.index ["contactable_id"], name: "index_p_contacts_on_contactable_id" end @@ -1463,6 +1464,11 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) do t.string "compta_account" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.integer "payment_delais" + t.string "tva_num" + t.integer "p_payment_type_id" + t.string "iban" + t.string "bic" end create_table "p_grades", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| diff --git a/lib/acts_as_csv_import/hook.rb b/lib/acts_as_csv_import/hook.rb index ab6502b..e140daf 100644 --- a/lib/acts_as_csv_import/hook.rb +++ b/lib/acts_as_csv_import/hook.rb @@ -9,7 +9,7 @@ module ActsAsCsvImport::Hook end def self.import_csv(list, import_csv) - puts self.instance_methods + # puts self.instance_methods if self.methods.include?(:custom_csv_import) custom_csv_import(list, import_csv) From 268456d09f109c52efb9a2779126bca3213318f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:38:31 +0200 Subject: [PATCH 42/91] add roo + awesome print --- Gemfile | 3 ++- Gemfile.lock | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f4aa40b..42799b6 100644 --- a/Gemfile +++ b/Gemfile @@ -103,7 +103,7 @@ group :development do gem 'capistrano-bundler', '~> 1.1', require: false gem "capistrano-rvm", group: :development gem 'capistrano3-nginx', '~> 2.0', group: :development - + gem "awesome_print" end gem 'zip-zip' @@ -114,3 +114,4 @@ gem 'axlsx', '3.0.0.pre' gem 'axlsx_rails' gem 'mimemagic', "0.3.10" +gem "roo" diff --git a/Gemfile.lock b/Gemfile.lock index a758dba..fa63faf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,6 +63,7 @@ GEM public_suffix (>= 2.0.2, < 5.0) airbrussh (1.3.3) sshkit (>= 1.6.1, != 1.7.0) + awesome_print (1.9.2) axlsx (3.0.0.pre) htmlentities (~> 4.3, >= 4.3.4) mimemagic (~> 0.3) @@ -270,6 +271,9 @@ GEM ffi (~> 1.0) regexp_parser (1.6.0) rmagick (4.2.2) + roo (2.8.2) + nokogiri (~> 1) + rubyzip (>= 1.2.1, < 2.0.0) ruby-vips (2.0.14) ffi (~> 1.9) ruby_dep (1.5.0) @@ -357,6 +361,7 @@ PLATFORMS DEPENDENCIES acts_as_commentable acts_as_tree + awesome_print axlsx (= 3.0.0.pre) axlsx_rails bcrypt (~> 3.1.7) @@ -390,6 +395,7 @@ DEPENDENCIES rails (= 6.0.3.4) rails_autolink rmagick + roo sass-rails (~> 5) searchkick selenium-webdriver From 0209a981d49f8c7623724e33f8dc81123b9b9f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:44:14 +0200 Subject: [PATCH 43/91] WIP import CSV fournisseur catalogue --- app/models/price_document.rb | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 24fcc09..3fe9fe5 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -31,6 +31,7 @@ class PriceDocument < ApplicationRecord AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed? + acts_as_csv_import :fields => [:p_fournisseur_id, :p_product_ref] def public_fournisseur_name_needed? if self.label == "Réponse fournisseur" @@ -707,6 +708,59 @@ class PriceDocument < ApplicationRecord end + def self.custom_csv_import(list, import_csv) + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap list + ap list.class + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap import_csv + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + list.each do |row| + + n = self.new(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur")) + # price_document = PriceDocument.new(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur")) + contact_2 = nil + contact_3 = nil + row.each do |key, value| + + if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal + eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" + # elsif key == "p_fournisseur_id" + # price_document.p_fournisseur = PFournisseur.find(key) + # elsif key == "p_contact_comment" + # contact_1.p_contact_types << PContactType.find_or_create_by(name: value) + # elsif key == "p_contact_tel" + # contact_1.tel = value + # elsif key == "p_contact_skype" + # contact_1.skype = value + # elsif key == "p_contact_email_1" + # contact_1.email = value + # elsif key == "p_contact_email_2" + # contact_2 = PContact.new(email: value) + # elsif key == "p_contact_email_3" + # contact_3 = PContact.new(email: value) + # elsif key == "p_payment_type" + # n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + else + eval "n.#{key} = value" + end + + end + # particular.organisation = self.name + # n.save + ap n + # n.p_contacts << contact_1 if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) + # n.p_contacts << contact_2 if contact_2 + # n.p_contacts << contact_3 if contact_3 + # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + end + end end From 9de88372a138ce2d116640e1101e0c54561d4d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 5 Oct 2021 15:51:33 +0200 Subject: [PATCH 44/91] add p_fournisseur_ref --- .../admin/p_fournisseur_refs_controller.rb | 76 +++++++++++++++++++ app/models/p_fournisseur_ref.rb | 4 + .../admin/p_fournisseur_refs/_form.html.haml | 14 ++++ .../_p_fournisseur_ref.html.haml | 16 ++++ .../admin/p_fournisseur_refs/create.js.erb | 2 + .../admin/p_fournisseur_refs/destroy.js.erb | 1 + .../admin/p_fournisseur_refs/edit.js.erb | 1 + .../admin/p_fournisseur_refs/index.html.haml | 16 ++++ app/views/admin/p_fournisseur_refs/new.js.erb | 1 + .../admin/p_fournisseur_refs/show.html.haml | 10 +++ .../admin/p_fournisseur_refs/update.js.erb | 2 + config/routes.rb | 11 +++ ...0211005134955_create_p_fournisseur_refs.rb | 11 +++ db/schema.rb | 14 +++- test/fixtures/p_fournisseur_refs.yml | 11 +++ test/models/p_fournisseur_ref_test.rb | 7 ++ 16 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_fournisseur_refs_controller.rb create mode 100644 app/models/p_fournisseur_ref.rb create mode 100644 app/views/admin/p_fournisseur_refs/_form.html.haml create mode 100644 app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml create mode 100644 app/views/admin/p_fournisseur_refs/create.js.erb create mode 100644 app/views/admin/p_fournisseur_refs/destroy.js.erb create mode 100644 app/views/admin/p_fournisseur_refs/edit.js.erb create mode 100644 app/views/admin/p_fournisseur_refs/index.html.haml create mode 100644 app/views/admin/p_fournisseur_refs/new.js.erb create mode 100644 app/views/admin/p_fournisseur_refs/show.html.haml create mode 100644 app/views/admin/p_fournisseur_refs/update.js.erb create mode 100644 db/migrate/20211005134955_create_p_fournisseur_refs.rb create mode 100644 test/fixtures/p_fournisseur_refs.yml create mode 100644 test/models/p_fournisseur_ref_test.rb diff --git a/app/controllers/admin/p_fournisseur_refs_controller.rb b/app/controllers/admin/p_fournisseur_refs_controller.rb new file mode 100644 index 0000000..31e86bc --- /dev/null +++ b/app/controllers/admin/p_fournisseur_refs_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PFournisseurRefsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_fournisseur_refs = PFournisseurRef.all + + @p_fournisseur_refs = sort_by_sorting(@p_fournisseur_refs, "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 + @p_fournisseur_refs = @p_fournisseur_refs.page(page).per(per_page) + + } + end + end + + def show + @p_fournisseur_ref = PFournisseurRef.find(params[:id]) + + end + + def new + @p_fournisseur_ref = PFournisseurRef.new + + end + + def edit + @p_fournisseur_ref = PFournisseurRef.find(params[:id]) + + end + + def create + @p_fournisseur_ref = PFournisseurRef.new(params.require(:p_fournisseur_ref).permit!) + + if @p_fournisseur_ref.save + + else + render action: "new" + + end + + end + + + def update + @p_fournisseur_ref = PFournisseurRef.find(params[:id]) + + + if @p_fournisseur_ref.update_attributes(params.require(:p_fournisseur_ref).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_fournisseur_ref = PFournisseurRef.find(params[:id]) + @p_fournisseur_ref.destroy + + end +end diff --git a/app/models/p_fournisseur_ref.rb b/app/models/p_fournisseur_ref.rb new file mode 100644 index 0000000..5c8fa6c --- /dev/null +++ b/app/models/p_fournisseur_ref.rb @@ -0,0 +1,4 @@ +class PFournisseurRef < ApplicationRecord + belongs_to :p_product_ref + belongs_to :p_fournisseur +end diff --git a/app/views/admin/p_fournisseur_refs/_form.html.haml b/app/views/admin/p_fournisseur_refs/_form.html.haml new file mode 100644 index 0000000..0fdf241 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/_form.html.haml @@ -0,0 +1,14 @@ +=semantic_form_for [:admin, @p_fournisseur_ref], :remote => true do |f| + + .content + =f.inputs do + = f.input :ref, :label => f.object.label_for(:ref) + = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) + = f.input :p_fournisseur, :label => f.object.label_for(:p_fournisseur) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml b/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml new file mode 100644 index 0000000..b9969b4 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/_p_fournisseur_ref.html.haml @@ -0,0 +1,16 @@ +%tr#p_fournisseur_ref_row{:id => p_fournisseur_ref.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_fournisseur_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true + = link_to i(:eye), admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_fournisseur_ref} + + + + \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/create.js.erb b/app/views/admin/p_fournisseur_refs/create.js.erb new file mode 100644 index 0000000..a57e725 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/create.js.erb @@ -0,0 +1,2 @@ +$('#p_fournisseur_refs_rows').prepend("<%= escape_javascript(render(@p_fournisseur_ref))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/destroy.js.erb b/app/views/admin/p_fournisseur_refs/destroy.js.erb new file mode 100644 index 0000000..72148c9 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/destroy.js.erb @@ -0,0 +1 @@ +$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/edit.js.erb b/app/views/admin/p_fournisseur_refs/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/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/p_fournisseur_refs/index.html.haml b/app/views/admin/p_fournisseur_refs/index.html.haml new file mode 100644 index 0000000..bcead3b --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_fournisseur_ref_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PFournisseurRef.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_fournisseur_refs} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_fournisseur_refs} + + + diff --git a/app/views/admin/p_fournisseur_refs/new.js.erb b/app/views/admin/p_fournisseur_refs/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/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/p_fournisseur_refs/show.html.haml b/app/views/admin/p_fournisseur_refs/show.html.haml new file mode 100644 index 0000000..213e4c6 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_fournisseur_ref \ No newline at end of file diff --git a/app/views/admin/p_fournisseur_refs/update.js.erb b/app/views/admin/p_fournisseur_refs/update.js.erb new file mode 100644 index 0000000..b135464 --- /dev/null +++ b/app/views/admin/p_fournisseur_refs/update.js.erb @@ -0,0 +1,2 @@ +$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').replaceWith("<%= escape_javascript(render(@p_fournisseur_ref))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 355ebde..d3a9d8a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_fournisseur_refs do + member do + + end + collection do + + end + end + end + namespace :admin do resources :price_line_resp_selects do member do diff --git a/db/migrate/20211005134955_create_p_fournisseur_refs.rb b/db/migrate/20211005134955_create_p_fournisseur_refs.rb new file mode 100644 index 0000000..dc65fc0 --- /dev/null +++ b/db/migrate/20211005134955_create_p_fournisseur_refs.rb @@ -0,0 +1,11 @@ +class CreatePFournisseurRefs < ActiveRecord::Migration[6.0] + def change + create_table :p_fournisseur_refs do |t| + t.string :ref + t.references :p_product_ref, foreign_key: true + t.references :p_fournisseur, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index dc64e8d..15f694f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_04_161753) do +ActiveRecord::Schema.define(version: 2021_10_05_134955) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1451,6 +1451,16 @@ ActiveRecord::Schema.define(version: 2021_10_04_161753) do t.index ["p_fournisseur_id"], name: "index_p_fournisseur_orders_on_p_fournisseur_id" end + create_table "p_fournisseur_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "ref" + t.bigint "p_product_ref_id" + t.bigint "p_fournisseur_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_fournisseur_id"], name: "index_p_fournisseur_refs_on_p_fournisseur_id" + t.index ["p_product_ref_id"], name: "index_p_fournisseur_refs_on_p_product_ref_id" + end + create_table "p_fournisseurs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" t.string "code" @@ -3158,6 +3168,8 @@ ActiveRecord::Schema.define(version: 2021_10_04_161753) do add_foreign_key "p_customer_product_prices", "p_customers" add_foreign_key "p_customer_product_prices", "p_product_refs" add_foreign_key "p_customer_ribs", "p_customers" + add_foreign_key "p_fournisseur_refs", "p_fournisseurs" + add_foreign_key "p_fournisseur_refs", "p_product_refs" add_foreign_key "p_product_aromes", "p_aromes" add_foreign_key "p_product_aromes", "p_products" add_foreign_key "p_product_images", "image_files" diff --git a/test/fixtures/p_fournisseur_refs.yml b/test/fixtures/p_fournisseur_refs.yml new file mode 100644 index 0000000..0e0af5e --- /dev/null +++ b/test/fixtures/p_fournisseur_refs.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + ref: MyString + p_product_ref: one + p_fournisseur: one + +two: + ref: MyString + p_product_ref: two + p_fournisseur: two diff --git a/test/models/p_fournisseur_ref_test.rb b/test/models/p_fournisseur_ref_test.rb new file mode 100644 index 0000000..c6087ea --- /dev/null +++ b/test/models/p_fournisseur_ref_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PFournisseurRefTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From e6945481e7cf20ca14d956d05d063c66a6bc5c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 7 Oct 2021 16:30:39 +0200 Subject: [PATCH 45/91] add label to p_fournisseur_ref --- db/migrate/20211005134955_create_p_fournisseur_refs.rb | 1 + db/schema.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/db/migrate/20211005134955_create_p_fournisseur_refs.rb b/db/migrate/20211005134955_create_p_fournisseur_refs.rb index dc65fc0..a7d3866 100644 --- a/db/migrate/20211005134955_create_p_fournisseur_refs.rb +++ b/db/migrate/20211005134955_create_p_fournisseur_refs.rb @@ -2,6 +2,7 @@ class CreatePFournisseurRefs < ActiveRecord::Migration[6.0] def change create_table :p_fournisseur_refs do |t| t.string :ref + t.string :label t.references :p_product_ref, foreign_key: true t.references :p_fournisseur, foreign_key: true diff --git a/db/schema.rb b/db/schema.rb index 15f694f..83454f6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1453,6 +1453,7 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do create_table "p_fournisseur_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "ref" + t.string "label" t.bigint "p_product_ref_id" t.bigint "p_fournisseur_id" t.datetime "created_at", precision: 6, null: false From 7e34e20757e504e4fdde7fe4f3ebd19e21f20655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 7 Oct 2021 17:19:22 +0200 Subject: [PATCH 46/91] p_fournisseur has_many p_fournisseur_ref --- app/models/p_fournisseur.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index e585732..c804f32 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -1,6 +1,7 @@ class PFournisseur < ApplicationRecord # has_many :particulars, :as => :owner, :dependent => :destroy has_many :p_contacts, :as => :contactable, :dependent => :destroy + has_many :p_fournisseur_refs acts_as_csv_import :fields => [ :name, From 97f0ae99c50947b2d70a5cd39986acd8ab49aece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 7 Oct 2021 17:19:56 +0200 Subject: [PATCH 47/91] price_document import --- app/models/price_document.rb | 87 +++++++++++++++++------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 3fe9fe5..5161238 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -31,7 +31,7 @@ class PriceDocument < ApplicationRecord AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed? - acts_as_csv_import :fields => [:p_fournisseur_id, :p_product_ref] + acts_as_csv_import :fields => [:p_fournisseur_id, :p_fournisseur_name, :p_fournisseur_ref_ref, :p_fournisseur_ref_label, :p_product_ref_name, :price_line_qte, :date, :price_line_ct_u_price_ht, :p_devise ] def public_fournisseur_name_needed? if self.label == "Réponse fournisseur" @@ -709,57 +709,52 @@ class PriceDocument < ApplicationRecord def self.custom_csv_import(list, import_csv) - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" - ap list - ap list.class - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" - ap import_csv - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" - ap "*********************************************************************************************************" list.each do |row| + p_product_ref = nil - n = self.new(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur")) - # price_document = PriceDocument.new(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur")) - contact_2 = nil - contact_3 = nil - row.each do |key, value| + p_devise = PDevise.find_by(symbol: row["p_devise"]) - if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal - eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" - # elsif key == "p_fournisseur_id" - # price_document.p_fournisseur = PFournisseur.find(key) - # elsif key == "p_contact_comment" - # contact_1.p_contact_types << PContactType.find_or_create_by(name: value) - # elsif key == "p_contact_tel" - # contact_1.tel = value - # elsif key == "p_contact_skype" - # contact_1.skype = value - # elsif key == "p_contact_email_1" - # contact_1.email = value - # elsif key == "p_contact_email_2" - # contact_2 = PContact.new(email: value) - # elsif key == "p_contact_email_3" - # contact_3 = PContact.new(email: value) - # elsif key == "p_payment_type" - # n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id - else - eval "n.#{key} = value" - end + p_fournisseur = PFournisseur.find_by(id: row["p_fournisseur_id"]) + if row["p_fournisseur_id"].nil? + p_fournisseur = PFournisseur.find_by(name: row["p_fournisseur_name"]) end - # particular.organisation = self.name - # n.save - ap n - # n.p_contacts << contact_1 if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) - # n.p_contacts << contact_2 if contact_2 - # n.p_contacts << contact_3 if contact_3 - # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + + raise "Fournisseur introuvable. Ajouter le fournisseur manquant avant l'import" if p_fournisseur.nil? + + n = self.find_or_initialize_by(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur"), p_fournisseur: p_fournisseur, date: row["date"], p_devise: p_devise ) + if n.price_line_block.nil? + n.price_line_block = PriceLineBlock.new(p_devise: p_devise, p_fournisseur: p_fournisseur, imported: true) + end + + + if row["p_fournisseur_ref_ref"].present? + p_fournisseur_ref = PFournisseurRef.find_by(p_fournisseur: p_fournisseur, ref: row["p_fournisseur_ref_ref"]) + p_product_ref = p_fournisseur_ref.p_product_ref if p_fournisseur_ref + else + p_fournisseur_ref = PFournisseurRef.find_by(p_fournisseur: p_fournisseur, label: row["p_fournisseur_ref_label"]) + p_product_ref = p_fournisseur_ref.p_product_ref if p_fournisseur_ref + end + + + if row["price_line_qte"].kind_of? Float + qte = row["price_line_qte"] + elsif row["price_line_qte"].kind_of? Integer + qte = row["price_line_qte"].to_f + elsif row["price_line_qte"].kind_of? String + qte = row["price_line_qte"].split.map {|x| x[/\d+/]}[0].to_f + else + qte = 0 + end + + price_line = PriceLine.new(p_product_ref: p_product_ref, ct_ref: row["p_fournisseur_ref_ref"], ct_title: row["p_fournisseur_ref_label"], price_line_block: n.price_line_block, qte: qte || 0.0, ct_u_price_ht: row["price_line_ct_u_price_ht"], imported: true ) + price_line.p_product = p_product_ref.p_product if p_product_ref && p_product_ref.p_product + n.price_line_block.price_lines << price_line + + + n.save + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) end end From 5a3cd4163b35af2f4b2add1a42eab3911e7d2f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 7 Oct 2021 17:21:37 +0200 Subject: [PATCH 48/91] p_product_ref_match --- .../admin/import_csvs_controller.rb | 9 +- .../admin/p_products_controller.rb | 2 +- .../admin/price_documents_controller.rb | 2 + app/controllers/application_controller.rb | 1 + app/models/p_product_ref.rb | 1 + app/models/price_line.rb | 24 ++++- app/models/price_line_block.rb | 2 +- .../admin/import_csvs/match_refs.html.haml | 26 ++++++ .../price_lines/_form_match_refs.html.haml | 93 +++++++++++++++++++ config/routes.rb | 3 + 10 files changed, 155 insertions(+), 8 deletions(-) create mode 100644 app/views/admin/import_csvs/match_refs.html.haml create mode 100644 app/views/admin/price_lines/_form_match_refs.html.haml diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index 4f8ae2c..9f70258 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -31,13 +31,20 @@ class Admin::ImportCsvsController < ApplicationController end + def match_refs + @price_documents = PriceDocument.joins(price_line_block: :price_lines).where({price_line_block: {price_lines: {p_product_ref: nil}}}).distinct + redirect_to :action => :index if @price_documents.empty? + end + def charge @import_csv = ImportCsv.find(params[:id]) @import_csv.load - redirect_to :action => :index + # redirect_to :action => :index + redirect_to match_refs_admin_import_csvs_path end + def new @import_csv = ImportCsv.new(:parent_id => params[:parent_id]) if @import_csv.parent diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index 9cb4915..2ded2ca 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -72,7 +72,7 @@ class Admin::PProductsController < ApplicationController @p_product = PProduct.new #(:p_customer_cat_ids => [3]) - + @p_product.name = params[:p_fournisseur_ref_label] if params[:p_fournisseur_ref_label] # @p_product.p_product_refs << PProductRef.new @p_product_refs = @p_product.p_product_refs.build @p_product_ref_specs = @p_product_refs.p_product_ref_specs.build diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index b224d70..f0b89fc 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -360,6 +360,8 @@ class Admin::PriceDocumentsController < ApplicationController redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] elsif @price_document.ref_element redirect_to [:admin, @price_document.ref_element] + elsif @price_document.label == "Catalogue fournisseur" + redirect_to match_refs_admin_import_csvs_path else redirect_to [:admin, @price_document] end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06d193f..a0b3022 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -127,6 +127,7 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" 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 end diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 9a7fccf..4b9d5a3 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -22,6 +22,7 @@ class PProductRef < ApplicationRecord has_many :p_customer_product_prices, :dependent => :destroy accepts_nested_attributes_for :p_customer_product_prices, allow_destroy: true + has_many :p_fournisseur_refs scope :enableds, -> {where(:enabled => true)} diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 32e2d5b..897399c 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -14,6 +14,7 @@ class PriceLine < ApplicationRecord default_scope { order('position ASC') } validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed? + validates :p_product_id, :presence => true, :if => :p_product_needed? validates :qte, :presence => true @@ -21,7 +22,8 @@ class PriceLine < ApplicationRecord has_many :line_stocks - + after_update :memorize_p_fournisseur_ref, if: :p_fournisseur_ref_is_memorizable? + acts_as_sorting :fields => { :ref => {:name => "Ref", :reorder => true}, :title => {:name => "Désignation", :reorder => true}, @@ -58,7 +60,7 @@ class PriceLine < ApplicationRecord COMMANDE_ACHAT_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) - + def to_no_archive if !self.imported %w(cost_ht marge_ht) @@ -170,7 +172,13 @@ class PriceLine < ApplicationRecord true end end - + + def p_product_needed? + if !self.ct_title? and !self.imported + true + end + end + def personalised_archive end @@ -617,6 +625,12 @@ class PriceLine < ApplicationRecord return [asap, non_asap] end - - + def p_fournisseur_ref_is_memorizable? + self.p_product_ref.present? && self.imported? && PFournisseurRef.where(p_fournisseur: self.p_fournisseur, ref: self.ct_ref, label: self.ct_title).empty? + end + + def memorize_p_fournisseur_ref + PFournisseurRef.create(p_fournisseur: self.p_fournisseur, p_product_ref: self.p_product_ref, ref: self.ct_ref, label: self.ct_title) + end + end diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 942a0ea..223aab1 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,7 +23,7 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"] + PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat", "Catalogue fournisseur"] SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] diff --git a/app/views/admin/import_csvs/match_refs.html.haml b/app/views/admin/import_csvs/match_refs.html.haml new file mode 100644 index 0000000..c44a8c0 --- /dev/null +++ b/app/views/admin/import_csvs/match_refs.html.haml @@ -0,0 +1,26 @@ +:javascript + var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}" +.qi_row + %h1 Rapprochement de références produits + + -@price_documents.each do |price_document| + %br + .qi_pannel.qi_plain.padding.mt-4 + =semantic_form_for [:admin, price_document] do |f| + =f.semantic_fields_for :price_line_block do |f| + %h2= "Import catalogue : " + f.object.p_fournisseur.name + %div{:style=>"padding:0 30px;"} + .row.qi_field_wrapper + %table{:style => "width:100%;border-collapse:separate;"} + %thead + %tr + %th + %th Référence Produit Arcom + %th Créer une référence + %th Référence fournisseur + %th + %tbody.price_lines_form + =f.semantic_fields_for :price_lines do |form| + -if form.object.p_product_ref.nil? + =render :partial => "admin/price_lines/form_match_refs", :locals => {:form => form} + =f.submit "Valider", class: "btn btn-primary mt-3" diff --git a/app/views/admin/price_lines/_form_match_refs.html.haml b/app/views/admin/price_lines/_form_match_refs.html.haml new file mode 100644 index 0000000..a8c2482 --- /dev/null +++ b/app/views/admin/price_lines/_form_match_refs.html.haml @@ -0,0 +1,93 @@ +%tr.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} + + + %td{:style => "width: 30px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} + .take.text-center.px-2 + =ic :arrows + %td{:style => "white-space: nowrap; width: 400px;"} + + + + .input-group + %input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"} + =form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" + + + + + .input-group-append + =link_to "#", class: "btn btn-dark",:onclick => "key=genRanHex(12);select_product_from_manager(key);$(this).closest('tr').find('.p_product_ref_id').attr('id', 'p_product_ref_id_'+key);$(this).closest('tr').find('.p_product_ref_name').attr('id', 'p_product_ref_name_'+key);$(this).closest('tr').find('.p_product_ref_qte').attr('id', 'p_product_ref_qte_'+key);return false;" do + =ic(:search) + + + %td.text-center{style: "width: 80px;"} + %span=link_to ic(:"plus"), new_admin_p_product_path(p_fournisseur_ref_label: form.object.title) + + + + %td.pl-2 + =form.object.title + %td.text-center{style: "width: 30px;"} + %span.destroy=link_to_remove_fields ic(:"trash-o"), form + + + =qi_js_field(form, :price_line, :tva_account_value, :hidden => true) + + = form.hidden_field :position, :class => "price_line_position_input" + + +:javascript + $('.p_product_ref_autocomplete_input').focus() + $( function() { + $('.p_product_ref_autocomplete_input').autocomplete({ + source: function( request, response ) { + $.ajax( { + url: "/admin/p_product_refs/autocomplete.json", + dataType: "json", + data: { + search: request.term, + p_customer_id: $(".p_customer_id").val() + }, + success: function(data){ + arr = jQuery.map( data, function( item ) { + return { + label: item.member_label, + value: item.member_label, + id: item.id + } + }); + response(arr) + } + }); + }, + minLength: 2, + select: function( event, ui ) { + $(this).next(".p_product_ref_id").val(ui.item.id) + form = $(this).closest(".price_line_form") + $.ajax( { + url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json", + dataType: "json", + data: { + type: "price", + qte: form.find(".input_price_line_qte").val(), + p_customer_id: $(".p_customer_id").val() + }, + success: function (data) { + form.find(".input_price_line_price_u_ht").val(data.price); + form.find(".input_price_line_tva_account_id").val(data.tva_account_id); + form.find(".input_price_line_tva_account_value").val(data.tva_account_value); + form.find(".input_price_line_weight_u").val(data.weight); + } + }); + //return false + } + }); + }); + + +:scss + .price_line_form{ + .form-group{ + margin-bottom:0;} + + } diff --git a/config/routes.rb b/config/routes.rb index d3a9d8a..6b62c9c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -456,6 +456,9 @@ Rails.application.routes.draw do namespace :admin do resources :import_csvs do + collection do + get :match_refs + end member do get :charge end From 1fc9e696bc6d8d1ba13455b2b7ac195361433f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 7 Oct 2021 17:21:48 +0200 Subject: [PATCH 49/91] bugfix autocomplete --- app/views/admin/price_lines/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 123ca49..6861e44 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -10,6 +10,7 @@ .input-group %input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"} + = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" @@ -22,7 +23,6 @@ - = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" From 296e4aef5fa29aadf2c3b9b86fac1a92eb074c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 8 Oct 2021 19:24:16 +0200 Subject: [PATCH 50/91] add new p_product_ref after import --- .../admin/import_csvs_controller.rb | 17 ++++ .../admin/p_product_refs_controller.rb | 12 ++- .../admin/p_products_controller.rb | 4 +- app/models/p_product.rb | 5 +- app/models/p_product_ref.rb | 5 +- app/models/p_product_ref_spec.rb | 2 + .../_form_temp_p_product.html.haml | 89 +++++++++++++++++++ .../admin/import_csvs/temp_p_product.js.erb | 1 + .../admin/p_product_ref_specs/_form.html.haml | 8 +- app/views/admin/p_product_refs/update.js.erb | 8 +- .../price_lines/_form_match_refs.html.haml | 4 +- config/routes.rb | 1 + 12 files changed, 138 insertions(+), 18 deletions(-) create mode 100644 app/views/admin/import_csvs/_form_temp_p_product.html.haml create mode 100644 app/views/admin/import_csvs/temp_p_product.js.erb diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index 9f70258..9d3ebb1 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -92,4 +92,21 @@ class Admin::ImportCsvsController < ApplicationController @import_csv.destroy end + + def temp_p_product + dev_mode = false + if dev_mode + @p_product_ref = PProductRef.last #DEV mode only + @price_line = PriceLine.find(params[:price_line_id]) + + @p_product_ref.ct_price_ht = @price_line.ct_u_price_ht #DEV ode onmy + @p_product_ref.p_product_ref_specs.build + else + if params[:price_line_id] + @price_line = PriceLine.find(params[:price_line_id]) + @p_product_ref = PProductRef.find_or_create_by(p_product: PProduct.find_by(name: "--> Selectioner un produit <--"), ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) + @p_product_ref.p_product_ref_specs.build + end + end + end end diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 736d823..2ff7f98 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -1,6 +1,8 @@ # -*- encoding : utf-8 -*- class Admin::PProductRefsController < ApplicationController + include ActionView::RecordIdentifier # adds `dom_id` + layout "admin" before_action :auth_admin @@ -102,12 +104,14 @@ class Admin::PProductRefsController < ApplicationController def update + @p_product_ref = PProductRef.find(params[:id]) - - if @p_product_ref.update_attributes(params.require(:p_product_ref).permit!) - - + if params[:update_price_line_id] + @price_line = PriceLine.find(params[:update_price_line_id]) + @price_line.update(p_product_ref: @p_product_ref) + end + # redirect_to admin_p_products_path(@p_product_ref.p_product, anchor: dom_id(@p_product_ref)) else render action: "edit" diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index 2ded2ca..aef9a1a 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -72,9 +72,9 @@ class Admin::PProductsController < ApplicationController @p_product = PProduct.new #(:p_customer_cat_ids => [3]) - @p_product.name = params[:p_fournisseur_ref_label] if params[:p_fournisseur_ref_label] # @p_product.p_product_refs << PProductRef.new - @p_product_refs = @p_product.p_product_refs.build + fournisseur_label = params[:fournisseur_label] if params[:fournisseur_label] + @p_product_refs = @p_product.p_product_refs.build(ct_sub_name: fournisseur_label) @p_product_ref_specs = @p_product_refs.p_product_ref_specs.build @p_spec_type = @p_product_ref_specs.build_p_spec_type @p_spec_value = @p_product_ref_specs.build_p_spec_value diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 893a83c..ef6cdc6 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -33,9 +33,8 @@ class PProduct < ApplicationRecord belongs_to :p_product_cat belongs_to :s_brand - validates :name, :presence => true - validates :code, :presence => true, :uniqueness => true - + validates :name, :presence => true, exclusion: { in: ["--> Selectioner un produit <--"], message: "Selectioner un produit avant de valider" } + validates :code, :presence => true, :uniqueness => true, exclusion: { in: ["--> Indiquer un code produit <--"], message: "Indiquer un code produit avant de valider" } has_many :tvable_tva_rates, :as => :tvable has_many :tva_rates, :through => :tvable_tva_rates diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 4b9d5a3..d11adc1 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -15,7 +15,7 @@ class PProductRef < ApplicationRecord accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true has_many :p_product_ref_specs - accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true + accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true, reject_if: :all_blank #validates :ct_price_ht, :presence => true validate :ean, :is_integer @@ -88,7 +88,8 @@ class PProductRef < ApplicationRecord self.p_product.p_product_cat_id end - QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name) + # 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) diff --git a/app/models/p_product_ref_spec.rb b/app/models/p_product_ref_spec.rb index a036951..e15b3f1 100644 --- a/app/models/p_product_ref_spec.rb +++ b/app/models/p_product_ref_spec.rb @@ -5,6 +5,8 @@ class PProductRefSpec < ApplicationRecord accepts_nested_attributes_for :p_spec_type, :p_spec_value + validates :p_spec_type_id, :p_spec_value_id, presence: true + acts_as_sorting :fields => { :id => {:name => "ID"}, :p_product_ref => {:name => "Référence produit", :reorder => true}, diff --git a/app/views/admin/import_csvs/_form_temp_p_product.html.haml b/app/views/admin/import_csvs/_form_temp_p_product.html.haml new file mode 100644 index 0000000..afa6595 --- /dev/null +++ b/app/views/admin/import_csvs/_form_temp_p_product.html.haml @@ -0,0 +1,89 @@ +=semantic_form_for [:admin, @p_product_ref], remote: true do |form| + =hidden_field_tag :update_price_line_id, @price_line.id + .content + .qi_row.field + .padding + + %h1 Ajouter une références + %table.form-table + %tr + %td{colspan: 3} + %label Selectionner le produit parent + .input-group + %input.p_product_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :class => "p_product_name"} + =form.hidden_field :p_product_id, :class => "p_product_id" + + =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.ct_sub_name) + + %tr + %td{:colspan => 3} + %input.form-control{type: "text", placeholder: @p_product_ref.ct_sub_name, "aria-label" => "Disabled input example", disabled: true} + =#form.input :ct_sub_name, label: "Label fournisseur", input_html: {disabled: true} + + %tr + %td{:colspan => 3} + = form.input :ct_sub_name, :label => "Désignation ARCOM :" + %tr + %td + = form.input :ref, :label => "Réf int. :" + + %td + = form.input :ct_price_ht, :label => "Prix vente HT :" + + %td + =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"} + %tr + %td + =form.input :ct_sorecop, :label => "Sorecop personalisée :" + %td + =form.input :sorecop_comment, :label => "Type de Sorecop :" + %td + =form.input :ct_deee, :label => "DEEE personalisée :" + %tr + %td + =form.input :ean + + %td{:colspan => 2} + = form.input :description, :label => "Désignation longue :" , :input_html => {rows: 1} + + %tr + %td{:colspan => 3} + .qi_pannel.qi_plain.padding + .p_product_ref_specs_form + = form.semantic_fields_for :p_product_ref_specs do |f| + =render :partial => "admin/p_product_ref_specs/form", :locals => {:form => f} + %p= link_to_add_fields "Ajouter une spec", form, :p_product_ref_specs + + .actions=form.submit "sauvegarder", :class => "btn btn-primary" + + + +:javascript + $('.p_product_autocomplete_input').focus() + $( function() { + $('.p_product_autocomplete_input').autocomplete({ + source: function( request, response ) { + $.ajax( { + url: "/admin/p_products/autocomplete.json", + dataType: "json", + data: { + search: request.term, + }, + success: function(data){ + arr = jQuery.map( data, function( item ) { + return { + label: item.name, + value: item.name, + id: item.id + } + }); + response(arr) + } + }); + }, + minLength: 2, + select: function( event, ui ) { + $(this).next(".p_product_id").val(ui.item.id) + } + }); + }); diff --git a/app/views/admin/import_csvs/temp_p_product.js.erb b/app/views/admin/import_csvs/temp_p_product.js.erb new file mode 100644 index 0000000..0562b62 --- /dev/null +++ b/app/views/admin/import_csvs/temp_p_product.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form_temp_p_product"))%>",700,900); diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index ffde9d3..d369fed 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -15,15 +15,15 @@ %table %tr %td - %h4 spec : - + %h4 Specs : + %tr %td -#form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type -#form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value - = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => false + = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => true,input_html: {class: "custom-select"} %td - = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false, :member_label => :member_label + = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => true, :member_label => :member_label, input_html: {class: "custom-select"} =#form.inputs do diff --git a/app/views/admin/p_product_refs/update.js.erb b/app/views/admin/p_product_refs/update.js.erb index 49eb092..8b84b1e 100644 --- a/app/views/admin/p_product_refs/update.js.erb +++ b/app/views/admin/p_product_refs/update.js.erb @@ -1,2 +1,8 @@ $('#p_product_ref_row_<%= @p_product_ref.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref))%>"); -close_pane_hover(); \ No newline at end of file + +if ($('#<%= dom_id(@price_line) %>').parents('.qi_pannel.qi_plain').find('tbody').find('tr').length === 1) { + $('#<%= dom_id(@price_line) %>').parents('.qi_pannel.qi_plain').remove() +} +$('#<%= dom_id(@price_line) %>').remove(); + +close_pane_hover(); diff --git a/app/views/admin/price_lines/_form_match_refs.html.haml b/app/views/admin/price_lines/_form_match_refs.html.haml index a8c2482..fb4fc62 100644 --- a/app/views/admin/price_lines/_form_match_refs.html.haml +++ b/app/views/admin/price_lines/_form_match_refs.html.haml @@ -1,4 +1,4 @@ -%tr.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} +%tr.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;", id: dom_id(form.object)} %td{:style => "width: 30px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} @@ -21,7 +21,7 @@ %td.text-center{style: "width: 80px;"} - %span=link_to ic(:"plus"), new_admin_p_product_path(p_fournisseur_ref_label: form.object.title) + %span=link_to ic(:"plus"), temp_p_product_admin_import_csvs_path(price_line_id: form.object.id), remote: true diff --git a/config/routes.rb b/config/routes.rb index 6b62c9c..59be0a4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -458,6 +458,7 @@ Rails.application.routes.draw do resources :import_csvs do collection do get :match_refs + get :temp_p_product end member do get :charge From 63d1069be5e426efee38b7b6d5ec1105eb457d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 8 Oct 2021 19:24:31 +0200 Subject: [PATCH 51/91] small improvement --- app/views/admin/p_product_refs/_form.html.haml | 6 +++--- app/views/admin/p_product_refs/_p_product_ref.html.haml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index 4b0b755..8b4149f 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -1,6 +1,6 @@ =#debug form.object.errors.messages =# form.input :ref, :label => "Ref :" -.qi_row.field +.qi_row.field{id: dom_id(form.object)} .qi_pannel.qi_plain.padding %table.form-table @@ -19,7 +19,7 @@ = form.input :ct_price_ht, :label => "Prix vente HT :" %td - =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true + =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"} %td =form.input :ct_sorecop, :label => "Sorecop personalisée :" %td @@ -44,7 +44,7 @@ %tr %td{:colspan => 2} %td{:colspan => 4} - = form.input :description, :label => "Désignation longue :" , :input_html => {:style => "height:100px;"} + = form.input :description, :label => "Désignation longue :" , :input_html => {rows: 1} -if false %tr diff --git a/app/views/admin/p_product_refs/_p_product_ref.html.haml b/app/views/admin/p_product_refs/_p_product_ref.html.haml index ca09295..3fb1b23 100644 --- a/app/views/admin/p_product_refs/_p_product_ref.html.haml +++ b/app/views/admin/p_product_refs/_p_product_ref.html.haml @@ -37,10 +37,10 @@ = link_to i(:"check"), "#",:onclick => "send_manager_product('"+p_product_ref.id.to_s+"', '"+escape_javascript(p_product_ref.member_label.to_s)+"');return false;" -else - = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false + = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product, anchor: dom_id(p_product_ref)), :remote => false = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref} - \ No newline at end of file + From dbc8d3bfd67d50b248fcadf5f2ab34ae4e545514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 11 Oct 2021 19:07:32 +0200 Subject: [PATCH 52/91] refacto --- app/controllers/admin/import_csvs_controller.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index 9d3ebb1..bac0c29 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -94,19 +94,11 @@ class Admin::ImportCsvsController < ApplicationController end def temp_p_product - dev_mode = false - if dev_mode - @p_product_ref = PProductRef.last #DEV mode only + if params[:price_line_id] @price_line = PriceLine.find(params[:price_line_id]) - - @p_product_ref.ct_price_ht = @price_line.ct_u_price_ht #DEV ode onmy + p_product = PProduct.find_or_create_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--") + @p_product_ref = PProductRef.find_or_create_by(p_product: p_product, ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) @p_product_ref.p_product_ref_specs.build - else - if params[:price_line_id] - @price_line = PriceLine.find(params[:price_line_id]) - @p_product_ref = PProductRef.find_or_create_by(p_product: PProduct.find_by(name: "--> Selectioner un produit <--"), ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) - @p_product_ref.p_product_ref_specs.build - end end end end From e56c6bb37dae798bdc6d0a5e3df6d6de0bd66ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 11 Oct 2021 19:13:34 +0200 Subject: [PATCH 53/91] update price_line after create p_product + destroy callbacks --- app/controllers/admin/p_products_controller.rb | 3 +++ app/models/p_product.rb | 8 +++++++- app/models/p_product_ref.rb | 13 +++++++++++++ .../import_csvs/_form_temp_p_product.html.haml | 2 +- app/views/admin/p_product_refs/_form.html.haml | 4 +++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index aef9a1a..871bd95 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -74,6 +74,9 @@ class Admin::PProductsController < ApplicationController @p_product = PProduct.new #(:p_customer_cat_ids => [3]) # @p_product.p_product_refs << PProductRef.new fournisseur_label = params[:fournisseur_label] if params[:fournisseur_label] + if params[:price_line_id] + @price_line = PriceLine.find(params[:price_line_id]) + end @p_product_refs = @p_product.p_product_refs.build(ct_sub_name: fournisseur_label) @p_product_ref_specs = @p_product_refs.p_product_ref_specs.build @p_spec_type = @p_product_ref_specs.build_p_spec_type diff --git a/app/models/p_product.rb b/app/models/p_product.rb index ef6cdc6..4e501c0 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -103,15 +103,21 @@ class PProduct < ApplicationRecord after_create do - end after_save do self.p_product_refs.each do |ppr| ppr.save end + self.class.destroy_temp_p_product end + def self.destroy_temp_p_product + temp_p_product = PProduct.find_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--") + if temp_p_product.present? + temp_p_product.destroy + end + end def tva_rate(accounting_zone_id) if r = self.tva_rates.where(:accounting_zone_id => accounting_zone_id).first diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index d11adc1..3203fc1 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -53,6 +53,19 @@ class PProductRef < ApplicationRecord acts_as_caching :fields => [:sorecop, :deee] + attr_accessor :price_line_id + + after_create do + if self.price_line_id + pl = PriceLine.find(self.price_line_id) + pl.update(p_product_ref: self) + end + end + + after_save do + PProduct.destroy_temp_p_product + end + def not_imported? if !self.p_product or !self.p_product.imported true diff --git a/app/views/admin/import_csvs/_form_temp_p_product.html.haml b/app/views/admin/import_csvs/_form_temp_p_product.html.haml index afa6595..9173a3d 100644 --- a/app/views/admin/import_csvs/_form_temp_p_product.html.haml +++ b/app/views/admin/import_csvs/_form_temp_p_product.html.haml @@ -13,7 +13,7 @@ %input.p_product_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :class => "p_product_name"} =form.hidden_field :p_product_id, :class => "p_product_id" - =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.ct_sub_name) + =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.ct_sub_name, price_line_id: @price_line.id) %tr %td{:colspan => 3} diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index 8b4149f..f89bf35 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -11,7 +11,9 @@ %td = form.input :ref, :label => "Réf int. :" =#form.hidden_field :ref_id - + -if @price_line + =form.hidden_field :price_line_id, value: @price_line.id + %td = form.input :ct_sub_name, :label => "Désignation :" From 906e101881e5f268fb2bc06ed0fe80802455720c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 11 Oct 2021 19:13:58 +0200 Subject: [PATCH 54/91] uncomment element add --- app/models/p_fournisseur.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index c804f32..0b6de85 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -76,7 +76,7 @@ class PFournisseur < ApplicationRecord n.p_contacts << contact_1 if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) n.p_contacts << contact_2 if contact_2 n.p_contacts << contact_3 if contact_3 - # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) end end end From 8f92692d79fb618193fd799fdcca42138e5d6cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 13 Oct 2021 18:13:47 +0200 Subject: [PATCH 55/91] refacto import --- app/models/p_fournisseur.rb | 125 +++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 36 deletions(-) diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index 0b6de85..44a7f77 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -4,27 +4,27 @@ class PFournisseur < ApplicationRecord has_many :p_fournisseur_refs acts_as_csv_import :fields => [ - :name, - :address1, + :nom_fournisseur, + :address, :cp, - :city, - :country, - :email, + :ville, + :pays, + :tva_intracom, + :delai_paiement, + :interlocuteur, + :fonction, :tel, - :p_contact_name, - :p_contact_comment, - :p_contact_tel, - :p_contact_skype, - :p_contact_email_1, - :p_contact_email_2, - :p_contact_email_3, - :bic, + :skype, + :email_1, + :email_2, + :email_3, :iban, - :payment_delais, - :tva_num, - :p_payment_type + :bic, + :reglement_par ] + + def self.custom_csv_import(list, import_csv) # ap "*********************************************************************************************************" # ap "*********************************************************************************************************" @@ -50,33 +50,86 @@ class PFournisseur < ApplicationRecord if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" - elsif key == "p_contact_name" - contact_1.name = value - elsif key == "p_contact_comment" - contact_1.p_contact_types << PContactType.find_or_create_by(name: value) - elsif key == "p_contact_tel" - contact_1.tel = value - elsif key == "p_contact_skype" - contact_1.skype = value - elsif key == "p_contact_email_1" - contact_1.email = value - elsif key == "p_contact_email_2" - contact_2 = PContact.new(email: value) - elsif key == "p_contact_email_3" - contact_3 = PContact.new(email: value) - elsif key == "p_payment_type" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id else - eval "n.#{key} = value" + case key + when "nom_fournisseur" + n.name = value + when "address" + n.address1 = value + when "ville" + n.city = value + when "pays" + n.country = value + when "tva_intracom" + n.tva_num = value + when "delai_paiement" + next if value.nil? + case value + when "A la commande" + n.payment_delais = 0 + when "A réception" + n.payment_delais = 0 + when "7 jours net" + n.payment_delais = 7 + when "21 jours net" + n.payment_delais = 21 + when "30 jours" + n.payment_delais = 30 + when "30 jours net" + n.payment_delais = 30 + when "30 jours fin de mois" + n.payment_delais = 30 + when "35 jours net" + n.payment_delais = 35 + when "40 jours net" + n.payment_delais = 40 + when "60 jours net" + n.payment_delais = 60 + when "60 jours fin de mois" + n.payment_delais = 60 + else + n.payment_delais = value + end + when "interlocuteur" + contact_1.name = value + when "fonction" + contact_1.p_contact_types << PContactType.find_or_create_by(name: value) + when "tel" + contact_1.tel = value + when "skype" + contact_1.skype = value + when "email_1" + contact_1.email = value + when "email_2" + contact_2 = PContact.new(email: value) + when "email_3" + contact_3 = PContact.new(email: value) + when "reglement_par" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + else + eval "n.#{key} = value" + end end end # particular.organisation = self.name n.save - n.p_contacts << contact_1 if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) - n.p_contacts << contact_2 if contact_2 - n.p_contacts << contact_3 if contact_3 + if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) + n.p_contacts << contact_1 + import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_1) + end + if contact_2 + n.p_contacts << contact_2 + import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_2) + end + + if contact_3 + n.p_contacts << contact_3 + import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_3) + end + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + end end end From 719f0007b72375acbc5bbac9b8bbbdacc26473ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 13 Oct 2021 18:14:15 +0200 Subject: [PATCH 56/91] can be deleted by csv_element destroy --- app/models/p_customer_rib.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/p_customer_rib.rb b/app/models/p_customer_rib.rb index 856d1d3..2b4a176 100644 --- a/app/models/p_customer_rib.rb +++ b/app/models/p_customer_rib.rb @@ -1,7 +1,7 @@ class PCustomerRib < ActiveRecord::Base belongs_to :p_customer - has_many :p_documents, :dependent => :nullify + # has_many :p_documents, :dependent => :nullify def generate_rum if self.sign_date From cbb5d65098e639dd356155844c53d2169829e54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 13 Oct 2021 18:14:41 +0200 Subject: [PATCH 57/91] add import p_customer --- app/views/admin/import_csvs/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/import_csvs/_form.html.haml b/app/views/admin/import_csvs/_form.html.haml index ede671b..499e7be 100644 --- a/app/views/admin/import_csvs/_form.html.haml +++ b/app/views/admin/import_csvs/_form.html.haml @@ -6,7 +6,7 @@ = f.input :name, :label => "Nom de l'import :" = f.input :file, :label => "file :" - = f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Base fournisseurs", "p_fournisseur"], ["Mise à jour catalogue prix","price_document"]] + = f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Base fournisseurs", "p_fournisseur"], ["Mise à jour catalogue prix","price_document"], ["Base client", "p_customer"]] -if f.object.id %table.import_csv_champs_form From 8cefeec6b3cf11167ff6c4d23493cd920743ea18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 13 Oct 2021 18:14:54 +0200 Subject: [PATCH 58/91] import p_customer --- app/models/p_bank.rb | 1 + app/models/p_customer.rb | 423 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 424 insertions(+) diff --git a/app/models/p_bank.rb b/app/models/p_bank.rb index cbd7d79..097616d 100644 --- a/app/models/p_bank.rb +++ b/app/models/p_bank.rb @@ -1,2 +1,3 @@ class PBank < ApplicationRecord + has_many :particulars, :as => :owner, :dependent => :destroy end diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index e1ee85d..282b46f 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -256,6 +256,7 @@ class PCustomer < ApplicationRecord end def solde_avoir_and_bills(date = Date.today) + raise # p_document_id à remplacer self.p_documents.where(:p_document_type_id => [4,7]).where("created_at < ?", date.to_time.end_of_day).sum(:cache_total_ttc) end @@ -480,5 +481,427 @@ class PCustomer < ApplicationRecord end while PCustomer.exists?(column => self[column]) end + acts_as_csv_import :fields => [ + :code, + :societe_raison_sociale, + :nom_enseigne, + :adresse_facturation_1, + :adresse_livraison_2, + :adresse_3, + :cp, + :cp2, + :ville_1, + :ville_2, + :pays, + :societe_livraison, + :forme_juridique, + :famille_client, + :facturer_ttc, + :mode_reglement, + :libelle_mode_reglement, + :telephone_1, + :telephone_2, + :fax, + :risque, + :bloque, + :credit_accorde, + :mode_tva, + :nii, + :nom_banque, + :adresse_banque_1, + :adresse_banque_2, + :adresse_banque_3, + :code_banque, + :ville_banque, + :pays_banque, + :code_banque, + :code_guichet, + :numero_compte, + :cle_rib, + :compte_comptable, + :analytique, + :taux_remise, + :observation, + :export_compta, + :releve_compte, + :email, + :url, + :siret, + :representant, + :nom_representant, + :encour_initial, + :credit_disponible, + :code_tarif, + :telephone_livraison, + :portable_livraison, + :fax_livraison, + :encours_courant, + :encours, + :client_divers, + :contacts_client, + :date_creation, + :code_iban, + :code_bic, + :nom_contact, + :societe_contact, + :titre_contact, + :fonction_contact, + :telephone_contact, + :portable_contact, + :email_contact + ] + def self.custom_csv_import(list, import_csv) + #OK Code AUTO :code OK :code + #OK Société - Raison Sociale :particular.organisation OK :societe_raison_sociale + #OK Nom enseigne :particular.com_name OK :nom_enseigne + #OK Adresse facturation 1 :particular.address_1 OK :adresse_facturation_1 + #OK Adresse Livraison 2 :particular.address_2 OK :adresse_livraison_2 + #OK Adresse 3 :particular.address_3 OK :adresse_3 + #OK Code Postal 1 :particular.cp OK :cp + #OK Code Postal 2 VIDE OK :cp2 + #OK Ville 1 :particular_city OK :ville_1 + #OK Ville 2 VIDE OK :ville_2 + #OK Pays :particular.country OK :pays + #OK Société Livraison :particular.address_4 OK :societe_livraison + #OK Forme juridique livraison :particular.address_5 OK :forme_juridique + #OK Famille Client VIDE OK :famille_client + #OK Facturer en TTC VIDE OK :facturer_ttc + #OK Mode Règlement :p_payment_type OK :mode_reglement + #OK Libellé Mode Règlement :payment_delais OK :libelle_mode_reglement + #OK Téléphone 1 :particular.tel OK :telephone_1 + #OK Téléphone 2 :particular.tel2 OK :telephone_2 + #OK Fax :particular.fax OK :fax + #OK Risque VIDE OK :risque + #OK Bloqué VIDE OK :bloque + #OK Crédit accordé VIDE OK :credit_accorde + #OK Mode TVA VIDE OK :mode_tva + #OK N.I.I. VIDE OK :nii + #OK Nom Banque :p_bank.name OK :nom_banque + #OK Adresse 1 Banque :p_bank.particular.address_1 OK :adresse_banque_1 + #OK Adresse 2 Banque :p_bank.particular.address_2 OK :adresse_banque_2 + #OK Adresse 3 Banque VIDE OK :adresse_banque_3 + #OK Code Postal Banque :p_bank.particular.cp OK :code_banque + #OK Ville Banque :p_bank.particular.ville OK :ville_banque + #OK Pays Banque :p_bank.particular.pays OK :pays_banque + #OK Code Banque INUTILE OK :code_banque + #OK Code Guichet INUTILE OK :code_guichet + #OK Numéro Compte INUTILE OK :numero_compte + #OK Clé RIB INUTILE OK :cle_rib + # Compte Comptable ??? ?? :compte_comptable + #OK Analytique VIDE OK :analytique + #OK Taux Remise VIDE OK :taux_remise + #OK Observations AUTO :p_customer_sheet_note OK :observation + #OK Export Compta VIDE OK :export_compta + # Relevé Compte Bboolean à ajouter dans la base ?? :releve_compte + #OK E-mail AUTO :email OK :email + #OK URL VIDE OK :url + #OK SIRET AUTO :siret OK :siret + #OK Représentant :p_commercial_code OK :representant + #OK Nom Représentant :p_commercial_firstname OK :nom_representant + # Encours initial ??? ?? :encour_initial + # Crédit Disponible ??? ?? :credit_disponible + #OK Code Tarif VIDE OK :code_tarif + #OK Téléphone Livraison :particular.send_tel OK :telephone_livraison + #OK Portable Livraison :particular.send_tel2 OK :portable_livraison + #OK Fax Livraison :particular.send_fax OK :fax_livraison + # Encours courant ??? ?? :encours_courant + # encours_courant ??? ?? :encours + # Client divers ??? ?? :client_divers + #OK Contacts client INUTILE OK :contacts_client + #OK Date de création INUTILE OK :date_creation + #OK Code IBAN :p_customer_ribs.iban OK :code_iban + #OK Code BIC :p_customer_ribs.bic OK :code_bic + #OK Nom du contact :p_contact_name OK :nom_contact + #OK Société du contact VIDE OK :societe_contact + #OK Titre du contact :p_contact.civilite OK :titre_contact + #OK Fonction du contact :p_contact.comment OK :fonction_contact + #OK Téléphone du contact :p_contact.tel OK :telephone_contact + #OK Portable du contact :p_contact.tel2 OK :portable_contact + #OK E-mail du contact :p_contact.email OK :email_contact + + + + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap list + # ap list.class + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap import_csv + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + + list.each do |row| + + n = self.new(imported: true, p_customer_cat: PCustomerCat.find_by_name("Professionnel")) + # particular = Particular.new(pro: true) + particular_bill = Particular.new + bank = bic = iban = p_commercial = particular_send = send_tel = send_tel2 = send_fax = send_address_2 = p_commercial_code = p_commercial_firstname = contact_2 = nil + + + bank_particular = Particular.new + contact = PContact.new + + row.each do |key, value| + + if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal + eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" + else + case key + when "societe_raison_sociale" + particular_bill.organisation = value + + when "nom_enseigne" + particular_bill.com_name = value + + when "adresse_facturation_1" + particular_bill.address_1 = value + + when "adresse_livraison_2" + send_address_2 = value + + when "adresse_3" + particular_bill.address_3 = value + + when "cp" + particular_bill.cp = value + + when "ville_1" + particular_bill.city = value + + when "pays" + particular_bill.country = value + + when "societe_livraison" + particular_bill.address_4 = value + + when "forme_juridique" + particular_bill.address_5 = value + + when "telephone_1" + particular_bill.tel = value + + when "telephone_2" + particular_bill.tel2 = value + + when "fax" + particular_bill.fax = value + + when "mode_reglement" + next if value.nil? + if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id + elsif value == "TRAITE" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id + else + n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + end + + when "libelle_mode_reglement" + case value + when "Virement à la commande" + n.payment_delais = 0 + when "Chèque à la commande" + n.payment_delais = 0 + when "Chèque à réception" + n.payment_delais = 0 + when "30 JOURS FIN DE MOIS" + n.payment_delais = 30 + when "VIR 60J NET DATE RELEVE" + n.payment_delais = 60 + when "TRAITE A 60 JOURS FIN DE MOIS" + n.payment_delais = 60 + when "Mensuel - 30j fin de mois du dépôt" + n.payment_delais = 30 + else + n.payment_delais = value + end + + when "nom_banque" + next if value.nil? + bank = PBank.find_or_create_by(name: value) + + when "adresse_banque_1" + bank_particular.address_1 = value + + when "adresse_banque_2" + bank_particular.address_2 = value + + when "code_banque" + bank_particular.cp = value + + when "ville_banque" + bank_particular.city = value + + when "pays_banque" + bank_particular.country = value + + when "telephone_livraison" + send_tel = value + + when "portable_livraison" + send_tel2 = value + + when "fax_livraison" + send_fax = value + + when "representant" + p_commercial_code = value + when "nom_representant" + p_commercial_firstname = value + + when "code_iban" + iban = value + when "code_bic" + bic = value + + when "nom_contact" + contact.name = value + + when "titre_contact" + particular_bill.civilite = value + + when "fonction_contact" + next if value.nil? + contact.p_contact_types << PContactType.find_or_create_by(name: value) + + when "telephone_contact" + contact.tel = value + + when "portable_contact" + next if value.nil? + if contact.tel.nil? + contact.tel = value + else + contact_2 = PContact.new(tel: value) + end + + when "email_contact" + contact.email = value + + when "observation" + n.p_customer_sheet_note = value + + + + + + + # champs vides ou inutiles : + when "cp2" + when "ville_2" + when "famille_client" + when "facturer_ttc" + when "risque" + when "bloque" + when "credit_accorde" + when "mode_tva" + when "nii" + when "adresse_banque_3" + when "code_banque" + when "code_guichet" + when "numero_compte" + when "cle_rib" + when "analytique" + when "taux_remise" + when "export_compta" + when "url" + when "code_tarif" + when "contacts_client" + when "date_creation" + when "societe_contact" + + # Champs ??? + when "compte_comptable" + when "encour_initial" + when "credit_disponible" + when "releve_compte" + when "encours_courant" + when "releve_compte" + when "encours" + when "client_divers" + + else + eval "n.#{key} = value" + end + + + + + end + end + + n.particulars << particular_bill + + n.save + + if bank + bank.bic = bic + bank.particulars << bank_particular if bank_particular.address_1 + bank.save + import_csv.import_csv_elements << ImportCsvElement.new(:element => bank) + + end + + if bic || iban + rib = PCustomerRib.create(bic: bic, iban: iban) + rib.bank = bank.name if bank + account = PBankAccount.create(bic: bic, iban: iban, p_bank: bank, p_customer: n) + n.p_customer_ribs << rib + import_csv.import_csv_elements << ImportCsvElement.new(:element => rib) + import_csv.import_csv_elements << ImportCsvElement.new(:element => account) + end + + if p_commercial_code || p_commercial_firstname + p_commercial = PCommercial.find_or_create_by(code: p_commercial_code, firstname: p_commercial_firstname) + n.p_commercial = p_commercial + end + + if send_tel || send_tel2 || send_fax || send_address_2 + particular_send = Particular.new + particular_send.tel = send_tel if send_tel + particular_send.tel2 = send_tel2 if send_tel2 + particular_send.fax = send_fax if send_fax + + n.particulars << particular_send + n.particular_send_id = particular_send.id + end + + n.p_contacts << contact if (contact.name || contact.tel || contact.email) + n.p_contacts << contact_2 if contact_2 + + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ contact §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap contact + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_contacts + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.particulars §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.particulars + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_customer_ribs §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_customer_ribs + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_commercial §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_commercial + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + end + end end From b57ed75754b77b259eff749ecbac7195e8af59b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 13 Oct 2021 18:23:10 +0200 Subject: [PATCH 59/91] add price_line to csv_element --- app/models/price_document.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 5161238..1e5a9b1 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -755,6 +755,7 @@ class PriceDocument < ApplicationRecord n.save import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + import_csv.import_csv_elements << ImportCsvElement.new(:element => price_line) end end From 2abba273a97dc700a7c26342f9e5c0365e9a510c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 09:08:25 +0200 Subject: [PATCH 60/91] remove next in custom_import --- app/models/p_customer.rb | 37 ++++++++++++++------------ app/models/p_fournisseur.rb | 53 +++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 282b46f..b2ee2c1 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -692,13 +692,14 @@ class PCustomer < ApplicationRecord particular_bill.fax = value when "mode_reglement" - next if value.nil? - if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id - elsif value == "TRAITE" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id - else - n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + if value.present? + if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id + elsif value == "TRAITE" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id + else + n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + end end when "libelle_mode_reglement" @@ -722,8 +723,9 @@ class PCustomer < ApplicationRecord end when "nom_banque" - next if value.nil? - bank = PBank.find_or_create_by(name: value) + if value.present? + bank = PBank.find_or_create_by(name: value) + end when "adresse_banque_1" bank_particular.address_1 = value @@ -766,18 +768,19 @@ class PCustomer < ApplicationRecord particular_bill.civilite = value when "fonction_contact" - next if value.nil? - contact.p_contact_types << PContactType.find_or_create_by(name: value) - + if value.present? + contact.p_contact_types << PContactType.find_or_create_by(name: value) + end when "telephone_contact" contact.tel = value when "portable_contact" - next if value.nil? - if contact.tel.nil? - contact.tel = value - else - contact_2 = PContact.new(tel: value) + if value.present? + if contact.tel.nil? + contact.tel = value + else + contact_2 = PContact.new(tel: value) + end end when "email_contact" diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index 44a7f77..f65ac86 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -63,32 +63,33 @@ class PFournisseur < ApplicationRecord when "tva_intracom" n.tva_num = value when "delai_paiement" - next if value.nil? - case value - when "A la commande" - n.payment_delais = 0 - when "A réception" - n.payment_delais = 0 - when "7 jours net" - n.payment_delais = 7 - when "21 jours net" - n.payment_delais = 21 - when "30 jours" - n.payment_delais = 30 - when "30 jours net" - n.payment_delais = 30 - when "30 jours fin de mois" - n.payment_delais = 30 - when "35 jours net" - n.payment_delais = 35 - when "40 jours net" - n.payment_delais = 40 - when "60 jours net" - n.payment_delais = 60 - when "60 jours fin de mois" - n.payment_delais = 60 - else - n.payment_delais = value + if value.present? + case value + when "A la commande" + n.payment_delais = 0 + when "A réception" + n.payment_delais = 0 + when "7 jours net" + n.payment_delais = 7 + when "21 jours net" + n.payment_delais = 21 + when "30 jours" + n.payment_delais = 30 + when "30 jours net" + n.payment_delais = 30 + when "30 jours fin de mois" + n.payment_delais = 30 + when "35 jours net" + n.payment_delais = 35 + when "40 jours net" + n.payment_delais = 40 + when "60 jours net" + n.payment_delais = 60 + when "60 jours fin de mois" + n.payment_delais = 60 + else + n.payment_delais = value + end end when "interlocuteur" contact_1.name = value From c3cc3b63cab30547502a6866ef5e79dd0b130223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 09:48:11 +0200 Subject: [PATCH 61/91] add p_customer import menu --- app/views/admin/import_csvs/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/import_csvs/_form.html.haml b/app/views/admin/import_csvs/_form.html.haml index 499e7be..71bbec7 100644 --- a/app/views/admin/import_csvs/_form.html.haml +++ b/app/views/admin/import_csvs/_form.html.haml @@ -6,7 +6,7 @@ = f.input :name, :label => "Nom de l'import :" = f.input :file, :label => "file :" - = f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Base fournisseurs", "p_fournisseur"], ["Mise à jour catalogue prix","price_document"], ["Base client", "p_customer"]] + = f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Mise à jour catalogue prix","price_document"], ["Base fournisseurs", "p_fournisseur"], ["Base client", "p_customer"], ["Base produit", "p_product"]] -if f.object.id %table.import_csv_champs_form From e313408aefbe55e9546fa6731905f902be736127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 09:48:42 +0200 Subject: [PATCH 62/91] WIP import csv p_product --- app/models/p_product.rb | 181 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 4e501c0..793b3c0 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -166,4 +166,185 @@ class PProduct < ApplicationRecord self.p_product_images.order(:position).first end + acts_as_csv_import :fields => [ + :gencode, + :id, + :marque, + :famille, + :reference, + :modele, + :couleur, + :color, + :connectivite, + :sim, + :taille, + :capacite, + :infos_supp, + :reference_fabricant, + :etat, + :code_hs, + :indice_reparabilite, + :duree_dispo_pces_detachees, + :das_tête, + :das_corps, + :das_membre, + :poids, + :nb_pcs_colis, + :code_om, + :dtl, + :gbh_code_971, + :gbh_code_972, + :gbh_code_973, + :code_art, + :sorecop, + :pmp_hors_sorecop, + :target_hors_sorecop, + :frs, + :date, + :spec, + :dtl_targ, + :commentaires, + :com + ] + + def self.custom_csv_import(list, import_csv) + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + ap "*********************************************************************************************************" + ap list.size + # ap list.class + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap import_csv + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + # ap "*********************************************************************************************************" + + list.each do |row| + next if row["marque"].blank? + + n = self.new(imported: true) + + row.each do |key, value| + if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal + eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" + else + case key + when "gencode" + + when "id" + + when "marque" + + when "famille" + n.p_product_cat = PProductCat.find_or_create_by(name: value) + + when "reference" + + when "modele" + + when "couleur" + + when "color" + + when "connectivite" + + when "sim" + + when "taille" + + when "capacite" + + when "infos_supp" + + when "reference_fabricant" + + when "etat" + + when "code_hs" + + when "indice_reparabilite" + + when "duree_dispo_pces_detachees" + + when "das_tête" + + when "das_corps" + + when "das_membre" + + when "poids" + + when "nb_pcs_colis" + + when "code_om" + + when "dtl" + + when "gbh_code_971" + + when "gbh_code_972" + + when "gbh_code_973" + + when "code_art" + + when "sorecop" + + when "pmp_hors_sorecop" + + when "target_hors_sorecop" + + when "frs" + + when "date" + + when "spec" + + when "dtl_targ" + + when "commentaires" + + when "com" + + else + # eval "n.#{key} = value" + end + end + end + + # n.save + + + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ contact §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap contact + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_contacts + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.particulars §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.particulars + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_customer_ribs §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_customer_ribs + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_commercial §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n.p_commercial + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + + # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + end + end end From c6912295556d85eb0ae29186b9dbd65d9fe8d77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 11:47:03 +0200 Subject: [PATCH 63/91] pluck existing unit in form --- app/models/p_spec_value.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb index 8471de5..c9aade6 100644 --- a/app/models/p_spec_value.rb +++ b/app/models/p_spec_value.rb @@ -1,7 +1,7 @@ class PSpecValue < ApplicationRecord has_many :p_product_ref_specs - UNITS = ["Go", "Mo"] + UNITS = self.distinct.pluck(:unit) def member_label "#{value} #{unit}" From cdb200f4a443a0d0c509c23bb39940a3abcabec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 18:32:16 +0200 Subject: [PATCH 64/91] add details to import --- ...211014081433_add_genecode_to_p_products.rb | 5 +++++ ...4444_add_import_field_to_p_product_refs.rb | 22 +++++++++++++++++++ db/schema.rb | 21 +++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20211014081433_add_genecode_to_p_products.rb create mode 100644 db/migrate/20211014134444_add_import_field_to_p_product_refs.rb diff --git a/db/migrate/20211014081433_add_genecode_to_p_products.rb b/db/migrate/20211014081433_add_genecode_to_p_products.rb new file mode 100644 index 0000000..d4acf40 --- /dev/null +++ b/db/migrate/20211014081433_add_genecode_to_p_products.rb @@ -0,0 +1,5 @@ +class AddGenecodeToPProducts < ActiveRecord::Migration[6.0] + def change + add_column :p_products, :genecode, :string + end +end diff --git a/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb b/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb new file mode 100644 index 0000000..d747875 --- /dev/null +++ b/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb @@ -0,0 +1,22 @@ +class AddImportFieldToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :manufacturer_ref, :string + add_column :p_product_refs, :used_state, :string + add_column :p_product_refs, :i_code_hs, :string + add_column :p_product_refs, :prepair_score, :decimal, precision: 10, scale: 2 + add_column :p_product_refs, :part_delay, :string + add_column :p_product_refs, :das_head, :string + add_column :p_product_refs, :das_body, :string + add_column :p_product_refs, :das_membre, :string + add_column :p_product_refs, :nb_pcs_colis, :integer + add_column :p_product_refs, :code_om, :string + add_column :p_product_refs, :gbh_code_971, :string + add_column :p_product_refs, :gbh_code_972, :string + add_column :p_product_refs, :gbh_code_973, :string + add_column :p_product_refs, :code_art, :string + add_column :p_product_refs, :i_comment, :string + add_column :p_product_refs, :i_pmp_hors_sorecop, :string + add_column :p_product_refs, :i_target_hors_sorecop, :string + add_column :p_product_refs, :p_fournisseur_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 5c1a20a..c4ad708 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_05_134955) do +ActiveRecord::Schema.define(version: 2021_10_14_134444) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1818,6 +1818,24 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" + t.string "manufacturer_ref" + t.string "used_state" + t.string "i_code_hs" + t.decimal "prepair_score", precision: 10, scale: 2 + t.string "part_delay" + t.string "das_head" + t.string "das_body" + t.string "das_membre" + t.integer "nb_pcs_colis" + t.string "code_om" + t.string "gbh_code_971" + t.string "gbh_code_972" + t.string "gbh_code_973" + t.string "code_art" + t.string "i_comment" + t.string "i_pmp_hors_sorecop" + t.string "i_target_hors_sorecop" + t.integer "p_fournisseur_id" end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| @@ -1908,6 +1926,7 @@ ActiveRecord::Schema.define(version: 2021_10_05_134955) do t.boolean "conserve_proportion", default: false t.boolean "frontpage", default: true t.integer "sorecop_cat_id" + t.string "genecode" 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 From e911fa598c6284db952b77fed2ae401657161b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 18:32:53 +0200 Subject: [PATCH 65/91] Update Type constant --- app/models/p_spec_type.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb index 42875d3..ec3b632 100644 --- a/app/models/p_spec_type.rb +++ b/app/models/p_spec_type.rb @@ -1,6 +1,7 @@ class PSpecType < ApplicationRecord has_many :p_product_ref_specs - TYPES = ["Ram", "Stockage"] + + TYPES = self.distinct.pluck(:name) acts_as_sorting :fields => { :id => {:name => "ID"}, From 6ce208d553216b1c429164df2fca8ef420f3ebe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 18:33:10 +0200 Subject: [PATCH 66/91] bugfix --- app/models/p_product_ref.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index fce57e9..5f8a453 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -165,7 +165,7 @@ class PProductRef < ApplicationRecord end def member_label - "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}" + "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.ca_name}" end def ca_sorecop From 2de306d5e6bc014b5accf4b7a6504bd96cf2e228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 14 Oct 2021 18:33:20 +0200 Subject: [PATCH 67/91] WIP Import --- app/models/p_product.rb | 144 ++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 44 deletions(-) diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 19088a9..4f8c65e 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -167,6 +167,7 @@ class PProduct < ApplicationRecord end acts_as_csv_import :fields => [ + :identifiant, :gencode, :id, :marque, @@ -185,7 +186,7 @@ class PProduct < ApplicationRecord :code_hs, :indice_reparabilite, :duree_dispo_pces_detachees, - :das_tête, + :das_tete, :das_corps, :das_membre, :poids, @@ -211,7 +212,7 @@ class PProduct < ApplicationRecord # ap "*********************************************************************************************************" # ap "*********************************************************************************************************" ap "*********************************************************************************************************" - ap list.size + # ap list.size # ap list.class # ap "*********************************************************************************************************" # ap "*********************************************************************************************************" @@ -220,96 +221,151 @@ class PProduct < ApplicationRecord # ap "*********************************************************************************************************" # ap "*********************************************************************************************************" # ap "*********************************************************************************************************" + soreco_cat_hash = { + "Smartphone" => "Smartphones & Téléphones mobiles", + "Tablette" => "Tablettes média et tablette PC", + "MP4" => "Baladeur MP4" + } list.each do |row| next if row["marque"].blank? n = self.new(imported: true) + ref = PProductRef.find_or_initialize_by(p_product: n, description: row["identifiant"]) row.each do |key, value| if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" else case key + when "identifiant" + ref.description = value when "gencode" - + n.genecode = value when "id" when "marque" + n.s_brand = SBrand.find_or_create_by(name: value) when "famille" n.p_product_cat = PProductCat.find_or_create_by(name: value) when "reference" + n.name = value when "modele" + ref.ct_sub_name = value if value.present? when "couleur" + ref.p_product_color = PProductColor.find_or_create_by(name: value) when "color" - + if ref.p_product_color.nil? + ref.p_product_color = PProductColor.find_or_create_by(color: value) + end when "connectivite" + arr = [] + cellular = [ "5G", "3G", "3G+", "4G", "4G+", "2G", "wifi", "BT"] + video = ["4K","HD" ] + power = ["5W", "12W", "18W", "20W", "96W", "40W", "10W", "40W"] + mix = ["<87W/4K", "5G/4K", "wifi/BT" ] + geoloc = [ "GPS" ] + + if mix.include?(value) + arr = value.split('/') + else + arr << value + end + + arr.each do |value| + spec = nil + if cellular.include?(value) + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + elsif video.include?(value) + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + elsif power.include?(value) + PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by(value: value.gsub('W', ''), unit: "W")) + elsif geoloc.include?(value) + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + else + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + end + import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) + end when "sim" + if ["DS", "SS"].include?(value) + PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Sim"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + elsif value == "4G" + PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + end when "taille" + PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by(value: value.to_s)) when "capacite" - + unit = value.match(/\D+/) + num = value.match(/\d+/) + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Stockage"), p_spec_value: PSpecValue.find_or_create_by(value: num.to_s, unit: unit.to_s)) + import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "infos_supp" - + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "reference_fabricant" - + ref.manufacturer_ref = value when "etat" - + ref.used_state = value when "code_hs" - + ref.i_code_hs = value when "indice_reparabilite" - + ref.prepair_score = value when "duree_dispo_pces_detachees" - - when "das_tête" - + ref.part_delay = value + when "das_tete" + ref.das_head = value when "das_corps" - + ref.das_body = value when "das_membre" - + ref.das_membre = value when "poids" - + ref.weight = value when "nb_pcs_colis" - + ref.nb_pcs_colis = value when "code_om" - - when "dtl" - + ref.code_om = value when "gbh_code_971" - + ref.gbh_code_971 = value when "gbh_code_972" - + ref.gbh_code_972 = value when "gbh_code_973" - + ref.gbh_code_973 = value when "code_art" - + ref.code_art = value when "sorecop" - + ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]]) + if ref.sorecop.kind_of?(String) + ref.ct_sorecop = value + end when "pmp_hors_sorecop" - + ref.i_pmp_hors_sorecop = value when "target_hors_sorecop" - + ref.i_target_hors_sorecop = value when "frs" - - when "date" - + ref.fournisseur_id = PFournisseur.find_or_create_by(name: value) when "spec" - - when "dtl_targ" - + spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "commentaires" - + ref.i_comment = value + # champs ignorés + when "date" + # colonne vide + when "dtl_targ" + when "dtl" when "com" else - # eval "n.#{key} = value" + eval "n.#{key} = value" end end end @@ -317,14 +373,14 @@ class PProduct < ApplicationRecord # n.save - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap n - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ contact §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # ap contact + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap n + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.ref §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + ap n.ref # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" @@ -344,7 +400,7 @@ class PProduct < ApplicationRecord # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - # import_csv.import_csv_elements << ImportCsvElement.new(:element => n) + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) end end end From a7b4ec4c1939a787d3cd32142bf6e0746db071f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 15 Oct 2021 10:03:31 +0200 Subject: [PATCH 68/91] Dropdown ok --- .../admin/p_customer_sheets_controller.rb | 9 ++---- app/models/p_customer_sheet.rb | 3 +- app/views/admin/buy_lists/index.html.haml | 32 ++++++++----------- app/views/admin/buy_lists/update.js.erb | 2 -- .../admin/p_customer_sheets/update.js.erb | 6 ++-- 5 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 app/views/admin/buy_lists/update.js.erb diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 8040166..8905ef1 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -192,16 +192,13 @@ class Admin::PCustomerSheetsController < ApplicationController def update @p_customer_sheet = PCustomerSheet.find(params[:id]) - if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) @p_customer = @p_customer_sheet.price_line_block.p_customer - if params[:no_redirect] == "true" - @price_line_id = params[:price_line_id] - render "admin/buy_lists/index" - else - redirect_to admin_p_customer_sheet_path(@p_customer_sheet) + respond_to do |format| + format.html{redirect_to admin_p_customer_sheet_path(@p_customer_sheet)} + format.js{} end else render action: "edit" diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 158e723..3d98974 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -44,6 +44,8 @@ class PCustomerSheet < ApplicationRecord :actions => {:name => "Actions", :reorder => false}, } + # STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"] + STATES = ["AV BPA", "PAS BPA","BPA", "Traitée"] def personalised_archive @@ -328,7 +330,6 @@ class PCustomerSheet < ApplicationRecord end - STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"] def unblock_price diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 36b8236..f561056 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -236,25 +236,19 @@ %td -@p_customer_sheet = price_line.price_line_block.price_lineable - -form = false - -if form - %form - =semantic_form_for [:admin, @p_customer_sheet], remote: true, authenticity_token: true do |f| - =f.inputs class: "form-inline d-flex flex-nowrap" do - =f.input :state, collection: ["AV BPA", "PAS BPA","BPA", "Traitée"], as: :select, :include_blank => false, label: false, selected: f.object.state, input_html: {class: "custom-select"}, remote: true - =hidden_field_tag :no_redirect, "true" - =hidden_field_tag :price_line_id, price_line.id - =f.button ic(:check), type: :submit, class: "btn btn-primary ml-1" - -if false - =f.actions class: "btn btn-primary ml-1" do - =f.action :submit, label: "#{ic(:check).html_safe}" - -if !form - %form - =form_with url: admin_buy_list_path(@p_customer_sheet), method: :patch, remote: true, authenticity_token: true, id: "p_customer_sheet_state_#{@p_customer_sheet.id}" do |f| - =hidden_field_tag :price_line_id, price_line.id - =f.select :state, ["AV BPA", "PAS BPA","BPA", "Traitée"] - =f.submit for: "p_customer_sheet_state_#{@p_customer_sheet.id}" - =#state_helper price_line.price_line_block.price_lineable.state + .dropdown + %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + %span.span_cat{'class' => "p_customer_sheet_#{@p_customer_sheet.id}"} + =#@p_customer_sheet.state + =state_helper @p_customer_sheet.state + %span.caret + %ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"} + -PCustomerSheet::STATES.each do |state| + %li + =link_to admin_p_customer_sheet_path(:id => @p_customer_sheet.id, :p_customer_sheet => {:state => state}), :method => :put, :remote => true, :onclick => "$('.dropdown-toggle').dropdown('hide');$(\".p_customer_sheet_#{@p_customer_sheet.id}\").html($(this).find('span').html());", :class => "dropdown-item" do + =ic :check if false + %span=state_helper state + %td =price_line.comment diff --git a/app/views/admin/buy_lists/update.js.erb b/app/views/admin/buy_lists/update.js.erb deleted file mode 100644 index 85ca3d0..0000000 --- a/app/views/admin/buy_lists/update.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -console.log('coucou'); -$('#price_line_row_<%= @price_line_id %>').replaceWith("<%= escape_javascript(render(@p_customer_sheet))%>"); diff --git a/app/views/admin/p_customer_sheets/update.js.erb b/app/views/admin/p_customer_sheets/update.js.erb index 1d96e9f..572c4eb 100644 --- a/app/views/admin/p_customer_sheets/update.js.erb +++ b/app/views/admin/p_customer_sheets/update.js.erb @@ -1,2 +1,4 @@ -$('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>"); -close_pane_hover(); \ No newline at end of file +<% if @p_customer_sheets %> + $('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>"); +<% end %> +close_pane_hover(); From 8965db5a59ffe672f16aaf624a702f4d82e46da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 15 Oct 2021 18:21:20 +0200 Subject: [PATCH 69/91] genecode to p_product_ref --- db/migrate/20211014081433_add_genecode_to_p_products.rb | 5 ----- .../20211014134444_add_import_field_to_p_product_refs.rb | 1 + db/schema.rb | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 db/migrate/20211014081433_add_genecode_to_p_products.rb diff --git a/db/migrate/20211014081433_add_genecode_to_p_products.rb b/db/migrate/20211014081433_add_genecode_to_p_products.rb deleted file mode 100644 index d4acf40..0000000 --- a/db/migrate/20211014081433_add_genecode_to_p_products.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddGenecodeToPProducts < ActiveRecord::Migration[6.0] - def change - add_column :p_products, :genecode, :string - end -end diff --git a/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb b/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb index d747875..439853f 100644 --- a/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb +++ b/db/migrate/20211014134444_add_import_field_to_p_product_refs.rb @@ -1,5 +1,6 @@ class AddImportFieldToPProductRefs < ActiveRecord::Migration[6.0] def change + add_column :p_product_refs, :genecode, :string add_column :p_product_refs, :manufacturer_ref, :string add_column :p_product_refs, :used_state, :string add_column :p_product_refs, :i_code_hs, :string diff --git a/db/schema.rb b/db/schema.rb index c4ad708..e724b16 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1818,6 +1818,7 @@ ActiveRecord::Schema.define(version: 2021_10_14_134444) do t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" + t.string "genecode" t.string "manufacturer_ref" t.string "used_state" t.string "i_code_hs" @@ -1926,7 +1927,6 @@ ActiveRecord::Schema.define(version: 2021_10_14_134444) do t.boolean "conserve_proportion", default: false t.boolean "frontpage", default: true t.integer "sorecop_cat_id" - t.string "genecode" 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 From ad135f6ff81de7f68ebc8f597e6f68ba950e2a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 15 Oct 2021 18:22:02 +0200 Subject: [PATCH 70/91] Import p_product ok --- app/models/p_product.rb | 115 ++++++++++++++++++++++++------------ app/models/p_product_ref.rb | 52 ++++++++++++---- app/models/s_brand.rb | 21 +++++++ 3 files changed, 139 insertions(+), 49 deletions(-) diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 4f8c65e..2b2a73a 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -70,6 +70,11 @@ class PProduct < ApplicationRecord } + before_validation do + if self.code.blank? + generate_code + end + end def self.for_search(search) @@ -166,6 +171,35 @@ class PProduct < ApplicationRecord self.p_product_images.order(:position).first end + + def generate_code + if !self.code + arr = [] + brand = self.s_brand.code.to_s if self.s_brand + + cat = self.p_product_cat.name.slice(0, 5).to_slug.upcase.to_s if self.p_product_cat + last_number = 1 + + arr << brand if brand.present? + arr << cat if cat.present? + arr << "%02d" % [last_number] + arr.prepend("PRODUCT") if arr.length < 2 + code = arr.join('-') + + while self.class.find_by(code: code) + arr = [] + last_number += 1 + arr << brand if brand.present? + arr << cat if cat.present? + arr << "%02d" % [last_number] + arr.prepend("PRODUCT") if arr.length < 2 + code = arr.join('-') + end + self.code = code + end + end + + acts_as_csv_import :fields => [ :identifiant, :gencode, @@ -223,32 +257,36 @@ class PProduct < ApplicationRecord # ap "*********************************************************************************************************" soreco_cat_hash = { "Smartphone" => "Smartphones & Téléphones mobiles", + "Mobile" => "Smartphones & Téléphones mobiles", "Tablette" => "Tablettes média et tablette PC", - "MP4" => "Baladeur MP4" + "MP4" => "Baladeur MP4", + "Clé USB" => "Clés USB", + "Carte Mémoire" => "Cartes mémoires", + "Boitier Multimédia" => "Décodeurs, téléviseurs, enregistreurs" } list.each do |row| next if row["marque"].blank? - - n = self.new(imported: true) - ref = PProductRef.find_or_initialize_by(p_product: n, description: row["identifiant"]) + n = self.find_or_initialize_by(s_brand: SBrand.find_by(name: row["marque"]), name: row["reference"]) + n.imported = true + n.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]]) + ref = n.p_product_refs.build row.each do |key, value| - if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal - eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" - else + if value.present? + puts key case key when "identifiant" ref.description = value when "gencode" - n.genecode = value + ref.genecode = value when "id" when "marque" - n.s_brand = SBrand.find_or_create_by(name: value) + n.s_brand = SBrand.find_or_create_by!(name: value) when "famille" - n.p_product_cat = PProductCat.find_or_create_by(name: value) + n.p_product_cat = PProductCat.find_or_create_by!(name: value) when "reference" n.name = value @@ -257,11 +295,11 @@ class PProduct < ApplicationRecord ref.ct_sub_name = value if value.present? when "couleur" - ref.p_product_color = PProductColor.find_or_create_by(name: value) + ref.p_product_color = PProductColor.find_or_create_by!(name: value) when "color" if ref.p_product_color.nil? - ref.p_product_color = PProductColor.find_or_create_by(color: value) + ref.p_product_color = PProductColor.find_or_create_by!(color: value) end when "connectivite" arr = [] @@ -280,36 +318,36 @@ class PProduct < ApplicationRecord arr.each do |value| spec = nil if cellular.include?(value) - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) elsif video.include?(value) - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) elsif power.include?(value) - PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by(value: value.gsub('W', ''), unit: "W")) + PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by!(value: value.gsub('W', ''), unit: "W")) elsif geoloc.include?(value) - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) else - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) end import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) end when "sim" if ["DS", "SS"].include?(value) - PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Sim"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Sim"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) elsif value == "4G" - PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) end when "taille" - PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by(value: value.to_s)) + PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s)) when "capacite" unit = value.match(/\D+/) num = value.match(/\d+/) - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Stockage"), p_spec_value: PSpecValue.find_or_create_by(value: num.to_s, unit: unit.to_s)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Stockage"), p_spec_value: PSpecValue.find_or_create_by!(value: num.to_s, unit: unit.to_s)) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "infos_supp" - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "reference_fabricant" ref.manufacturer_ref = value @@ -344,43 +382,47 @@ class PProduct < ApplicationRecord when "sorecop" ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]]) if ref.sorecop.kind_of?(String) - ref.ct_sorecop = value + ref.ct_sorecop = value if !value.blank? end when "pmp_hors_sorecop" ref.i_pmp_hors_sorecop = value when "target_hors_sorecop" ref.i_target_hors_sorecop = value when "frs" - ref.fournisseur_id = PFournisseur.find_or_create_by(name: value) + ref.p_fournisseur_id = PFournisseur.find_or_create_by!(name: value).id when "spec" - spec = PProductRefSpec.create(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "commentaires" ref.i_comment = value + # champs ignorés when "date" # colonne vide when "dtl_targ" when "dtl" when "com" - else eval "n.#{key} = value" end + # if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal + # eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')" + # end end end - # n.save + n.save! + import_csv.import_csv_elements << ImportCsvElement.new(:element => ref) + import_csv.import_csv_elements << ImportCsvElement.new(:element => n) - - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap n - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.ref §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - ap n.ref + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap n + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.ref §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" + # ap ref # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" @@ -400,7 +442,6 @@ class PProduct < ApplicationRecord # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" # ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§" - import_csv.import_csv_elements << ImportCsvElement.new(:element => n) end end end diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 5f8a453..5790117 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -15,7 +15,7 @@ class PProductRef < ApplicationRecord has_many :p_article_serial_nums, through: :p_articles accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true - has_many :p_product_ref_specs + has_many :p_product_ref_specs, dependent: :destroy accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true, reject_if: :all_blank #validates :ct_price_ht, :presence => true @@ -52,7 +52,7 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } - acts_as_caching :fields => [:sorecop, :deee] + acts_as_caching :fields => [:sorecop, :deee, :name, :code] attr_accessor :price_line_id @@ -89,9 +89,35 @@ class PProductRef < ApplicationRecord def ca_name - if self.p_product - self.p_product.name + " - " + self.ct_sub_name - end + storage = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Stockage")).first + cellular = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Connectivité")).first + screen = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Résolution")).first + power = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Puissance éléctrique")).first + geoloc = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Géolocalisation")).first + sim = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Sim")).first + size = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Taille")).first + version = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Version ROM")).first + + + + + arr = [] + arr << self.p_product.name if self.p_product + arr << self.ct_sub_name + arr << storage.p_spec_value.member_label if storage + arr << cellular.p_spec_value.member_label if cellular + arr << screen.p_spec_value.member_label if screen + arr << power.p_spec_value.member_label if power + arr << geoloc.p_spec_value.member_label if geoloc + arr << sim.p_spec_value.member_label if sim + arr << size.p_spec_value.member_label if size + arr << version.p_spec_value.member_label if version + arr << self.p_product_color.name if p_product_color + + arr.compact.each{|el| el.strip!}.join(' ') + # if self.p_product + # self.p_product.name + " - " + self.ct_sub_name + # end end def ca_code @@ -169,14 +195,14 @@ class PProductRef < ApplicationRecord end def ca_sorecop - return ct_sorecop if ct_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 + # if self.cc_sorecop and self.cc_sorecop > 0.0 + # return self.cc_sorecop + # else find_sorecop_tax - end + # end end def find_sorecop_tax @@ -184,10 +210,12 @@ class PProductRef < ApplicationRecord 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") + if p_product_ref_spec.p_spec_value.unit.casecmp?("Gb") 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") + elsif p_product_ref_spec.p_spec_value.unit.casecmp?("Tb") tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity * 1000, storage_capacity * 1000).first + elsif p_product_ref_spec.p_spec_value.unit.casecmp?("Mb") + 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 diff --git a/app/models/s_brand.rb b/app/models/s_brand.rb index c5db009..4f87015 100644 --- a/app/models/s_brand.rb +++ b/app/models/s_brand.rb @@ -1,4 +1,25 @@ class SBrand < ApplicationRecord validates :name, :presence => true, :uniqueness => true + + before_save do + if self.code.blank? + generate_code + end + end + + + def generate_code + if self.code.blank? + prefix = self.name.slice(0, 4).to_slug.upcase + last_number = 1 + code = prefix + "%02d" % [last_number] + + while self.class.find_by(code: code) + last_number += 1 + code = prefix + "%02d" % [last_number] + end + self.code = code + end + end end From cd0d3d2b53b3a88074022c017ca6b4274f283f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 15 Oct 2021 18:24:23 +0200 Subject: [PATCH 71/91] protect from zero --- app/models/p_product.rb | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 2b2a73a..1147c4a 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -277,9 +277,9 @@ class PProduct < ApplicationRecord puts key case key when "identifiant" - ref.description = value + ref.description = value if !value.blank? when "gencode" - ref.genecode = value + ref.genecode = value if !value.blank? when "id" when "marque" @@ -289,10 +289,10 @@ class PProduct < ApplicationRecord n.p_product_cat = PProductCat.find_or_create_by!(name: value) when "reference" - n.name = value + n.name = value if !value.blank? when "modele" - ref.ct_sub_name = value if value.present? + ref.ct_sub_name = value if !value.blank? when "couleur" ref.p_product_color = PProductColor.find_or_create_by!(name: value) @@ -350,51 +350,51 @@ class PProduct < ApplicationRecord spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "reference_fabricant" - ref.manufacturer_ref = value + ref.manufacturer_ref = value if !value.blank? when "etat" - ref.used_state = value + ref.used_state = value if !value.blank? when "code_hs" - ref.i_code_hs = value + ref.i_code_hs = value if !value.blank? when "indice_reparabilite" - ref.prepair_score = value + ref.prepair_score = value if !value.blank? when "duree_dispo_pces_detachees" - ref.part_delay = value + ref.part_delay = value if !value.blank? when "das_tete" - ref.das_head = value + ref.das_head = value if !value.blank? when "das_corps" - ref.das_body = value + ref.das_body = value if !value.blank? when "das_membre" - ref.das_membre = value + ref.das_membre = value if !value.blank? when "poids" - ref.weight = value + ref.weight = value if !value.blank? when "nb_pcs_colis" - ref.nb_pcs_colis = value + ref.nb_pcs_colis = value if !value.blank? when "code_om" - ref.code_om = value + ref.code_om = value if !value.blank? when "gbh_code_971" - ref.gbh_code_971 = value + ref.gbh_code_971 = value if !value.blank? when "gbh_code_972" - ref.gbh_code_972 = value + ref.gbh_code_972 = value if !value.blank? when "gbh_code_973" - ref.gbh_code_973 = value + ref.gbh_code_973 = value if !value.blank? when "code_art" - ref.code_art = value + ref.code_art = value if !value.blank? when "sorecop" ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]]) if ref.sorecop.kind_of?(String) ref.ct_sorecop = value if !value.blank? end when "pmp_hors_sorecop" - ref.i_pmp_hors_sorecop = value + ref.i_pmp_hors_sorecop = value if !value.blank? when "target_hors_sorecop" - ref.i_target_hors_sorecop = value + ref.i_target_hors_sorecop = value if !value.blank? when "frs" ref.p_fournisseur_id = PFournisseur.find_or_create_by!(name: value).id when "spec" spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) when "commentaires" - ref.i_comment = value + ref.i_comment = value if !value.blank? # champs ignorés when "date" From 3a7b510e64430ea371afc5ddc68250e3566b5e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 09:42:01 +0200 Subject: [PATCH 72/91] raise if creation abort --- app/models/p_customer.rb | 12 ++++++------ app/models/p_fournisseur.rb | 6 +++--- app/models/price_document.rb | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index b2ee2c1..a0e3a00 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -694,11 +694,11 @@ class PCustomer < ApplicationRecord when "mode_reglement" if value.present? if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id + n.p_payment_type_id = PPaymentType.find_or_create_by!(name: "Virement").id elsif value == "TRAITE" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id + n.p_payment_type_id = PPaymentType.find_or_create_by!(name: "Traite").id else - n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id end end @@ -724,7 +724,7 @@ class PCustomer < ApplicationRecord when "nom_banque" if value.present? - bank = PBank.find_or_create_by(name: value) + bank = PBank.find_or_create_by!(name: value) end when "adresse_banque_1" @@ -769,7 +769,7 @@ class PCustomer < ApplicationRecord when "fonction_contact" if value.present? - contact.p_contact_types << PContactType.find_or_create_by(name: value) + contact.p_contact_types << PContactType.find_or_create_by!(name: value) end when "telephone_contact" contact.tel = value @@ -860,7 +860,7 @@ class PCustomer < ApplicationRecord end if p_commercial_code || p_commercial_firstname - p_commercial = PCommercial.find_or_create_by(code: p_commercial_code, firstname: p_commercial_firstname) + p_commercial = PCommercial.find_or_create_by!(code: p_commercial_code, firstname: p_commercial_firstname) n.p_commercial = p_commercial end diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index f65ac86..344c669 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -94,7 +94,7 @@ class PFournisseur < ApplicationRecord when "interlocuteur" contact_1.name = value when "fonction" - contact_1.p_contact_types << PContactType.find_or_create_by(name: value) + contact_1.p_contact_types << PContactType.find_or_create_by!(name: value) when "tel" contact_1.tel = value when "skype" @@ -106,7 +106,7 @@ class PFournisseur < ApplicationRecord when "email_3" contact_3 = PContact.new(email: value) when "reglement_par" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id else eval "n.#{key} = value" end @@ -114,7 +114,7 @@ class PFournisseur < ApplicationRecord end # particular.organisation = self.name - n.save + n.save! if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email) n.p_contacts << contact_1 import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_1) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 1e5a9b1..a6b847b 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -753,7 +753,7 @@ class PriceDocument < ApplicationRecord n.price_line_block.price_lines << price_line - n.save + n.save! import_csv.import_csv_elements << ImportCsvElement.new(:element => n) import_csv.import_csv_elements << ImportCsvElement.new(:element => price_line) end From 5da52468000065cbd1a616c5f5ea566b57eeef3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 09:42:12 +0200 Subject: [PATCH 73/91] protect from blank --- app/models/p_customer.rb | 66 ++++++++++++++++++------------------- app/models/p_fournisseur.rb | 22 ++++++------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index a0e3a00..42bf4cd 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -653,43 +653,43 @@ class PCustomer < ApplicationRecord else case key when "societe_raison_sociale" - particular_bill.organisation = value + particular_bill.organisation = value if !value.blank? when "nom_enseigne" - particular_bill.com_name = value + particular_bill.com_name = value if !value.blank? when "adresse_facturation_1" - particular_bill.address_1 = value + particular_bill.address_1 = value if !value.blank? when "adresse_livraison_2" - send_address_2 = value + send_address_2 = value if !value.blank? when "adresse_3" - particular_bill.address_3 = value + particular_bill.address_3 = value if !value.blank? when "cp" - particular_bill.cp = value + particular_bill.cp = value if !value.blank? when "ville_1" - particular_bill.city = value + particular_bill.city = value if !value.blank? when "pays" - particular_bill.country = value + particular_bill.country = value if !value.blank? when "societe_livraison" - particular_bill.address_4 = value + particular_bill.address_4 = value if !value.blank? when "forme_juridique" - particular_bill.address_5 = value + particular_bill.address_5 = value if !value.blank? when "telephone_1" - particular_bill.tel = value + particular_bill.tel = value if !value.blank? when "telephone_2" - particular_bill.tel2 = value + particular_bill.tel2 = value if !value.blank? when "fax" - particular_bill.fax = value + particular_bill.fax = value if !value.blank? when "mode_reglement" if value.present? @@ -719,7 +719,7 @@ class PCustomer < ApplicationRecord when "Mensuel - 30j fin de mois du dépôt" n.payment_delais = 30 else - n.payment_delais = value + n.payment_delais = value if !value.blank? end when "nom_banque" @@ -728,66 +728,66 @@ class PCustomer < ApplicationRecord end when "adresse_banque_1" - bank_particular.address_1 = value + bank_particular.address_1 = value if !value.blank? when "adresse_banque_2" - bank_particular.address_2 = value + bank_particular.address_2 = value if !value.blank? when "code_banque" - bank_particular.cp = value + bank_particular.cp = value if !value.blank? when "ville_banque" - bank_particular.city = value + bank_particular.city = value if !value.blank? when "pays_banque" - bank_particular.country = value + bank_particular.country = value if !value.blank? when "telephone_livraison" - send_tel = value + send_tel = value if !value.blank? when "portable_livraison" - send_tel2 = value + send_tel2 = value if !value.blank? when "fax_livraison" - send_fax = value + send_fax = value if !value.blank? when "representant" - p_commercial_code = value + p_commercial_code = value if !value.blank? when "nom_representant" - p_commercial_firstname = value + p_commercial_firstname = value if !value.blank? when "code_iban" - iban = value + iban = value if !value.blank? when "code_bic" - bic = value + bic = value if !value.blank? when "nom_contact" - contact.name = value + contact.name = value if !value.blank? when "titre_contact" - particular_bill.civilite = value + particular_bill.civilite = value if !value.blank? when "fonction_contact" if value.present? contact.p_contact_types << PContactType.find_or_create_by!(name: value) end when "telephone_contact" - contact.tel = value + contact.tel = value if !value.blank? when "portable_contact" if value.present? if contact.tel.nil? - contact.tel = value + contact.tel = value if !value.blank? else contact_2 = PContact.new(tel: value) end end when "email_contact" - contact.email = value + contact.email = value if !value.blank? when "observation" - n.p_customer_sheet_note = value + n.p_customer_sheet_note = value if !value.blank? @@ -829,7 +829,7 @@ class PCustomer < ApplicationRecord when "client_divers" else - eval "n.#{key} = value" + eval "n.#{key} = value if !value.blank?" end diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index 344c669..6f0cacb 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -53,15 +53,15 @@ class PFournisseur < ApplicationRecord else case key when "nom_fournisseur" - n.name = value + n.name = value if !value.blank? when "address" - n.address1 = value + n.address1 = value if !value.blank? when "ville" - n.city = value + n.city = value if !value.blank? when "pays" - n.country = value + n.country = value if !value.blank? when "tva_intracom" - n.tva_num = value + n.tva_num = value if !value.blank? when "delai_paiement" if value.present? case value @@ -88,19 +88,19 @@ class PFournisseur < ApplicationRecord when "60 jours fin de mois" n.payment_delais = 60 else - n.payment_delais = value + n.payment_delais = value if !value.blank? end end when "interlocuteur" - contact_1.name = value + contact_1.name = value if !value.blank? when "fonction" contact_1.p_contact_types << PContactType.find_or_create_by!(name: value) when "tel" - contact_1.tel = value + contact_1.tel = value if !value.blank? when "skype" - contact_1.skype = value + contact_1.skype = value if !value.blank? when "email_1" - contact_1.email = value + contact_1.email = value if !value.blank? when "email_2" contact_2 = PContact.new(email: value) when "email_3" @@ -108,7 +108,7 @@ class PFournisseur < ApplicationRecord when "reglement_par" n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id else - eval "n.#{key} = value" + eval "n.#{key} = value if !value.blank?" end end From 0fad587a3e35b360d74aae94b41556aa6345f356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 14:32:05 +0200 Subject: [PATCH 74/91] Display price_line data on matching index --- .../_form_temp_p_product.html.haml | 22 ++++++++++++------- .../admin/import_csvs/match_refs.html.haml | 5 +++-- .../price_lines/_form_match_refs.html.haml | 7 ++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/views/admin/import_csvs/_form_temp_p_product.html.haml b/app/views/admin/import_csvs/_form_temp_p_product.html.haml index 9173a3d..f5a2ac1 100644 --- a/app/views/admin/import_csvs/_form_temp_p_product.html.haml +++ b/app/views/admin/import_csvs/_form_temp_p_product.html.haml @@ -4,21 +4,27 @@ .qi_row.field .padding - %h1 Ajouter une références + %h1 Ajouter une référence + .card.border.border-primary.mb-3 + %h5.card-header.border-bottom Rappel des infos fournisseurs + .card-body + %h5.card-title libellé : + %p.card-text + =@p_product_ref.ct_sub_name + + %table.form-table %tr %td{colspan: 3} - %label Selectionner le produit parent + %label Selectionner le produit parent : .input-group %input.p_product_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :class => "p_product_name"} =form.hidden_field :p_product_id, :class => "p_product_id" =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.ct_sub_name, price_line_id: @price_line.id) + %br - %tr - %td{:colspan => 3} - %input.form-control{type: "text", placeholder: @p_product_ref.ct_sub_name, "aria-label" => "Disabled input example", disabled: true} - =#form.input :ct_sub_name, label: "Label fournisseur", input_html: {disabled: true} + %tr{height: "20px"} %tr %td{:colspan => 3} @@ -34,9 +40,9 @@ =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"} %tr %td - =form.input :ct_sorecop, :label => "Sorecop personalisée :" + =form.input :ct_sorecop, :label => "Sorecop personalisée (€) :" %td - =form.input :sorecop_comment, :label => "Type de Sorecop :" + =form.input :sorecop_comment, :label => "Commentaire Sorecop :" %td =form.input :ct_deee, :label => "DEEE personalisée :" %tr diff --git a/app/views/admin/import_csvs/match_refs.html.haml b/app/views/admin/import_csvs/match_refs.html.haml index c44a8c0..c55dd77 100644 --- a/app/views/admin/import_csvs/match_refs.html.haml +++ b/app/views/admin/import_csvs/match_refs.html.haml @@ -17,8 +17,9 @@ %th %th Référence Produit Arcom %th Créer une référence - %th Référence fournisseur - %th + %th Libélé fournisseur + %th Prix unitaire + %th Quantité %tbody.price_lines_form =f.semantic_fields_for :price_lines do |form| -if form.object.p_product_ref.nil? diff --git a/app/views/admin/price_lines/_form_match_refs.html.haml b/app/views/admin/price_lines/_form_match_refs.html.haml index fb4fc62..0fd0b42 100644 --- a/app/views/admin/price_lines/_form_match_refs.html.haml +++ b/app/views/admin/price_lines/_form_match_refs.html.haml @@ -24,9 +24,13 @@ %span=link_to ic(:"plus"), temp_p_product_admin_import_csvs_path(price_line_id: form.object.id), remote: true - + %td.pl-2 =form.object.title + %td + =number_to_currency form.object.price_u_ht + %td + =form.object.qte %td.text-center{style: "width: 30px;"} %span.destroy=link_to_remove_fields ic(:"trash-o"), form @@ -35,7 +39,6 @@ = form.hidden_field :position, :class => "price_line_position_input" - :javascript $('.p_product_ref_autocomplete_input').focus() $( function() { From 999ae95c827d8db5093ea605e1048c9eeeb25a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 14:32:21 +0200 Subject: [PATCH 75/91] Generate code for client --- app/models/p_customer.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 42bf4cd..54900d5 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -65,6 +65,26 @@ class PCustomer < ApplicationRecord has_many :order_hists # before_validation :set_auth_token, on: [:create, :update] + before_validation do + if self.code.blank? + generate_code + end + end + + def generate_code + if !self.code + last_used_code = self.class.all.order(code: :desc).limit(1)[0].code + last_number = last_used_code.match(/\d+/).to_s.to_i + 1 + + code = "CLI%04d" % [last_number] + + while self.class.find_by(code: code) + last_number += 1 + code = "CLI%04d" % [last_number] + end + self.code = code + end + end def self.qi_table_order From 14faad87376ceb8d3937c8d81a92c3b81f71f750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 14:36:33 +0200 Subject: [PATCH 76/91] p_customer code auto --- app/views/admin/p_customers/_form.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/admin/p_customers/_form.html.haml b/app/views/admin/p_customers/_form.html.haml index 36b96f5..ee76638 100755 --- a/app/views/admin/p_customers/_form.html.haml +++ b/app/views/admin/p_customers/_form.html.haml @@ -61,7 +61,8 @@ = form.input :particular_send_id, :collection => form.object.particulars.all, :as => :select, :member_label => :address_line, :include_blank => true, :label => "Adresse de livraison :" - =form.input :code, :label => "Code client" + -if false + =form.input :code, :label => "Code client" -if !@p_customer.id From 56820f3f0438d8c54f9cea5c188ce1012b90eca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 16:16:55 +0200 Subject: [PATCH 77/91] remove useless import p_fournisseur --- .../admin/p_fournisseurs_controller.rb | 13 ------------- .../p_fournisseurs/import_fournisseurs.html.haml | 16 ---------------- app/views/admin/p_fournisseurs/index.html.haml | 1 - config/routes.rb | 2 -- 4 files changed, 32 deletions(-) delete mode 100644 app/views/admin/p_fournisseurs/import_fournisseurs.html.haml diff --git a/app/controllers/admin/p_fournisseurs_controller.rb b/app/controllers/admin/p_fournisseurs_controller.rb index e406eed..992106e 100644 --- a/app/controllers/admin/p_fournisseurs_controller.rb +++ b/app/controllers/admin/p_fournisseurs_controller.rb @@ -22,19 +22,6 @@ class Admin::PFournisseursController < ApplicationController end end - - def import_fournisseurs - # @file = params[:csv_file] - # require 'csv' - - # csv_text = File.read("#{Rails.root}/import_csv/fournisseurs.csv") #.force_encoding('ISO-8859-1') - # @csv = CSV.parse(csv_text, :headers => true, :col_sep => ";") - - end - - def import_fournisseurs_xls - raise - end def index @p_fournisseurs = PFournisseur.order(:name).all diff --git a/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml b/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml deleted file mode 100644 index 1010d73..0000000 --- a/app/views/admin/p_fournisseurs/import_fournisseurs.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.qi_header - .right - %h1 - Import - %span - Fournisseurs - - -.qi_row - .qi_pannel.qi_plain.padding - %table.table - %tr - %td - =form_with url: import_fournisseurs_xls_admin_p_fournisseurs_path() do |form| - =form.file_field_tag 'Base client', accept: '.xls, .xlsx' - =form.submit_tag 'importer' diff --git a/app/views/admin/p_fournisseurs/index.html.haml b/app/views/admin/p_fournisseurs/index.html.haml index 22fa1ce..3423253 100644 --- a/app/views/admin/p_fournisseurs/index.html.haml +++ b/app/views/admin/p_fournisseurs/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right = link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true - =link_to 'import base fournisseurs', import_fournisseurs_admin_p_fournisseurs_path(), :class => "btn btn-primary" %h1 Achats %span diff --git a/config/routes.rb b/config/routes.rb index ab30648..a385f22 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1004,8 +1004,6 @@ Rails.application.routes.draw do resources :p_fournisseurs do collection do get :import - get :import_fournisseurs - post :import_fournisseurs_xls end From 6ed30defc6ce5dd1dc17718c06ff678faf5a5a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 16:18:06 +0200 Subject: [PATCH 78/91] bugfix import --- app/models/p_customer.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 54900d5..23c9012 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -732,12 +732,16 @@ class PCustomer < ApplicationRecord n.payment_delais = 0 when "30 JOURS FIN DE MOIS" n.payment_delais = 30 + n.comptant = false when "VIR 60J NET DATE RELEVE" n.payment_delais = 60 + n.comptant = false when "TRAITE A 60 JOURS FIN DE MOIS" n.payment_delais = 60 + n.comptant = false when "Mensuel - 30j fin de mois du dépôt" n.payment_delais = 30 + n.comptant = false else n.payment_delais = value if !value.blank? end @@ -860,20 +864,22 @@ class PCustomer < ApplicationRecord n.particulars << particular_bill - n.save + n.save! if bank bank.bic = bic bank.particulars << bank_particular if bank_particular.address_1 - bank.save + bank.save! import_csv.import_csv_elements << ImportCsvElement.new(:element => bank) end if bic || iban - rib = PCustomerRib.create(bic: bic, iban: iban) + rib = PCustomerRib.find_or_create_by!(bic: bic, iban: iban) rib.bank = bank.name if bank - account = PBankAccount.create(bic: bic, iban: iban, p_bank: bank, p_customer: n) + account = PBankAccount.find_or_create_by!(bic: bic, iban: iban, p_customer: n) + account.update(p_bank: bank) if bank + n.p_customer_ribs << rib import_csv.import_csv_elements << ImportCsvElement.new(:element => rib) import_csv.import_csv_elements << ImportCsvElement.new(:element => account) @@ -882,6 +888,7 @@ class PCustomer < ApplicationRecord if p_commercial_code || p_commercial_firstname p_commercial = PCommercial.find_or_create_by!(code: p_commercial_code, firstname: p_commercial_firstname) n.p_commercial = p_commercial + import_csv.import_csv_elements << ImportCsvElement.new(:element => p_commercial) end if send_tel || send_tel2 || send_fax || send_address_2 From c9c65474cfe738fdf9399306e6b0e72d846cb0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 16:18:26 +0200 Subject: [PATCH 79/91] show automatic cc_name --- app/models/p_product_ref.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 5790117..0248b8d 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -42,8 +42,8 @@ class PProductRef < ApplicationRecord :p_product_cat => {:name => "Catégorie", :reorder => true}, :ref => {:name => "Référence"}, :cc_name => {:name => "Produit"}, - :description => {:name => "Description"}, - :ct_sub_name => {:name => "Nom référence"}, + # :description => {:name => "Description"}, + :cc_name => {:name => "Nom référence"}, :ct_price_ht => {:name => "Prix de vente", :as => :currency}, :ean => {:name => "EAN"}, :deee => {:name => "DEEE", :as => :currency}, @@ -195,7 +195,7 @@ class PProductRef < ApplicationRecord end def ca_sorecop - # return ct_sorecop if ct_sorecop + return ct_sorecop if ct_sorecop return "Pas de catégorie Sorecop" if self.p_product.sorecop_cat.blank? # if self.cc_sorecop and self.cc_sorecop > 0.0 From bd277931c066f009adc49f68a55cf80d1267c334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 16:18:34 +0200 Subject: [PATCH 80/91] remove deug --- app/views/admin/import_csvs/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/import_csvs/index.html.haml b/app/views/admin/import_csvs/index.html.haml index 54de32a..70eead3 100644 --- a/app/views/admin/import_csvs/index.html.haml +++ b/app/views/admin/import_csvs/index.html.haml @@ -12,4 +12,4 @@ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs} -=debug OrderHistLine.new.class.type_for_attribute("ff") +=#debug OrderHistLine.new.class.type_for_attribute("ff") From 9660ba7147a7136088f9e2aec164f7cf62337954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 17:14:51 +0200 Subject: [PATCH 81/91] upgrade scale for sorecop_tax --- db/migrate/20211018142636_add3scale_for_sorecop_taxex.rb | 6 ++++++ db/schema.rb | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20211018142636_add3scale_for_sorecop_taxex.rb diff --git a/db/migrate/20211018142636_add3scale_for_sorecop_taxex.rb b/db/migrate/20211018142636_add3scale_for_sorecop_taxex.rb new file mode 100644 index 0000000..c14b795 --- /dev/null +++ b/db/migrate/20211018142636_add3scale_for_sorecop_taxex.rb @@ -0,0 +1,6 @@ +class Add3scaleForSorecopTaxex < ActiveRecord::Migration[6.0] + def change + change_column :sorecop_taxes, :critere_min, :decimal, :precision => 14, :scale => 3 + change_column :sorecop_taxes, :critere_max, :decimal, :precision => 14, :scale => 3 + end +end diff --git a/db/schema.rb b/db/schema.rb index e724b16..1bbd164 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_14_134444) do +ActiveRecord::Schema.define(version: 2021_10_18_142636) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -2798,8 +2798,8 @@ ActiveRecord::Schema.define(version: 2021_10_14_134444) do 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.decimal "critere_min", precision: 14, scale: 3 + t.decimal "critere_max", precision: 14, scale: 3 t.string "title" t.boolean "fixed_price", default: true t.decimal "price", precision: 10, scale: 2 From 58b262a14f6482f50570ab68892dce37ecfc5402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 17:15:02 +0200 Subject: [PATCH 82/91] default sorting --- app/controllers/admin/sorecop_taxes_controller.rb | 2 +- app/models/sorecop_tax.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/sorecop_taxes_controller.rb b/app/controllers/admin/sorecop_taxes_controller.rb index a67105b..4f62458 100644 --- a/app/controllers/admin/sorecop_taxes_controller.rb +++ b/app/controllers/admin/sorecop_taxes_controller.rb @@ -13,7 +13,7 @@ class Admin::SorecopTaxesController < ApplicationController def index @sorecop_taxes = SorecopTax.all - @sorecop_taxes = sort_by_sorting(@sorecop_taxes, "id DESC") + @sorecop_taxes = sort_by_sorting(@sorecop_taxes, "sorecop_cat_id ASC") respond_to do |format| format.html{ diff --git a/app/models/sorecop_tax.rb b/app/models/sorecop_tax.rb index 061dd00..66bec55 100644 --- a/app/models/sorecop_tax.rb +++ b/app/models/sorecop_tax.rb @@ -8,7 +8,7 @@ class SorecopTax < ApplicationRecord :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}, + :sorecop_cat => {:name => "Catégorie SORECOP",member_label: :name, :reorder => true, :sort_name => "sorecop_taxes.sorecop_cat_id"}, :price => {:name => "Prix", :reorder => false, as: :currency}, :actions => {:name => "Actions", :reorder => true} } From 60dadd0cb9441b7617c94e600ac19fa581ea5384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 10:44:19 +0200 Subject: [PATCH 83/91] small improvement for ref match form --- .../admin/import_csvs_controller.rb | 2 +- .../_form_temp_p_product.html.haml | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index bac0c29..7a3ed47 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -97,7 +97,7 @@ class Admin::ImportCsvsController < ApplicationController if params[:price_line_id] @price_line = PriceLine.find(params[:price_line_id]) p_product = PProduct.find_or_create_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--") - @p_product_ref = PProductRef.find_or_create_by(p_product: p_product, ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) + @p_product_ref = PProductRef.find_or_create_by(p_product: p_product, description: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) @p_product_ref.p_product_ref_specs.build end end diff --git a/app/views/admin/import_csvs/_form_temp_p_product.html.haml b/app/views/admin/import_csvs/_form_temp_p_product.html.haml index f5a2ac1..f2c41fa 100644 --- a/app/views/admin/import_csvs/_form_temp_p_product.html.haml +++ b/app/views/admin/import_csvs/_form_temp_p_product.html.haml @@ -7,10 +7,24 @@ %h1 Ajouter une référence .card.border.border-primary.mb-3 %h5.card-header.border-bottom Rappel des infos fournisseurs - .card-body - %h5.card-title libellé : - %p.card-text - =@p_product_ref.ct_sub_name + %ul.list-group.list-group-flush + %li.list-group-item + .d-inline-flex + %h5.card-title{style: "min-width: 80px;"} libellé : + %p.card-text=@p_product_ref.description + %li.list-group-item + .d-inline-flex + %h5.card-title{style: "min-width: 80px;"} Qté : + %p.card-text + =@price_line.qte + %li.list-group-item + .d-inline-flex + %h5.card-title{style: "min-width: 80px;"} Prix : + %p.card-text + =number_to_currency @p_product_ref.ct_price_ht + + + %table.form-table @@ -21,20 +35,20 @@ %input.p_product_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :class => "p_product_name"} =form.hidden_field :p_product_id, :class => "p_product_id" - =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.ct_sub_name, price_line_id: @price_line.id) + =link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.description, price_line_id: @price_line.id) %br %tr{height: "20px"} - - %tr - %td{:colspan => 3} - = form.input :ct_sub_name, :label => "Désignation ARCOM :" + -if false + %tr + %td{:colspan => 3} + = form.input :ct_sub_name, :label => "Désignation ARCOM :" %tr %td = form.input :ref, :label => "Réf int. :" %td - = form.input :ct_price_ht, :label => "Prix vente HT :" + = form.input :ct_price_ht, :label => "Prix vente € HT:" %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"} @@ -44,7 +58,7 @@ %td =form.input :sorecop_comment, :label => "Commentaire Sorecop :" %td - =form.input :ct_deee, :label => "DEEE personalisée :" + =form.input :ct_deee, :label => "DEEE personalisée (€):" %tr %td =form.input :ean From 2941d5f2848d8a503306d86856ef78bb4f46e7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 10:44:55 +0200 Subject: [PATCH 84/91] don't raise on error --- app/models/price_document.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index a6b847b..125545e 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -721,7 +721,10 @@ class PriceDocument < ApplicationRecord p_fournisseur = PFournisseur.find_by(name: row["p_fournisseur_name"]) end - raise "Fournisseur introuvable. Ajouter le fournisseur manquant avant l'import" if p_fournisseur.nil? + if p_fournisseur.nil? + # TODO : envoyer une alerte sans bloquer l'import. + # idée ? creer une priceline vide => pour la retrouver dans les ref à matcher. + end n = self.find_or_initialize_by(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur"), p_fournisseur: p_fournisseur, date: row["date"], p_devise: p_devise ) if n.price_line_block.nil? @@ -753,7 +756,7 @@ class PriceDocument < ApplicationRecord n.price_line_block.price_lines << price_line - n.save! + n.save import_csv.import_csv_elements << ImportCsvElement.new(:element => n) import_csv.import_csv_elements << ImportCsvElement.new(:element => price_line) end From 761a36693e4eedc27086055c2c060fa9a6871a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 10:51:31 +0200 Subject: [PATCH 85/91] remove bottom space --- app/views/admin/import_csvs/_form_temp_p_product.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/import_csvs/_form_temp_p_product.html.haml b/app/views/admin/import_csvs/_form_temp_p_product.html.haml index f2c41fa..c27d130 100644 --- a/app/views/admin/import_csvs/_form_temp_p_product.html.haml +++ b/app/views/admin/import_csvs/_form_temp_p_product.html.haml @@ -10,16 +10,16 @@ %ul.list-group.list-group-flush %li.list-group-item .d-inline-flex - %h5.card-title{style: "min-width: 80px;"} libellé : + %h5{style: "min-width: 80px;"} libellé : %p.card-text=@p_product_ref.description %li.list-group-item .d-inline-flex - %h5.card-title{style: "min-width: 80px;"} Qté : + %h5{style: "min-width: 80px;"} Qté : %p.card-text =@price_line.qte %li.list-group-item .d-inline-flex - %h5.card-title{style: "min-width: 80px;"} Prix : + %h5{style: "min-width: 80px;"} Prix : %p.card-text =number_to_currency @p_product_ref.ct_price_ht From 0ebfb92f329b15b3a4b451f43807cad293b1f859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 15:00:40 +0200 Subject: [PATCH 86/91] update schema + bugfix import name --- app/models/p_customer.rb | 11 +++--- db/schema.rb | 78 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index d622a3a..372e15b 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -533,7 +533,7 @@ class PCustomer < ApplicationRecord :adresse_banque_1, :adresse_banque_2, :adresse_banque_3, - :code_banque, + :code_postal_banque, :ville_banque, :pays_banque, :code_banque, @@ -603,7 +603,7 @@ class PCustomer < ApplicationRecord #OK Adresse 1 Banque :p_bank.particular.address_1 OK :adresse_banque_1 #OK Adresse 2 Banque :p_bank.particular.address_2 OK :adresse_banque_2 #OK Adresse 3 Banque VIDE OK :adresse_banque_3 - #OK Code Postal Banque :p_bank.particular.cp OK :code_banque + #OK Code Postal Banque :p_bank.particular.cp OK :code_postal_banque #OK Ville Banque :p_bank.particular.ville OK :ville_banque #OK Pays Banque :p_bank.particular.pays OK :pays_banque #OK Code Banque INUTILE OK :code_banque @@ -661,11 +661,11 @@ class PCustomer < ApplicationRecord n = self.new(imported: true, p_customer_cat: PCustomerCat.find_by_name("Professionnel")) # particular = Particular.new(pro: true) - particular_bill = Particular.new + particular_bill = Particular.new(pro: true) bank = bic = iban = p_commercial = particular_send = send_tel = send_tel2 = send_fax = send_address_2 = p_commercial_code = p_commercial_firstname = contact_2 = nil - bank_particular = Particular.new + bank_particular = Particular.new(pro: true) contact = PContact.new row.each do |key, value| @@ -759,7 +759,7 @@ class PCustomer < ApplicationRecord when "adresse_banque_2" bank_particular.address_2 = value if !value.blank? - when "code_banque" + when "code_postal_banque" bank_particular.cp = value if !value.blank? when "ville_banque" @@ -870,6 +870,7 @@ class PCustomer < ApplicationRecord if bank bank.bic = bic + bank_particular.organisation = bank.name bank.particulars << bank_particular if bank_particular.address_1 bank.save! import_csv.import_csv_elements << ImportCsvElement.new(:element => bank) diff --git a/db/schema.rb b/db/schema.rb index 66c23b3..68d0a77 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1167,6 +1167,7 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.string "contactable_type", limit: 255 t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "skype" t.index ["contactable_id"], name: "idx_55093_index_p_contacts_on_contactable_id" end @@ -1453,6 +1454,17 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.index ["p_fournisseur_id"], name: "idx_55335_index_p_fournisseur_orders_on_p_fournisseur_id" end + create_table "p_fournisseur_refs", force: :cascade do |t| + t.string "ref" + t.string "label" + t.bigint "p_product_ref_id" + t.bigint "p_fournisseur_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_fournisseur_id"], name: "index_p_fournisseur_refs_on_p_fournisseur_id" + t.index ["p_product_ref_id"], name: "index_p_fournisseur_refs_on_p_product_ref_id" + end + create_table "p_fournisseurs", force: :cascade do |t| t.string "name", limit: 255 t.string "code", limit: 255 @@ -1466,6 +1478,11 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.string "compta_account", limit: 255 t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "payment_delais" + t.string "tva_num" + t.integer "p_payment_type_id" + t.string "iban" + t.string "bic" end create_table "p_grades", force: :cascade do |t| @@ -1796,6 +1813,33 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.boolean "stocked", default: true t.text "description" t.bigint "p_product_color_id" + 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 "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" + t.string "sorecop_comment" + t.string "genecode" + t.string "manufacturer_ref" + t.string "used_state" + t.string "i_code_hs" + t.decimal "prepair_score", precision: 10, scale: 2 + t.string "part_delay" + t.string "das_head" + t.string "das_body" + t.string "das_membre" + t.integer "nb_pcs_colis" + t.string "code_om" + t.string "gbh_code_971" + t.string "gbh_code_972" + t.string "gbh_code_973" + t.string "code_art" + t.string "i_comment" + t.string "i_pmp_hors_sorecop" + t.string "i_target_hors_sorecop" + t.integer "p_fournisseur_id" end create_table "p_product_specs", force: :cascade do |t| @@ -1885,6 +1929,7 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) 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: "idx_55431_index_p_products_on_p_product_cat_id" t.index ["s_brand_id"], name: "idx_55431_index_p_products_on_s_brand_id" end @@ -2254,6 +2299,11 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.string "f_token", limit: 255 t.text "acheteur_text" t.string "public_fournisseur_name", limit: 255 + t.integer "bon_de_commande_achat_id" + t.integer "bon_de_reception_achat_id" + t.integer "demande_de_prix_id" + t.integer "avoir_achat_id" + t.integer "facture_achat_id" t.index ["p_customer_id"], name: "idx_54688_index_price_documents_on_p_customer_id" end @@ -2406,6 +2456,13 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.index ["p_customer_id"], name: "idx_54863_index_price_line_blocks_on_p_customer_id" end + create_table "price_line_resp_selects", force: :cascade do |t| + t.integer "price_line_demand_id" + t.integer "price_line_resp_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "price_lines", force: :cascade do |t| t.boolean "archived" t.bigint "price_line_block_id" @@ -2737,6 +2794,24 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do t.decimal "ac_remise", precision: 14, scale: 2 end + create_table "sorecop_cats", 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", force: :cascade do |t| + t.decimal "critere_min", precision: 14, scale: 3 + t.decimal "critere_max", precision: 14, scale: 3 + 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", force: :cascade do |t| t.string "key", limit: 255 t.string "value", limit: 255 @@ -3135,6 +3210,8 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do add_foreign_key "p_customer_product_prices", "p_customers", on_update: :restrict, on_delete: :restrict add_foreign_key "p_customer_product_prices", "p_product_refs", on_update: :restrict, on_delete: :restrict add_foreign_key "p_customer_ribs", "p_customers", on_update: :restrict, on_delete: :restrict + add_foreign_key "p_fournisseur_refs", "p_fournisseurs" + add_foreign_key "p_fournisseur_refs", "p_product_refs" add_foreign_key "p_product_aromes", "p_aromes", on_update: :restrict, on_delete: :restrict add_foreign_key "p_product_aromes", "p_products", on_update: :restrict, on_delete: :restrict add_foreign_key "p_product_images", "image_files", on_update: :restrict, on_delete: :restrict @@ -3159,6 +3236,7 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do add_foreign_key "partition_lines", "partitions", on_update: :restrict, on_delete: :restrict add_foreign_key "partitions", "admins", on_update: :restrict, on_delete: :restrict add_foreign_key "s_modules", "s_modules_states", on_update: :restrict, on_delete: :restrict + add_foreign_key "sorecop_taxes", "sorecop_cats" add_foreign_key "stat_lines", "p_commercials", on_update: :restrict, on_delete: :restrict add_foreign_key "stat_lines", "p_customers", on_update: :restrict, on_delete: :restrict add_foreign_key "stat_lines", "p_product_refs", on_update: :restrict, on_delete: :restrict From 4f799af47ac9034505103dfe264e3e4dd4207ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 19:00:48 +0200 Subject: [PATCH 87/91] split screen size unit --- app/models/p_product.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/p_product.rb b/app/models/p_product.rb index a28d2a7..bad4974 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -284,7 +284,6 @@ class PProduct < ApplicationRecord row.each do |key, value| if value.present? - puts key case key when "identifiant" ref.description = value if !value.blank? @@ -328,13 +327,13 @@ class PProduct < ApplicationRecord arr.each do |value| spec = nil if cellular.include?(value) - spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) elsif video.include?(value) - spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s)) elsif power.include?(value) PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by!(value: value.gsub('W', ''), unit: "W")) elsif geoloc.include?(value) - spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) + spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) else spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) end @@ -349,7 +348,8 @@ class PProduct < ApplicationRecord end when "taille" - PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s)) + float = value.to_s.match(/[^"\s]*/) + PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: float.to_s, unit: '"')) when "capacite" unit = value.match(/\D+/) From e2e6ff305b54b0550b7eda34361cf5030cc36566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 19:01:02 +0200 Subject: [PATCH 88/91] bugfix caching p_product_cat_id --- app/models/p_product_ref.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index ce4686a..31ae21e 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -41,7 +41,7 @@ class PProductRef < ApplicationRecord acts_as_sorting :fields => { :id => {:name => "Id", :reorder => true}, - :p_product_cat => {:name => "Catégorie", :reorder => true}, + :p_product_cat => {:name => "Catégorie", :reorder => true, :sort_name => "cc_p_product_cat_id",}, :ref => {:name => "Référence"}, :cc_name => {:name => "Produit"}, # :description => {:name => "Description"}, @@ -54,7 +54,7 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } - acts_as_caching :fields => [:sorecop, :deee, :name, :code] + acts_as_caching :fields => [:sorecop, :deee, :name, :code, :p_product_cat_id] include PgSearch::Model pg_search_scope :global_search, against: [:ref, :cc_name], From 028c860da95c72d12b4a7837b02a0744961da0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 19 Oct 2021 19:01:20 +0200 Subject: [PATCH 89/91] initial show ok --- app/views/admin/p_product_refs/show.html.haml | 150 +++++++++--------- 1 file changed, 76 insertions(+), 74 deletions(-) diff --git a/app/views/admin/p_product_refs/show.html.haml b/app/views/admin/p_product_refs/show.html.haml index 309a88d..d30bd50 100644 --- a/app/views/admin/p_product_refs/show.html.haml +++ b/app/views/admin/p_product_refs/show.html.haml @@ -19,16 +19,42 @@ %tr %td Produit %td=@p_product_ref.p_product.name #link_to @p_product_ref.p_product.name, [:admin, @p_product_ref.p_product] + -if false + %tr + %td Actif ? + %td=@p_product_ref.enabled ? "Oui" : "Non" + + + %tr + %td Référence assemblée ? + %td=@p_product_ref.assembled ? "Oui" : "Non" - %tr - %td Actif ? - %td=@p_product_ref.enabled ? "Oui" : "Non" - - - %tr - %td Référence assemblée ? - %td=@p_product_ref.assembled ? "Oui" : "Non" - + %tr + %td Conditionnement de référence : + %td + -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning + = @p_product_ref.p_product.p_product_conditioning.name + %tr + %td Unité de vente (archive) : + %td= @p_product_ref.uv + + %tr + %td Conditionnement : + %td + -if @p_product_ref.p_product_conditioning + = @p_product_ref.p_product_conditioning.name + + %tr + %td Prix de vente à l'unité de référence + %td + =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? + ="/" + = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning + %tr + %td Quantité par rapport au conditionnement de référence : + %td + = @p_product_ref.conditioning_ref_qte + %tr %td Référence interne : %td=@p_product_ref.ref @@ -38,40 +64,16 @@ %td=@p_product_ref.ct_sub_name %tr - %td Prix de vente : + %td Dernier prix d'achat : %td=number_to_currency @p_product_ref.ct_price_ht - %tr - %td Unité de vente (archive) : - %td= @p_product_ref.uv - - %tr - %td Conditionnement de référence : - %td - -if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning - = @p_product_ref.p_product.p_product_conditioning.name + - - %tr - %td Conditionnement : - %td - -if @p_product_ref.p_product_conditioning - = @p_product_ref.p_product_conditioning.name - - %tr - %td Quantité par rapport au conditionnement de référence : - %td - = @p_product_ref.conditioning_ref_qte - - %tr - %td Prix de vente à l'unité de référence - %td - =number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte? - ="/" - = @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning + + --if @p_product_ref +-if false -@line_stocks = @p_product_ref.line_stocks .qi_kpi @@ -133,40 +135,40 @@ .clear -.qi_row - .qi_pannel - %h3 Historique des prix d'achat - - %table.table.table-striped.table-hover.table-bordered - %tr - %th - Date - %th Fournisseur - %th Document - %th Total - %th Qté - %th P.U. - - -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| - +-if false + .qi_row + .qi_pannel + %h3 Historique des prix d'achat + + %table.table.table-striped.table-hover.table-bordered %tr - %td - =l price_line.price_line_block.price_lineable.date, :format => :date - - %td - =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur - - %td - =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] - - %td - =number_to_currency price_line.tot_amount_ht - - - %td - =price_line.qte - - %td - =number_to_currency price_line.price_u_ht - - \ No newline at end of file + %th + Date + %th Fournisseur + %th Document + %th Total + %th Qté + %th P.U. + + -price_line_achats = PriceLine.joins(:price_lineable).joins(:price_line_block).where(:cc_block_type => "Facture achat").where(:p_product_ref_id => @p_product_ref.id).order("price_documents.date DESC").each do |price_line| + + %tr + %td + =l price_line.price_line_block.price_lineable.date, :format => :date + + %td + =link_to price_line.price_lineable.p_fournisseur.show_name, [:admin, price_line.price_lineable.p_fournisseur] if price_line.price_lineable.p_fournisseur + + %td + =link_to price_line.price_lineable.d_number, [:admin, price_line.price_lineable] + + %td + =number_to_currency price_line.tot_amount_ht + + + %td + =price_line.qte + + %td + =number_to_currency price_line.price_u_ht + From b9e8fec1282119603de3b5194571aaa00556fa58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 20 Oct 2021 13:10:49 +0200 Subject: [PATCH 90/91] bugfix autocomplete --- app/models/p_product_ref.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 31ae21e..a4ef1e7 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -43,7 +43,7 @@ class PProductRef < ApplicationRecord :id => {:name => "Id", :reorder => true}, :p_product_cat => {:name => "Catégorie", :reorder => true, :sort_name => "cc_p_product_cat_id",}, :ref => {:name => "Référence"}, - :cc_name => {:name => "Produit"}, + # :cc_name => {:name => "Produit"}, # :description => {:name => "Description"}, :cc_name => {:name => "Nom référence"}, :ct_price_ht => {:name => "Prix de vente", :as => :currency}, @@ -204,7 +204,7 @@ class PProductRef < ApplicationRecord end def member_label - "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.ca_name}" + "#{self.ref} | #{self.cc_name}" end def ca_sorecop From 3a0dab44787d68ad1ea45bd45761c35b4bbed71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 20 Oct 2021 13:21:30 +0200 Subject: [PATCH 91/91] bugfix autocomplete --- .../admin/p_product_refs_controller.rb | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 4e0a2b7..2aa9872 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -139,31 +139,38 @@ class Admin::PProductRefsController < ApplicationController end def autocomplete - @p_product_refs = PProductRef.joins(:p_product).all - # @p_product_refs = PProductRef.for_search(params[:search]).limit(50) - - if params[:p_customer_id] - @p_customer = PCustomer.where(:id => params[:p_customer_id]).first - #@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id}) - end - - @p_product_refs = @p_product_refs.where(:p_products => {:enabled => true}) - - if params[:not_assembled].to_s == "true" - - @p_product_refs = @p_product_refs.not_assembleds - - end - + # @p_product_refs = PProductRef.joins(:p_product) + @p_product_refs = PProductRef.limit(10).global_search(params[:search]) + + + # @p_product_refs = PProductRef.joins(:p_product).all + # # @p_product_refs = PProductRef.for_search(params[:search]).limit(50) + + # if params[:p_customer_id] + # @p_customer = PCustomer.where(:id => params[:p_customer_id]).first + # #@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id}) + # end + + # @p_product_refs = @p_product_refs.where(:p_products => {:enabled => true}) + + # if params[:not_assembled].to_s == "true" + + # @p_product_refs = @p_product_refs.not_assembleds + + # end + result = [] - - - @p_product_refs.distinct.all.each do |p_product_ref| - result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id } + + + # @p_product_refs.distinct.all.each do |p_product_ref| + # result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id } + # end + + @p_product_refs.all.each do |p_product_ref| + result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id } end - respond_to do |format| - format.json { render json: result} + format.json { render json: result} end end