Report count mismatch issue fixed

This commit is contained in:
prakash 2022-03-09 20:40:49 +05:30
parent 3a0e595043
commit be95e4a0c7
1 changed files with 6 additions and 11 deletions

View File

@ -67,13 +67,13 @@ class BudgetAmtAnalysis(models.Model):
pro.pricing_type as pricing_type,
pro.project_type as project_type,
null::date AS timesheet_date,
(AAL.unit_amount * pro_emp.employee_price) AS revenue
--(AAL.unit_amount * pro_emp.price_unit) AS revenue
(sum(AAL.unit_amount) * pro_emp.employee_price) AS revenue
FROM project_project PRO
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
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 and AAL.employee_id = pro_emp.employee_id
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
group by pro.id, aal.employee_id, aal.start_datetime, pro_emp.employee_price
union
SELECT
pro.id AS project_id,
@ -103,9 +103,6 @@ class BudgetAmtAnalysis(models.Model):
pro.project_type as project_type,
null::date AS timesheet_date,
(pro.hourly_rate * pro.timesheet_hour) AS revenue
--(pro.hourly_rate * sum(AAL.unit_amount)) AS revenue
--(AAL.unit_amount) AS revenue
--(AAL.unit_amount * pro_emp.price_unit) AS revenue
FROM project_project PRO
--Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
--LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
@ -125,14 +122,13 @@ class BudgetAmtAnalysis(models.Model):
pro.pricing_type as pricing_type,
pro.project_type as project_type,
AAL.date AS timesheet_date,
(AAL.unit_amount * pro_emp.price_unit) AS revenue
--(AAL.amount * -1) AS revenue
--(AAL.unit_amount * pro_emp.employee_price) AS revenue
(sum(AAL.unit_amount) * pro_emp.price_unit) AS revenue
FROM project_project PRO
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
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 and AAL.employee_id = pro_emp.employee_id
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate'
WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate'
group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.price_unit
--and PRO.project_type = 'hours_in_consultant'
union
SELECT
@ -147,7 +143,6 @@ class BudgetAmtAnalysis(models.Model):
pro.project_type as project_type,
AAL.date AS timesheet_date,
(AAL.amount * -1) AS revenue
--(AAL.unit_amount * pro_emp.employee_price) 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