562 lines
16 KiB
Plaintext
562 lines
16 KiB
Plaintext
-start_date = Time.parse("2015/06/30")
|
|
|
|
|
|
.row
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Chiffre d'affaire
|
|
.panel-body
|
|
%p
|
|
-total_ht = Order.between(Time.now.beginning_of_day, Time.now.end_of_day).where("unpaid is null").where("payment_type_id = 2").where(:paid => true).sum(:price_ht)
|
|
%strong{:style => "color:green"}
|
|
=number_to_currency total_ht
|
|
HT
|
|
(
|
|
=number_to_currency (total_ht*1.2)
|
|
TTC
|
|
)
|
|
aujourd'hui
|
|
%p
|
|
-total_ht = Order.between(start_date, Time.now.end_of_day).where("unpaid is null").where("payment_type_id = 2", ((start_date).beginning_of_day)).where(:paid => true).sum(:price_ht)
|
|
%strong{:style => "color:green"}
|
|
=number_to_currency total_ht
|
|
HT
|
|
(
|
|
=number_to_currency (total_ht*1.2)
|
|
TTC
|
|
)
|
|
%p
|
|
depuis le
|
|
=l start_date, :format => :date
|
|
|
|
|
|
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Stats depuis le
|
|
=l start_date, :format => :date
|
|
.panel-body
|
|
%p
|
|
=link_to admin_customers_path do
|
|
%strong=Customer.count
|
|
comptes
|
|
dont :
|
|
%p
|
|
%strong=Customer.where("binary_parent_id IS NOT NULL").count
|
|
dans le binaire
|
|
%p
|
|
%strong=Customer.where("binary_parent_id IS NULL").count
|
|
gratuits
|
|
%p
|
|
=link_to "/search.html" do
|
|
%strong=Annonce.valid_to_show.count
|
|
annonces
|
|
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Commissions depuis le
|
|
=l start_date, :format => :date
|
|
.panel-body
|
|
|
|
%p
|
|
Commissions directes :
|
|
-com_direct = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 1).sum(:amount)
|
|
%strong=number_to_currency com_direct
|
|
%p
|
|
Commissions binaires :
|
|
-com_binaire = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 2).sum(:amount)
|
|
%strong=number_to_currency com_binaire
|
|
%p
|
|
Commissions de participation :
|
|
-com_part_1 = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 3).sum(:amount)
|
|
%strong=number_to_currency com_part_1
|
|
|
|
%p
|
|
Cumul des 3 commissions :
|
|
-com_part_1 = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 3).sum(:amount)
|
|
%strong=number_to_currency com_binaire + com_direct + com_part_1
|
|
.row
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Commissions versées
|
|
=l start_date, :format => :date
|
|
.panel-body
|
|
%p
|
|
Demandes de virements :
|
|
-com_virements = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 4).sum(:amount)
|
|
%strong=number_to_currency com_virements
|
|
%p
|
|
Utilisé pour acheté des crédits :
|
|
-com_credits = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 5).sum(:amount)
|
|
%strong=number_to_currency com_credits
|
|
|
|
%p
|
|
Solde commissions à verser :
|
|
%strong=number_to_currency Commission.where("created_at >= ?", ((start_date).beginning_of_day)).sum(:amount)
|
|
|
|
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Prochain versement de coms de participations
|
|
|
|
.panel-body
|
|
|
|
-last_cpc = CountPartCom.last_paid
|
|
|
|
%p
|
|
|
|
Date de début du calcul :
|
|
%strong=start = CountPartCom.last_paid.last_day.tomorrow.beginning_of_day
|
|
%p
|
|
|
|
Date de fin du calcul :
|
|
%strong=stop = CountPartCom.order("last_day DESC").first.last_day.end_of_day
|
|
|
|
%p
|
|
Montant :
|
|
%strong=number_to_currency(next_part_com = Order.com_part_between(start, stop))
|
|
|
|
|
|
.alert.alert-info
|
|
%p
|
|
Points binaires
|
|
%strong= Order.points_binaires_between(start, stop)
|
|
%p
|
|
Points binaires MLM
|
|
%strong= Order.points_binaires_mlm_between(start, stop)
|
|
|
|
%p
|
|
Points binaires hors MLM
|
|
%strong= Order.points_binaires_direct_between(start, stop)
|
|
|
|
|
|
.col-md-4
|
|
.panel.panel-default
|
|
.panel-heading
|
|
Commissions reversées
|
|
|
|
.panel-body
|
|
%p
|
|
Avant le prochain versement :
|
|
%strong=number_to_currency com_binaire + com_direct + com_part_1
|
|
%p
|
|
Avec le prochain :
|
|
%strong=number_to_currency com_binaire + com_direct + com_part_1 + next_part_com
|
|
|
|
%p
|
|
Soit
|
|
%strong=number_to_percentage ((com_binaire + com_direct + com_part_1 + next_part_com)*100)/total_ht, precision: 1
|
|
du chiffre d'affaire total HT
|
|
="."
|
|
|
|
%p
|
|
Soit
|
|
%strong=number_to_percentage ((Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id =>[1,2,3] ).sum(:amount) + next_part_com - Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id =>[1,2,3] ).where(:customer_id => [1,2,5]).sum(:amount))*100)/total_ht, precision: 1
|
|
du chiffre d'affaire total HT
|
|
en excluant les 3 premiers comptes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.container
|
|
|
|
|
|
|
|
|
|
|
|
.stats
|
|
|
|
|
|
|
|
%p
|
|
Chiffre d'affaire aujourd'hui :
|
|
-total_ht = Order.between(Time.now.beginning_of_day, Time.now.end_of_day).where("unpaid is null").where("payment_type_id = 2").where(:paid => true).sum(:price_ht)
|
|
%strong{:style => "color:green"}
|
|
=number_to_currency total_ht
|
|
HT
|
|
(
|
|
=number_to_currency (total_ht*1.2)
|
|
TTC
|
|
)
|
|
%p
|
|
%strong
|
|
Depuis le :
|
|
=l start_date, :format => :date
|
|
%p
|
|
|
|
Chiffre d'affaire :
|
|
-total_ht = Order.between(start_date, Time.now.end_of_day).where("unpaid is null").where("payment_type_id = 2", ((start_date).beginning_of_day)).where(:paid => true).sum(:price_ht)
|
|
%strong{:style => "color:green"}
|
|
=number_to_currency total_ht
|
|
HT
|
|
(
|
|
=number_to_currency (total_ht*1.2)
|
|
TTC
|
|
)
|
|
|
|
|
|
<div>
|
|
<canvas id="ca_stats" height="200" width="600"></canvas>
|
|
</div>
|
|
|
|
-labels = []
|
|
-datas_ht = []
|
|
-datas_ttc = []
|
|
|
|
-date = start_date.end_of_day
|
|
|
|
|
|
-while date <= Time.now.end_of_day
|
|
-labels << l(date, :format => "%a %d %b")
|
|
-ht = Order.between(start_date,date).where("unpaid is null").where("payment_type_id = 2", ((start_date).beginning_of_day)).where(:paid => true).sum(:price_ht)
|
|
|
|
-datas_ht << ht
|
|
-datas_ttc << (ht * 1.2)
|
|
-date = date.tomorrow.end_of_day
|
|
|
|
|
|
|
|
|
|
<script>
|
|
var lineChartData2 = {
|
|
=raw"labels : #{labels.to_json},"
|
|
datasets : [
|
|
{
|
|
label: "Chiffre HT",
|
|
fillColor : "rgba(22,156,67,0.1)",
|
|
strokeColor : "rgba(22,156,67,1)",
|
|
pointColor : "rgba(22,156,67,1)",
|
|
pointStrokeColor : "#fff",
|
|
pointHighlightFill : "#fff",
|
|
pointHighlightStroke : "rgba(220,220,220,1)",
|
|
=raw"data : #{datas_ht.to_json}"
|
|
|
|
},
|
|
{
|
|
label: "Chiffre TTC",
|
|
fillColor : "rgba(20,133,201,0.1)",
|
|
strokeColor : "rgba(20,133,201,1)",
|
|
pointColor : "rgba(20,133,201,1)",
|
|
pointStrokeColor : "#fff",
|
|
pointHighlightFill : "#fff",
|
|
pointHighlightStroke : "rgba(220,220,220,1)",
|
|
=raw"data : #{datas_ttc.to_json}"
|
|
|
|
}
|
|
]
|
|
|
|
}
|
|
|
|
|
|
var ctx2 = document.getElementById("ca_stats").getContext("2d");
|
|
new Chart(ctx2).Line(lineChartData2, {
|
|
responsive: true,
|
|
bezierCurve : false
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
%p
|
|
TVA :
|
|
%strong= number_to_currency (total_ht*0.2)
|
|
%p
|
|
25% directement commissionné à Alpinea pour commercialisation (ne prend pas en compte les coms non versées "bonus"):
|
|
%br
|
|
%strong= number_to_currency (total_ht*0.25)
|
|
%p
|
|
Commissions directes les 7 derniers jours :
|
|
-com_direct = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 1).sum(:amount)
|
|
=number_to_currency com_direct
|
|
%p
|
|
Commissions binaires les 7 derniers jours :
|
|
-com_binaire = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => 2).sum(:amount)
|
|
=number_to_currency com_binaire
|
|
|
|
%p
|
|
Cumul des comissions directes & binaires :
|
|
%strong{:style => "color:orange"}= number_to_currency (com_binaire + com_direct)
|
|
|
|
%p
|
|
Solde point binaires 7 derniers jours (points sur les achats réalisés) :
|
|
|
|
%strong=points_binaires = Order.points_binaires_between(start_date, Time.now.end_of_day)
|
|
%p
|
|
20 % des points binaires :
|
|
-com_part = Order.com_part_between(start_date, Time.now.end_of_day)
|
|
%strong=number_to_currency com_part
|
|
|
|
%p
|
|
Cumul comissions directes, binaires & participation :
|
|
%strong{:style => "color:red"}= number_to_currency com_part + com_binaire + com_direct
|
|
(
|
|
= (com_part + com_binaire + com_direct - Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:customer_id => [1,2,5]).sum(:amount))
|
|
en excluant les 3 premiers comptes
|
|
)
|
|
%p
|
|
Pour contrôle :
|
|
-c = Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:commission_type_id => [1,2,3]).sum(:amount)
|
|
=number_to_currency c
|
|
|
|
%p
|
|
Soit
|
|
%strong=number_to_percentage ((com_part + com_binaire + com_direct)*100)/total_ht, precision: 1
|
|
du chiffre d'affaire total HT
|
|
="."
|
|
%p
|
|
%strong=number_to_percentage ((com_part + com_binaire + com_direct - Commission.where("created_at >= ?", ((start_date).beginning_of_day)).where(:customer_id => [1,2,5]).sum(:amount))*100)/total_ht, precision: 1
|
|
en ignorant les 3 premiers comptes.
|
|
%p
|
|
Reste :
|
|
%strong{:style => "color:green"}=number_to_currency (total_ht - (com_part + com_binaire + com_direct))
|
|
|
|
|
|
%p
|
|
Marges de sécurité de commissions (50% du CA HT - les coms à verser, servira aux investissements où bonus, où nouvelle commissions) :
|
|
%br
|
|
-securite = (total_ht * 0.5) - (com_part + com_binaire + com_direct)
|
|
=number_to_currency(securite)
|
|
%p
|
|
divisé par deux :
|
|
=number_to_currency(securite/2)
|
|
|
|
%p
|
|
Nombre de comptes :
|
|
=Customer.count
|
|
%p
|
|
Nombre d'inscrits dans le binaire :
|
|
=Customer.where("binary_parent_id IS NOT NULL").count
|
|
%p
|
|
Nombre de personnes non inscrite dans le binaire :
|
|
=Customer.where("binary_parent_id IS NULL").count
|
|
|
|
%h3 premier essai, à vérifier ! :
|
|
%p
|
|
Nombre de parts actives aujourd'hui
|
|
%strong (pas encore sûr du calcul) :
|
|
|
|
- parts = Credit.parts_at(Date.today)
|
|
%strong= parts
|
|
%p
|
|
Parts pour controle
|
|
-icont = 0.0
|
|
-Customer.all.each do |customer|
|
|
-if customer.callif(Time.now)
|
|
-icont = icont + customer.callif(Time.now)[3]
|
|
=icont
|
|
|
|
|
|
|
|
|
|
%p
|
|
Ce qui donnerait
|
|
|
|
%strong=number_to_currency com_part/parts
|
|
par parts (donnée brut :
|
|
=com_part/parts
|
|
).
|
|
|
|
%hr
|
|
|
|
%p Date de dernière distribution de coms
|
|
%table.table
|
|
%tr
|
|
%th
|
|
Date
|
|
%th
|
|
Nombre de parts
|
|
%th
|
|
Prix par parts
|
|
%th
|
|
Montant total
|
|
-amount = 0.0
|
|
-CountPartCom.where(:paid => true).order(:last_day).each do |cpc|
|
|
|
|
%tr
|
|
%td=l cpc.last_day.end_of_day
|
|
%td=cpc.nbr_parts
|
|
%td=number_to_currency cpc.part_price
|
|
%td=number_to_currency cpc.control_amount
|
|
-amount = amount + cpc.control_amount.to_f
|
|
|
|
%tr
|
|
%td{:colspan => 2}
|
|
%td
|
|
Montant total :
|
|
%td=number_to_currency amount
|
|
%p
|
|
Montant des coms parts versée pour controle
|
|
%strong=number_to_currency Commission.where(:commission_type_id => 3).sum(:amount)
|
|
|
|
%hr
|
|
-last_cpc = CountPartCom.last_paid
|
|
%p
|
|
Date de début pour le calcul des nouvelles parts :
|
|
%strong=start = CountPartCom.last_paid.last_day.tomorrow.beginning_of_day
|
|
|
|
%p
|
|
Date de fin pour le calcul des nouvelles parts :
|
|
%strong=stop = CountPartCom.order("last_day DESC").first.last_day.end_of_day
|
|
|
|
%p
|
|
Nombre de parts à la date de fin :
|
|
%strong=nbr_parts = Credit.parts_at(stop)
|
|
|
|
|
|
|
|
|
|
|
|
%p
|
|
Points binaires réalisés entre les deux dates :
|
|
%strong=points = Order.points_binaires_between(start, stop)
|
|
%p
|
|
CA réalisé sur la période :
|
|
%strong=number_to_currency ca = Order.between(start, stop).where("unpaid is null").where("payment_type_id = 2").where(:paid => true).sum(:price_ht)
|
|
%p
|
|
Com normale :
|
|
%strong=number_to_currency Order.com_part_between(start, stop)
|
|
(
|
|
|
|
=number_to_percentage((Order.com_part_between(start, stop)*100)/ca, :precision => 2)
|
|
|
|
du CA de la période)
|
|
|
|
%br
|
|
Soit
|
|
=number_to_currency(Order.com_part_between(start, stop) / nbr_parts)
|
|
part parts
|
|
|
|
%p
|
|
Com à 50% :
|
|
-com = points * 0.5
|
|
%strong=number_to_currency com
|
|
(
|
|
|
|
=number_to_percentage((com*100)/ca, :precision => 2)
|
|
|
|
du CA de la période)
|
|
%br
|
|
Soit
|
|
=number_to_currency(com / nbr_parts)
|
|
par parts
|
|
|
|
%p
|
|
-com = points * 0.7
|
|
|
|
Com à 70% :
|
|
%strong=number_to_currency com
|
|
(
|
|
|
|
=number_to_percentage((com*100)/ca, :precision => 2)
|
|
|
|
du CA de la période)
|
|
|
|
%br
|
|
Soit
|
|
=number_to_currency(com / nbr_parts)
|
|
par parts
|
|
|
|
|
|
|
|
|
|
|
|
%h3 Evolution du nombre de comptes
|
|
|
|
.chart_legend
|
|
.pastille{:style => "background:rgba(22,156,67,1);"}
|
|
Nombre de comptes
|
|
|
|
.pastille{:style => "background:rgba(20,133,201,1);"}
|
|
Nombre de comptes payants
|
|
|
|
.pastille{:style => "background:rgba(239,75,41,1);"}
|
|
Nombre de comptes gratuits
|
|
|
|
<div>
|
|
<canvas id="account_stats" height="300" width="600"></canvas>
|
|
</div>
|
|
|
|
-labels = []
|
|
-datas = []
|
|
-data_gratuits = []
|
|
-data_payants = []
|
|
|
|
-date = start_date.end_of_day
|
|
-while date <= Time.now.end_of_day
|
|
-labels << l(date, :format => "%a %d %b")
|
|
-nbr = Customer.where("created_at <= ?", date).count
|
|
-nbr_payants = Customer.where("binary_parent_id is not null and created_at <= ?", date).count
|
|
-datas << nbr
|
|
-data_payants << nbr_payants
|
|
-data_gratuits << (nbr - nbr_payants)
|
|
-date = date.tomorrow.end_of_day
|
|
|
|
|
|
|
|
|
|
<script>
|
|
var lineChartData = {
|
|
=raw"labels : #{labels.to_json},"
|
|
datasets : [
|
|
{
|
|
label: "Nombre de comptes",
|
|
fillColor : "rgba(22,156,67,0.1)",
|
|
strokeColor : "rgba(22,156,67,1)",
|
|
pointColor : "rgba(22,156,67,1)",
|
|
pointStrokeColor : "#fff",
|
|
pointHighlightFill : "#fff",
|
|
pointHighlightStroke : "rgba(220,220,220,1)",
|
|
=raw"data : #{datas.to_json}"
|
|
|
|
},
|
|
{
|
|
label: "Nombre de comptes payants",
|
|
fillColor : "rgba(20,133,201,0.1)",
|
|
strokeColor : "rgba(20,133,201,1)",
|
|
pointColor : "rgba(20,133,201,1)",
|
|
pointStrokeColor : "#fff",
|
|
pointHighlightFill : "#fff",
|
|
pointHighlightStroke : "rgba(220,220,220,1)",
|
|
=raw"data : #{data_payants.to_json}"
|
|
|
|
},
|
|
{
|
|
label: "Nombre de comptes gratuits",
|
|
fillColor : "rgba(239,75,41,0.1)",
|
|
strokeColor : "rgba(239,75,41,1)",
|
|
pointColor : "rgba(239,75,41,1)",
|
|
pointStrokeColor : "#fff",
|
|
pointHighlightFill : "#fff",
|
|
pointHighlightStroke : "rgba(220,220,220,1)",
|
|
=raw"data : #{data_gratuits.to_json}"
|
|
|
|
}
|
|
]
|
|
|
|
}
|
|
|
|
window.onload = function(){
|
|
var ctx = document.getElementById("account_stats").getContext("2d");
|
|
window.myLine = new Chart(ctx).Line(lineChartData, {
|
|
responsive: true,
|
|
bezierCurve : false
|
|
});
|
|
}
|
|
|
|
|
|
</script> |