diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index 6459879..6b06e02 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -123,9 +123,9 @@ invoice_date as ( ), data1 as ( SELECT - drange_data1.start_date, - drange_data1.end_date, - drange_data1.project_id, + TO_CHAR(start_datetime, 'YYYY-MM-01')::date as start_date, + (date_trunc('month', end_datetime) + interval '1 month' - interval '1 day')::date as end_date, + pro_data.pproject_id as project_id, pro_data.project_active, pro_data.project_type, pro_data.pricing_type, @@ -134,7 +134,7 @@ data1 as ( null::char as role, pro_data.tag_name, pro_data.partner_id, - drange_data1.employee_id, + AAL.employee_id, AAL.id as timesheet_id, AAL.start_datetime as timesheet_sdatetime, 0 as overall_budgeted_revenue, @@ -149,19 +149,11 @@ data1 as ( 0.0 AS expenses_amt, (0.0 - (sum(AAL.amount) * -1)) AS profit_amt, 0.0 AS profit_per - FROM drange_data1 - left join pro_data on pro_data.pproject_id = drange_data1.project_id - left join tsheet_data1 on tsheet_data1.project_id=drange_data1.project_id and tsheet_data1.employee_id=drange_data1.employee_id - left join account_analytic_line AAL on AAL.project_id=tsheet_data1.project_id and AAL.employee_id=tsheet_data1.employee_id - and AAL.start_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) - >= drange_data1.start_date::date + '00:00:00'::time AT TIME ZONE 'UTC' - and AAL.end_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) - <= drange_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' + FROM pro_data + left join account_analytic_line AAL on AAL.project_id=pro_data.pproject_id where pro_data.pricing_type = 'fixed_rate' and COALESCE(pro_data.is_sub_project, FALSE) = False group by - drange_data1.start_date, - drange_data1.end_date, - drange_data1.project_id, + pro_data.pproject_id, pro_data.project_active, pro_data.project_type, pro_data.pricing_type, @@ -169,7 +161,7 @@ data1 as ( AAL.sub_project, pro_data.tag_name, pro_data.partner_id, - drange_data1.employee_id, + AAL.employee_id, AAL.id, AAL.start_datetime ),