diff --git a/.gitignore b/.gitignore index 431afe9..3142665 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,6 @@ yarn-debug.log* /pdf/* /.sass_cache/* +/.sass-cache/* /test* diff --git a/.sass-cache/8733fa08796e17fefbefc6517a63d69bb4e801b6/(__TEMPLATE__)c b/.sass-cache/8733fa08796e17fefbefc6517a63d69bb4e801b6/(__TEMPLATE__)c deleted file mode 100644 index cc3a232..0000000 Binary files a/.sass-cache/8733fa08796e17fefbefc6517a63d69bb4e801b6/(__TEMPLATE__)c and /dev/null differ diff --git a/.sass-cache/8c7afa2ca120fb449b855301fbe142d6d39647fd/(__TEMPLATE__)c b/.sass-cache/8c7afa2ca120fb449b855301fbe142d6d39647fd/(__TEMPLATE__)c deleted file mode 100644 index a7e7e2d..0000000 Binary files a/.sass-cache/8c7afa2ca120fb449b855301fbe142d6d39647fd/(__TEMPLATE__)c and /dev/null differ diff --git a/Gemfile.lock b/Gemfile.lock index 4eae6b9..35568d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/models/m_odr_file.rb b/app/models/m_odr_file.rb index 3b6ca0d..4e1422d 100644 --- a/app/models/m_odr_file.rb +++ b/app/models/m_odr_file.rb @@ -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 diff --git a/app/views/public/m_events/_m_event.html.haml b/app/views/public/m_events/_m_event.html.haml index 241ccd3..b639969 100644 --- a/app/views/public/m_events/_m_event.html.haml +++ b/app/views/public/m_events/_m_event.html.haml @@ -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 diff --git a/app/views/public/my_account/index.html.haml b/app/views/public/my_account/index.html.haml index 5023bdc..a86c673 100644 --- a/app/views/public/my_account/index.html.haml +++ b/app/views/public/my_account/index.html.haml @@ -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 diff --git a/db/migrate/20220111154814_add_cc_doc_date_to_m_odr_files.rb b/db/migrate/20220111154814_add_cc_doc_date_to_m_odr_files.rb new file mode 100644 index 0000000..cbfce25 --- /dev/null +++ b/db/migrate/20220111154814_add_cc_doc_date_to_m_odr_files.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 6855ef4..77a22bd 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_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