Commit 1bf9d91c authored by Frank Bergmann's avatar Frank Bergmann

- fixed issue for invoices with no im_invoice.invoice_office_id value,

  using the company's main office instead
parent 8e028469
......@@ -14,7 +14,7 @@ ad_page_contract {
@author frank.bergmann@project-open.com
} {
{ invoice_id:integer 90763 }
{ invoice_id:integer "" }
}
# ---------------------------------------------------------------
......@@ -22,9 +22,10 @@ ad_page_contract {
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set today [db_string today "select to_char(now(), 'YYYY-MM-DD')"]
# ---------------------------------------------------------------
# Get information about the financial document ("invoice")
# ---------------------------------------------------------------
......@@ -32,16 +33,9 @@ set today [db_string today "select to_char(now(), 'YYYY-MM-DD')"]
if {![db_0or1row project_info "
select c.*,
i.*,
coalesce(i.invoice_office_id, cust.main_office_id) as cust_office_id,
o.creation_date as issue_date,
cust.company_name as customer_name,
ocust.address_line1 as customer_address_line1,
ocust.address_line2 as customer_address_line2,
ocust.address_city as customer_address_city,
ocust.address_state as customer_address_state,
ocust.address_postal_code as customer_address_postal_code,
ocust.address_country_code as customer_address_country_code,
prov.company_name as provider_name,
oprov.address_line1 as provider_address_line1,
oprov.address_line2 as provider_address_line2,
......@@ -64,7 +58,6 @@ if {![db_0or1row project_info "
acs_objects o,
im_companies cust,
im_companies prov,
im_offices ocust,
im_offices oprov,
users_contact cust_contact,
users_contact prov_contact
......@@ -74,15 +67,33 @@ if {![db_0or1row project_info "
and i.invoice_id = o.object_id
and c.customer_id = cust.company_id
and c.provider_id = prov.company_id
and ocust.office_id = i.invoice_office_id
and oprov.office_id = prov.main_office_id
and i.company_contact_id = cust_contact.user_id
and prov.accounting_contact_id = prov_contact.user_id
"]} {
ad_return_complaint 1 [lang::message::lookup "" intranet-ubl.Financial_Document_Not_Found "Didn't find financial document \#%project_id%"]
ad_return_complaint 1 [lang::message::lookup "" intranet-ubl.Financial_Document_Not_Found "Didn't find financial document \#%invoice_id%"]
return
}
if {![db_0or1row cust_office_info "
select
ocust.address_line1 as customer_address_line1,
ocust.address_line2 as customer_address_line2,
ocust.address_city as customer_address_city,
ocust.address_state as customer_address_state,
ocust.address_postal_code as customer_address_postal_code,
ocust.address_country_code as customer_address_country_code
from
im_offices ocust
where
ocust.office_id = :cust_office_id
"]} {
ad_return_complaint 1 [lang::message::lookup "" intranet-ubl.Office_Not_Found "Didn't find customer's office information \#%cust_office_id%"]
return
}
set invoice_url "/intranet-invoices/view?invoice_id=$invoice_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