}
.client {
+ margin-top: -80px;
margin-left: auto;
- margin-right: auto;
- width: 200px;
+ width: 400px;
+}
+
+.numbers {
+ text-align: right;
}
content {
class PrestationsController < ApplicationController
-
+ before_action :set_prestation, only: [:show, :edit, :update, :destroy]
+
+
def index
authorize Prestation
params[:date] ||= Date.today
unless params[:structure_id].blank?
- @prestations = @prestations.joins(enfant: [:compte]).where(comptes: { structure_id: params[:structure_id] })
+ @prestations = @prestations.joins(enfant: [:prestation]).where(prestations: { structure_id: params[:structure_id] })
@classrooms = @classrooms.where(structure_id: params[:structure_id])
end
@prestations = @prestations.paginate(page: params[:page])
end
+ def show
+ authorize Prestation
+ end
+
+ # GET /prestations/1/edit
+ def edit
+ authorize Prestation
+ end
+
+ # POST /prestations
+ # POST /prestations.json
+ def create
+ authorize Prestation
+ end
+
+ # PATCH/PUT /prestations/1
+ # PATCH/PUT /prestations/1.json
+ def update
+ authorize Prestation
+
+ respond_to do |format|
+ if @prestation.update(prestation_params)
+ format.html { redirect_to @prestation, notice: 'Prestation modifié.e avec succès.' }
+ format.json { render :show, status: :ok, location: @prestation }
+ else
+ format.html { render :edit }
+ format.json { render json: @prestation.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /prestations/1
+ # DELETE /prestations/1.json
+ def destroy
+ authorize Prestation
+
+ @prestation.destroy
+ respond_to do |format|
+ format.html { redirect_to prestations_url, notice: 'Prestation supprimé.e avec succès.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_prestation
+ @prestation = Prestation.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def prestation_params
+ params.require(:prestation).permit(:qté)
+ end
+
+
+
end
<tr>
<td><%= facture.réf %></td>
<td><%= l facture.date %></td>
- <td><%= l facture.échéance %></td>
<td><%= facture.compte.nom %></td>
<td><%= l facture.envoyée_le if facture.envoyée_le %></td>
- <td><%= number_to_currency(facture.montant, unit: '€', precision: 2, format: "%n %u") %></td>
+ <td><%= number_to_currency(facture.montant, unit: '€', precision: 2, format: '%n %u') %></td>
<td><%= facture.vérifiée %></td>
<td><%= facture.mémo %></td>
- <td><%= link_to 'Show', facture %></td>
+ <td><%= link_to 'Voir', facture %></td>
<td><%= link_to 'PDF', facture_url(facture, format: :pdf) %></td>
- <td><%= link_to 'Edit', edit_facture_path(facture) %></td>
- <td><%= link_to 'Destroy', facture, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= link_to 'Suppr.', facture, method: :delete, data: { confirm: 'Etes-vous certain.e ?' } %></td>
+ <td>
+ <% if policy(facture).destroy? %>
+ <%= link_to facture, method: :delete, data: { confirm: 'Etes-vous bien certain.e ???' } do %>
+ <i class="fas fa-trash-alt"></i>
+ <% end %>
+ <% end %>
+ </td>
</tr>
<tr>
<th>Réf</th>
<th>Date</th>
- <th>échéance</th>
<th>Compte</th>
<th>Envoyée le</th>
<th>Montant</th>
<%= @facture.envoyée_le %>
</p>
-<p>
- <strong>Montant:</strong>
- <%= number_to_currency(@facture.montant, unit: '€', precision: 2, format: "%n %u") %>
-</p>
-
<p>
<strong>Vérifiée:</strong>
<%= @facture.vérifiée %>
<%= @facture.mémo %>
</p>
-<%= link_to 'Editer', edit_facture_path(@facture) %> |
-<%= link_to 'Retour', factures_path %>
-
-
-<table class="table">
+<table class="table table-striped">
+ <thead>
+ <tr>
+ <th>Intitulé</th>
+ <th>Prestation</th>
+ <th>Qté</th>
+ <th>Prix</th>
+ <th>Total</th>
+ </tr>
+ </thead>
<% @facture.facture_lignes.each do |ligne| %>
<tr>
<td><%= ligne.intitulé %></td>
<td><%= number_to_currency(ligne.total, unit: '€', precision: 2, format: "%n %u") %></td>
</tr>
<% end %>
+ <tfoot>
+ <tr>
+ <td colspan=4></td>
+ <td>
+ <b><%= number_to_currency(@facture.montant, unit: '€', precision: 2, format: "%n %u") %></b>
+ </td>
+ </tr>
+ </tfoot>
</table>
+
+<%= link_to 'PDF', facture_url(@facture, format: :pdf) %> |
+<%= link_to 'Editer', edit_facture_path(@facture) %> |
+<%= link_to 'Retour', factures_path %>
<%= @facture.compte.adresse1 %><br />
<%= @facture.compte.adresse2 %><br />
<%= @facture.compte.cp %> <%= @facture.compte.ville %><br /><br />
- <%= @facture.compte.ville %>, le <%= l @facture.date %>
+ <%= @facture.compte.ville %>, le <%= l @facture.date.to_date %>
</div>
<p>
- <strong>Réf:</strong>
- <%= @facture.réf %>
+ <strong>
+ Réf: <%= @facture.réf %>
+ </strong>
+</p>
+
+<p>
+ <strong><%= @facture.mémo %></strong>
</p>
<table class="table_pdf">
+ <thead>
+ <tr>
+ <th>Intitulé</th>
+ <th>Prestation</th>
+ <th>Qté</th>
+ <th>Prix</th>
+ <th>Total</th>
+ </tr>
+ </thead>
<% @facture.facture_lignes.each do |ligne| %>
<tr>
- <td><%= ligne.qté %></td>
+ <td><%= ligne.intitulé %></td>
<td><%= ligne.prestation_type.nom %></td>
- <td><%= number_to_currency(ligne.prix, unit: '€', precision: 2, format: "%n %u") %></td>
- <td><%= number_to_currency(ligne.total, unit: '€', precision: 2, format: "%n %u") %></td>
+ <td class="numbers"><%= ligne.qté %></td>
+ <td class="numbers"><%= number_to_currency(ligne.prix, unit: '€', precision: 2, format: "%n %u") %></td>
+ <td class="numbers"><%= number_to_currency(ligne.total, unit: '€', precision: 2, format: "%n %u") %></td>
</tr>
<% end %>
- <tfoot>
- <tr>
- <td colspan=4>TOTAL: <%= number_to_currency(@facture.montant, unit: '€', precision: 2, format: "%n %u") %></td>
- </tr>
- </tfoot>
+ <tfoot>
+ <tr>
+ <td colspan=4></td>
+ <td class="numbers">
+ <b>TOTAL: <%= number_to_currency(@facture.montant, unit: '€', precision: 2, format: "%n %u") %></b>
+ </td>
+ </tr>
+ </tfoot>
</table>
\ No newline at end of file
<%= link_to absences_url, class: "nav-link" do %><i class="fas fa-calendar-times"></i></span> Absences<% end %>
</li>
<li class="nav-item <%= (params[:controller]=='prestations' ? 'active' : '') %>">
- <%= link_to prestations_index_url, class: "nav-link" do %><i class="fas fa-utensils"></i></span> Prestations<% end %>
+ <%= link_to prestations_url, class: "nav-link" do %><i class="fas fa-utensils"></i></span> Prestations<% end %>
</li>
<li class="nav-item <%= (params[:controller]=='factures' ? 'active' : '') %>">
<%= link_to factures_url, class: "nav-link" do %><i class="fas fa-file-invoice"></i></span> Factures<% end %>
<td><%= link_to prestation.enfant.prénom, prestation.enfant, class: "text-primary" %></td>
<td><%= prestation.enfant.classroom.nom %></td>
<td><%= prestation.qté %></td>
- <td></td>
+ <td>
+ <% if policy(prestation).edit? %>
+ <%= link_to edit_prestation_path(prestation) do %>
+ <i class="far fa-edit"></i>
+ <% end %>
+ <% end %>
+ </td>
+ <td>
+ <% if policy(prestation).destroy? %>
+ <%= link_to prestation, method: :delete, data: { confirm: 'Etes-vous bien certain.e ???' } do %>
+ <i class="fas fa-trash-alt"></i>
+ <% end %>
+ <% end %>
+ </td>
</tr>
--- /dev/null
+<h1>Editer Prestation</h1>
+
+<%= render 'form', prestation: @prestation %>
+
+<%= link_to 'Voir', @prestation %> |
+<%= link_to 'Retour', prestations_path %>
<h1><i class="fas fa-utensils"></i> Prestations</h1>
</div>
-<%= bootstrap_form_tag url: prestations_index_path, method: :get do |f| %>
+<%= bootstrap_form_tag url: prestations_path, method: :get do |f| %>
<div class="row">
<div class="col-sm-3"><%= f.select :structure_id, options_from_collection_for_select(@structures, 'id', 'nom', params[:structure_id]), { include_blank: true, label: "Structure" }, { class: "selectpicker", onchange: "this.form.submit()" } %></div>
<div class="col-sm-2"><%= f.select :classroom_id, options_from_collection_for_select(@classrooms, 'id', 'nom', params[:classroom_id]), { include_blank: true, label: "Classe" }, { class: "selectpicker", onchange: "this.form.submit()" } %></div>
Rails.application.routes.draw do
- resources :factures
- get 'prestations/index'
get 'admin/index'
get 'admin/ajout_prestations'
post 'admin/ajout_prestations_do'
get 'admin/ajout_factures'
post 'admin/ajout_factures_do'
+ resources :factures
+ resources :prestations
resources :tarifs
resources :absences
resources :reservations
index = chrono.index + 1
# créer l'entête de facture
- facture = compte.factures.new(réf: Facture.fabrique_une_référence_facture(index), date: DateTime.now, échéance: Date.today + 1.month)
+ facture = compte.factures.new(
+ réf: Facture.fabrique_une_référence_facture(index),
+ date: DateTime.now,
+ échéance: Date.today + 1.month,
+ mémo: "Période du #{I18n.l date_début} au #{I18n.l date_fin}"
+ )
+
facture.save if args[:enregistrer] == "1"
# totaliser les prestations consommées par ce compte durant la période