Commit 6359602e authored by Frank Bergmann's avatar Frank Bergmann

Added button to create Cancellation Invoice

parent 0bf4dec7
......@@ -796,7 +796,7 @@ begin
'intranet-invoices', -- package_name
'invoices_customers_new_invoice_from_quote', -- label
'New Customer Invoice from Quote', -- name
'/intranet-invoices/new-copy?target_cost_type_id=3700\&source_cost_type_id=3702',
'/intranet-invoices/new-copy?target_cost_type_id=3700&source_cost_type_id=3702',
320, -- sort_order
v_invoices_new_menu, -- parent_menu_id
null -- visible_tcl
......@@ -1074,7 +1074,7 @@ begin
'intranet-invoices', -- package_name
'invoices_customers_new_invoice_from_delnote', -- label
'New Customer Invoice from Delivery Note', -- name
'/intranet-invoices/new-copy?target_cost_type_id=3700\&source_cost_type_id=3724',
'/intranet-invoices/new-copy?target_cost_type_id=3700&source_cost_type_id=3724',
325, -- sort_order
v_invoices_customers, -- parent_menu_id
null -- visible_tcl
......@@ -1239,7 +1239,7 @@ begin
'intranet-invoices', -- package_name
'invoices_customers_new_invoice_from_delnote', -- label
'New Customer Invoice from Delivery Note', -- name
'/intranet-invoices/new-copy?target_cost_type_id=3700\&source_cost_type_id=3724',
'/intranet-invoices/new-copy?target_cost_type_id=3700&source_cost_type_id=3724',
325, -- sort_order
v_invoices_customers, -- parent_menu_id
null -- visible_tcl
......
......@@ -191,13 +191,12 @@ ad_proc -public im_next_invoice_nr {
3730 { set prefix "II" }
3732 { set prefix "IQ" }
3734 { set prefix "R" }
3737 { set prefix "T" }
3738 { set prefix "L" }
3739 { set prefix "CR" }
3740 { set prefix "DP" }
3741 { set prefix "CE" }
3752 { set prefix "C" }
default { set prefix "" }
}
}
......
......@@ -16,10 +16,11 @@ ad_page_contract {
{ source_invoice_id:integer,multiple "" }
source_cost_type_id:integer,optional
target_cost_type_id:integer
{customer_id:integer ""}
{provider_id:integer ""}
{project_id:integer ""}
{zero_quantities_p 0}
{ customer_id:integer ""}
{ provider_id:integer ""}
{ project_id:integer ""}
{ zero_quantities_p 0}
{ invert_quantities_p 0}
{ blurb "Copy Financial Document" }
{ return_url "/intranet-invoice/"}
}
......@@ -58,7 +59,7 @@ foreach source_id $source_invoice_id {
# we want to copy. So let's redirect and this page is going
# to refer us back to this one.
if {0 == [llength $source_invoice_id]} {
ad_returnredirect [export_vars -base new-copy-custselect { source_cost_type_id target_cost_type_id customer_id provider_id project_id zero_quantities_p blurb return_url}]
ad_returnredirect [export_vars -base new-copy-custselect { source_cost_type_id target_cost_type_id customer_id provider_id project_id zero_quantities_p invert_quantities_p blurb return_url}]
ad_script_abort
}
......@@ -271,6 +272,7 @@ db_foreach invoice_items "" {
# Special flag in order to create documents with empty amounts
if {$zero_quantities_p} { set item_units "" }
if {$invert_quantities_p} { set item_units [expr -1.0 * $item_units] }
set item_name [ns_quotehtml $item_name]
......
......@@ -135,8 +135,15 @@
<if @document_invoice_p@ eq "1">
<li>
<A HREF="/intranet-invoices/new-copy?target_cost_type_id=3700&amp;source_cost_type_id=3700&amp;source_invoice_id=<%=$invoice_id%>"><%= [lang::message::lookup "" intranet-invoices.Duplicate_Invoice "Duplicate Invoice"] %></a>
<A HREF="/intranet-invoices/new-copy?target_cost_type_id=3700&amp;source_cost_type_id=3700&amp;source_invoice_id=<%=$invoice_id%>"><%= [lang::message::lookup "" intranet-invoices.Create_Duplicate_Invoice "Create duplicate invoice"] %></a>
</li>
<if @cancellation_invoice_enabled_p@ eq "1">
<li>
<A HREF="/intranet-invoices/new-copy?target_cost_type_id=3752&amp;source_cost_type_id=3700&amp;source_invoice_id=<%=$invoice_id%>&amp;invert_quantities_p=1"><%= [lang::message::lookup "" intranet-invoices.Create_Cancellation_Invoice "Create cancellation invoice"] %></a>
</li>
</if>
</if>
</if>
......@@ -145,14 +152,14 @@
<if "adp" eq @invoice_template_type@>
<li>
<% set url [export_vars -base "/intranet-invoices/view" {invoice_id {render_template_id $invoice_template_id} {send_to_user_as "html"} return_url}] %>
<a HREF="@url@"><%= [lang::message::lookup "" intranet-invoices.Send_document_as_HTML_attachment "Send this %cost_type% as HTML attachment"] %></a>
<a HREF="@url@"><%= [lang::message::lookup "" intranet-invoices.Send_document_as_HTML_attachment "Send this %cost_type_l10n% as HTML attachment"] %></a>
</li>
</if>
<if @pdf_enabled_p@>
<li>
<% set url [export_vars -base "/intranet-invoices/view" {invoice_id {render_template_id $invoice_template_id} {send_to_user_as "pdf"} return_url}] %>
<a HREF="@url@"><%= [lang::message::lookup "" intranet-invoices.Send_document_as_PDF_attachment "Send this %cost_type% as PDF attachment"] %></a>
<a HREF="@url@"><%= [lang::message::lookup "" intranet-invoices.Send_document_as_PDF_attachment "Send this %cost_type_l10n% as PDF attachment"] %></a>
</li>
</if>
</if>
......@@ -221,7 +228,7 @@
<tr>
<td class=rowodd>#intranet-invoices.cost_type_type_1#</td>
<td class=rowodd>@cost_type@</td>
<td class=rowodd>@cost_type_l10n@</td>
</tr>
<tr>
......@@ -235,7 +242,7 @@
<td class=rowodd>@invoice_period_start_pretty@</td>
</tr>
<tr>
<td class=roweven><%= [lang::message::lookup "" intranet-timesheet2-invoices.Invoicing_Period_Start "Invoice Period End"] %></td>
<td class=roweven><%= [lang::message::lookup "" intranet-timesheet2-invoices.Invoicing_Period_End "Invoice Period End"] %></td>
<td class=roweven>@invoice_period_end_pretty@</td>
</tr>
</if>
......
......@@ -192,6 +192,7 @@ set show_leading_invoice_item_nr [im_parameter -package_id [im_package_invoices_
set show_outline_number [im_column_exists im_invoice_items item_outline_number]
set show_import_from_csv $show_outline_number
set show_promote_to_timesheet_invoice_p [im_parameter -package_id [im_package_invoices_id] "ShowPromoteInvoiceToTimesheetInvoiceP" "" 0]
set cancellation_invoice_enabled_p [db_string cancellation_p "select CASE WHEN 't' = (select enabled_p from im_categories where category_id = 3752) THEN 1 ELSE 0 END"]
# Should we show the customer's PO number in the document?
# This makes only sense in "customer documents", i.e. quotes, invoices and delivery notes
......@@ -486,7 +487,7 @@ set query "
to_date(to_char(ci.effective_date, 'YYYY-MM-DD'), 'YYYY-MM-DD') + ci.payment_days as calculated_due_date,
im_cost_center_name_from_id(ci.cost_center_id) as cost_center_name,
im_category_from_id(ci.cost_status_id) as cost_status,
im_category_from_id(ci.cost_type_id) as cost_type,
im_category_from_id(ci.cost_type_id) as cost_type_untranslated,
im_category_from_id(ci.template_id) as invoice_template,
(select object_type from acs_objects o where o.object_id = i.invoice_id) as object_type
from
......@@ -572,9 +573,10 @@ if {"im_timesheet_invoice" eq $object_type} {
# ---------------------------------------------------------------
# ToDo: Isn't this included in the Internal company query above?
set cost_type_mapped [string map {" " "_"} $cost_type_untranslated]
set cost_type_l10n [lang::message::lookup $locale intranet-invoices.$cost_type_mapped $cost_type_untranslated]
set cost_type $cost_type_l10n
set cost_type_mapped [string map {" " "_"} $cost_type]
set cost_type_l10n [lang::message::lookup $locale intranet-invoices.$cost_type_mapped $cost_type]
# Fallback for empty office_id: Main Office
if {"" == $invoice_office_id} {
......@@ -1546,3 +1548,4 @@ if {$document_po_p} {
if {"" != $err_mess} {
set err_mess [lang::message::lookup "" $err_mess "Document Nr. not available anymore, please note and verify newly assigned number"]
}
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