From 3216ec9d1516d9480b3063af15c61ad28b8088f4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Sep 2022 12:52:33 +0530 Subject: [PATCH 01/10] Report optimized --- project_report/report/project_revenue_custom_report3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index d98df9e..3ba97ad 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -458,8 +458,8 @@ invoice_data as (SELECT 0.0 AS profit_per from invoice_date left join pro_data on pro_data.pproject_id = invoice_date.project_id --and pro_data.employee_id = invoice_date.employee_id - left join drange_data1 on invoice_date.project_id = drange_data1.project_id and invoice_date.employee_id = drange_data1.employee_id - and invoice_date.date >= drange_data1.start_date and invoice_date.date <= drange_data1.end_date + --left join drange_data1 on invoice_date.project_id = drange_data1.project_id and invoice_date.employee_id = drange_data1.employee_id + --and invoice_date.date >= drange_data1.start_date and invoice_date.date <= drange_data1.end_date ), res as ( select * from data1 From 6de9a9fff2a091c5dac4430c9b04b5df6124e81c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Sep 2022 14:17:02 +0530 Subject: [PATCH 02/10] view allocation all report display --- project_report/report/project_revenue_custom_report3.py | 4 ++-- project_report/views/project_view.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index 3ba97ad..8a66324 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -236,8 +236,8 @@ SELECT 0 as budgeted_revenue, 0 as budgeted_hours, 0 as overall_hourly_rate, - AAL.unit_amount, - pro_data.pro_hourly_rate, + AAL.unit_amount as unit_amount, + pro_data.pro_hourly_rate as pro_hourly_rate, ((AAL.amount * -1)/NULLIF(AAL.unit_amount, 0)) as timesheet_cost, (AAL.unit_amount * pro_data.pro_hourly_rate) AS actual_revenue, (AAL.amount * -1) as actual_cost, diff --git a/project_report/views/project_view.xml b/project_report/views/project_view.xml index fe4d369..d745a3e 100755 --- a/project_report/views/project_view.xml +++ b/project_report/views/project_view.xml @@ -10,10 +10,10 @@
+ From 9c6df537515c7299eef03f5c00a633aae05d5ec1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Sep 2022 12:30:56 +0530 Subject: [PATCH 06/10] timezone related issue code updated --- .../report/project_revenue_custom_report3.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index d8617d7..835bb8e 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -153,9 +153,9 @@ data1 as ( 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) + 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 - and AAL.end_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + 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 where pro_data.pricing_type = 'fixed_rate' and COALESCE(pro_data.is_sub_project, FALSE) = False group by @@ -247,9 +247,9 @@ SELECT FROM drange_data1 left join pro_data on pro_data.pproject_id = drange_data1.project_id left join account_analytic_line AAL on AAL.project_id=drange_data1.project_id and AAL.employee_id=drange_data1.employee_id - and AAL.start_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + 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 - and AAL.end_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + 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 WHERE pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_no_limit' and COALESCE(pro_data.is_sub_project, FALSE) = False group by @@ -399,14 +399,14 @@ SELECT 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) + 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 - and AAL.end_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + 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 left join cons_data1 on cons_data1.project_id=drange_data1.project_id and cons_data1.employee_id=drange_data1.employee_id - and AAL.start_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + and AAL.start_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) >= cons_data1.start_date::date + '00:00:00'::time - and AAL.end_datetime at time zone 'utc' at time zone (select tz from res_partner where id=3) + and AAL.end_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) <= cons_data1.end_date::date + '23:59:59'::time where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' and COALESCE(pro_data.is_sub_project, FALSE) = False group by From 6dec1811a852e1426fbfd3fb200e760921b739e6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Sep 2022 14:51:10 +0530 Subject: [PATCH 07/10] timezone related issue code updated --- .../report/project_revenue_custom_report3.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index 835bb8e..6459879 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -76,9 +76,9 @@ with pro_data as ( cons_data1 as ( SELECT date_trunc('month', min(PRO_EMP.start_date)) AS min, - date_trunc('month', coalesce(max(PRO_EMP.end_date), current_date)) AS max, + date_trunc('month', coalesce(max(PRO_EMP.end_date), current_date AT TIME ZONE 'UTC')) AS max, PRO_EMP.start_date as start_date, - coalesce(PRO_EMP.end_date, current_date) as end_date, + coalesce(PRO_EMP.end_date, current_date AT TIME ZONE 'UTC') as end_date, PRO_EMP.project_id, PRO_EMP.employee_id, PRO_EMP.role, @@ -154,9 +154,9 @@ data1 as ( 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 + >= 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 + <= drange_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' where pro_data.pricing_type = 'fixed_rate' and COALESCE(pro_data.is_sub_project, FALSE) = False group by drange_data1.start_date, @@ -248,9 +248,9 @@ SELECT left join pro_data on pro_data.pproject_id = drange_data1.project_id left join account_analytic_line AAL on AAL.project_id=drange_data1.project_id and AAL.employee_id=drange_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 + >= 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 + <= drange_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' WHERE pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_no_limit' and COALESCE(pro_data.is_sub_project, FALSE) = False group by drange_data1.start_date, @@ -400,14 +400,14 @@ SELECT 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 + >= 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 + <= drange_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' left join cons_data1 on cons_data1.project_id=drange_data1.project_id and cons_data1.employee_id=drange_data1.employee_id and AAL.start_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) - >= cons_data1.start_date::date + '00:00:00'::time + >= cons_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) - <= cons_data1.end_date::date + '23:59:59'::time + <= cons_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' and COALESCE(pro_data.is_sub_project, FALSE) = False group by drange_data1.start_date, From 466b38577ad7bd4f881a593feef263d4df1ede65 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Sep 2022 18:46:11 +0530 Subject: [PATCH 08/10] Report 1 type updated --- .../report/project_revenue_custom_report3.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) 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 ), From 2510dd2c4da92b2f22599179a0d4aa1df3afaa88 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Sep 2022 20:04:00 +0530 Subject: [PATCH 09/10] Report 2 and 3 type updated --- .../report/project_revenue_custom_report3.py | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index 6b06e02..128241c 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -210,9 +210,9 @@ data2 as ( pro_data.expenses_amt UNION 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, @@ -221,7 +221,7 @@ SELECT 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, @@ -236,20 +236,13 @@ SELECT 0 AS expenses_amt, ((AAL.unit_amount * pro_data.pro_hourly_rate) - (AAL.amount * -1)) AS profit_amt, ((AAL.unit_amount * pro_data.pro_hourly_rate) - (AAL.amount * -1))/NULLIF((AAL.unit_amount * pro_data.pro_hourly_rate),0) AS profit_per - FROM drange_data1 - left join pro_data on pro_data.pproject_id = drange_data1.project_id - left join account_analytic_line AAL on AAL.project_id=drange_data1.project_id and AAL.employee_id=drange_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='employee_rate' and pro_data.project_type='hours_no_limit' and COALESCE(pro_data.is_sub_project, FALSE) = False group by - drange_data1.start_date, - drange_data1.end_date, pro_data.pro_sdate, pro_data.pro_edate, - drange_data1.project_id, + pro_data.pproject_id, pro_data.project_active, pro_data.project_type, pro_data.pricing_type, @@ -257,12 +250,12 @@ SELECT AAL.sub_project, pro_data.tag_name, pro_data.partner_id, - drange_data1.employee_id, + AAL.employee_id, AAL.id, AAL.start_datetime, pro_data.pro_hourly_rate, - aal.unit_amount, - aal.amount, + AAL.unit_amount, + AAL.amount, pro_data.budgeted_hours, pro_data.expenses_amt ), @@ -358,9 +351,9 @@ SELECT pro_data.partner_id UNION 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, @@ -369,7 +362,7 @@ SELECT cons_data1.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, @@ -387,25 +380,18 @@ SELECT then (AAL.amount * -1) else (AAL.unit_amount * cons_data1.cons_timesheet_cost) end as profit_amt, (((AAL.unit_amount * COALESCE(cons_data1.cons_hourly_cost, 0)) - case when cons_data1.cons_timesheet_cost is null then (AAL.amount * -1) else (AAL.unit_amount * cons_data1.cons_timesheet_cost) end) / NULLIF((AAL.unit_amount * COALESCE(cons_data1.cons_hourly_cost, 0)), 0)) * 100 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' - left join cons_data1 on cons_data1.project_id=drange_data1.project_id and cons_data1.employee_id=drange_data1.employee_id + FROM pro_data + left join account_analytic_line AAL on AAL.project_id=pro_data.pproject_id + left join cons_data1 on cons_data1.project_id=AAL.project_id and cons_data1.employee_id=AAL.employee_id and AAL.start_datetime --at time zone 'utc' at time zone (select tz from res_partner where id=3) >= cons_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) <= cons_data1.end_date::date + '23:59:59'::time AT TIME ZONE 'UTC' - where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' and COALESCE(pro_data.is_sub_project, FALSE) = False + where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' + and COALESCE(pro_data.is_sub_project, FALSE) = False group by - drange_data1.start_date, - drange_data1.end_date, - drange_data1.project_id, - drange_data1.employee_id, + pro_data.pproject_id, + AAL.employee_id, AAL.id, AAL.start_datetime, pro_data.project_active, From 89948f78c5d9a3cf50bc9301f82033f450dc4b56 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Sep 2022 13:32:42 +0530 Subject: [PATCH 10/10] Timesheet date is added in the report --- project_report/report/project_revenue_custom_report3_views.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/project_report/report/project_revenue_custom_report3_views.xml b/project_report/report/project_revenue_custom_report3_views.xml index f45a730..6532631 100644 --- a/project_report/report/project_revenue_custom_report3_views.xml +++ b/project_report/report/project_revenue_custom_report3_views.xml @@ -57,6 +57,7 @@ +