From f1bad61fd2722ae319293df1754d5bb0b8ff613b Mon Sep 17 00:00:00 2001
From: Philippe
Date: Tue, 2 Nov 2021 19:36:31 +0100
Subject: [PATCH] adding nested p articles and SN
---
app/assets/stylesheets/pane_hover.scss | 2 +-
.../admin/price_lines_controller.rb | 15 +++++-
app/helpers/application_helper.rb | 3 +-
app/helpers/document_line_helper.rb | 12 +++++
app/models/line_stock.rb | 2 +
app/models/p_article.rb | 4 ++
app/models/p_customer.rb | 9 +++-
app/models/p_customer_sheet.rb | 3 +-
app/models/price_document.rb | 8 ++--
app/models/price_line.rb | 3 ++
app/models/price_line_block.rb | 2 +-
app/models/price_line_p_article.rb | 4 ++
.../p_article_serial_nums/_form.html.haml | 9 ++--
app/views/admin/p_articles/_form.html.haml | 47 ++++++++++++-------
.../admin/p_customer_sheets/_form.html.haml | 30 ++++++++----
app/views/admin/p_products/_form.html.haml | 24 ++++------
.../admin/price_documents/_form.html.haml | 2 +-
.../admin/price_documents/show.html.haml | 47 +++++++++----------
.../admin/price_line_blocks/_form.html.haml | 2 +-
.../_form_facture_achat.html.haml | 19 ++++----
.../price_lines/_add_p_article_form.html.haml | 9 ++++
.../_reponse_pane_hover_form.html.haml | 2 -
...p_articles.js.erb => add_p_article.js.erb} | 2 +-
config/routes.rb | 1 +
...211102094225_add_stockable_to_p_product.rb | 6 +++
...1102105934_create_price_line_p_articles.rb | 12 +++++
db/schema.rb | 13 ++++-
test/fixtures/price_line_p_articles.yml | 11 +++++
test/models/price_line_p_article_test.rb | 7 +++
29 files changed, 212 insertions(+), 98 deletions(-)
create mode 100644 app/models/price_line_p_article.rb
create mode 100644 app/views/admin/price_lines/_add_p_article_form.html.haml
rename app/views/admin/price_lines/{add_p_articles.js.erb => add_p_article.js.erb} (68%)
create mode 100644 db/migrate/20211102094225_add_stockable_to_p_product.rb
create mode 100644 db/migrate/20211102105934_create_price_line_p_articles.rb
create mode 100644 test/fixtures/price_line_p_articles.yml
create mode 100644 test/models/price_line_p_article_test.rb
diff --git a/app/assets/stylesheets/pane_hover.scss b/app/assets/stylesheets/pane_hover.scss
index 31ad878..e94bb43 100644
--- a/app/assets/stylesheets/pane_hover.scss
+++ b/app/assets/stylesheets/pane_hover.scss
@@ -10,7 +10,7 @@
.actions{
- position:absolute;
+ position: static;
bottom:0px;
left:0px;
right:0px;
diff --git a/app/controllers/admin/price_lines_controller.rb b/app/controllers/admin/price_lines_controller.rb
index 0874893..be13d20 100644
--- a/app/controllers/admin/price_lines_controller.rb
+++ b/app/controllers/admin/price_lines_controller.rb
@@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*-
-
+require "awesome_print"
class Admin::PriceLinesController < ApplicationController
layout "admin"
before_action :auth_admin, :except => [:edit, :update]
@@ -44,12 +44,17 @@ 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
@@ -62,4 +67,10 @@ class Admin::PriceLinesController < ApplicationController
@price_line.destroy
end
+
+ def add_p_article
+ @price_line = PriceLine.find(params[:price_line_id])
+ # @p_article = PArticle.new#@price_line.p_articles.build
+ # @p_article_serial_nums = @p_article.p_article_serial_nums.build
+ end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 31e8de0..43aa011 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -78,7 +78,6 @@ 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
end
diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb
index 0e54205..88a9a6e 100644
--- a/app/helpers/document_line_helper.rb
+++ b/app/helpers/document_line_helper.rb
@@ -20,6 +20,18 @@ module DocumentLineHelper
end
+
+ if association == :p_articles
+
+
+
+ new_object.p_product_ref_id = f.object.p_product_ref_id
+
+
+
+
+ end
+
if options[:partial]
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render(options[:partial], :form => builder)
diff --git a/app/models/line_stock.rb b/app/models/line_stock.rb
index a8886b9..9847dfb 100644
--- a/app/models/line_stock.rb
+++ b/app/models/line_stock.rb
@@ -6,6 +6,8 @@
belongs_to :price_line_block
belongs_to :stock_movement_line
belongs_to :partition_lines
+
+
acts_as_sorting :fields => {
:id => {:name => "ID", :reorder => false},
:date => {:name => "Date", :reorder => true, :as => :date},
diff --git a/app/models/p_article.rb b/app/models/p_article.rb
index ca44f4f..bd9cbdc 100644
--- a/app/models/p_article.rb
+++ b/app/models/p_article.rb
@@ -7,8 +7,12 @@ class PArticle < ApplicationRecord
has_many :p_article_serial_nums, dependent: :destroy
# has_many :p_serial_num_values, through: :p_article_serial_nums
+ has_many :price_line_p_articles
+ has_many :price_lines, through: :price_line_p_articles
accepts_nested_attributes_for :p_article_serial_nums
+
+
validates_presence_of :p_product_ref
# has_many :p_product_ref_specs, through: :p_product_ref
# accepts_nested_attributes_for :p_product_ref_specs
diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb
index 372e15b..0d11ced 100644
--- a/app/models/p_customer.rb
+++ b/app/models/p_customer.rb
@@ -73,8 +73,13 @@ class PCustomer < ApplicationRecord
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
+ if self.class.all.order(code: :desc).limit(1)[0]
+ 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
+ else
+ last_used_code = 1
+ last_number = 1
+ end
code = "CLI%04d" % [last_number]
diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb
index cada486..45d7409 100644
--- a/app/models/p_customer_sheet.rb
+++ b/app/models/p_customer_sheet.rb
@@ -12,8 +12,9 @@ class PCustomerSheet < ApplicationRecord
belongs_to :p_customer
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
diff --git a/app/models/price_document.rb b/app/models/price_document.rb
index 0f019c2..de113f8 100644
--- a/app/models/price_document.rb
+++ b/app/models/price_document.rb
@@ -284,7 +284,7 @@ class PriceDocument < ApplicationRecord
:label => {:name => "Type", :reorder => false},
:stock_ok => {:name => "Stock mis à jour ?", :reorder => true},
:tva_type_name => {:name => "ID Type de TVA", :reorder => true},
- :package_number => {:name => "Nombre de colis", :reorder => true},
+ #:package_number => {:name => "Nombre de colis", :reorder => true},
:d_number => {:name => "Numéro", :reorder => true},
:date => {:name => "Date", :reorder => true},
:cc_payment_end_at => {:name => "Date d'échance", :reorder => true},
@@ -308,9 +308,9 @@ class PriceDocument < ApplicationRecord
self.tva_type.name
end
- def package_number
- self.price_line_block.package_number
- end
+ # def package_number
+ # self.price_line_block.package_number
+ # end
def self.valid_sort
r = []
diff --git a/app/models/price_line.rb b/app/models/price_line.rb
index dc50cd1..3eb2621 100644
--- a/app/models/price_line.rb
+++ b/app/models/price_line.rb
@@ -10,6 +10,9 @@ class PriceLine < ApplicationRecord
has_one :p_fournisseur, :through => :price_line_block
#has_many :price_line_demands, through: :price_line_resp_selects
+ has_many :price_line_p_articles
+ has_many :p_articles, through: :price_line_p_articles
+ accepts_nested_attributes_for :p_articles
default_scope { order('position ASC') }
diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb
index 0bdb058..8e4ee2c 100644
--- a/app/models/price_line_block.rb
+++ b/app/models/price_line_block.rb
@@ -543,7 +543,7 @@ class PriceLineBlock < ApplicationRecord
def ca_tot_lines_tva
r = 0.0
self.price_lines.each do |pl|
- r+= pl.tot_amount_tva
+ r+= pl.tot_amount_tva if pl
end
return r
end
diff --git a/app/models/price_line_p_article.rb b/app/models/price_line_p_article.rb
new file mode 100644
index 0000000..2edaf5e
--- /dev/null
+++ b/app/models/price_line_p_article.rb
@@ -0,0 +1,4 @@
+class PriceLinePArticle < ApplicationRecord
+ belongs_to :price_line
+ belongs_to :p_article
+end
diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml
index d3ec238..88de8b6 100644
--- a/app/views/admin/p_article_serial_nums/_form.html.haml
+++ b/app/views/admin/p_article_serial_nums/_form.html.haml
@@ -12,7 +12,8 @@
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
- else
- .p_article_serial_nums_form.field
- =form.inputs do
- = form.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id)
- = form.input :value
+ .ml-5
+ .p_article_serial_nums_form.field
+ =form.inputs do
+ = form.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id)
+ = form.input :value
diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml
index 4da53fd..3a2568b 100644
--- a/app/views/admin/p_articles/_form.html.haml
+++ b/app/views/admin/p_articles/_form.html.haml
@@ -1,17 +1,32 @@
-=semantic_form_for [:admin, @p_article], :remote => true do |f|
+- if params[:controller] == "admin/p_articles"
+ =semantic_form_for [:admin, @p_article], :remote => true do |f|
+ .content
+ =f.inputs do
+ -if params[:p_product_ref_id]
+ = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :selected => f.object.p_product_ref , :label => f.object.label_for(:p_product_ref)
+ -else
+ = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => f.object.label_for(:p_product_ref)
+ -if PGrade::ACTIVATED
+ = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade"
+ %h4 Numero de série :
+ .p_article_serial_nums_form
+ = f.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", f, :p_article_serial_nums, {:class => "btn btn-primary"}
- .content
- =f.inputs do
- -if params[:p_product_ref_id]
- = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :selected => f.object.p_product_ref , :label => f.object.label_for(:p_product_ref)
- -else
- = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => f.object.label_for(:p_product_ref)
- -if PGrade::ACTIVATED
- = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade"
- %h4 Numero de série :
- .p_article_serial_nums_form
- = f.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", f, :p_article_serial_nums, {:class => "btn btn-primary"}
-
- .actions=f.submit "sauvegarder", :class => "btn btn-primary"
+ .actions=f.submit "sauvegarder", :class => "btn btn-primary"
+- else
+ = 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}
+ = form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
+ -else
+ = 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}
+ = form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
+ -if PGrade::ACTIVATED
+ = form.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade"
+ %h4 Numero de série :
+ .p_article_serial_nums_form
+ = 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 2c1194a..f38a269 100755
--- a/app/views/admin/p_customer_sheets/_form.html.haml
+++ b/app/views/admin/p_customer_sheets/_form.html.haml
@@ -5,21 +5,31 @@
.content
.qi_row
.qi_pannel.qi_plain.padding.row
- .col-2
+ .col-8
+ =@p_customer_sheet.p_customer.particular.organisation
-if @p_customer_sheet and @p_customer_sheet.state != "commande"
=#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 :discount
- .col-2
+ =#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
- .col-8
- =yield :particular
+
+ .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
+
- =yield :price_lines
+ .qi_row
+ .qi_pannel.qi_plain.padding.row
+ =yield :price_lines
+ .qi_row
+ .qi_pannel.qi_plain.padding.row
+ =yield :discount
+
+
+
+
.large_actions
.actions
=link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn"
diff --git a/app/views/admin/p_products/_form.html.haml b/app/views/admin/p_products/_form.html.haml
index 0b0953c..d8f02c4 100755
--- a/app/views/admin/p_products/_form.html.haml
+++ b/app/views/admin/p_products/_form.html.haml
@@ -4,26 +4,24 @@
.qi_pannel.qi_plain.padding
=f.inputs do
.row.qi_cancel_margins
-
.col-sm-2
= f.input :p_product_cat_id, :label => "Catégorie produit :", :collection => PProductCat.all, :as => :select, :include_blank => false
-
-
.col-sm-2
%br
= f.input :enabled, :label => "Produit actif ?"
-
.col-sm-2
-
+ %br
+ = f.input :stockable, :label => "Produit stockable ?", :input_html => {:onclick => "$('#with_serial').toggle('slow');"}
+ .col-sm-2
+ %br
+ #with_serial
+ = f.input :with_serial_number, :label => "Avec n° de série ?"
+ .col-sm-2
=f.input :s_brand_id, :label => "Marque :", :collection => SBrand.all, :as => :select, :include_blank => true
-
=# 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
-
-
-
+
-if false
%table{:style => "width:100%"}
%tr
@@ -108,9 +106,3 @@
}
-
-
-
-
-
-
diff --git a/app/views/admin/price_documents/_form.html.haml b/app/views/admin/price_documents/_form.html.haml
index 3062be9..0f516cc 100644
--- a/app/views/admin/price_documents/_form.html.haml
+++ b/app/views/admin/price_documents/_form.html.haml
@@ -45,7 +45,7 @@ PRICE_DOCUMENTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7
.row
.col-6
- = f.input :date, :label => "Date de la facture achat :", :as => :date
+ = f.input :date, :label => "Date de la facture achat :", :as => :date, input_html: {value: Date.today}
.col-6
= f.input :supplier_document_date, :label => "Date du document fournisseur :", :as => :date
.col-6
diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml
index 87f7ba9..59cf845 100644
--- a/app/views/admin/price_documents/show.html.haml
+++ b/app/views/admin/price_documents/show.html.haml
@@ -18,7 +18,7 @@
.qi_row
-
+ =debug @price_document.price_line_block.price_lines.count
%table.table.table-striped
-if @price_document.label == "Réponse fournisseur"
@@ -196,7 +196,7 @@
%table.table
%thead
%tr
- %th
+ %th ID
%th Référence
%th Marque
%th Désignation
@@ -205,47 +205,46 @@
%th TVA
%th Montant HT
%th Actions
-
- %tbody
- -price_line_block.price_lines.each do |price_line|
+
+ -price_line_block.price_lines.each do |price_line|
+ %tbody
%tr
- %td
- ="##{price_line.id}"
+ -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
=price_line.ref
-
-
-
-
%td
=price_line.p_product_ref.p_product.s_brand.name
-
%td{class: "p_product_ref_cc_name_#{@price_document.id}"}
=link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product
-
%td.numeraire{class: "price_line_qte_#{@price_document.id}"}
=price_line.qte
-
%td.numeraire{class: "price_line_price_u_ht_#{@price_document.id}"}
=number_to_currency price_line.price_u_ht
-
-
%td.numeraire
=price_line.tva_account_value.to_s+"%"
-
-
-
-
%td.numeraire
=number_to_currency price_line.tot_amount_ht
-
%td.actions
= link_to i(:"trash-o"), admin_price_line_path(price_line), method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_price_line_path(price_line), :remote => true
= link_to i(:eye), admin_price_line_path(price_line), :remote => true
- = link_to i(:"mobile-alt"), new_admin_p_article_path(p_product_ref_id: price_line.p_product_ref.id), :remote => true
-
- / %td=# price_line.line_stocks.sum(:price_ht)
+ = link_to i(:"mobile-alt"), add_p_article_admin_price_lines_path(p_product_ref_id: price_line.p_product_ref.id, price_line_id: price_line.id), :remote => true
+ -price_line.p_articles.each do |p_article|
+ %tr
+ %td
+ %td="##{p_article.id}"
+ %td=p_article.p_product_ref.name
+ %td
+ - p_article.p_article_serial_nums.each do |sn|
+ ="#{sn.p_serial_num_type.name} - #{sn.value} /"
.qi_row
-if current_admin.has_permission?("show-costs")
diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml
index f01c327..8f441a3 100644
--- a/app/views/admin/price_line_blocks/_form.html.haml
+++ b/app/views/admin/price_line_blocks/_form.html.haml
@@ -80,7 +80,7 @@
=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_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 :"
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 82c3485..db81fc0 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
@@ -42,14 +42,14 @@ PRICE LINE BLOCKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
=# f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date
.row
.col-6
- = f.input :stock_entrance_date, :label => "Date d'entrée en stock :", :as => :date
+ = f.input :stock_entrance_date, :label => "Date d'entrée en stock :", :as => :date, input_html: {value: Date.today}
.row
.col-6
= f.input :customer_ref, :label => "Référence commande fournisseur :"
-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;"}
+ =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"}
-if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note?
%div
@@ -71,17 +71,18 @@ PRICE LINE BLOCKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
.qi_pannel.qi_plain.padding.price_line_block_footer{:style => "margin:20px 0;"}
-if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")
+ = f.input :cc_tot_amount_ht, label: "Somme HT des produits", input_html: {disabled: true}
-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 => "Montant des frais de port HT (€) :"
+ =# 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 => "Montant des frais de port HT (€) :"
-if !@avoir
-if current_admin.has_permission?("customer-sheets-bl")
- = f.input :ct_nbr_ship, :label => "Nombre de colis :"
-
- = f.input :cc_tot_amount_ttc, label: "Montant TTC à payer", :input_html => {disabled: true}
- = f.input :cc_tot_amount_ht, label: "Montant HT à payer", input_html: {disabled: true}
- = f.input :ct_tot_amount_ht, label: "Montant HT personnalisé"
+ =# f.input :ct_nbr_ship, :label => "Nombre de colis :"
+ = f.input :ct_tot_amount_ht, label: "Montant HT à payer"
+ = f.input :cc_tot_amount_ttc, label: "Montant TTC à payer", :input_html => {disabled: false}
+
+
-if current_admin.has_permission?("payments")
diff --git a/app/views/admin/price_lines/_add_p_article_form.html.haml b/app/views/admin/price_lines/_add_p_article_form.html.haml
new file mode 100644
index 0000000..6367aa5
--- /dev/null
+++ b/app/views/admin/price_lines/_add_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
+ .p_articles_form
+ = f.semantic_fields_for :p_articles do |form|
+ =render :partial => "admin/p_articles/form", :locals => {:form => form, @price_line => f.object}
+ %p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary"} if f.object.p_articles.count < f.object.qte
+ .actions=f.submit "Sauvegarder", :class => "btn btn-primary"
diff --git a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml
index 4444417..7bf404a 100644
--- a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml
+++ b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml
@@ -1,5 +1,3 @@
-
-
=semantic_form_for [:admin, @price_line], :remote => true do |form|
.content
diff --git a/app/views/admin/price_lines/add_p_articles.js.erb b/app/views/admin/price_lines/add_p_article.js.erb
similarity index 68%
rename from app/views/admin/price_lines/add_p_articles.js.erb
rename to app/views/admin/price_lines/add_p_article.js.erb
index dc68c39..b669ed6 100644
--- a/app/views/admin/price_lines/add_p_articles.js.erb
+++ b/app/views/admin/price_lines/add_p_article.js.erb
@@ -1 +1 @@
-show_pane_hover("<%= escape_javascript(render(:partial => "add_p_articles_form"))%>",700,900);
\ No newline at end of file
+show_pane_hover("<%= escape_javascript(render(:partial => "add_p_article_form"))%>",700,900);
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index a385f22..6c3c724 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -697,6 +697,7 @@ Rails.application.routes.draw do
end
collection do
+ get :add_p_article
end
end
diff --git a/db/migrate/20211102094225_add_stockable_to_p_product.rb b/db/migrate/20211102094225_add_stockable_to_p_product.rb
new file mode 100644
index 0000000..db26f91
--- /dev/null
+++ b/db/migrate/20211102094225_add_stockable_to_p_product.rb
@@ -0,0 +1,6 @@
+class AddStockableToPProduct < ActiveRecord::Migration[6.0]
+ def change
+ add_column :p_products, :stockable, :boolean
+ add_column :p_products, :with_serial_number, :boolean
+ end
+end
diff --git a/db/migrate/20211102105934_create_price_line_p_articles.rb b/db/migrate/20211102105934_create_price_line_p_articles.rb
new file mode 100644
index 0000000..b505378
--- /dev/null
+++ b/db/migrate/20211102105934_create_price_line_p_articles.rb
@@ -0,0 +1,12 @@
+class CreatePriceLinePArticles < ActiveRecord::Migration[6.0]
+ def change
+ create_table :price_line_p_articles do |t|
+ t.belongs_to :p_article
+ t.belongs_to :price_line
+
+ t.timestamps
+ end
+ #add_reference :price_lines, :price_line_p_article, index: true
+ #add_reference :p_articles, :price_line_p_article, index: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1a08c45..3fe7b90 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_29_111104) do
+ActiveRecord::Schema.define(version: 2021_11_02_105934) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -1930,6 +1930,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_111104) do
t.boolean "conserve_proportion", default: false
t.boolean "frontpage", default: true
t.integer "sorecop_cat_id"
+ t.boolean "stockable"
+ t.boolean "with_serial_number"
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
@@ -2463,6 +2465,15 @@ ActiveRecord::Schema.define(version: 2021_10_29_111104) do
t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id"
end
+ create_table "price_line_p_articles", force: :cascade do |t|
+ t.bigint "p_article_id"
+ t.bigint "price_line_id"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["p_article_id"], name: "index_price_line_p_articles_on_p_article_id"
+ t.index ["price_line_id"], name: "index_price_line_p_articles_on_price_line_id"
+ end
+
create_table "price_line_resp_selects", force: :cascade do |t|
t.integer "price_line_demand_id"
t.integer "price_line_resp_id"
diff --git a/test/fixtures/price_line_p_articles.yml b/test/fixtures/price_line_p_articles.yml
new file mode 100644
index 0000000..5181636
--- /dev/null
+++ b/test/fixtures/price_line_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/price_line_p_article_test.rb b/test/models/price_line_p_article_test.rb
new file mode 100644
index 0000000..8c4666d
--- /dev/null
+++ b/test/models/price_line_p_article_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PriceLinePArticleTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end