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/app/controllers/admin/line_stocks_controller.rb b/app/controllers/admin/line_stocks_controller.rb index 81131f2..caab464 100644 --- a/app/controllers/admin/line_stocks_controller.rb +++ b/app/controllers/admin/line_stocks_controller.rb @@ -133,4 +133,8 @@ class Admin::LineStocksController < ApplicationController def empty_stock @price_document = PriceDocument.where(:price_document_type_id => 4, :cost_ok => false) end + + def show_p_article + @line_stock = LineStock.find(params[:line_stock_id]) + end end diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 8905ef1..806e13f 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -146,17 +146,20 @@ class Admin::PCustomerSheetsController < ApplicationController def new - - @p_customer_sheet = PCustomerSheet.new() - @p_customer = PCustomer.find(params[:p_customer_id]) if params[:p_customer_id] - + + @p_customer_sheet.p_customer = @p_customer - @p_customer_sheet.price_line_block = PriceLineBlock.new(:particular_bill_id => @p_customer.particular_bill_id, :particular_send_id => @p_customer.particular_send_id) + @p_customer_sheet.price_line_block = PriceLineBlock.new @p_customer_sheet.price_line_block.price_lines.build @p_customer_sheet.price_line_block.p_customer = @p_customer + + @p_customer_sheet.price_line_block.build_particular_send(owner: @p_customer) + @p_customer_sheet.price_line_block.build_particular_bill(owner: @p_customer) + + end @@ -171,15 +174,15 @@ class Admin::PCustomerSheetsController < ApplicationController def create @p_customer_sheet = PCustomerSheet.new(params.require(:p_customer_sheet).permit!) - @p_customer_sheet.admin = current_admin - - - if @p_customer_sheet.save redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else + puts "ERRORSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" + puts params + puts @p_customer_sheet.errors.messages + puts "ERRORSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" @p_customer = @p_customer_sheet.price_line_block.p_customer render action: "new" diff --git a/app/controllers/admin/price_lines_controller.rb b/app/controllers/admin/price_lines_controller.rb index be13d20..12df066 100644 --- a/app/controllers/admin/price_lines_controller.rb +++ b/app/controllers/admin/price_lines_controller.rb @@ -44,19 +44,12 @@ class Admin::PriceLinesController < ApplicationController def update - puts "PAAMSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" - puts params - puts "PAAMSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" @price_line = PriceLine.find(params[:id]) if @price_line.update_attributes(params.require(:price_line).permit!) - + else - puts "ERRORSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" - puts @price_line.errors.messages - puts "ERRORSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" render action: "edit" - end end @@ -73,4 +66,8 @@ class Admin::PriceLinesController < ApplicationController # @p_article = PArticle.new#@price_line.p_articles.build # @p_article_serial_nums = @p_article.p_article_serial_nums.build end + + def add_price_line_p_article + @price_line = PriceLine.find(params[:price_line_id]) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 43aa011..d0e29b3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,6 +78,16 @@ module ApplicationHelper icon = sort_direction == "asc" ? "chevron-up" : "chevron-down" icon = column == sort_column ? icon : "" link_to raw("#{title} "+ic(icon).html_safe), request.query_parameters.merge({column: column, direction: direction}) - end + end + + def id_color(price_line) + if price_line.p_articles.count == 0 + return "background-color: red" + elsif price_line.p_articles.count < price_line.qte + return "background-color: orange" + else + return "background-color: #70ff29" + end + end end diff --git a/app/models/line_stock.rb b/app/models/line_stock.rb index 9847dfb..21da23b 100644 --- a/app/models/line_stock.rb +++ b/app/models/line_stock.rb @@ -7,6 +7,9 @@ belongs_to :stock_movement_line belongs_to :partition_lines + has_many :line_stock_p_articles + has_many :p_articles, through: :line_stock_p_articles + acts_as_sorting :fields => { :id => {:name => "ID", :reorder => false}, diff --git a/app/models/line_stock_p_article.rb b/app/models/line_stock_p_article.rb new file mode 100644 index 0000000..54c2762 --- /dev/null +++ b/app/models/line_stock_p_article.rb @@ -0,0 +1,4 @@ +class LineStockPArticle < ApplicationRecord + belongs_to :line_stock + belongs_to :p_article +end diff --git a/app/models/p_article.rb b/app/models/p_article.rb index bd9cbdc..6f695d4 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -10,6 +10,9 @@ class PArticle < ApplicationRecord has_many :price_line_p_articles has_many :price_lines, through: :price_line_p_articles accepts_nested_attributes_for :p_article_serial_nums + + has_many :line_stock_p_articles + has_many :line_stocks, through: :line_stock_p_articles diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 45d7409..a16ac3a 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -13,12 +13,13 @@ class PCustomerSheet < ApplicationRecord belongs_to :particular_bill, :class_name => "Particular"#, :dependent => :destroy accepts_nested_attributes_for :particular_bill + belongs_to :particular_send, :class_name => "Particular"#, :dependent => :destroy accepts_nested_attributes_for :particular_send has_one :price_line_block, :as => :price_lineable - accepts_nested_attributes_for :price_line_block + accepts_nested_attributes_for :price_line_block has_many :price_lines, :through => :price_line_block diff --git a/app/models/particular.rb b/app/models/particular.rb index 9458945..9fbe2bd 100644 --- a/app/models/particular.rb +++ b/app/models/particular.rb @@ -7,6 +7,7 @@ class Particular < ApplicationRecord has_many :open_ranges, :through => :open_range_elements belongs_to :owner, :polymorphic => true + #has_many :p_customer_sheets #validates :civilite, :presence => true, :if => :force_validation #validates :name, :presence => true, :if => :force_validation #validates :firstname, :presence => true, :if => :force_validation diff --git a/app/models/price_document.rb b/app/models/price_document.rb index de113f8..ae3a1f6 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -764,4 +764,9 @@ class PriceDocument < ApplicationRecord end end + def stock_generable + return self.price_line_block.price_lines.joins(:p_articles).count < self.price_line_block.price_lines.sum(:qte) ? false : true + #exclure les produit non stockable et sans SN + end + end diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 3eb2621..faa5f6d 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -13,6 +13,7 @@ class PriceLine < ApplicationRecord has_many :price_line_p_articles has_many :p_articles, through: :price_line_p_articles accepts_nested_attributes_for :p_articles + accepts_nested_attributes_for :price_line_p_articles default_scope { order('position ASC') } diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 8e4ee2c..744e069 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -7,8 +7,8 @@ class PriceLineBlock < ApplicationRecord validates :p_customer_id, :presence => true, :if => :p_customer_needed? #validates :p_fournisseur_id, :presence => true, :if => :p_fournisseur_needed? - validates :particular_bill_id, :presence => true, :if => :particular_bill_needed? - validates :particular_send_id, :presence => true, :if => :particular_send_needed? + #validates :particular_bill_id, :presence => true, :if => :particular_bill_needed? + #validates :particular_send_id, :presence => true, :if => :particular_send_needed? belongs_to :particular_bill, :class_name => "Particular"#, :dependent => :destroy @@ -208,8 +208,18 @@ class PriceLineBlock < ApplicationRecord def generate_stock self.price_lines.each do |pl| if pl.p_product_ref - LineStock.create(:dluo => pl.dluo, :date => self.price_lineable.date, :p_product_ref => pl.p_product_ref, :description => "Entrée en stock par facture d'achat", :qte => pl.qte, :price_ht => pl.local_tot_amount_ht, :price_line => pl, :price_line_block => self, :stockable => self.price_lineable) - + ls = LineStock.new( + :dluo => pl.dluo, + :date => self.price_lineable.date, + :p_product_ref => pl.p_product_ref, + :description => "Entrée en stock par facture d'achat", + :qte => pl.qte, + :price_ht => pl.local_tot_amount_ht, + :price_line => pl, + :price_line_block => self, + :stockable => self.price_lineable) + ls.p_articles = pl.p_articles + ls.save end @@ -441,6 +451,9 @@ class PriceLineBlock < ApplicationRecord end if self.particular_bill_needed? and (!self.p_customer or !self.particular_bill or !self.particular_bill.owner or self.particular_bill.owner != self.p_customer) + puts "PARTICULEARRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" + puts self.particular_bill + puts "PARTICULEARRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" errors.add(:particular_bill_id, 'doit être une adresse du client') end diff --git a/app/views/admin/line_stocks/_line_stock.html.haml b/app/views/admin/line_stocks/_line_stock.html.haml index 0dae2d5..fb479c4 100644 --- a/app/views/admin/line_stocks/_line_stock.html.haml +++ b/app/views/admin/line_stocks/_line_stock.html.haml @@ -25,6 +25,7 @@ = link_to i(:"trash-o"), [:admin, line_stock], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:pencil), edit_admin_line_stock_path(line_stock), :remote => true = link_to i(:eye), admin_line_stock_path(line_stock), :remote => true + = link_to i(:"mobile-alt"), show_p_article_admin_line_stocks_path(line_stock_id: line_stock.id), :remote => true diff --git a/app/views/admin/line_stocks/_show_p_article_form.html.haml b/app/views/admin/line_stocks/_show_p_article_form.html.haml new file mode 100644 index 0000000..4d014a9 --- /dev/null +++ b/app/views/admin/line_stocks/_show_p_article_form.html.haml @@ -0,0 +1,13 @@ +.mx-2.my-2 + %table.table-bordered + %tbody + -@line_stock.p_articles.each do |p_article| + %tr + %td="##{p_article.id}" + %td=p_article.p_product_ref.name + - p_article.p_article_serial_nums.each do |sn| + %tr + %td + %td + ="#{sn.p_serial_num_type.name} - #{sn.value}" +.actions \ No newline at end of file diff --git a/app/views/admin/line_stocks/index.html.haml b/app/views/admin/line_stocks/index.html.haml index 7360c8e..f7d8347 100644 --- a/app/views/admin/line_stocks/index.html.haml +++ b/app/views/admin/line_stocks/index.html.haml @@ -140,3 +140,4 @@ + \ No newline at end of file diff --git a/app/views/admin/line_stocks/show_p_article.js.erb b/app/views/admin/line_stocks/show_p_article.js.erb new file mode 100644 index 0000000..9f660b6 --- /dev/null +++ b/app/views/admin/line_stocks/show_p_article.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "show_p_article_form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 3a2568b..6b380c1 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -15,7 +15,7 @@ %p= link_to_add_fields "Ajouter un numéro de série", f, :p_article_serial_nums, {:class => "btn btn-primary"} .actions=f.submit "sauvegarder", :class => "btn btn-primary" -- else +- elsif params[:controller] == "admin/price_lines" = form.inputs do -if params[:p_product_ref_id] = form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true} @@ -30,3 +30,4 @@ = form.semantic_fields_for :p_article_serial_nums do |form| =render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form} %p= link_to_add_fields "Ajouter un numéro de série", form, :p_article_serial_nums, {:class => "btn btn-primary"} + diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index f38a269..5c93951 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -1,7 +1,8 @@ =semantic_form_for [:admin, @p_customer_sheet], :html => {:class => "qi_price_form"}, :remote => false do |form| + =#debug form.object.errors.messages if current_admin.id == 1 =form.semantic_fields_for :price_line_block do |f| =render :partial => "admin/price_line_blocks/form", :locals => {:f => f} - + .content .qi_row .qi_pannel.qi_plain.padding.row @@ -11,23 +12,6 @@ =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" =#form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" =#form.input :past_id, :label => "N° système actuel" - =yield :shipping_date - - .qi_row - .qi_pannel.qi_plain.padding.row - nested form for particular send et bill qui crée à chaque fois un particular - ajouter accept nested attributed for particular dans pcustomer sheet - - - - .qi_row - .qi_pannel.qi_plain.padding.row - =yield :price_lines - .qi_row - .qi_pannel.qi_plain.padding.row - =yield :discount - - .large_actions diff --git a/app/views/admin/particulars/_form.html.haml b/app/views/admin/particulars/_form.html.haml index 55bd784..03eb796 100644 --- a/app/views/admin/particulars/_form.html.haml +++ b/app/views/admin/particulars/_form.html.haml @@ -1,4 +1,3 @@ - =form.hidden_field :particular_type =form.hidden_field :skip_validation, :class => "skip_validation" =form.hidden_field :pro @@ -31,15 +30,14 @@ =#form.input :email, :label => false, :placeholder => qit("don-particular-email","Email") =#form.input :tel, :label => false, :placeholder => qit("don-particular-phone","Téléphone") -Contacts de l'adresse : +-if !params[:controller] == "p_customer_sheets" + Contacts de l'adresse : + .p_contacts_form + =form.semantic_fields_for :p_contacts do |form| + =render :partial => "admin/p_contacts/form", :locals => {:form => form} -.p_contacts_form - =form.semantic_fields_for :p_contacts do |form| - =render :partial => "admin/p_contacts/form", :locals => {:form => form} - - -%p= link_to_add_fields ic(:plus)+" Ajouter un contact à l'adresse", form, :p_contacts + %p= link_to_add_fields ic(:plus)+" Ajouter un contact à l'adresse", form, :p_contacts =#form.input :open_ranges, :label => "Horaires d'ouvertures :", :collection => OpenRange.all, :as => :check_boxes diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 59cf845..a66ebcd 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -209,15 +209,8 @@ -price_line_block.price_lines.each do |price_line| %tbody %tr - -if price_line.p_articles.count == 0 - %td{style: "background-color: red;"} - ="##{price_line.id}" - - elsif price_line.p_articles.count < price_line.qte - %td{style: "background-color: orange"} - ="##{price_line.id}" - - else - %td{style: "background-color: green"} - ="##{price_line.id}" + %td{style: id_color(price_line)} + ="##{price_line.id}" %td =price_line.ref %td @@ -250,7 +243,8 @@ -if current_admin.has_permission?("show-costs") %p -if @price_document.price_document_type_id == 6 - =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok + =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable + =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable -elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 %p Coût : diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index 8f441a3..9adc306 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -4,47 +4,42 @@ -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - = f.hidden_field :p_customer_id, :class => "p_customer_id" - =content_for :particular do - .row - .p_customer_sheet_customer.col-12.mb-4 + = f.text_field :p_customer_id, :class => "p_customer_id" + .row + .p_customer_sheet_customer.col-12.mb-4 + -if f.object.p_customer and f.object.p_customer.particular + =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular} - -if f.object.p_customer and f.object.p_customer.particular - =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular} + .qi_row + .qi_pannel.qi_plain.padding.row .col-6 - .addresses.row - .columns.span_6 - %h4 Adresse de facturation + Adresse de livraison : + =f.semantic_fields_for :particular_send do |form_particular_send| + =render :partial => "admin/particulars/form", :locals => {:form => form_particular_send} + =form_particular_send.text_field :owner_id + =form_particular_send.text_field :owner_type - -if f.object.p_customer - =f.inputs do - = f.input :particular_bill_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation" - -else - =f.inputs do - = f.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" .col-6 - .addresses.row - .columns.span_6 - %h4 Adresse de livraison + Adresse de facturation : + =f.semantic_fields_for :particular_bill do |form_particular_bill| + =render :partial => "admin/particulars/form", :locals => {:form => form_particular_bill} + =form_particular_bill.text_field :owner_id + =form_particular_bill.text_field :owner_type + + + - -if f.object.p_customer - =f.inputs do - = f.input :particular_send_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison" - -else - =f.inputs do - = f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" .clear - =content_for :shipping_date do - = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date - = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date - = f.input :validation_date, :label => "Date de validation :", :as => :date + = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date + = f.input :validation_date, :label => "Date de validation :", :as => :date - = f.input :customer_ref, :label => "Référence commande client :" + = f.input :customer_ref, :label => "Référence commande clientttt :" -if current_admin.has_permission?("customer-sheets-bl") =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} @@ -55,33 +50,30 @@ %br + %div{:style=>"padding:0 30px;"} + .row.qi_field_wrapper + %table{:style => "width:100%;border-collapse:separate;"} + %thead + %tr + %th + %th Produit + %th{:style => "width:200px;"} Prix + %th + %th{:style => "width:100px;"} Qté + %th TVA + %th + %tbody.price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form", :locals => {:form => f} - =content_for :price_lines do - %div{:style=>"padding:0 30px;"} - .row.qi_field_wrapper - %table{:style => "width:100%;border-collapse:separate;"} - %thead - %tr - %th - %th Produit - %th{:style => "width:200px;"} Prix - %th - %th{:style => "width:100px;"} Qté - %th TVA - %th - %tbody.price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form", :locals => {:form => f} - - %p{:style=>"padding-top:10px;"}= link_to_add_fields ic("plus-circle") + " ligne", f, :price_lines, {:class => "btn btn-primary p-2", tabindex: 10, style: "position: sticky; top: 100px"} + %p{:style=>"padding-top:10px;"}= link_to_add_fields ic("plus-circle") + " ligne", f, :price_lines, {:class => "btn btn-primary p-2", tabindex: 10, style: "position: sticky; top: 100px"} -if current_admin.has_permission?("payments") - =content_for :discount do - -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - -if !@avoir - = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :"#, :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} - = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + -if !@avoir + = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :"#, :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} + = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" -if current_admin.has_permission?("payments") @@ -103,7 +95,3 @@ -if false = f.input :ct_payment_month_end, :label => "Fin de mois ?" - - - - diff --git a/app/views/admin/price_line_blocks/_price_line_block.html.haml b/app/views/admin/price_line_blocks/_price_line_block.html.haml index 390aec3..961c8ae 100644 --- a/app/views/admin/price_line_blocks/_price_line_block.html.haml +++ b/app/views/admin/price_line_blocks/_price_line_block.html.haml @@ -96,6 +96,9 @@ %td.numeraire =price_line.qte + %td + = price_line.p_articles.count + = link_to i(:"mobile-alt"), add_price_line_p_article_admin_price_lines_path(p_product_ref_id: price_line.p_product_ref.id, price_line_id: price_line.id), :remote => true -if @price_document and @price_document.label != "Demande prix" and @price_document.label != "Réponse fournisseur" %td.numeraire diff --git a/app/views/admin/price_line_p_articles/_form.html.haml b/app/views/admin/price_line_p_articles/_form.html.haml new file mode 100644 index 0000000..b7c9644 --- /dev/null +++ b/app/views/admin/price_line_p_articles/_form.html.haml @@ -0,0 +1 @@ +=form.input :p_article_id, as: :select, collection: PArticle.all, member_label: :id \ No newline at end of file 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 new file mode 100644 index 0000000..8575343 --- /dev/null +++ b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml @@ -0,0 +1,9 @@ +.mx-2.my-2 + =semantic_form_for [:admin, @price_line], :remote => true do |f| + .content + =f.inputs do + .price_line_p_articles_form + = f.semantic_fields_for :price_line_p_articles do |form| + =render :partial => "admin/price_line_p_articles/form", :locals => {:form => form} + %p= link_to_add_fields "Ajouter un article", f, :price_line_p_articles, {:class => "btn btn-primary"} + .actions=f.submit "Sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/price_lines/add_price_line_p_article.js.erb b/app/views/admin/price_lines/add_price_line_p_article.js.erb new file mode 100644 index 0000000..d64a968 --- /dev/null +++ b/app/views/admin/price_lines/add_price_line_p_article.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "add_price_line_p_article_form"))%>",700,900); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6c3c724..e0a0032 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -447,6 +447,7 @@ Rails.application.routes.draw do collection do get "stock_resume" get "empty_stock" + get :show_p_article end end end @@ -698,6 +699,7 @@ Rails.application.routes.draw do end collection do get :add_p_article + get :add_price_line_p_article end end diff --git a/db/migrate/20211103085623_create_line_stock_p_articles.rb b/db/migrate/20211103085623_create_line_stock_p_articles.rb new file mode 100644 index 0000000..0ec4e0e --- /dev/null +++ b/db/migrate/20211103085623_create_line_stock_p_articles.rb @@ -0,0 +1,10 @@ +class CreateLineStockPArticles < ActiveRecord::Migration[6.0] + def change + create_table :line_stock_p_articles do |t| + t.belongs_to :p_article + t.belongs_to :line_stock + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3fe7b90..c6cfc94 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_11_02_105934) do +ActiveRecord::Schema.define(version: 2021_11_03_085623) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -549,6 +549,15 @@ ActiveRecord::Schema.define(version: 2021_11_02_105934) do t.datetime "updated_at", precision: 6, null: false end + create_table "line_stock_p_articles", force: :cascade do |t| + t.bigint "p_article_id" + t.bigint "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_p_articles_on_line_stock_id" + t.index ["p_article_id"], name: "index_line_stock_p_articles_on_p_article_id" + end + create_table "line_stock_usages", force: :cascade do |t| t.bigint "line_stock_id" t.decimal "qte", precision: 14, scale: 2 diff --git a/test/fixtures/line_stock_p_articles.yml b/test/fixtures/line_stock_p_articles.yml new file mode 100644 index 0000000..5181636 --- /dev/null +++ b/test/fixtures/line_stock_p_articles.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/line_stock_p_article_test.rb b/test/models/line_stock_p_article_test.rb new file mode 100644 index 0000000..c5688f1 --- /dev/null +++ b/test/models/line_stock_p_article_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LineStockPArticleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end