Commit 566d9ab0 authored by cosine's avatar cosine

- cosine massive update allowing for sub-types of financial documents

parent 28187494
......@@ -37,7 +37,7 @@ set html [im_ad_hoc_query -format html "
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3702 and
tc.cost_type_id in (select im_sub_categories(3702)) and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as quotes,
......@@ -49,7 +49,7 @@ set html [im_ad_hoc_query -format html "
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3700 and
tc.cost_type_id in (select im_sub_categories(3700)) and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as invoices,
......@@ -61,7 +61,7 @@ set html [im_ad_hoc_query -format html "
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3706 and
tc.cost_type_id n (select im_sub_categories(3706)) and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as pos,
......@@ -73,7 +73,7 @@ set html [im_ad_hoc_query -format html "
where tii.invoice_id = tc.cost_id and
tii.item_outline_number = i.item_outline_number and
tii.item_uom_id = i.item_uom_id and
tc.cost_type_id = 3704 and
tc.cost_type_id in (select im_sub_categories(3704)) and
tc.project_id = p.project_id and
p.tree_sortkey between i.tree_sortkey and tree_right(i.tree_sortkey)
) as bills,
......
......@@ -137,7 +137,6 @@ ad_proc -public im_next_invoice_nr {
To deal with this situation, the calling procedure has to double check
before confirming the invoice.
} {
# ----------------------------------------------------
# Get some parameters that influence the counters:
......@@ -174,8 +173,10 @@ ad_proc -public im_next_invoice_nr {
3706 { set prefix "P" }
3718 { set prefix "T" }
3720 { set prefix "E" }
3720 { set prefix "R" }
3724 { set prefix "D" }
3730 { set prefix "II" }
3732 { set prefix "IQ" }
3734 { set prefix "R" }
default { set prefix "" }
}
}
......
......@@ -356,10 +356,10 @@ if {$letter eq "ALL"} {
set new_document_menu ""
set parent_menu_label ""
if {$cost_type_id == [im_cost_type_company_doc]} {
if {[im_category_is_a [$cost_type_id [im_cost_type_company_doc]]} {
set parent_menu_label "invoices_customers"
set parent_menu_sql "'invoices_customers'"
} elseif {$cost_type_id == [im_cost_type_provider_doc]} {
} elseif {[im_category_is_a $cost_type_id [im_cost_type_provider_doc]]} {
set parent_menu_label "invoices_providers"
set parent_menu_sql "'invoices_providers'"
} else {
......
......@@ -59,12 +59,13 @@ set outline_number_exists_p [im_column_exists im_invoice_items item_outline_numb
# Determine whether it's an Invoice or a Bill
# ---------------------------------------------------------------
if {"" eq $cost_type_id} { ad_return_complaint 1 "You need to specify the cost type" }
# Invoices and Quotes have a "Company" fields.
set invoice_or_quote_p [expr $cost_type_id == [im_cost_type_invoice] || $cost_type_id == [im_cost_type_quote]]
set invoice_or_quote_p [expr [im_category_is_a $cost_type_id [im_cost_type_invoice]] || [im_category_is_a $cost_type_id [im_cost_type_quote]]]
ns_log Notice "intranet-invoices/new-2: invoice_or_quote_p=$invoice_or_quote_p"
# Invoices and Bills have a "Payment Terms" field.
set invoice_or_bill_p [expr $cost_type_id == [im_cost_type_invoice] || $cost_type_id == [im_cost_type_bill]]
set invoice_or_bill_p [expr [im_category_is_a $cost_type_id [im_cost_type_invoice]] || [im_category_is_a $cost_type_id [im_cost_type_bill]]]
ns_log Notice "intranet-invoices/new-2: invoice_or_bill_p=$invoice_or_bill_p"
if {$invoice_or_quote_p} {
......
......@@ -159,7 +159,7 @@ if {"" != $project_id} {
# In a project, we may have POs for multiple providers...
if {"" != $company_id && "" == $project_id} {
if {$source_cost_type_id == [im_cost_type_invoice] || $source_cost_type_id == [im_cost_type_quote] || $source_cost_type_id == [im_cost_type_delivery_note] || $source_cost_type_id == [im_cost_type_interco_invoice] || $source_cost_type_id == [im_cost_type_interco_quote]} {
if {[im_category_is_a $source_cost_type_id [im_cost_type_invoice]] || [im_category_is_a $source_cost_type_id [im_cost_type_quote]] || [im_category_is_a $source_cost_type_id [im_cost_type_delivery_note]] || [im_category_is_a $source_cost_type_id [im_cost_type_interco_invoice]] || [im_category_is_a $source_cost_type_id [im_cost_type_interco_quote]]} {
lappend criteria "i.customer_id = :company_id"
} else {
lappend criteria "i.provider_id = :company_id"
......@@ -213,14 +213,14 @@ from
and m.member_id = :user_id
and p.privilege = h.privilege
and p.grantee_id = m.party_id
and ct.cost_type_id = :source_cost_type_id
and ct.cost_type_id in (select * from im_sub_categories(:source_cost_type_id))
) readable_ccs
where
i.invoice_id = o.object_id
and i.invoice_id = ci.cost_id
and i.customer_id = c.company_id
and i.provider_id = p.company_id
and ci.cost_type_id = :source_cost_type_id
and ci.cost_type_id in (select * from im_sub_categories(:source_cost_type_id))
and ci.cost_center_id = readable_ccs.cost_center_id
$project_where_clause
$order_by_clause
......
......@@ -176,7 +176,7 @@ if {[im_column_exists im_companies default_tax]} {
}
if {$target_cost_type_id == [im_cost_type_invoice]} {
if {[im_category_is_a $target_cost_type_id [im_cost_type_invoice]]} {
if {"" != $default_vat} { set vat $default_vat }
if {"" != $default_tax} { set tax $default_tax }
if {"" != $default_payment_days} { set payment_days $default_payment_days }
......
......@@ -334,13 +334,10 @@ set payment_method_select [im_invoice_payment_method_select payment_method_id $p
set template_select [im_cost_template_select template_id $template_id]
set status_select [im_cost_status_select cost_status_id $cost_status_id]
set type_select [im_cost_type_select cost_type_id $cost_type_id 0 "financial_doc"]
if {"" != $cost_type_id} {
set type_select "
<input type=hidden name=cost_type_id value=$cost_type_id>
$cost_type
"
}
set super_type_id 0
if {"" != $cost_type_id} { set super_type_id $cost_type_id }
set type_select [im_cost_type_select cost_type_id $cost_type_id $super_type_id "financial_doc"]
if {0 && "" != $cost_type_id} { set type_select "<input type=hidden name=cost_type_id value=$cost_type_id>$cost_type" }
set customer_select [im_company_select -tag_attributes {onchange "ajaxFunction();" onkeyup "ajaxFunction();"} customer_id $customer_id "" "CustOrIntl"]
set provider_select [im_company_select -tag_attributes {onchange "ajaxFunction();" onkeyup "ajaxFunction();"} provider_id $provider_id "" "Provider"]
......
......@@ -97,7 +97,7 @@ where i.invoice_id = ci.cost_id
and i.invoice_id = :invoice_id
"
if {$cost_type_id == [im_cost_type_quote] || $cost_type_id == [im_cost_type_invoice]} {
if {[im_category_is_a $cost_type_id [im_cost_type_quote]] || [im_category_is_a $cost_type_id [im_cost_type_invoice]]} {
set company_id $customer_id
} else {
set company_id $provider_id
......
......@@ -65,7 +65,7 @@
<if @admin@>
<if @cost_type_id@ eq @quote_cost_type_id@>
<if @document_quote_p@ eq "1">
<li>
<% set blurb [lang::message::lookup $locale intranet-invoices.Generate_Invoice_from_Quote "Generate Invoice from Quote"] %>
<% set source_invoice_id $invoice_id %>
......@@ -80,7 +80,7 @@
<A HREF="/intranet-invoices/new-copy?@gen_vars@">@blurb@</A>
</if>
<if @cost_type_id@ eq @delnote_cost_type_id@>
<if @document_delnote_p@ eq "1">
<li>
<% set blurb [lang::message::lookup $locale intranet-invoices.Generate_Invoice_from_DelNote "Generate Invoice from Delivery Note"] %>
<% set source_invoice_id $invoice_id %>
......@@ -90,7 +90,7 @@
</if>
<if @cost_type_id@ eq @po_cost_type_id@>
<if @document_po_p@ eq "1">
<li>
<% set blurb [lang::message::lookup $locale intranet-invoices.Generate_Provider_Bill_from_Purchase_Order "Generate Provider Bill from Purchase Order"] %>
<% set source_invoice_id $invoice_id %>
......@@ -99,7 +99,7 @@
<A HREF="/intranet-invoices/new-copy?@gen_vars@">@blurb@</A>
</if>
<if @cost_type_id@ eq @invoice_cost_type_id@>
<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"] %>
......
......@@ -73,9 +73,17 @@ set bgcolor(0) "class=invoiceroweven"
set bgcolor(1) "class=invoicerowodd"
set required_field "<font color=red size=+1><B>*</B></font>"
set cost_type_id [db_string cost_type_id "select cost_type_id from im_costs where cost_id = :invoice_id" -default 0]
set document_quote_p [im_category_is_a $cost_type_id [im_cost_type_quote]]
set document_invoice_p [im_category_is_a $cost_type_id [im_cost_type_invoice]]
set document_bill_p [im_category_is_a $cost_type_id [im_cost_type_bill]]
set document_po_p [im_category_is_a $cost_type_id [im_cost_type_po]]
set document_delnote_p [im_category_is_a $cost_type_id [im_cost_type_delivery_note]]
set document_customer_doc_p [im_category_is_a $cost_type_id [im_cost_type_customer_doc]]
set document_provider_doc_p [im_category_is_a $cost_type_id [im_cost_type_provider_doc]]
# ---------------------------------------------------------------
# Redirect to other page if this is not an invoice
......@@ -85,18 +93,7 @@ set invoice_p [db_string invoice_p "select count(*) from im_invoices where invoi
if {!$invoice_p} {
# This tends to happen in error situations.
# First check if this is really a financial document suitable to be displayed by this page:
# 3700 | Customer Invoice
# 3702 | Quote
# 3704 | Provider Bill
# 3706 | Purchase Order
# 3708 | Customer Documents
# 3710 | Provider Documents
# 3724 | Delivery Note
# 3730 | InterCo Invoice
# 3732 | InterCo Quote
# 3734 | Provider Receipt
set findoc_type_ids {3700 3702 3704 3706 3708 3710 3724 3730 3732 3734}
if {[lsearch $findoc_type_ids $cost_type_id] < 0} {
if {$cost_type_id ni [im_cost_financial_document_type_ids]} {
# This is a cost item different from a financial document - redirect
ad_returnredirect [export_vars -base "/intranet-cost/costs/new" {{form_mode display} {cost_id $invoice_id}}]
} else {
......@@ -147,7 +144,7 @@ set show_import_from_csv $show_outline_number
# 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
set show_company_project_nr [im_parameter -package_id [im_package_invoices_id] "ShowInvoiceCustomerProjectNr" "" 1]
if {![im_category_is_a $cost_type_id [im_cost_type_customer_doc]]} {
if {!$document_customer_doc_p} {
set show_company_project_nr 0
set invoice_or_quote_p 0
} else {
......@@ -197,16 +194,16 @@ set invoice_cost_type_id [im_cost_type_invoice]
set bill_cost_type_id [im_cost_type_bill]
# Invoices and Bills have a "Payment Terms" field.
set invoice_or_bill_p [expr $cost_type_id == [im_cost_type_invoice] || $cost_type_id == [im_cost_type_bill]]
set invoice_or_bill_p [expr $document_invoice_p || $document_bill_p]
# CostType for "Generate Invoice from Quote" or "Generate Bill from PO"
set target_cost_type_id ""
set generation_blurb ""
if {$cost_type_id == [im_cost_type_quote]} {
if {$document_quote_p} {
set target_cost_type_id [im_cost_type_invoice]
set generation_blurb "[lang::message::lookup $locale intranet-invoices.lt_Generate_Invoice_from]"
}
if {$cost_type_id == [im_cost_type_po]} {
if {$document_po_p} {
set target_cost_type_id [im_cost_type_bill]
set generation_blurb "[lang::message::lookup $locale intranet-invoices.lt_Generate_Provider_Bil]"
}
......@@ -229,7 +226,7 @@ if {!$invoice_or_quote_p} { set company_project_nr_exists 0}
set cost_object_type [db_string cost_object_type "select object_type from acs_objects where object_id = :invoice_id" -default ""]
set timesheet_report_enabled_p 0
if {"im_timesheet_invoice" == $cost_object_type} {
if {$cost_type_id == [im_cost_type_invoice]} {
if {$document_invoice_p} {
set timesheet_report_enabled_p 1
}
}
......@@ -1055,7 +1052,7 @@ set note_html "
"
set terms_html ""
if {$cost_type_id == [im_cost_type_invoice] || $cost_type_id == [im_cost_type_bill]} {
if {$document_invoice_p || $document_bill_p} {
set terms_html [concat $payment_terms_html $payment_method_html]
}
append terms_html "$canned_note_html $note_html"
......@@ -1294,7 +1291,7 @@ if {[llength $related_projects] != 1} {
# correct problem created by -r 1.33 view.adp
# ---------------------------------------------------------------------
if {$cost_type_id == [im_cost_type_po]} {
if {$document_po_p} {
set customer_id $comp_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