negos_app/app/views/admin/orders/index.html.haml
2016-02-16 21:09:48 +01:00

152 lines
3.4 KiB
Plaintext
Executable File

%h1 Liste des commandes
-params[:y]= params[:y] || Time.now.year
-params[:m]= params[:m] || Time.now.month
-t = Time.parse("2015-07-01").beginning_of_month
-while t <= Time.now.beginning_of_month do
=link_to l(t, :format => " %B %Y"), admin_orders_path(:y => t.year, :m => t.month), :class => "btn btn-default "+("btn-primary" if t.year == params[:y].to_i and t.month == params[:m].to_i).to_s
-t = t+1.month
-@start_date = Time.parse("#{params[:y]}-#{params[:m]}-01").beginning_of_day
-@end_date = @start_date.end_of_month.end_of_day
%h2 Résumé
Période du
=l @start_date
au
=l @end_date
-Order.between(@start_date, @end_date).group(:country).each do |order|
.country_detail
%h3=order.country
.row
.col-md-6
-orders = Order.between(@start_date, @end_date).where("unpaid is null").where("payment_type_id = 2").where("country = ?", order.country)
%strong
Commandes
(
=orders.count
commandes
)
%table.table.table-striped
%tr
%td
HT :
%td
-ht = orders.sum(:amount_ht)
=number_to_currency ht
%tr
%td
TTC :
%td
-ttc = orders.sum(:amount_ttc)
=number_to_currency ttc
%tr
%td
TVA :
%td
=number_to_currency ttc - ht
.col-md-6
-orders = Order.between(@start_date, @end_date).where(:unpaid => true).where("payment_type_id = 2").where("country = ?", order.country)
%strong
Remboursements
(
=orders.count
remboursements
)
%table.table.table-striped
%tr
%td
HT :
%td
-ht = orders.sum(:amount_ht)
=number_to_currency ht
%tr
%td
TTC :
%td
-ttc = orders.sum(:amount_ttc)
=number_to_currency ttc
%tr
%td
TVA :
%td
=number_to_currency ttc - ht
%h2 Virements commissions
-Virement.execute_between(@start_date, @end_date).joins(:customer_rib).group("customer_ribs.country").each do |virement|
%h3=virement.customer_rib.country
-virements = Virement.execute_between(@start_date, @end_date).joins(:customer_rib).where("customer_ribs.country = ?", virement.customer_rib.country)
%table.table.table-striped
%tr
%td
HT :
%td
-ht = virements.sum(:amount_ht)
=number_to_currency ht
%tr
%td
TTC :
%td
-ttc = virements.sum(:amount_ttc)
=number_to_currency ttc
%tr
%td
TVA :
%td
=number_to_currency ttc - ht
%div{:style => "page-break-after: always;"}
%h2 Détail
%table.table.table-hover.table-striped.order_table
%thead#order_rows_header.rows_header
%tr
%th Compte
%th
Date
%th Date de paiement
%th Type de paiement
%th Crédits
%th Points binaires
%th Parts
%th Prix TTC
%th Prix HT
%th Commissions reversées
%th Delta
%td{:style => "width:100px"}
&nbsp;
%tbody#order_rows.rows
=render @orders
.pagination= paginate @orders