Skip to content
Extraits de code Groupes Projets
Valider c25c6fec rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[FIX] compute analaytic lines

parent c303ee31
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -181,13 +181,12 @@ class LeFilamentTdb(models.Model):
select
customer as "Client",
sum(prod) as "Imput.",
sum(invoiced + purchase + expense)::int as "Balance Prod",
sum(invoiced + purchase + expense)/NULLIF(sum(prod), 0) as "Taux Horaire",
sum(invoiced + expense)::int as "Balance Prod",
sum(invoiced + expense)/NULLIF(sum(prod), 0) as "Taux Horaire",
sum(invoiced + invoiced_mco) as "Tot. Fact.",
sum(invoiced)::int as "Fact. Prod",
sum(invoiced_mco)::int as "Fact. Maint",
sum(purchase)::int as "Achats",
sum(expense)::int as "NdF"
sum(expense)::int as "Achats / NdF"
from
(
-- Sélection des heures
......@@ -196,11 +195,11 @@ class LeFilamentTdb(models.Model):
p.name as customer,
-- contact != Filament et projet != Maintenance et pas flagué vacances
case when aal.partner_id != 1 or aal.partner_id is null
and aal.holiday_id is null and project_id != 19
and aal.holiday_id is null and aal.global_leave_id is null
and project_id != 19
then unit_amount else 0 end as prod,
0 as invoiced,
0 as invoiced_mco,
0 as purchase,
0 as expense
from
account_analytic_line aal
......@@ -214,7 +213,7 @@ class LeFilamentTdb(models.Model):
aal.project_id is not null
and aal.date <= CURRENT_DATE
and (lt.active is true or lt.active is null)
and partner_id != 1
and aal.partner_id != 1
-- Sélection du facturé hors maintenance
union all
......@@ -224,7 +223,6 @@ class LeFilamentTdb(models.Model):
0 as prod,
(aml.credit - aml.debit) as invoiced,
0 as invoiced_mco,
0 as purchase,
0 as expense
from account_move_line aml
left join account_move i on aml.move_id = i.id
......@@ -243,7 +241,6 @@ class LeFilamentTdb(models.Model):
0 as prod,
0 as invoiced,
(aml.credit - aml.debit) as invoiced_mco,
0 as purchase,
0 as expense
from account_move_line aml
left join account_move i on aml.move_id = i.id
......@@ -262,37 +259,14 @@ class LeFilamentTdb(models.Model):
0 as prod,
0 as invoiced,
0 as invoiced_mco,
amount as purchase,
0 as expense
from account_analytic_line aal
left join account_move_line aml on aal.move_line_id = aml.id
left join account_move i on aml.move_id = i.id
left join account_analytic_account a on aal.account_id = a.id
left join res_partner p on a.partner_id = p.id
where
(a.plan_id is null or a.plan_id = 1)
and i.state = 'posted'
and aml.journal_id = 2
-- Sélection des NDF
union all
select
aal.date as line_date,
p.name as customer,
0 as prod,
0 as invoiced,
0 as invoiced_mco,
0 as purchase,
amount as expense
from account_analytic_line aal
left join account_move_line aml on aal.move_line_id = aml.id
left join account_move i on aml.move_id = i.id
left join account_analytic_account a on aal.account_id = a.id
left join res_partner p on a.partner_id = p.id
where
(a.plan_id is null or a.plan_id = 1)
and i.state = 'posted'
and aml.journal_id = 9
aal.account_id is not null and aal.project_id is null
and aal.category in ('vendor_bill', 'other')
and a.partner_id is not null
) query
%s
group by
......@@ -326,13 +300,11 @@ class LeFilamentTdb(models.Model):
from
account_analytic_line aal
left join
account_analytic_account aa on aal.account_id = aa.id
left join
account_analytic_plan aap on aa.plan_id = aap.id
account_analytic_account aa on aal.x_plan3_id = aa.id
left join
res_partner p on aa.partner_id = p.id
where
aap.id = 3
aal.x_plan3_id IS NOT NULL
%s
group by p.name
......@@ -343,7 +315,10 @@ class LeFilamentTdb(models.Model):
sum(case when aal.partner_id != 1 or aal.partner_id is null
and aal.holiday_id is null then unit_amount else 0 end)
as production,
sum(case when aal.partner_id = 1 and aal.holiday_id is null
sum(case when
aal.partner_id = 1
and aal.holiday_id is null
and aal.global_leave_id IS NULL
then unit_amount else 0 end)
as internal,
0 as revenue
......@@ -356,7 +331,7 @@ class LeFilamentTdb(models.Model):
left join
hr_leave_type lt on l.holiday_status_id = lt.id
where
aal.project_id is not null
aal.project_id IS NOT NULL
%s
group by e.name
) query
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter