Commit bf9a7cf8 authored by Frank Bergmann's avatar Frank Bergmann

- added timesheet-invoicing, basicly works (alpha)

parent 37a19d91
......@@ -15,7 +15,7 @@
<provides url="intranet-timesheet2-invoices" version="3.0.0"/>
<requires url="intranet-core" version="3.0.0"/>
<requires url="intranet-timesheet" version="3.0.0"/>
<requires url="intranet-timesheet2" version="3.0.0"/>
<requires url="intranet-invoices" version="3.0.0"/>
<callbacks>
......
......@@ -24,7 +24,8 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} {
set bgcolor(0) " class=roweven "
set bgcolor(1) " class=rowodd "
set price_format "000.00"
# set price_format "000.00"
set price_format "%0.2f"
set colspan 7
set price_list_html "
......@@ -73,7 +74,7 @@ order by
<td>$uom</td>
<td>$task_type</td>
<td>$material</td>
<td>[format "%0.3f" $price] $currency</td>
<td>[format $price_format $price] $currency</td>
<td><input type=checkbox name=price_id.$price_id></td>
</tr>"
incr ctr
......
......@@ -66,7 +66,27 @@ set in_clause_list [list]
foreach selected_project $select_project {
lappend in_clause_list $selected_project
}
set projects_where_clause "and p.project_id in ([join $in_clause_list ","])"
set projects_where_clause "
and p.project_id in (
select
children.project_id
from
im_projects parent,
im_projects children
where
children.project_status_id not in (
[im_project_status_deleted],
[im_project_status_canceled]
)
and children.tree_sortkey
between parent.tree_sortkey
and tree_right(parent.tree_sortkey)
and parent.project_id in ([join $in_clause_list ","])
order by
children.tree_sortkey
)
"
# check that all projects are from the same client
......@@ -111,13 +131,15 @@ select
p.project_path,
p.project_path as project_short_name,
t.task_id,
t.task_units,
t.task_name,
t.planned_units,
t.billable_units,
t.task_uom_id,
t.reported_units_cache,
t.uom_id,
t.task_type_id,
t.project_id,
im_category_from_id(t.task_uom_id) as uom_name,
im_material_name_from_id(t.material_id) as material_name,
im_category_from_id(t.uom_id) as uom_name,
im_category_from_id(t.task_type_id) as type_name,
im_category_from_id(t.task_status_id) as task_status
from
......@@ -126,32 +148,48 @@ from
where
t.project_id = p.project_id
$task_invoice_id_null
$projects_where_clause
order by
project_id, task_id
"
set disabled_task_status_where "
and t.task_status_id in (
select task_status_id
from im_task_status
where upper(task_status) not in (
select category_id
from im_categories
where category_type = 'Intranet Timesheet Task Status'
and upper(category) not in (
'CLOSED','INVOICED','PARTIALLY PAID',
'DECLINED','PAID','DELETED','CANCELED'
)
)
$projects_where_clause
order by
project_id, task_id
"
set task_table "
<tr>
<td class=rowtitle align=middle>[im_gif help "Include in Invoice"]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Task_Name]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Units]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Material]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Planned_Units]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Billable_Units]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Reported_Units]</td>
<td class=rowtitle>
[_ intranet-timesheet2-invoices.UoM] [im_gif help "Unit of Measure"]
</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Type]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Status]</td>
</tr>
"
<tr>
<td></td>
<td colspan=2>Please select the type of hours to use:</td>
<td align=center><input type=radio name=invoice_hour_type value=planned></td>
<td align=center><input type=radio name=invoice_hour_type value=billable checked></td>
<td align=center><input type=radio name=invoice_hour_type value=reported></td>
<td></td>
<td></td>
<td></td>
</tr>\n"
set task_table_rows ""
set ctr 0
......@@ -181,8 +219,10 @@ db_foreach select_tasks $sql {
<input type=checkbox name=include_task value=$task_id checked>
</td>
<td align=left>$task_name</td>
<td align=right>$task_units</td>
<td align=right>$material_name</td>
<td align=right>$planned_units</td>
<td align=right>$billable_units</td>
<td align=right>$reported_units_cache</td>
<td align=right>$uom_name</td>
<td>$type_name</td>
<td>$task_status</td>
......
......@@ -42,10 +42,13 @@ where
<querytext>
select
trim(both ' ' from to_char(s.task_sum, :number_format)) as task_sum,
trim(both ' ' from to_char(s.planned_sum, :number_format)) as planned_sum,
trim(both ' ' from to_char(s.billable_sum, :number_format)) as billable_sum,
trim(both ' ' from to_char(s.reported_sum, :number_format)) as reported_sum,
s.task_type_id,
s.material_id,
s.task_uom_id,
im_material_name_from_id(s.material_id) as material_name,
s.uom_id,
c_type.category as task_type,
c_uom.category as task_uom,
s.company_id,
......@@ -53,11 +56,11 @@ select
p.project_name,
p.project_path,
p.project_path as project_short_name,
p.company_project_nr
p.project_nr
from
($task_sum_inner_sql) s
LEFT JOIN
im_categories c_uom ON s.task_uom_id=c_uom.category_id
im_categories c_uom ON s.uom_id=c_uom.category_id
LEFT JOIN
im_categories c_type ON s.task_type_id=c_type.category_id
LEFT JOIN
......
......@@ -7,4 +7,181 @@
<property name="context">@context_bar@</property>
<property name="main_navbar_label">finance</property>
@page_body;noquote@
\ No newline at end of file
<%= [im_costs_navbar "none" "/intranet/invoicing/index" "" "" [list]] %>
<form action=new-4 method=POST>
<%= [export_form_vars customer_id provider_id invoice_id cost_status_id return_url] %>
@include_task_html;noquote@
<!-- Invoice Data and Receipient Tables -->
<table cellpadding=0 cellspacing=0 bordercolor=#6699CC border=0 width=100%>
<tr valign=top>
<td>
<table border=0 cellPadding=0 cellspacing=2>
<!-- Invoice Data -->
<tr>
<td align=middle class=rowtitle colspan=2>
#intranet-timesheet2-invoices.Invoice_Data#
</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Invoice_nr#:</td>
<td class=rowodd>
<input type=text name=invoice_nr size=15 value='@invoice_nr@'>
</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Invoice_date#:</td>
<td class=roweven>
<input type=text name=invoice_date size=15 value='@invoice_date@'>
</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Type#</td>
<td class=rowodd>
<%= [im_cost_type_select cost_type_id $cost_type_id [im_cost_type_company_doc]] %>
</td>
</tr>
<if @cost_type_id@ eq @cost_type_invoice@>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Payment_terms#</td>
<td class=roweven>
<input type=text name=payment_days size=5 value='@payment_days@'>
days date of invoice</td>
</tr>
<tr>
<td class=rowodd>
#intranet-timesheet2-invoices.Payment_Method#
</td>
<td class=rowodd>
[im_invoice_payment_method_select payment_method_id $payment_method_id]
</td>
</tr>\n"
</if>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Invoice_template#:</td>
<td class=roweven>
<%= [im_cost_template_select template_id $template_id] %>
</td>
</tr>
</table>
</td>
<td></td>
<td align=right>
<table border=0 cellspacing=2 cellpadding=0 >
<tr>
<td align=center valign=top class=rowtitle colspan=2>
#intranet-timesheet2-invoices.Recipient#
</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Company_name#</td>
<td class=rowodd>
<A href=/intranet/companies/view?company_id=@company_id@>@company_name@</A>
</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.VAT#</td>
<td class=roweven>@vat_number@</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Accounting_Contact#</td>
<td class=rowodd>
<A href=/intranet/users/view?user_id=@accounting_contact_id@>@company_contact_name@</A>
</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Adress#</td>
<td class=roweven>@address_line1@ <br> @address_line2@</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Zip#</td>
<td class=rowodd>@address_postal_code@</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Country#</td>
<td class=roweven>@country_name@</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Phone#</td>
<td class=rowodd>@phone@</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Fax#</td>
<td class=roweven>@fax@</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Email#</td>
<td class=rowodd>@company_contact_email@</td>
</tr>
</table>
</tr>
</table>
<!-- the list of tasks (invoicable items) -->
<table cellpadding=2 cellspacing=2 border=0 width='100%'>
@task_table;noquote@
</table>
<!-- the list of task sums, distinguised by type and UOM -->
<table width=100%>
<tr>
<td align=right><table border=0 cellspacing=2 cellpadding=1>
@task_sum_html;noquote@
<!-- grand_total -->
<tr>
<td>
</td>
<td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<tr>
<td>#intranet-timesheet2-invoices.VAT#</td>
<td><input type=text name=vat value='@vat@' size=4> % &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<tr>
<td>#intranet-timesheet2-invoices.TAX#</td>
<td><input type=text name=tax value='@tax@' size=4> % &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp; </td>
<td colspan=6 align=right>
<input type=submit name=submit value='@button_text@'>
</td>
</tr>
</td>
</tr>
</table>
</form>
<!-- the list of reference prices -->
<table>
@reference_price_html;noquote@
</table>
This diff is collapsed.
......@@ -254,13 +254,11 @@ select
p.project_name,
p.project_nr,
p.project_path,
p.final_company,
p.project_lead_id,
p.company_id,
c.company_name,
p.project_status_id,
im_name_from_user_id(p.project_lead_id) as lead_name,
im_category_from_id(p.subject_area_id) as subject_area,
im_category_from_id(p.project_type_id) as project_type,
im_category_from_id(p.project_status_id) as project_status,
im_proj_url_from_type(p.project_id, 'website') as url,
......
......@@ -57,20 +57,7 @@ from im_categories
where category_type = 'Intranet Project Type'
"]
set task_type_options [linsert $task_type_options 0 [list "" ""]]
set language_options [db_list_of_lists uom_options "
select category, category_id
from im_categories
where category_type = 'Intranet Translation Language'
"]
set language_options [linsert $language_options 0 [list "" ""]]
set material_options [db_list_of_lists uom_options "
select category, category_id
from im_categories
where category_type = 'Intranet Translation Subject Area'
"]
set material_options [linsert $material_options 0 [list "" ""]]
set material_options [im_material_options -include_empty 1]
set include_empty 0
set currency_options [im_currency_options $include_empty]
......@@ -82,7 +69,7 @@ ad_form \
-mode $form_mode \
-export {next_url user_id return_url} \
-form {
price_id:key(im_trans_prices_seq)
price_id:key(im_timesheet_prices_seq)
{company_id:text(hidden)}
{uom_id:text(select) {label "[_ intranet-timesheet2-invoices.Unit_of_Measure]"} {options $uom_options} }
{task_type_id:text(select),optional {label "[_ intranet-timesheet2-invoices.Task_Type]"} {options $task_type_options} }
......@@ -98,13 +85,13 @@ ad_form -extend -name price -on_request {
} -select_query {
select p.*
from im_trans_prices p
from im_timesheet_prices p
where p.price_id = :price_id
} -new_data {
db_dml price_insert "
insert into im_trans_prices (
insert into im_timesheet_prices (
price_id,
uom_id,
company_id,
......
......@@ -51,13 +51,13 @@ if {"" != $del} {
if {0 == [llength $price_list]} { ad_returnredirect $return_url }
db_dml delete_prices "
delete from im_timesheet2-_prices
delete from im_timesheet_prices
where price_id in ([join $price_list ","])
"
ad_returnredirect $return_url
return
}
ad_return_complaint 1 "<li>[_ intranet-timesheet2--invoices.lt_Unknown_action_for_pr]"
ad_return_complaint 1 "<li>[_ intranet-timesheet2-invoices.lt_Unknown_action_for_pr]"
return
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