Commit bdc01833 authored by cvs2svn's avatar cvs2svn

This commit was manufactured by cvs2svn to create tag 'v2-1-0-try1'.

Sprout from master 2004-08-02 09:57:55 UTC Frank Bergmann  <frank.bergmann@project-open.com> '- added new.adp, list.tcl and copy-new.adp'
Delete:
    intranet-invoices.info
    sql/oracle/intranet-invoices-create.sql
    sql/oracle/intranet-invoices-drop.sql
    sql/oracle/upgrade/upgrade-2.0.0-2.0.1.sql
    tcl/intranet-invoices-procs.tcl
    www/index.tcl
    www/invoice-action.tcl
    www/list.tcl
    www/new-2.tcl
    www/new-copy.tcl
    www/new.adp
    www/new.tcl
    www/view.tcl
parent 85fe9e38
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package key="intranet-invoices" url="http://openacs.org/repository/apm/packages/intranet-invoices" type="apm_application">
<package-name>Project/Open Invoices</package-name>
<pretty-plural>Project/Open Invoices</pretty-plural>
<initial-install-p>f</initial-install-p>
<singleton-p>t</singleton-p>
<auto-mount>intranet-invoices</auto-mount>
<version name="2.0.1" url="http://openacs.org/repository/download/apm/intranet-invoices-2.0.1.apm">
<owner url="mailto:fraber@fraber.de">Frank Bergmann</owner>
<vendor url="http://www.project-open.com/">Project/Open</vendor>
<provides url="intranet-invoices" version="2.0.1"/>
<requires url="intranet-core" version="2.0.1"/>
<callbacks>
</callbacks>
<parameters>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="InvoiceTemplatePathUnix" default="/web/intranet/filestorage/templates" description="Path for Invoicing templates"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="DefaultPaymentDays" default="30" description="DefaultPaymentDays"/>
</parameters>
</version>
</package>
This diff is collapsed.
-- /packages/intranet-invoices/sql/oracle/intranet-invoices-drop.sql
--
-- Copyright (C) 2003-2004 Project/Open
--
-- All rights reserved. Please check
-- http://www.project-open.com/license/ for details.
--
-- @author frank.bergmann@project-open.com
BEGIN
im_component_plugin.del_module(module_name => 'intranet-invoices');
im_menu.del_module(module_name => 'intranet-invoices');
END;
/
commit;
delete from acs_rels r where r.object_id_two in (select invoice_id from im_invoices);
delete from im_invoice_items;
delete from im_invoices;
delete from im_view_columns where view_id >= 30 and view_id <=39;
delete from im_views where view_id >= 30 and view_id <=39;
drop sequence im_invoices_seq;
drop sequence im_invoice_items_seq;
drop table im_invoice_items;
drop table im_invoices_audit;
drop table im_invoices;
------------------------------------------------------------------------------
-- packages/intranet-invoices/sql/oracle/upgrade-2.0.0-2.0.1.sql
--
-- @author frank.bergmann@project-open.com
-- @creation-date 2004-08-01
--
-- Simply source the create script, because it doesn't
-- delete any data and it recreates menus and views.
@../intranet-invoices-create.sql
This diff is collapsed.
# /packages/intranet-invoices/www/index.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Offers a menu to create new Invoices, Quotes, POs
and Bills
@author frank.bergmann@project-open.com
} {
{ project_id 0 }
{ customer_id 0 }
}
set user_id [ad_maybe_redirect_for_registration]
# select the "Finance" Menu
set parent_menu_sql "select menu_id from im_menus where label='invoices_new'"
set parent_menu_id [db_string parent_admin_menu $parent_menu_sql]
set menu_select_sql "
select m.*
from im_menus m
where parent_menu_id = :parent_menu_id
and acs_permission.permission_p(m.menu_id, :user_id, 'read') = 't'
order by sort_order"
# Start formatting the menu bar
set new_list_html ""
set ctr 0
db_foreach menu_select $menu_select_sql {
ns_log Notice "im_sub_navbar: menu_name='$name'"
if {$customer_id} { append url "&customer_id=$customer_id" }
if {$project_id} { append url "&project_id=$project_id" }
append new_list_html "<li><a href=\"$url\">$name</a></li>\n"
}
set page_title "New Financial Item"
set context_bar [ad_context_bar $page_title]
# /packages/intranet-invoices/www/invoice-action.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Purpose: Takes commands from the /intranet/invoices/index
page and deletes invoices where marked
@param return_url the url to return to
@param group_id group id
@author frank.bergmann@project-open.com
} {
{ return_url "/intranet-invoices/" }
del_invoice:multiple,optional
invoice_status:array,optional
submit
}
set user_id [ad_maybe_redirect_for_registration]
if {![im_permission $user_id add_invoices]} {
ad_return_complaint 1 "<li>You have insufficient privileges to see this page"
return
}
set task_status_delivered [db_string task_status_delivered "select task_status_id from im_task_status where upper(task_status)='DELIVERED'"]
set project_status_delivered [db_string project_status_delivered "select project_status_id from im_project_status where upper(project_status)='DELIVERED'"]
ns_log Notice "invoice-action: submit=$submit"
switch $submit {
"Save" {
# Save the stati for the invoices on this list
foreach invoice_id [array names invoice_status] {
set invoice_status_id $invoice_status($invoice_id)
ns_log Notice "set invoice_status($invoice_id) = $invoice_status_id"
db_dml update_invoice_status "update im_invoices set invoice_status_id=:invoice_status_id where invoice_id=:invoice_id"
}
ad_returnredirect $return_url
return
}
"Del" {
# "Del" button pressed: delete the marked invoices:
# - Mark the associated im_trans_tasks as "delivered"
# and reset their invoice_id (to be able to
# delete the invoice).
# - Delete the associated im_invoice_items
# - Delete from project-invoice-map!!!
#
set in_clause_list [list]
# Maybe the list of invoices was empty...
if {![info exists del_invoice]} {
ad_returnredirect $return_url
return
}
foreach invoice_id $del_invoice {
lappend in_clause_list $invoice_id
}
set invoice_where_list "([join $in_clause_list ","])"
set delete_invoice_items_sql "
delete from im_invoice_items i
where i.invoice_id in $invoice_where_list
"
# Reset the status of all project to "delivered" that
# were included in the invoice
set reset_projects_included_sql "
update im_projects
set project_status_id=:project_status_delivered
where project_id in (
select distinct
r.object_id_one
from
acs_rels r
where
r.object_id_two in $invoice_where_list
)
"
# Set all projects back to "delivered" that have tasks
# that were included in the invoices to delete.
set reset_projects_with_tasks_sql "
update im_projects
set project_status_id=:project_status_delivered
where project_id in (
select distinct
t.project_id
from
im_trans_tasks t
where
t.invoice_id in $invoice_where_list
)
"
# Reset the status of all invoiced tasks to delivered.
set reset_tasks_sql "
update im_trans_tasks t
set invoice_id=null
where t.invoice_id in $invoice_where_list
"
set delete_map_sql "
delete from acs_rels r
where r.object_id_two in $invoice_where_list
"
set delete_invoices_sql "
delete from im_invoices
where invoice_id in $invoice_where_list
"
db_transaction {
# Changing project state back to "delivered" and
# changing im_trans_tasks to not-invoice only for translation...
if {[db_table_exists "im_trans_tasks"]} {
db_dml reset_projects_with_tasks $reset_projects_with_tasks_sql
db_dml reset_tasks $reset_tasks_sql
}
db_dml reset_projects_included $reset_projects_included_sql
db_dml delete_invoice_items $delete_invoice_items_sql
db_dml delete_map $delete_map_sql
db_dml delete_invoices $delete_invoices_sql
}
ad_returnredirect $return_url
return
}
default {
set error "Unknown submit command: '$submit'"
ad_returnredirect "/error?error=$error"
}
}
This diff is collapsed.
# /packages/intranet-invoices/www/new-2.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Saves invoice changes and set the invoice status to "Created".<br>
Please note that there are different forms to create invoices for
example in the intranet-trans-invoicing module of the
intranet-server-hosting module.
@author frank.bergmann@project-open.com
} {
invoice_id:integer
{ customer_id:integer 0 }
{ provider_id:integer 0 }
{ project_id:integer 0 }
invoice_nr
invoice_date
{ invoice_status_id 602 }
{ invoice_type_id "[im_invoice_type_invoice]" }
payment_days:integer
{ payment_method_id:integer "[im_payment_method_undefined]" }
invoice_template_id:integer
vat
tax
item_sort_order:array
item_name:array
item_units:float,array
item_uom_id:integer,array
item_type_id:integer,array
item_project_id:integer,array
item_rate:float,array
item_currency:array
{ return_url "/intranet-invoices/" }
}
# ---------------------------------------------------------------
# Determine whether it's an Invoice or a Bill
# ---------------------------------------------------------------
# Invoices and Quotes have a "Customer" fields.
set invoice_or_quote_p [expr $invoice_type_id == [im_invoice_type_invoice] || $invoice_type_id == [im_invoice_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 $invoice_type_id == [im_invoice_type_invoice] || $invoice_type_id == [im_invoice_type_bill]]
ns_log Notice "intranet-invoices/new-2: invoice_or_bill_p=$invoice_or_bill_p"
if {$invoice_or_quote_p} {
set company_id $customer_id
} else {
set company_id $provider_id
}
# ---------------------------------------------------------------
# Defaults & Security
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
if {![im_permission $user_id add_invoices]} {
ad_return_complaint 1 "<li>You don't have sufficient privileges to see this page."
return
}
# Invoices and Bills need a payment method, quotes and POs not
if {$invoice_or_bill_p && !$payment_method_id} {
ad_return_complaint 1 "<li>No payment method specified"
return
}
set customer_internal [db_string customer_internal "select customer_id from im_customers where lower(customer_path) = 'internal'" -default 0]
if {!$customer_internal} {
ad_return_complaint 1 "<li>Unable to find 'Internal' customer with path 'internal'. <br>Maybe somebody has change the path of the customer?"
return
}
if {!$provider_id} { set provider_id $customer_internal }
if {!$customer_id} { set customer_id $customer_internal }
# ---------------------------------------------------------------
# Update invoice base data
# ---------------------------------------------------------------
set invoice_exists_p [db_string invoice_count "select count(*) from im_invoices where invoice_id=:invoice_id"]
# Just update the invoice if it already exists:
if {!$invoice_exists_p} {
# Let's create the new invoice
db_dml create_invoice "
DECLARE
v_invoice_id integer;
BEGIN
v_invoice_id := im_invoice.new (
invoice_id => :invoice_id,
creation_user => :user_id,
creation_ip => '[ad_conn peeraddr]',
invoice_nr => :invoice_nr,
customer_id => :customer_id,
provider_id => :provider_id,
invoice_date => sysdate,
invoice_template_id => :invoice_template_id,
invoice_status_id => [im_invoice_status_created],
invoice_type_id => :invoice_type_id,
payment_method_id => :payment_method_id,
payment_days => :payment_days,
vat => :vat,
tax => :tax
);
END;"
}
db_dml update_im_invoices "
UPDATE im_invoices
SET
invoice_nr=:invoice_nr,
customer_id=:customer_id,
provider_id=:provider_id,
invoice_date=:invoice_date,
payment_days=:payment_days,
payment_method_id=:payment_method_id,
invoice_template_id=:invoice_template_id,
vat=:vat,
tax=:tax,
invoice_status_id=:invoice_status_id,
invoice_type_id=:invoice_type_id,
last_modified=sysdate,
last_modifying_user=:user_id,
modified_ip_address='[ad_conn peeraddr]'
WHERE
invoice_id=:invoice_id"
# ---------------------------------------------------------------
# Create the im_invoice_items for the invoice
# ---------------------------------------------------------------
# Delete the old items if they exist
db_dml delete_invoice_items "
DELETE from im_invoice_items
WHERE invoice_id=:invoice_id
"
set item_list [array names item_name]
foreach nr $item_list {
set name $item_name($nr)
set units $item_units($nr)
set uom_id $item_uom_id($nr)
set type_id $item_type_id($nr)
set project_id $item_project_id($nr)
set rate $item_rate($nr)
set currency $item_currency($nr)
set sort_order $item_sort_order($nr)
ns_log Notice "item($nr, $name, $units, $uom_id, $project_id, $rate, $currency)"
# Insert only if it's not an empty line from the edit screen
if {!("" == [string trim $name] && (0 == $units || "" == $units))} {
set item_id [db_nextval "im_invoice_items_seq"]
set insert_invoice_items_sql "
INSERT INTO im_invoice_items (
item_id, item_name, project_id, invoice_id, item_units, item_uom_id,
price_per_unit, currency, sort_order, item_type_id, item_status_id, description
) VALUES (
:item_id, :name, :project_id, :invoice_id, :units, :uom_id,
:rate, :currency, :sort_order, :type_id, null, ''
)"
db_dml insert_invoice_items $insert_invoice_items_sql
}
}
db_release_unused_handles
ad_returnredirect "/intranet-invoices/view?invoice_id=$invoice_id"
This diff is collapsed.
<master src="../../intranet-core/www/master">
<property name="title">@page_title;noquote@</property>
<%= [im_invoices_navbar "none" "/intranet/invoices/index" "" "" [list]] %>
<form action=new-2 method=POST>
<%= [export_form_vars invoice_id project_id return_url] %>
<table border=0 width=100%>
<tr><td>
<table cellpadding=0 cellspacing=0 bordercolor=#6699CC border=0 width=100%>
<tr valign=top>
<td>
<table border=0 cellPadding=0 cellspacing=2 width=100%>
<tr><td align=middle class=rowtitle colspan=2>@invoice_type@ Data</td></tr>
<tr>
<td class=rowodd>@invoice_type@ nr.:</td>
<td class=rowodd>
<input type=text name=invoice_nr size=15 value='@invoice_nr@'>
</td>
</tr>
<tr>
<td class=roweven>@invoice_type@ date:</td>
<td class=roweven>
<input type=text name=invoice_date size=15 value='@invoice_date@'>
</td>
</tr>
<tr>
<td class=roweven>Payment terms</td>
<td class=roweven>
<input type=text name=payment_days size=5 value='@payment_days@'>
days</td>
</tr>
<if @invoice_or_bill_p@>
<tr>
<td class=rowodd>Payment Method</td>
<td class=rowodd>@payment_method_select;noquote@</td>
</tr>
</if>
<tr>
<td class=roweven> @invoice_type@ template:</td>
<td class=roweven>@template_select;noquote@</td>
</tr>
<tr>
<td class=rowodd>@invoice_type@ status</td>
<td class=rowodd>@status_select;noquote@</td>
</tr>
<tr>
<td class=roweven>@invoice_type@ type</td>
<td class=roweven>@type_select;noquote@</td>
</tr>
</table>
</td>
<td></td>
<td align=right>
<table border=0 cellspacing=2 cellpadding=0 width=100%>
<if @invoice_or_quote_p@>
<!-- Let the user select the customer. Provider=Internal -->
<tr>
<td align=center valign=top class=rowtitle colspan=2>Customer</td>
</tr>
<tr>
<td class=roweven>Customer:</tr>
<td class=roweven>@customer_select;noquote@</td>
</tr>
<input type=hidden name=provider_id value=0>
</if>
<else>
<tr>
<td align=center valign=top class=rowtitle colspan=2>Provider</td>
</tr>
<tr>
<td class=roweven>Provider:</tr>
<td class=roweven>@provider_select;noquote@</td>
</tr>
<input type=hidden name=customer_id value=0>
</else>
</table>
</tr>
</table>
</td></tr>
<tr><td>
<table width=100%>
<tr>
<td align=right>
<table border=0 cellspacing=2 cellpadding=1 width=100%>
<!-- the list of task sums, distinguised by type and UOM -->
@task_sum_html;noquote@
<tr>
<td>
</td>
<td colspan=99 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<tr>
<td>VAT&nbsp;</td>
<td><input type=text name=vat value='@vat@' size=4> % &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td colspan=99 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<tr>
<td>TAX&nbsp;</td>
<td><input type=text name=tax value='@tax@' size=4> % &nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp; </td>
<td colspan=6 align=right>
<input type=submit name=submit value='@button_text@'>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
</table>
</form>
This diff is collapsed.
This diff is collapsed.
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