Merge remote-tracking branch 'origin/master'

This commit is contained in:
Nicolas Bally 2022-02-13 20:25:50 +01:00
commit 2a6fc4cce6
9 changed files with 55 additions and 9 deletions

1
.gitignore vendored
View File

@ -42,5 +42,6 @@ yarn-debug.log*
/pdf/*
/.sass_cache/*
/.sass-cache/*
/test*

View File

@ -224,7 +224,9 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.5)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)

View File

@ -20,7 +20,7 @@ class MOdrFile < ApplicationRecord
mount_uploader :file, OdrUploader
validates :file, :presence => true
validates :file, :presence => true, :if => :file_needed?
@ -28,6 +28,31 @@ class MOdrFile < ApplicationRecord
validates :buy_at, :presence => true, :if => :buy_at_needed?
acts_as_caching :fields => [:doc_date]
def file_needed?
true if !self.id
end
def ca_doc_date
if self.m_odr_file_type_id == 1
if m_odr_file_roulage = self.m_odr_file_roulages.order("date DESC").first
m_odr_file_roulage.date
else
self.created_at
end
elsif self.m_odr_file_type_id == 2
if self.buy_at
self.buy_at
else
self.created_at
end
end
end
def buy_at_needed?
true if self.m_odr_file_type_id == 2
end

View File

@ -13,7 +13,7 @@
%h3
=link_to m_event.m_event_type_title, public_m_events_path(:search => {:m_event_type_title => [m_event.m_event_type_title]})
="-"
=link_to m_event.circuit.name, public_m_events_path(:search => {:circuit_id => m_event.circuit.id})
=link_to m_event.circuit.name, public_circuit_path(:id => m_event.circuit.slug)
%span.date
-if m_event.start_at.to_date == m_event.end_at.to_date

View File

@ -51,7 +51,7 @@
=link_to "Modifier mes coordonnées", edit_public_particular_path(current_p_customer.particular)
%p
-if current_p_customer.sticker
-if false #current_p_customer.sticker
%br
%span.green
=ic :flag
@ -186,8 +186,10 @@
.doc_pannel
%h3 Mes factures de pneus
-if m_odr_files = current_p_customer.m_odr_files.where(:m_odr_file_type_id => 2) and m_odr_files.count > 0
%h3
Mes factures de pneus
=Date.today.year
-if m_odr_files = current_p_customer.m_odr_files.where(:m_odr_file_type_id => 2).where("cc_doc_date >= ? and cc_doc_date <= ?", Date.today.beginning_of_year, Date.today.end_of_year) and m_odr_files.count > 0
%table.table
=render m_odr_files
@ -199,8 +201,10 @@
= link_to 'Envoyer une facture de pneus', new_public_m_odr_file_path(:m_odr_file_type_id => 2), :class => "new_btn"
%br
%br
%h3 Mes journées de roulages
-if m_odr_files = current_p_customer.m_odr_files.where(:m_odr_file_type_id => 1) and m_odr_files.count > 0
%h3
Mes journées de roulages
=Date.today.year
-if m_odr_files = current_p_customer.m_odr_files.where(:m_odr_file_type_id => 1).where("cc_doc_date >= ? and cc_doc_date <= ?", Date.today.beginning_of_year, Date.today.end_of_year) and m_odr_files.count > 0
%table.table
=render m_odr_files
-else

View File

@ -0,0 +1,12 @@
class AddCcDocDateToMOdrFiles < ActiveRecord::Migration[6.0]
def change
add_column :m_odr_files, :cc_doc_date, :date
add_column :m_odr_files, :ac_doc_date, :date
MOdrFile.all.each do |odr|
odr.save
end
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: 2021_07_01_095917) do
ActiveRecord::Schema.define(version: 2022_01_11_154814) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
@ -790,6 +790,8 @@ ActiveRecord::Schema.define(version: 2021_07_01_095917) do
t.integer "nbr_primes"
t.integer "nbr_primes_useds"
t.integer "nbr_primes_not_useds"
t.date "cc_doc_date"
t.date "ac_doc_date"
t.index ["m_odr_file_type_id"], name: "index_m_odr_files_on_m_odr_file_type_id"
t.index ["m_odr_rep_id"], name: "index_m_odr_files_on_m_odr_rep_id"
end