Adding tva_type to price_documents and package_number to price_line_blocks
This commit is contained in:
parent
41774b1731
commit
118116ab70
@ -5,6 +5,7 @@ class PriceDocument < ApplicationRecord
|
||||
belongs_to :p_commercial
|
||||
belongs_to :p_devise
|
||||
belongs_to :p_payment_type
|
||||
belongs_to :tva_type
|
||||
|
||||
|
||||
has_one :p_compta_element, :dependent => :destroy, :as => :element
|
||||
@ -26,7 +27,7 @@ class PriceDocument < ApplicationRecord
|
||||
accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true
|
||||
|
||||
#PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture achat", "Consultation fournisseur"]
|
||||
PURCHASES = ["Commande achat"]
|
||||
PURCHASES = ["Facture achat"]
|
||||
SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"]
|
||||
# AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
|
||||
AVANCEMENT = ["0%", "25%", "50%", "75%", "100"]
|
||||
@ -265,23 +266,24 @@ class PriceDocument < ApplicationRecord
|
||||
def self.qi_table_order
|
||||
{
|
||||
|
||||
:p_customer_code => {:name => "Code client", :reorder => false},
|
||||
|
||||
|
||||
:avancement => {:name => "Avancement (%)", :reorder => true},
|
||||
:list_designaton => {:name => "Designation liste", :reorder => true},
|
||||
:end_date => {:name => "Fin de consultation", :reorder => true},
|
||||
:dp_comment => {:name => "Commentaire", :reorder => true},
|
||||
:acheteur_text => {:name => "Envoyé à", :reorder => true},
|
||||
:id => {:name => "ID", :reorder => false},
|
||||
:p_customer_code => {:name => "Code client", :reorder => false},
|
||||
#:avancement => {:name => "Avancement (%)", :reorder => true},
|
||||
#:list_designaton => {:name => "Designation liste", :reorder => true},
|
||||
#:end_date => {:name => "Fin de consultation", :reorder => true},
|
||||
#:dp_comment => {:name => "Commentaire", :reorder => true},
|
||||
#:acheteur_text => {:name => "Envoyé à", :reorder => true},
|
||||
:customer_ref => {:name => "Ref cotation", :reorder => false},
|
||||
|
||||
|
||||
:p_commercial => {:name => "Commercial", :reorder => false},
|
||||
#:p_commercial => {:name => "Commercial", :reorder => false},
|
||||
:p_customer => {:name => "Client", :reorder => false},
|
||||
:public_fournisseur_name => {:name => "Nom fournisseur saisi", :reorder => false},
|
||||
:p_fournisseur => {:name => "Fournisseur", :reorder => false},
|
||||
:com_counter => {:name => "N° Offre", :reorder => false},
|
||||
: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},
|
||||
:d_number => {:name => "Numéro", :reorder => true},
|
||||
:date => {:name => "Date", :reorder => true},
|
||||
:cc_payment_end_at => {:name => "Date d'échance", :reorder => true},
|
||||
@ -296,21 +298,20 @@ class PriceDocument < ApplicationRecord
|
||||
:cc_cost_ht => {:name => "Coût HT", :reorder => true, :as => :currency},
|
||||
:cc_marge_ht => {:name => "Marge HT", :reorder => true, :as => :currency},
|
||||
:cost_ok => {:name => "Marge calculée", :reorder => true, :as => :boolean},
|
||||
:f_token => {:name => "Liens consultation"},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:stock_ok => {:name => "Stock mis à jour ?", :reorder => true},
|
||||
#:f_token => {:name => "Liens consultation"},
|
||||
:actions => {:name => "Actions", :reorder => false}
|
||||
|
||||
|
||||
}
|
||||
#, :sort_name => "code"
|
||||
end
|
||||
|
||||
def ca_tva_type_name
|
||||
self.tva_type.name
|
||||
end
|
||||
|
||||
def package_number
|
||||
self.price_line_block.package_number
|
||||
end
|
||||
|
||||
def self.valid_sort
|
||||
r = []
|
||||
self.qi_table_order.each do |key, value|
|
||||
@ -343,7 +344,7 @@ class PriceDocument < ApplicationRecord
|
||||
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
QI_DYNAMICS = %w(solded_nbr_days solded_at cost_ht marge_ht weight_tot accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva label header footer payment_days payment_delais payment_month_end payment_end_at to_paid_ht to_paid_ttc to_paid_tva solded)
|
||||
QI_DYNAMICS = %w(solded_nbr_days solded_at cost_ht marge_ht weight_tot accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva label header footer payment_days payment_delais payment_month_end payment_end_at to_paid_ht to_paid_ttc to_paid_tva solded tva_type_name)
|
||||
|
||||
|
||||
def reset_for_update
|
||||
|
3
app/models/tva_type.rb
Normal file
3
app/models/tva_type.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class TvaType < ApplicationRecord
|
||||
has_many :price_documents
|
||||
end
|
@ -1,3 +1,4 @@
|
||||
PRICE_DOCUMENTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
|
||||
=semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |f|
|
||||
-@p_customer = @price_document.p_customer
|
||||
=diag do
|
||||
@ -42,7 +43,11 @@
|
||||
|
||||
|
||||
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7
|
||||
= f.input :date, :label => "Date du document :", :as => :date
|
||||
.row
|
||||
.col-6
|
||||
= f.input :date, :label => "Date du document :", :as => :date
|
||||
.col-6
|
||||
= f.input :tva_type_id, :label => "Type de TVA :", as: :select, collection: TvaType.pluck(:name, :id)
|
||||
.price_line_block_form
|
||||
=f.semantic_fields_for :price_line_block do |f|
|
||||
=render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f}
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
PRICE LINE BLOCKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||
=f.inputs do
|
||||
|
||||
|
||||
@ -34,22 +34,23 @@
|
||||
= 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"
|
||||
= f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de livraison"
|
||||
|
||||
.clear
|
||||
|
||||
|
||||
%table{:style => "width:100%;"}
|
||||
%tr
|
||||
%td{:style => "width:50%;"}
|
||||
= f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date
|
||||
|
||||
%td{:style => "width:50%;"}
|
||||
= f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date
|
||||
%td
|
||||
=# f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date
|
||||
%td
|
||||
=# 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 :customer_ref, :label => "Référence commande fournisseur :"
|
||||
.col-6
|
||||
= f.input :package_number, :label => "Nombre de colis :"
|
||||
|
||||
|
||||
|
||||
= f.input :customer_ref, :label => "Référence commande client :"
|
||||
-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;"}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
%td{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
||||
.take.mr-1
|
||||
="PRICE_LINEEEEEEEE"
|
||||
=ic :arrows
|
||||
%td{:style => "white-space: nowrap;"}
|
||||
|
||||
|
17
db/migrate/20211028091122_create_tva_types.rb
Normal file
17
db/migrate/20211028091122_create_tva_types.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class CreateTvaTypes < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :tva_types do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
TvaType.create(name: "basique")
|
||||
TvaType.create(name: "Sur Marge")
|
||||
|
||||
add_reference :price_documents, :tva_type, index: true
|
||||
add_column :price_documents, :ac_tva_type_name, :string
|
||||
add_column :price_documents, :cc_tva_type_name, :string
|
||||
add_column :price_line_blocks, :package_number, :integer
|
||||
end
|
||||
end
|
13
db/schema.rb
13
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_18_142636) do
|
||||
ActiveRecord::Schema.define(version: 2021_10_28_091122) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -2304,7 +2304,11 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do
|
||||
t.integer "demande_de_prix_id"
|
||||
t.integer "avoir_achat_id"
|
||||
t.integer "facture_achat_id"
|
||||
t.bigint "tva_type_id"
|
||||
t.string "ac_tva_type_name"
|
||||
t.string "cc_tva_type_name"
|
||||
t.index ["p_customer_id"], name: "index_price_documents_on_p_customer_id"
|
||||
t.index ["tva_type_id"], name: "index_price_documents_on_tva_type_id"
|
||||
end
|
||||
|
||||
create_table "price_line_blocks", force: :cascade do |t|
|
||||
@ -2453,6 +2457,7 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do
|
||||
t.boolean "imported", default: false
|
||||
t.date "validation_date"
|
||||
t.string "cc_state"
|
||||
t.integer "package_number"
|
||||
t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id"
|
||||
end
|
||||
|
||||
@ -3007,6 +3012,12 @@ ActiveRecord::Schema.define(version: 2021_10_18_142636) do
|
||||
t.index ["accounting_zone_id"], name: "index_tva_rates_on_accounting_zone_id"
|
||||
end
|
||||
|
||||
create_table "tva_types", 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 "tvable_tva_rates", force: :cascade do |t|
|
||||
t.integer "tvable_id"
|
||||
t.string "tvable_type"
|
||||
|
11
test/fixtures/tva_types.yml
vendored
Normal file
11
test/fixtures/tva_types.yml
vendored
Normal file
@ -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
|
7
test/models/tva_type_test.rb
Normal file
7
test/models/tva_type_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TvaTypeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Reference in New Issue
Block a user