Fixed report cons updated

This commit is contained in:
projectsodoo 2021-01-11 23:06:57 +05:30
parent 8d30c1246b
commit e4746d5d2c
1 changed files with 18 additions and 17 deletions

View File

@ -58,20 +58,20 @@ class BudgetAmtAnalysis(models.Model):
FROM project_project PRO
Left JOIN project_sale_line_employee_map Pro_emp ON Pro_emp.project_id = Pro.id
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
union
SELECT
PRO.id AS project_id,
PRO.create_date AS create_date,
PRO.partner_id AS partner_id,
AAL.employee_id AS employee_id,
'Actual Revenue' as amount_type,
PRO.pricing_type as pricing_type,
PRO.project_type as project_type,
(AAL.amount * -1) AS revenue
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
--union
--SELECT
--PRO.id AS project_id,
--PRO.create_date AS create_date,
--PRO.partner_id AS partner_id,
--AAL.employee_id AS employee_id,
--'Actual Revenue' as amount_type,
--PRO.pricing_type as pricing_type,
--PRO.project_type as project_type,
--(AAL.amount * -1) AS revenue
--FROM project_project PRO
--LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
--LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
--WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
union
SELECT
PRO.id AS project_id,
@ -81,12 +81,13 @@ class BudgetAmtAnalysis(models.Model):
'Actual Revenue' as amount_type,
PRO.pricing_type as pricing_type,
PRO.project_type as project_type,
pro.total_expenses AS revenue
(AAL.amount * -1) + pro.expenses_amt AS revenue
--pro.total_expenses AS revenue
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
WHERE PRO.active = 't'
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue
WHERE PRO.active = 't' and (PRO.pricing_type = 'fixed_rate' OR PRO.project_type = 'hours_no_limit')
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, AAL.amount
order by create_date desc, project_id, amount_type desc) as res
)""" % (self._table,))