Commit e6ca12c4 authored by Frank Bergmann's avatar Frank Bergmann

Added Cancellation Invoice

parent 52902324
......@@ -60,7 +60,7 @@ BEGIN
'revenues',
15110,
15000,
'select coalesce(round(sum(amount)), 0) from im_costs where cost_type_id = 3700 and effective_date between now()::date-60 and now()::date-30',
'select coalesce(round(sum(amount)), 0) from im_costs where cost_type_id in (select * from im_sub_categories(3700)) and effective_date between now()::date-60 and now()::date-30',
0,
1000,
5
......@@ -124,25 +124,26 @@ BEGIN
'net_margin',
15110,
15000,
'select
round((invoices - bills - timesheet - expenses) / (invoices+0.000001) * 100, 1) as net_margin
from
(select
(select sum(amount) from im_costs where cost_type_id = 3700 and effective_date between now()::date-60 and now()::date-30) as invoices,
(select sum(amount) from im_costs where cost_type_id = 3702 and effective_date between now()::date-60 and now()::date-30) as quotes,
(select sum(amount) from im_costs where cost_type_id = 3704 and effective_date between now()::date-60 and now()::date-30) as bills,
(select sum(amount) from im_costs where cost_type_id = 3706 and effective_date between now()::date-60 and now()::date-30) as pos,
(select sum(amount) from im_costs where cost_type_id = 3718 and effective_date between now()::date-60 and now()::date-30) as timesheet,
(select sum(amount) from im_costs where cost_type_id = 3720 and effective_date between now()::date-60 and now()::date-30) as expenses
) base
;
',
'select 1',
0,
20,
5
);
update im_reports
set report_sql = 'select
round((invoices - bills - timesheet - expenses) / (invoices+0.000001) * 100, 1) as net_margin
from
(select
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3700)) and effective_date between now()::date-60 and now()::date-30) as invoices,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3702)) and effective_date between now()::date-60 and now()::date-30) as quotes,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3704)) and effective_date between now()::date-60 and now()::date-30) as bills,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3706)) and effective_date between now()::date-60 and now()::date-30) as pos,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3718)) and effective_date between now()::date-60 and now()::date-30) as timesheet,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3720)) and effective_date between now()::date-60 and now()::date-30) as expenses
) base;'
where report_name = 'Net Margin Two Months Ago';
update im_indicators set
indicator_section_id = 15200
where indicator_id = v_id;
......@@ -174,24 +175,26 @@ BEGIN
'prelim_bruto_margin',
15110,
15000,
'select
round((quotes - pos) / (quotes+0.000001) * 100,1) as prelim_brut_margin
from
(select
(select sum(amount) from im_costs where cost_type_id = 3700 and effective_date between now()::date-60 and now()::date-30) as invoices,
(select sum(amount) from im_costs where cost_type_id = 3702 and effective_date between now()::date-60 and now()::date-30) as quotes,
(select sum(amount) from im_costs where cost_type_id = 3704 and effective_date between now()::date-60 and now()::date-30) as bills,
(select sum(amount) from im_costs where cost_type_id = 3706 and effective_date between now()::date-60 and now()::date-30) as pos,
(select sum(amount) from im_costs where cost_type_id = 3718 and effective_date between now()::date-60 and now()::date-30) as timesheet,
(select sum(amount) from im_costs where cost_type_id = 3720 and effective_date between now()::date-60 and now()::date-30) as expenses
) base
;',
'select 1',
0,
60,
5
);
update im_reports
set report_sql = 'select
round((quotes - pos) / (quotes+0.000001) * 100,1) as prelim_brut_margin
from
(select
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3700)) and effective_date between now()::date-60 and now()::date-30) as invoices,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3702)) and effective_date between now()::date-60 and now()::date-30) as quotes,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3704)) and effective_date between now()::date-60 and now()::date-30) as bills,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3706)) and effective_date between now()::date-60 and now()::date-30) as pos,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3718)) and effective_date between now()::date-60 and now()::date-30) as timesheet,
(select sum(amount) from im_costs where cost_type_id in (select * from im_sub_categories(3720)) and effective_date between now()::date-60 and now()::date-30) as expenses
) base;'
where report_name = 'Preliminary Bruto Margin Two Months Ago';
update im_indicators set
indicator_section_id = 15200
where indicator_id = v_id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment