diff --git a/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c b/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c index f14f694..e1c3ae1 100644 Binary files a/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c and b/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c differ diff --git a/Gemfile b/Gemfile index bab2ceb..3806597 100644 --- a/Gemfile +++ b/Gemfile @@ -54,9 +54,9 @@ group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + # # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + # gem 'spring' + # gem 'spring-watcher-listen', '~> 2.0.0' end group :test do @@ -118,3 +118,5 @@ gem 'axlsx_rails' gem 'mimemagic', "0.3.10" gem "roo" +gem "select2-rails" + diff --git a/Gemfile.lock b/Gemfile.lock index 93c6cac..d374180 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -301,6 +301,7 @@ GEM activemodel (>= 5) elasticsearch (>= 6) hashie + select2-rails (4.0.13) selenium-webdriver (3.142.3) childprocess (>= 0.5, < 2.0) rubyzip (~> 1.2, >= 1.2.2) @@ -308,10 +309,6 @@ GEM sixarm_ruby_unaccent (1.2.0) sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) - spring (2.1.0) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -406,9 +403,8 @@ DEPENDENCIES roo sass-rails (~> 5) searchkick + select2-rails selenium-webdriver - spring - spring-watcher-listen (~> 2.0.0) sprockets tiny_tds (= 1.3.0) truncate_html diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index ea98f59..b0b76cb 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -15,7 +15,7 @@ #= require vendor/jquery.fileupload #= require vendor/jquery.fileupload-ui #= require vendor/jquery.fileupload-process -#= require vendor/select2.min +#= require select2 #= require vendor/accounting #= require vendor/jquery.mask #= require vendor/datatables.min diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index cb1ee54..af45036 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -1,3 +1,6 @@ +/* +*= require select2 +*/ // Variables @import "1-variables/app"; diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index a58c531..0446561 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -98,7 +98,7 @@ class Admin::PriceDocumentsController < ApplicationController if true - @price_documents = @price_documents.where(:price_document_type_id => params[:price_document_type_ids]) if params[:price_document_type_ids].size > 0 + @price_documents = @price_documents.where(:price_document_type_id => params[:price_document_type_ids]).order(:id) if params[:price_document_type_ids].size > 0 if current_admin.p_commercial @@ -234,7 +234,6 @@ class Admin::PriceDocumentsController < ApplicationController redirect_to admin_p_fournisseurs_path(:create_document => "Commande achat" ) else - @price_document = PriceDocument.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) @price_document.price_document_type = PriceDocumentType.where(:label => params[:document_type]).first @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) @@ -332,7 +331,7 @@ class Admin::PriceDocumentsController < ApplicationController if @price_document.save #if @price_document.cc_label == "Demande prix" if @price_document.cc_label == "Facture achat" - render action: :show + redirect_to admin_price_document_path(@price_document) else redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id) end diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index c477f8c..414af69 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -268,9 +268,11 @@ class PCustomerSheet < ApplicationRecord self.archive_now if !self.archived self.block_price if !self.price_blocked price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today) + #raise price_document.p_customer = self.p_customer price_document.price_line_block = self.price_line_block.dup + price_document.tva_type = self.price_line_block.price_document.tva_type price_document.price_line_block.ac_block_type = nil @@ -278,7 +280,7 @@ class PCustomerSheet < ApplicationRecord new_pl = pl.dup new_pl.ac_block_type = nil price_document.price_line_block.price_lines << new_pl - end + end if price_document.save @@ -306,7 +308,7 @@ class PCustomerSheet < ApplicationRecord def generate_bc - generate_doc("Bon de commande", "commande") + generate_doc("Bon de commande client", "commande") end diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 744e069..abee8ee 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -29,6 +29,8 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_fournisseur accepts_nested_attributes_for :p_fournisseur + + belongs_to :price_document def to_no_archive if self.imported @@ -827,10 +829,6 @@ class PriceLineBlock < ApplicationRecord AVOIR_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) - - - - - + end diff --git a/app/views/admin/price_documents/index.html.haml b/app/views/admin/price_documents/index.html.haml index 9b37cf8..6ad976f 100644 --- a/app/views/admin/price_documents/index.html.haml +++ b/app/views/admin/price_documents/index.html.haml @@ -11,8 +11,6 @@ -if params[:price_document_type_id] =breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label - - .qi_search_row =form_tag "", :method => "get", :onsubmit => "" do @@ -137,7 +135,7 @@ =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @price_documents} -if true #if params[:price_document_type_id].to_i != 0 - =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => params[:price_document_type_id].to_s} + = render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => params[:price_document_type_id].to_s} :scss diff --git a/app/views/admin/price_line_blocks/_form_facture_achat.html.haml b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml index ca2fae3..d71d68c 100644 --- a/app/views/admin/price_line_blocks/_form_facture_achat.html.haml +++ b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml @@ -63,7 +63,7 @@ =f.semantic_fields_for :price_lines do |f| =render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f} - %p= link_to_add_fields "Ajouter une ligneeeeeee", f, :price_lines, {:class => "btn btn-primary add_lines"} + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary add_lines"} -if current_admin.has_permission?("payments") @@ -106,7 +106,8 @@ :javascript $('.add_lines').click(function() { - console.log('LENGTH ' + $('.p_product_ref_select').length) - $('.p_product_ref_select').last().select2(); - $('.p_product_ref_select').last().removeClass('form-control'); + $('.p_product_ref_select').last().select2({ + //theme: "bootstrap" + }); + //$('.p_product_ref_select').last().removeClass('form-control'); }) diff --git a/app/views/admin/price_line_p_articles/_form.html.haml b/app/views/admin/price_line_p_articles/_form.html.haml index adf36d2..ea396e6 100644 --- a/app/views/admin/price_line_p_articles/_form.html.haml +++ b/app/views/admin/price_line_p_articles/_form.html.haml @@ -1,5 +1,7 @@ -=form.input :p_article_id, as: :select, collection: PArticle.all.map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"} += form.input :p_article_id, as: :select, collection: PArticle.joins(:p_product_ref).where(p_product_ref: price_line.p_product_ref).map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"} :javascript - $('.p_article_select').select2(); - $('.p_article_select').removeClass('form-control'); + $('.p_article_select').select2({ + //theme: "bootstrap" + }); + //$('.p_article_select').removeClass('form-control'); diff --git a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml index b601611..8071164 100644 --- a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml +++ b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml @@ -1,8 +1,8 @@ .mx-2.my-2 =semantic_form_for [:admin, @price_line], :remote => true do |f| =f.inputs do - .price_line_p_articles_form + .price_line_p_articles_form.col-3 = f.semantic_fields_for :price_line_p_articles do |form| - =render :partial => "admin/price_line_p_articles/form", :locals => {:form => form} + =render :partial => "admin/price_line_p_articles/form", :locals => {:form => form, price_line: @price_line} %p= link_to_add_fields "Ajouter un article", f, :price_line_p_articles, {:class => "btn btn-primary"} if @price_line.p_articles.count < @price_line.qte =render :partial => "qi/actions", :locals => {:f => f} diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 5e3ba63..ffc3c7a 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -4,8 +4,8 @@ .take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} =ic :arrows - .col-3{:style => "white-space: nowrap;"} - =form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence", input_html: {class:"p_product_ref_select"} + .col-3 + = form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence :", input_html: {class:"p_product_ref_select"} .input-group -# %label Référence -# %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"} @@ -32,7 +32,7 @@ -# = form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "form-inline input_price_line_forced_price"} -# .forced_price_wrapper.mx-2{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"} .col-3 - = form.input :qte, :label => "Quantité", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1} + = form.input :qte, :label => "Quantité :", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1} .col-3 = form.input :ct_u_price_ht, :label => "Prix Unitaire HT :", :input_html => { class: "mx-2"} @@ -43,59 +43,50 @@ = 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;} - - } +-# $('.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 +-# } +-# }); +-# }); \ No newline at end of file diff --git a/db/migrate/20211029111104_add_columns_to_price_docs_adn_price_line_blocks.rb b/db/migrate/20211029111104_add_columns_to_price_docs_adn_price_line_blocks.rb index eafc48e..d94c68b 100644 --- a/db/migrate/20211029111104_add_columns_to_price_docs_adn_price_line_blocks.rb +++ b/db/migrate/20211029111104_add_columns_to_price_docs_adn_price_line_blocks.rb @@ -6,5 +6,8 @@ class AddColumnsToPriceDocsAdnPriceLineBlocks < ActiveRecord::Migration[6.0] add_column :price_documents, :supplier_document_date, :date add_column :price_line_blocks, :stock_entrance_date, :date add_column :price_line_blocks, :ct_tot_amount_ht, :decimal, :precision => 14, :scale => 2 + change_table :price_line_blocks do |t| + t.belongs_to :price_document + end end end diff --git a/db/schema.rb b/db/schema.rb index c6cfc94..4128f51 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2471,7 +2471,9 @@ ActiveRecord::Schema.define(version: 2021_11_03_085623) do t.string "cc_state" t.date "stock_entrance_date" t.decimal "ct_tot_amount_ht", precision: 14, scale: 2 + t.bigint "price_document_id" t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id" + t.index ["price_document_id"], name: "index_price_line_blocks_on_price_document_id" end create_table "price_line_p_articles", force: :cascade do |t|