Commit 66782aec authored by Frank Bergmann's avatar Frank Bergmann

Added Cancellation Invoice

parent 64cc6d7f
......@@ -31,10 +31,14 @@ group by
main_p.project_id, main_p.project_name,
c.cost_type_id
"
# ad_return_complaint 1 [im_ad_hoc_query -format html $cost_sql]
db_foreach cost_info $cost_sql {
set project_hash($project_id) $project_name
# Handle Cancelation Invoices just like invoices
if {[im_cost_type_cancellation_invoice] == $cost_type_id} { set cost_type_id [im_cost_type_invoice] }
# Roll-up values to super cost types
set super_cost_type_ids [util_memoize [list db_list super_cats "select distinct category_id from (select $cost_type_id as category_id UNION select parent_id as category_id from im_category_hierarchy where child_id = $cost_type_id) t"]]
foreach ctid $super_cost_type_ids {
......
......@@ -69,10 +69,12 @@ SELECT im_category_new (910,'po.es.adp','Intranet Cost Template');
-- Creating category Cost Type
SELECT im_category_new (3700,'Customer Invoice','Intranet Cost Type');
SELECT im_category_new (3702,'Quote','Intranet Cost Type');
SELECT im_category_new (3703,'Order','Intranet Cost Type');
SELECT im_category_new (3704,'Provider Bill','Intranet Cost Type');
SELECT im_category_new (3706,'Purchase Order','Intranet Cost Type');
SELECT im_category_new (3708,'Customer Documents','Intranet Cost Type');
SELECT im_category_new (3710,'Provider Documents','Intranet Cost Type');
-- SELECT im_category_new (3712,'Provider Travel ???','Intranet Cost Type');
SELECT im_category_new (3714,'Employee Salary','Intranet Cost Type');
SELECT im_category_new (3716,'Repeating Cost','Intranet Cost Type');
SELECT im_category_new (3718,'Timesheet Cost','Intranet Cost Type');
......@@ -84,13 +86,18 @@ SELECT im_category_new (3728,'Expense Planned Cost','Intranet Cost Type');
SELECT im_category_new (3730,'InterCo Invoice','Intranet Cost Type');
SELECT im_category_new (3732,'InterCo Quote','Intranet Cost Type');
SELECT im_category_new (3734,'Provider Receipt','Intranet Cost Type');
SELECT im_category_new (3736,'Timesheet Hours','Intranet Cost Type'); -- Fake cost types for timesheet_hours
-- Fake cost types for timesheet_hours
SELECT im_category_new (3736,'Timesheet Hours','Intranet Cost Type');
SELECT im_category_new (3738,'Planned Purchase','Intranet Cost Type');
SELECT im_category_new (3740,'Customer Purchase Order','Intranet Cost Type');
SELECT im_category_new (3742,'Goods Received','Intranet Cost Type');
SELECT im_category_new (3744,'Goods Accepted','Intranet Cost Type');
SELECT im_category_new (3744,'Purchase Request','Intranet Cost Type');
SELECT im_category_new (3746,'Purchase Request','Intranet Cost Type');
-- SELECT im_category_new (3748,'Purchase Etc','Intranet Cost Type');
-- 3750 reserved for cosine "mission
SELECT im_category_new (3752,'Cancellation Invoice','Intranet Cost Type');
-- reserved until 3799
......@@ -111,6 +118,10 @@ SELECT im_category_hierarchy_new(3724,3708);
SELECT im_category_hierarchy_new(3730,3708);
SELECT im_category_hierarchy_new(3732,3708);
-- Cancellation Invoice _is_a_ customer document and an invoice
SELECT im_category_hierarchy_new(3752,3700);
SELECT im_category_hierarchy_new(3752,3708);
......
......@@ -70,10 +70,15 @@ SELECT im_component_plugin__new (
'Top 10 Unpaid Customer Invoices', -- plugin_name - shown in menu
'intranet-cost', -- package_name
'left', -- location
'/intranet-cost/index', -- page_url
'/intranet-invoices/dashboard', -- page_url
null, -- view_name
10, -- sort_order
'
15, -- sort_order
'set a "not implemented yet"',
'lang::message::lookup "" intranet-cost.Top_10_Unpaid_Customer_Invoices "Top 10 Unpaid Customer Invoices"'
);
update im_component_plugins
set component_tcl = '
im_ad_hoc_query -format html -package_key intranet-cost "
select ''<a href=/intranet-invoices/view?invoice_id='' || c.cost_id || ''>'' || c.cost_name || ''</a>'' as document_nr,
''<a href=/intranet-cost/cost-centers/new?cost_center_id='' || c.cost_center_id || ''>'' || im_cost_center_code_from_id(c.cost_center_id) || ''</a>'' as cost_center,
......@@ -82,14 +87,11 @@ select ''<a href=/intranet-invoices/view?invoice_id='' || c.cost_id || ''>'' ||
c.amount::text || '' '' || c.currency as amount,
c.paid_amount::text || '' '' || c.paid_currency as paid_amount
from im_costs c
where c.cost_type_id = 3700 and
where c.cost_type_id in (select * from im_sub_categories(3700)) and
c.cost_status_id not in (3810, 3814, 3816, 3818)
order by coalesce(c.amount,0) DESC
limit 10
"',
'lang::message::lookup "" intranet-cost.Top_10_Unpaid_Customer_Invoices "Top 10 Unpaid Customer Invoices"'
);
limit 10"'
where plugin_name = 'Top 10 Unpaid Customer Invoices';
SELECT im_component_plugin__new (
......
......@@ -374,7 +374,7 @@ create or replace view im_cost_types as
select category_id as cost_type_id,
category as cost_type,
CASE
WHEN category_id = 3700 THEN 'fi_read_invoices'
WHEN category_id in (3700, 3752) THEN 'fi_read_invoices'
WHEN category_id = 3702 THEN 'fi_read_quotes'
WHEN category_id = 3704 THEN 'fi_read_bills'
WHEN category_id = 3706 THEN 'fi_read_pos'
......@@ -388,7 +388,7 @@ select category_id as cost_type_id,
ELSE 'fi_read_all'
END as read_privilege,
CASE
WHEN category_id = 3700 THEN 'fi_write_invoices'
WHEN category_id in (3700, 3752) THEN 'fi_write_invoices'
WHEN category_id = 3702 THEN 'fi_write_quotes'
WHEN category_id = 3704 THEN 'fi_write_bills'
WHEN category_id = 3706 THEN 'fi_write_pos'
......@@ -402,7 +402,7 @@ select category_id as cost_type_id,
ELSE 'fi_write_all'
END as write_privilege,
CASE
WHEN category_id = 3700 THEN 'invoice'
WHEN category_id in (3700, 3752) THEN 'invoice'
WHEN category_id = 3702 THEN 'quote'
WHEN category_id = 3704 THEN 'bill'
WHEN category_id = 3706 THEN 'po'
......@@ -620,7 +620,7 @@ begin
from im_companies c
where c.company_path = 'internal';
IF v_cost_type_id not in (3700,3702,3704,3706,3720,3724,3730,3732) THEN
IF v_cost_type_id not in (3700,3702,3704,3706,3720,3724,3730,3732,3752) THEN
return 'invalid cost type: ' || v_cost_type;
END IF;
......@@ -657,7 +657,7 @@ begin
END IF;
RAISE NOTICE 'im_cost_vat_type_from_cost_id: v_provider_eu_p=%', v_provider_eu_p;
IF v_cost_type_id in (3700,3702,3730,3732)
IF v_cost_type_id in (3700,3702,3730,3732,3752)
THEN v_cost_is_invoice_or_quote_p := 1;
ELSE v_cost_is_invoice_or_quote_p := 0;
END IF;
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ ad_proc -public im_cost_type_po {} { return 3706 }
ad_proc -public im_cost_type_company_doc {} { return 3708 }
ad_proc -public im_cost_type_customer_doc {} { return 3708 }
ad_proc -public im_cost_type_provider_doc {} { return 3710 }
ad_proc -public im_cost_type_provider_travel {} { return 3712 }
# ad_proc -public im_cost_type_provider_travel {} { return 3712 }
ad_proc -public im_cost_type_employee {} { return 3714 }
ad_proc -public im_cost_type_repeating {} { return 3716 }
ad_proc -public im_cost_type_timesheet {} { return 3718 }
......@@ -67,6 +67,7 @@ ad_proc -public im_cost_type_goods_accepted {} { return 3744 }
ad_proc -public im_cost_type_purchase_request {} { return 3746 }
ad_proc -public im_cost_type_purchase_etc {} { return 3748 }
# 3750 reserved for cosine "mission"
ad_proc -public im_cost_type_cancellation_invoice {} { return 3752 }
ad_proc -public im_cost_type_short_name { cost_type_id } {
......@@ -88,6 +89,7 @@ ad_proc -public im_cost_type_short_name { cost_type_id } {
3728 { return "expense_planned" }
3730 { return "interco_invoice" }
3732 { return "interco_quote" }
3752 { return "cancellation_invoice" }
default { return "unknown" }
}
}
......@@ -1808,6 +1810,11 @@ ad_proc im_costs_project_finance_component {
<tr>
<td>[_ intranet-cost.Customer_Invoices]</td>\n"
set subtotal $subtotals([im_cost_type_invoice])
set cancelled 0
if {[info exists subtotals([im_cost_type_cancellation_invoice])]} {
set cancelled $subtotals([im_cost_type_cancellation_invoice])
}
set subtotal [expr $subtotal + $cancelled]
append hard_cost_html "<td align=right>$subtotal $default_currency</td>\n"
set grand_total $subtotal
......@@ -2389,7 +2396,9 @@ ad_proc -public im_cost_update_project_cost_cache {
set subtotals($id) [expr $amount_converted + $subtotals($id)]
}
}
# ad_return_complaint 1 [array get subtotals]
# --------------------------------------------------------------------
# Calculate "Planned Timesheet" cost according to a parameter
# --------------------------------------------------------------------
......@@ -2569,7 +2578,7 @@ ad_proc -public im_cost_update_project_cost_cache {
# have been converted to default_currency
db_dml update_projects "
update im_projects set
cost_invoices_cache = $subtotals([im_cost_type_invoice]),
cost_invoices_cache = $subtotals([im_cost_type_invoice]) + $subtotals([im_cost_type_cancellation_invoice]),
cost_delivery_notes_cache = $subtotals([im_cost_type_delivery_note]),
cost_quotes_cache = $subtotals([im_cost_type_quote]),
cost_bills_cache = $subtotals([im_cost_type_bill]),
......@@ -2721,6 +2730,7 @@ ad_proc -public im_cost_project_document_icons_helper {
3702 { set gif "q" }
3704 { set gif "b" }
3706 { set gif "p" }
3752 { set gif "c" }
default { set gif "cross" }
}
set alt_txt "$cost_name, [lang::message::lookup "" intranet-cost.Amount Amount]:$amount_converted"
......
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