mise à jour process clients + facture

This commit is contained in:
Nicolas Bally 2020-11-09 15:38:09 +01:00
parent c4ae300c80
commit 9b86a9a314
9 changed files with 63 additions and 44 deletions

View File

@ -225,7 +225,7 @@ class Admin::PriceDocumentsController < ApplicationController
end
redirect_to admin_price_documents_path("price_document_type_ids[]" => @price_document.price_document_type_id)
redirect_back(fallback_location: admin_price_documents_path)
end

View File

@ -31,7 +31,7 @@ class PCustomer < ApplicationRecord
has_many :p_documents
validates :code, :presence => true, :uniqueness => true
#validates :code, :presence => true, :uniqueness => true
has_many :p_compta_elements
@ -101,18 +101,7 @@ class PCustomer < ApplicationRecord
before_validation do
if !self.code?
if self.particulars[0]
cars = self.particulars[0].organisation
cars += self.particulars[0].name
cars += self.particulars[0].firstname
cars = cars.to_slug.gsub(/\W/,'').upcase
cars = cars[0..2]
cars +=
self.code = self.particulars[0].cp+cars
end
end
generate_mlm_token
@ -298,6 +287,14 @@ class PCustomer < ApplicationRecord
end
if !self.code?
last = PCustomer.order("code_index DESC").first
self.code_index = last.code_index + 1
self.code = "CLT"+('%05d' % self.code_index)
self.save
end
end
def archive_import

View File

@ -20,6 +20,19 @@ class PCustomerSheet < ApplicationRecord
has_many :price_documents, :as => :ref_element
acts_as_sorting :fields => {
:p_commercial => {:name => "Commercial", :reorder => false},
:created_at => {:name => "Date", :reorder => true, :sort_name => "p_customer_sheets.created_at"},
:admin_id => {:name => "Déposée par", :reorder => true},
:demande_type => {:name => "Type de demande", :reorder => true},
:p_customer => {:name => "Client", :reorder => false},
:tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"},
:tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"},
:state => {:name => "Statut", :reorder => false},
:actions => {:name => "Actions", :reorder => false},
}
QI_DYNAMICS = %w(accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva payment_days payment_delais payment_month_end payment_end_at )

View File

@ -11,9 +11,9 @@ class Particular < ApplicationRecord
#validates :name, :presence => true, :if => :force_validation
#validates :firstname, :presence => true, :if => :force_validation
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :if => :force_email_validation
validates :address_2, :presence => true, :if => :force_validation
#validates :address_2, :presence => true, :if => :force_validation
validates :cp, :presence => true, :if => :force_validation
validates :city, :presence => true, :if => :force_validation
#validates :city, :presence => true, :if => :force_validation
validates :country, :presence => true, :if => :force_validation
#validates :tel, :presence => true, :if => :force_validation
#validates :organisation, :presence => true, :if => :force_validation

View File

@ -43,11 +43,6 @@
-if @p_customer.id or (@p_customer.code? and @p_customer.errors[:code])
= form.input :code, :label => "Code client :"
= form.input :siret, :label => "Siret :"
= form.input :ape, :label => "Ape :"
= form.input :tva_intra, :label => "TVA intra. :"
= form.input :website, :label => "Site Web :"
.qi_row
@ -77,6 +72,15 @@
.qi_row
.qi_pannel.qi_plain.padding
= form.input :siret, :label => "Siret :"
= form.input :ape, :label => "Ape :"
= form.input :tva_intra, :label => "TVA intra. :"
= form.input :website, :label => "Site Web :"
.qi_row
.qi_pannel.qi_plain.padding
-if true
%h4 Paiements
.row.qi_cancel_margins
.col-sm-4

View File

@ -62,9 +62,9 @@
.qi_row#tabs
.qi_pannel
%ul.nav.nav-tabs
-params[:tab] = params[:tab] || "projets"
-params[:tab] = params[:tab] || "offres"
%li{:class => ("active" if params[:tab] == "projets")}=link_to "Projets", "?tab=projets#tabs"
%li{:class => ("active" if params[:tab] == "offres")}=link_to "Offres", "?tab=offres#tabs"
-if false
%li{:class => ("active" if params[:tab] == "etat")}=link_to "Etat de compte", "?tab=etat#tabs"
@ -74,13 +74,13 @@
%li{:class => ("active" if params[:tab] == "payments")}=link_to "Paiements", "?tab=payments#tabs"
.qi_tab_content
-if params[:tab] == "projets"
-if params[:tab] == "offres"
#offres
.qi_tab_header
.right{:style => "text-align:right;"}
-if @p_customer.enabled
=#link_to ic(:plus)+" Demande de commande", new_admin_s_project_path(:p_customer_id => @p_customer.id), :class => "btn btn-primary btn-ap-add"
=link_to ic(:plus)+" Nouvelle offre", new_admin_p_customer_sheet_path(:p_customer_id => @p_customer.id), :class => "btn btn-primary btn-ap-add"
@ -91,11 +91,11 @@
-params[:search][:per_page] = params[:search][:per_page] || 50
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@s_projects =@p_customer.s_projects
-@s_projects = sort_by_sorting(@s_projects, "created_at DESC")
-@s_projects = @s_projects.page(page).per(per_page)
-@p_customer_sheets =@p_customer.p_customer_sheets
-@p_customer_sheets = sort_by_sorting(@p_customer_sheets, "created_at DESC")
-@p_customer_sheets = @p_customer_sheets.page(page).per(per_page)
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @s_projects}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets}

View File

@ -63,7 +63,6 @@
p_customer_id: $(".p_customer_id").val()
},
success: function (data) {
alert(data.p_product_cat_id);
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_p_product_cat_id").val(data.p_product_cat_id);

View File

@ -0,0 +1,5 @@
class AddCodeIndexToPCustomers < ActiveRecord::Migration[6.0]
def change
add_column :p_customers, :code_index, :integer
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_05_25_113631) do
ActiveRecord::Schema.define(version: 2020_11_09_142527) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
@ -978,6 +978,7 @@ ActiveRecord::Schema.define(version: 2020_05_25_113631) do
t.string "nav_vat_bus_posting_group"
t.string "nav_primary_contact_no"
t.datetime "nav_last_date_modified"
t.integer "code_index"
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"