Commit 29308060 authored by Frank Bergmann's avatar Frank Bergmann

- Modified invoices:

	- Disabling "tax" field if not desired
	- Implemented material_id in im_invoice_lines
parent d72169c6
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</table> </table>
<form action=new-3 method=POST> <form action=new-3 method=POST>
<%= [export_form_vars company_id invoice_currency target_cost_type_id return_url select_project start_date end_date] %> <%= [export_form_vars company_id invoice_currency cost_center_id target_cost_type_id return_url select_project start_date end_date] %>
<table cellpadding=1 cellspacing=1 border=0> <table cellpadding=1 cellspacing=1 border=0>
@task_table_rows;noquote@ @task_table_rows;noquote@
......
...@@ -19,9 +19,10 @@ ad_page_contract { ...@@ -19,9 +19,10 @@ ad_page_contract {
{ select_project:multiple } { select_project:multiple }
invoice_currency invoice_currency
target_cost_type_id:integer target_cost_type_id:integer
{ return_url ""} { cost_center_id ""}
{ start_date "" } { start_date "" }
{ end_date "" } { end_date "" }
{ return_url ""}
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
...@@ -31,7 +32,7 @@ ad_page_contract { ...@@ -31,7 +32,7 @@ ad_page_contract {
# User id already verified by filters # User id already verified by filters
set user_id [ad_maybe_redirect_for_registration] set user_id [ad_maybe_redirect_for_registration]
set current_user_id $user_id set current_user_id $user_id
set current_url [im_url_with_query]
set page_focus "im_header_form.keywords" set page_focus "im_header_form.keywords"
set view_name "invoice_tasks" set view_name "invoice_tasks"
set page_title "New Timesheet Invoice" set page_title "New Timesheet Invoice"
...@@ -46,6 +47,30 @@ if {![im_permission $user_id add_invoices]} { ...@@ -46,6 +47,30 @@ if {![im_permission $user_id add_invoices]} {
<li>[_ intranet-timesheet2-invoices.lt_You_dont_have_suffici]" <li>[_ intranet-timesheet2-invoices.lt_You_dont_have_suffici]"
} }
# Do we need the cost_center_id for creating a new invoice?
# This is necessary if the invoice_nr depends on the cost_center_id (profit center).
set cost_center_required_p [parameter::get_from_package_key -package_key "intranet-invoices" -parameter "NewInvoiceRequiresCostCenterP" -default 0]
set cost_center_required_p 1
if {$cost_center_required_p && ($cost_center_id == "" || $cost_center_id == 0)} {
ad_returnredirect [export_vars -base "/intranet-invoices/new-cost-center-select" {
{pass_through_variables {cost_type_id customer_id provider_id project_id invoice_currency create_invoice_from_template select_project source_cost_type_id target_cost_type_id start_date end_date}}
select_project
cost_type_id
source_cost_type_id
target_cost_type_id
customer_id
provider_id
project_id
invoice_currency
cost_center_id
start_date
end_date
create_invoice_from_template
{return_url $current_url}
}]
}
set target_cost_type [im_category_from_id $target_cost_type_id] set target_cost_type [im_category_from_id $target_cost_type_id]
set allowed_cost_type [im_cost_type_write_permissions $current_user_id] set allowed_cost_type [im_cost_type_write_permissions $current_user_id]
......
...@@ -142,8 +142,13 @@ ...@@ -142,8 +142,13 @@
<!-- grand_total --> <!-- grand_total -->
<tr> <tr>
<td> <td></td>
</td> <if @material_enabled_p@>
<td></td>
</if>
<if @project_type_enabled_p@>
<td></td>
</if>
<td colspan=4 align=right> <td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0> <table border=0 cellspacing=1 cellpadding=0>
<tr> <tr>
...@@ -153,9 +158,17 @@ ...@@ -153,9 +158,17 @@
</table> </table>
</td> </td>
</tr> </tr>
<if @tax_enabled_p@>
<tr> <tr>
<td> <td></td>
</td> <if @material_enabled_p@>
<td></td>
</if>
<if @project_type_enabled_p@>
<td></td>
</if>
<td colspan=4 align=right> <td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0> <table border=0 cellspacing=1 cellpadding=0>
<tr> <tr>
...@@ -165,6 +178,11 @@ ...@@ -165,6 +178,11 @@
</table> </table>
</td> </td>
</tr> </tr>
</if>
<else>
<input type=hidden name=tax value='@default_tax@'>
</else>
<tr> <tr>
<td>&nbsp; </td> <td>&nbsp; </td>
<td colspan=6 align=right> <td colspan=6 align=right>
......
...@@ -72,6 +72,7 @@ if {[lsearch -exact $allowed_cost_type $target_cost_type_id] == -1} { ...@@ -72,6 +72,7 @@ if {[lsearch -exact $allowed_cost_type $target_cost_type_id] == -1} {
ad_script_abort ad_script_abort
} }
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Sub-Navbar # Sub-Navbar
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
...@@ -171,7 +172,7 @@ set page_title [lang::message::lookup "" intranet-timesheet2-invoices.New_$targe ...@@ -171,7 +172,7 @@ set page_title [lang::message::lookup "" intranet-timesheet2-invoices.New_$targe
set context_bar [im_context_bar [list /intranet/invoices/ "[_ intranet-timesheet2-invoices.Invoices]"] $page_title] set context_bar [im_context_bar [list /intranet/invoices/ "[_ intranet-timesheet2-invoices.Invoices]"] $page_title]
set invoice_id [im_new_object_id] set invoice_id [im_new_object_id]
set invoice_nr [im_next_invoice_nr -cost_type_id $target_cost_type_id] set invoice_nr [im_next_invoice_nr -cost_type_id $target_cost_type_id -cost_center_id $cost_center_id]
set invoice_date $todays_date set invoice_date $todays_date
set provider_id [im_company_internal] set provider_id [im_company_internal]
set customer_id $company_id set customer_id $company_id
...@@ -185,6 +186,13 @@ set default_payment_method_id "" ...@@ -185,6 +186,13 @@ set default_payment_method_id ""
set default_template_id "" set default_template_id ""
set default_payment_days [ad_parameter -package_id [im_package_cost_id] "DefaultCompanyInvoicePaymentDays" "" 30] set default_payment_days [ad_parameter -package_id [im_package_cost_id] "DefaultCompanyInvoicePaymentDays" "" 30]
# Should we show a "Material" field for invoice lines?
set material_enabled_p [ad_parameter -package_id [im_package_invoices_id] "ShowInvoiceItemMaterialFieldP" "" 0]
set project_type_enabled_p [ad_parameter -package_id [im_package_invoices_id] "ShowInvoiceItemProjectTypeFieldP" "" 1]
# Should we show the "Tax" field?
set tax_enabled_p [ad_parameter -package_id [im_package_invoices_id] "EnabledInvoiceTaxFieldP" "" 1]
if {[info exists customer_id]} { if {[info exists customer_id]} {
db_0or1row customer_info " db_0or1row customer_info "
select default_vat, select default_vat,
...@@ -218,6 +226,14 @@ set task_sum_html " ...@@ -218,6 +226,14 @@ set task_sum_html "
<tr align=center> <tr align=center>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Order]</td> <td class=rowtitle>[_ intranet-timesheet2-invoices.Order]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Description]</td> <td class=rowtitle>[_ intranet-timesheet2-invoices.Description]</td>
"
if {$material_enabled_p} {
append task_sum_html "<td class=rowtitle>[lang::message::lookup "" intranet-invoices.Material "Material"]</td>"
}
if {$project_type_enabled_p} {
append task_sum_html "<td class=rowtitle>[lang::message::lookup "" intranet-invoices.Type "Type"]</td>"
}
append task_sum_html "
<td class=rowtitle>[_ intranet-timesheet2-invoices.Units]</td> <td class=rowtitle>[_ intranet-timesheet2-invoices.Units]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.UOM]</td> <td class=rowtitle>[_ intranet-timesheet2-invoices.UOM]</td>
<td class=rowtitle>[_ intranet-timesheet2-invoices.Rate]</td> <td class=rowtitle>[_ intranet-timesheet2-invoices.Rate]</td>
...@@ -521,8 +537,23 @@ order by ...@@ -521,8 +537,23 @@ order by
<input type=text name=item_sort_order.$ctr size=2 value='$ctr'> <input type=text name=item_sort_order.$ctr size=2 value='$ctr'>
</td> </td>
<td> <td>
<input type=text name=item_name.$ctr size=40 value='$task_name'> <input type=text name=item_name.$ctr size=40 value='[ns_quotehtml $task_name]'>
</td> </td>
"
if {$material_enabled_p} {
append task_sum_html "<td>[im_material_select item_material_id.$ctr $material_id]</td>"
} else {
append task_sum_html "<input type=hidden name=item_material_id.$ctr value='$material_id'>"
}
if {$project_type_enabled_p} {
append task_sum_html "<td>[im_category_select "Intranet Project Type" item_type_id.$ctr $task_type_id]</td>"
} else {
append task_sum_html "<input type=hidden name=item_type_id.$ctr value='$task_type_id'>"
}
append task_sum_html "
<td align=right> <td align=right>
<input type=text name=item_units.$ctr size=4 value='$task_sum'> <input type=text name=item_units.$ctr size=4 value='$task_sum'>
</td> </td>
...@@ -537,7 +568,7 @@ order by ...@@ -537,7 +568,7 @@ order by
</td> </td>
</tr> </tr>
<input type=hidden name=item_project_id.$ctr value='$project_id'> <input type=hidden name=item_project_id.$ctr value='$project_id'>
<input type=hidden name=item_type_id.$ctr value='$task_type_id'>\n" "
incr ctr incr ctr
} }
......
...@@ -38,6 +38,7 @@ ad_page_contract { ...@@ -38,6 +38,7 @@ ad_page_contract {
item_units:float,array item_units:float,array
item_uom_id:integer,array item_uom_id:integer,array
item_type_id:integer,array item_type_id:integer,array
item_material_id:integer,array
item_project_id:integer,array item_project_id:integer,array
item_rate:float,array item_rate:float,array
item_currency:array item_currency:array
...@@ -195,6 +196,7 @@ foreach nr $item_list { ...@@ -195,6 +196,7 @@ foreach nr $item_list {
set units $item_units($nr) set units $item_units($nr)
set uom_id $item_uom_id($nr) set uom_id $item_uom_id($nr)
set type_id $item_type_id($nr) set type_id $item_type_id($nr)
set material_id $item_material_id($nr)
set project_id $item_project_id($nr) set project_id $item_project_id($nr)
set rate $item_rate($nr) set rate $item_rate($nr)
set currency $item_currency($nr) set currency $item_currency($nr)
...@@ -211,6 +213,7 @@ foreach nr $item_list { ...@@ -211,6 +213,7 @@ foreach nr $item_list {
item_units, item_uom_id, item_units, item_uom_id,
price_per_unit, currency, price_per_unit, currency,
sort_order, item_type_id, sort_order, item_type_id,
item_material_id,
item_status_id, description item_status_id, description
) VALUES ( ) VALUES (
:item_id, :name, :item_id, :name,
...@@ -218,6 +221,7 @@ foreach nr $item_list { ...@@ -218,6 +221,7 @@ foreach nr $item_list {
:units, :uom_id, :units, :uom_id,
:rate, :currency, :rate, :currency,
:sort_order, :type_id, :sort_order, :type_id,
:material_id,
null, '' null, ''
)" )"
......
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