Commit 754157d6 authored by Frank Bergmann's avatar Frank Bergmann

- Finished importing invoices and payments

parent 8251eb0d
......@@ -137,7 +137,7 @@ is
invoice_id in integer default null,
object_type in varchar default 'im_invoice',
creation_date in date default sysdate,
creation_user in integer default null,
creation_user in integer,
creation_ip in varchar default null,
context_id in integer default null,
invoice_nr in varchar,
......@@ -170,7 +170,7 @@ is
invoice_id in integer default null,
object_type in varchar default 'im_invoice',
creation_date in date default sysdate,
creation_user in integer default null,
creation_user in integer,
creation_ip in varchar default null,
context_id in integer default null,
invoice_nr in varchar,
......@@ -358,6 +358,8 @@ create table im_invoice_items (
constraint im_invoices_items_pk
primary key,
item_name varchar(200),
-- project_id if != null is used to access project details
-- for invoice generation, such as the customer PO# etc.
project_id integer
constraint im_invoices_items_project
references im_projects,
......@@ -379,7 +381,10 @@ create table im_invoice_items (
item_status_id integer
constraint im_invoices_items_item_status
references im_categories,
description varchar(4000)
description varchar(4000),
-- Make sure we can't create duplicate entries per invoice
constraint im_invoice_items_un
unique (item_name, invoice_id, project_id, item_uom_id)
);
------------------------------------------------------
......@@ -717,7 +722,7 @@ begin
location => 'left',
sort_order => 10,
component_tcl =>
'im_invoices_project_component $project_id'
'im_invoices_project_component $user_id $project_id'
);
end;
/
......@@ -734,7 +739,7 @@ begin
location => 'left',
sort_order => 10,
component_tcl =>
'im_invoices_customer_component $customer_id'
'im_invoices_customer_component $user_id $customer_id'
);
end;
/
......
......@@ -106,25 +106,29 @@ where
}
ad_proc im_invoices_customer_component { customer_id } {
ad_proc im_invoices_customer_component { user_id customer_id } {
Returns a HTML table containing a list of invoices for a particular
customer.
} {
return [im_invoices_base_component $customer_id ""]
return [im_invoices_base_component $user_id $customer_id ""]
}
ad_proc im_invoices_project_component { project_id } {
ad_proc im_invoices_project_component { user_id project_id } {
Returns a HTML table containing a list of invoices for a particular
particular project.
} {
return [im_invoices_base_component "" $project_id]
return [im_invoices_base_component $user_id "" $project_id]
}
ad_proc im_invoices_base_component { {customer_id ""} {project_id ""} } {
ad_proc im_invoices_base_component { user_id {customer_id ""} {project_id ""} } {
Returns a HTML table containing a list of invoices for a particular
customer or a particular project.
} {
if {![im_permission $user_id view_invoices]} {
return ""
}
set bgcolor(0) " class=roweven "
set bgcolor(1) " class=rowodd "
set max_invoices 5
......@@ -250,6 +254,22 @@ order by
}
ad_proc -public im_invoice_type_select { select_name { default "" } } {
Returns an html select box named $select_name and defaulted to
$default with a list of all the invoice_types in the system
} {
return [im_category_select "Intranet Invoice Type" $select_name $default]
}
ad_proc -public im_invoice_status_select { select_name { default "" } } {
Returns an html select box named $select_name and defaulted to
$default with a list of all the invoice status_types in the system
} {
return [im_category_select "Intranet Invoice Status" $select_name $default]
}
ad_proc im_invoices_select { select_name { default "" } { status "" } { exclude_status "" } } {
Returns an html select box named $select_name and defaulted to
......
......@@ -195,15 +195,15 @@ if { ![empty_string_p $where_clause] } {
# Define extra SQL for payments
# -----------------------------------------------------------------
set payment_amount ""
set payment_currency ""
#set payment_amount ""
#set payment_currency ""
set extra_select ""
set extra_from ""
set extra_where ""
if { [db_table_exists im_payments] } {
append extra_select ", pa.payment_amount,pa.payment_currency\n"
append extra_select ", pa.payment_amount, pa.payment_currency\n"
append extra_from ",
(select
sum(amount) as payment_amount,
......
......@@ -18,6 +18,7 @@ ad_page_contract {
{ provider_id:integer 0 }
invoice_nr
invoice_date
{ invoice_status_id 602 }
{ invoice_type_id 700 }
payment_days:integer
payment_method_id:integer
......@@ -83,9 +84,9 @@ SET
tax=:tax,
invoice_status_id=:invoice_status_id,
invoice_type_id=:invoice_type_id,
last_modified=:last_modified,
last_modifying_user=:last_modifying_user,
modified_ip_address=:modified_ip_address
last_modified=sysdate,
last_modifying_user=:user_id,
modified_ip_address='[ad_conn peeraddr]'
WHERE
invoice_id=:invoice_id"
......
......@@ -52,6 +52,12 @@ set bgcolor(0) " class=roweven"
set bgcolor(1) " class=rowodd"
set required_field "<font color=red size=+1><B>*</B></font>"
# Get some categories for a new invoice
set invoice_status_created_id [db_string invoice_status "select invoice_status_id from im_invoice_status where upper(invoice_status)='CREATED'"]
set invoice_type_normal_id [db_string invoice_type "select invoice_type_id from im_invoice_type where upper(invoice_type)='NORMAL'"]
# Tricky case: Sombebody has called this page from a project
# So we need to find out the customer of the project and create
# an invoice from scratch, invoicing all project elements.
......@@ -111,15 +117,13 @@ from
im_invoice_items i
where
i.invoice_id=:invoice_id"
}
} err_msg
} err_msg
}
} else {
# ---------------------------------------------------------------
# 3. Gather invoice data
# b: if the invoice is new
# (and add a new invoice skeleton with status "In Process"
# Setup the fields for a new invoice
# ---------------------------------------------------------------
# Build the list of selected tasks ready for invoices
......@@ -131,15 +135,11 @@ where
set invoice_id [db_nextval "im_invoices_seq"]
set invoice_nr [im_next_invoice_nr]
set invoice_status_id $invoice_status_created_id
set invoice_type_id $invoice_type_normal_id
set invoice_date $todays_date
set payment_days [ad_parameter "DefaultPaymentDays" intranet 30]
set due_date [db_string get_due_date "select sysdate+:payment_days from dual"]
set invoice_status_created_id [db_string invoice_status "select category_id from im_categories where category_type='Intranet Invoice Status' and upper(category)='CREATED'"]
set invoice_status_in_process_id [db_string invoice_status "select category_id from im_categories where category_type='Intranet Invoice Status' and upper(category)='IN PROCESS'"]
set invoice_type_id [db_string invoice_type "select invoice_type_id from im_invoice_type where upper(invoice_type)='NORMAL'"]
set vat 0
set tax 0
set note ""
......@@ -210,6 +210,14 @@ set invoice_data_html "
<td class=roweven> Invoice template:</td>
<td class=roweven>[im_invoice_template_select invoice_template_id $invoice_template_id]</td>
</tr>
<tr>
<td class=rowodd> Invoice status</td>
<td class=rowodd>[im_invoice_status_select invoice_status_id $invoice_status_id]</td>
</tr>
<tr>
<td class=roweven> Invoice type</td>
<td class=roweven>[im_invoice_type_select invoice_type_id $invoice_type_id]</td>
</tr>
"
set customer_html "
......
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