diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..e8c328f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project_report/report/project_revenue_custom_report3.py b/project_report/report/project_revenue_custom_report3.py index cfe772c..eebcf75 100644 --- a/project_report/report/project_revenue_custom_report3.py +++ b/project_report/report/project_revenue_custom_report3.py @@ -45,6 +45,7 @@ class ProjectRevenueCustomReport3(models.Model): role = fields.Selection([('Manager', 'Manager'), ('Employee', 'Employee')], string="Role") #is_sub_project = fields.Boolean("Is Sub Project") sub_project = fields.Many2one('project.project', string='Sub Project') + fixed_amount_date = fields.Date('Fixed Amount Date', readonly=True) def init(self): @@ -169,7 +170,8 @@ data1 as ( (sum(AAL.amount) * -1) as actual_cost, 0.0 AS expenses_amt, (0.0 - (sum(AAL.amount) * -1)) AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + null::date as fixed_amount_date FROM pro_data right 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 @@ -222,7 +224,8 @@ data1_sub as ( (sum(AAL.amount) * -1) as actual_cost, 0.0 AS expenses_amt, (0.0 - (sum(AAL.amount) * -1)) AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + null::date as fixed_amount_date FROM sub_pro_data right join account_analytic_line AAL on AAL.sub_project=sub_pro_data.sub_project LEFT JOIN cons_data1 ON cons_data1.project_id = AAL.project_id @@ -274,7 +277,8 @@ data2 as ( 0 as actual_cost, pro_data.expenses_amt, 0.0 AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + null::date as fixed_amount_date FROM pro_data WHERE pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_no_limit' and COALESCE(pro_data.is_sub_project, FALSE) = False @@ -320,7 +324,8 @@ SELECT (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 + ((AAL.unit_amount * pro_data.pro_hourly_rate) - (AAL.amount * -1))/NULLIF((AAL.unit_amount * pro_data.pro_hourly_rate),0) AS profit_per, + null::date as fixed_amount_date FROM pro_data right 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' @@ -375,7 +380,8 @@ data2_sub_project as ( 0 as actual_cost, sub_pro_data.expenses_amt, 0.0 AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + null::date as fixed_amount_date FROM sub_pro_data WHERE sub_pro_data.pricing_type='employee_rate' and sub_pro_data.project_type='hours_no_limit' and sub_pro_data.is_sub_project = TRUE @@ -421,7 +427,8 @@ SELECT (AAL.amount * -1) as actual_cost, 0 AS expenses_amt, ((AAL.unit_amount * sub_pro_data.pro_hourly_rate) - (AAL.amount * -1)) AS profit_amt, - ((AAL.unit_amount * sub_pro_data.pro_hourly_rate) - (AAL.amount * -1))/NULLIF((AAL.unit_amount * sub_pro_data.pro_hourly_rate),0) AS profit_per + ((AAL.unit_amount * sub_pro_data.pro_hourly_rate) - (AAL.amount * -1))/NULLIF((AAL.unit_amount * sub_pro_data.pro_hourly_rate),0) AS profit_per, + null::date as fixed_amount_date FROM sub_pro_data right join account_analytic_line AAL on AAL.sub_project=sub_pro_data.sub_project WHERE sub_pro_data.pricing_type='employee_rate' and sub_pro_data.project_type='hours_no_limit' @@ -476,7 +483,8 @@ SELECT 0.0 as actual_cost, pro_data.expenses_amt, 0.0 as profit_amt, - 0.0 as profit_per + 0.0 as profit_per, + null::date as fixed_amount_date FROM pro_data right 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_in_consultant' @@ -523,7 +531,8 @@ SELECT 0 as actual_cost, 0 as expenses_amt, 0 as profit_amt, - 0 as profit_per + 0 as profit_per, + null::date as fixed_amount_date FROM pro_data left join cons_data1 on cons_data1.project_id = pro_data.pproject_id where pro_data.pricing_type='employee_rate' and pro_data.project_type='hours_in_consultant' @@ -573,7 +582,8 @@ SELECT (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 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 + 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, + null::date as fixed_amount_date FROM pro_data right 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 @@ -633,7 +643,8 @@ SELECT 0.0 as actual_cost, sub_pro_data.expenses_amt, 0.0 as profit_amt, - 0.0 as profit_per + 0.0 as profit_per, + null::date as fixed_amount_date FROM sub_pro_data where sub_pro_data.pricing_type='employee_rate' and sub_pro_data.project_type='hours_in_consultant' and sub_pro_data.is_sub_project = True @@ -679,7 +690,8 @@ SELECT 0 as actual_cost, 0 as expenses_amt, 0 as profit_amt, - 0 as profit_per + 0 as profit_per, + null::date as fixed_amount_date FROM sub_pro_data left join cons_data1 on cons_data1.project_id = sub_pro_data.sub_project where sub_pro_data.pricing_type='employee_rate' and sub_pro_data.project_type='hours_in_consultant' @@ -730,7 +742,8 @@ SELECT (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 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 + 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, + null::date as fixed_amount_date FROM sub_pro_data right join account_analytic_line AAL on AAL.sub_project=sub_pro_data.sub_project left join cons_data1 on cons_data1.project_id=AAL.sub_project and cons_data1.employee_id=AAL.employee_id @@ -788,7 +801,8 @@ invoice_data as (SELECT 0 as actual_cost, 0.0 AS expenses_amt, invoice_date.fixed_amount AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + invoice_date.date as fixed_amount_date 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 where COALESCE(pro_data.is_sub_project, FALSE) = False @@ -820,7 +834,8 @@ invoice_data_sub as (SELECT 0 as actual_cost, 0.0 AS expenses_amt, invoice_date.fixed_amount AS profit_amt, - 0.0 AS profit_per + 0.0 AS profit_per, + invoice_date.date as fixed_amount_date from invoice_date left join sub_pro_data on sub_pro_data.sub_project = invoice_date.project_id where sub_pro_data.is_sub_project = True @@ -870,7 +885,8 @@ select actual_cost, expenses_amt, profit_amt, - profit_per + profit_per, + fixed_amount_date from res group by start_date, @@ -899,7 +915,8 @@ group by actual_cost, expenses_amt, profit_amt, - profit_per + profit_per, + fixed_amount_date )""" % (self._table,)) @api.model