diff --git a/project_report/report/project_revenue_custom_report2_views.xml b/project_report/report/project_revenue_custom_report2_views.xml
index dfda5ea..a55727a 100755
--- a/project_report/report/project_revenue_custom_report2_views.xml
+++ b/project_report/report/project_revenue_custom_report2_views.xml
@@ -6,7 +6,7 @@
project.revenue.custom.report2
-
+
diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py
index d98df9e..128241c 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', max(coalesce(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,
@@ -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
- 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
+ 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
),
@@ -218,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,
@@ -229,35 +221,28 @@ 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,
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,
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
- 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
+ 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,
@@ -265,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
),
@@ -366,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,
@@ -377,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,
@@ -395,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
- 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)
- >= 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)
- <= 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
+ 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
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,
@@ -458,8 +436,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
diff --git a/project_report/report/project_revenue_custom_report3_views.xml b/project_report/report/project_revenue_custom_report3_views.xml
index 155dd93..6532631 100644
--- a/project_report/report/project_revenue_custom_report3_views.xml
+++ b/project_report/report/project_revenue_custom_report3_views.xml
@@ -6,7 +6,7 @@
project.revenue.custom.report3
-
+
@@ -57,6 +57,7 @@
+
@@ -107,9 +108,10 @@
project.revenue.custom.report3pivot,tree,graph
- {'search_default_group_project': 1, 'search_default_group_employee': 1,
+ {}
+
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 @@