Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-invoices
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-invoices
Commits
82ff01ac
Commit
82ff01ac
authored
May 02, 2023
by
Project Open
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.project-open.net/project-open/intranet-invoices
parents
4297f093
fc0e508c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
225 additions
and
70 deletions
+225
-70
dependency-tree.adp
lib/dependency-tree.adp
+28
-1
dependency-tree.tcl
lib/dependency-tree.tcl
+18
-35
intranet-invoices-preds-succs.sql
sql/postgresql/intranet-invoices-preds-succs.sql
+89
-0
invoice-association-action.tcl
www/invoice-association-action.tcl
+2
-2
list.tcl
www/list.tcl
+68
-21
new-2.tcl
www/new-2.tcl
+17
-1
new-copy.tcl
www/new-copy.tcl
+0
-7
view.tcl
www/view.tcl
+3
-3
No files found.
lib/dependency-tree.adp
View file @
82ff01ac
@html;noquote@
\ No newline at end of file
<if 1 eq @show_html_p@>
<table>
<tr valign=top>
<td width='70%'>
<table cellspaing=2 cellpadding=2>
<tr>
<td class=rowtitle>Name</td>
<td class=rowtitle>Amount</td>
<td class=rowtitle>Type</td>
<td class=rowtitle>Status</td>
</tr>
<tr><td colspan=99><h1>Predecessors</h1></td></tr>
@predecessor_html;noquote@
<tr><td colspan=99><h1>Successors</h1></td></tr>
@successor_html;noquote@
</table>
</td>
<td width='30%'>
<p>This portlet shows predecessors (= financial documents from which this document was created)
and successors (= financial documents created based on this one).</p>
</td>
</td>
</table>
</if>
lib/dependency-tree.tcl
View file @
82ff01ac
...
...
@@ -3,7 +3,7 @@
# Expected variables:
# invoice_id
#
project_id set by portlet TCL
#
Try behaving like a page if not called as a portlet (may not work yet
)
if
{
!
[
info
exists invoice_id
]}
{
ad_page_contract
{}
{
invoice_id:integer
""
}
}
...
...
@@ -20,6 +20,13 @@ if {!$read_p} {
set
invoice_base_url
"/intranet-invoices/view"
# Check if the calling page (invoices/view?invoice_id=123
)
has a locale set
set
locale
[
uplevel
2
{
if
{[
info
exists locale
]}
{
set locale
}}]
if
{
""
eq
$locale
}
{
set locale
[
lang::user::locale
]
}
# -------------------------------------------------------------
# Main project
# -------------------------------------------------------------
...
...
@@ -33,7 +40,6 @@ set main_project_ids [db_list pids "
p.project_id = r.object_id_one and
main_p.tree_sortkey = tree_root_key(p.tree_sortkey);
"
]
lappend
main_project_ids 0
# -------------------------------------------------------------
...
...
@@ -42,7 +48,7 @@ lappend main_project_ids 0
set
costs_sql
"
select cost_id, item_id, cost_name, cost_nr, cost_type_id, cost_status_id, item_source_invoice_id,
cost_amount, cost_currency,
co
alesce(cost_amount, 0.0) as co
st_amount, cost_currency,
CASE WHEN item_source_invoice_id = cost_id THEN null ELSE item_source_invoice_id END as source_id
from (
select c.*,
...
...
@@ -61,7 +67,7 @@ set costs_sql "
c.cost_type_id not in (3714, 3718, 3720, 3722, 3726, 3736, 73102)
UNION
select c.*,
c
.amount
as cost_amount,
c
oalesce(c.amount, 0.0)
as cost_amount,
c.currency as cost_currency,
i.*,
ii.*
...
...
@@ -91,7 +97,7 @@ db_foreach costs $costs_sql {
set name_hash
(
$cost
_id
)
$cost
_name
set type_hash
(
$cost
_id
)
$cost
_type_id
set status_hash
(
$cost
_id
)
$cost
_status_id
set amount_hash
(
$cost
_id
)
"
$cost
_amount
$cost
_currency"
set amount_hash
(
$cost
_id
)
"
[
lc_numeric
$cost
_amount
"%.2f"
$locale
]
$cost
_currency"
if
{
""
ne
$source
_id
}
{
set predecessors
{}
...
...
@@ -169,14 +175,17 @@ while {[llength $list] > 0 && $cnt < 10} {
set amount
$amount
_hash(
$id
)
set type
[
im_category_from_id
$type
_hash
(
$id
)]
set status
[
im_category_from_id
$status
_hash
(
$id
)]
set link "
<a href=$url>$name</a>
"
} else {
set name "
Unknown #$id
"
set url ""
set name "
Deleted #$id
"
set amount ""
set type ""
set status ""
set link
$name
}
append predecessor_html "
<tr>
<td>
<a href=$url>$name</a>
</td>
<td>
$link
</td>
<td>$amount</td>
<td>$type</td>
<td>$status</td>
...
...
@@ -251,36 +260,10 @@ while {[llength $list] > 0 && $cnt < 100} {
# -------------------------------------------------------------
#
#
Output HTML
# -------------------------------------------------------------
if {"" eq
$predecessor
_html} { set predecessor_html "
<tr><td colspan=99>No predecessors found</td></tr>
" }
if {"" eq
$successor
_html} { set successor_html "
<tr><td colspan=99>No successors found</td></tr>
" }
set html "
<table><tr valign=top>
<td width='70%'>
<table cellspaing=2 cellpadding=2>
<tr>
<td class=rowtitle>Name</td>
<td class=rowtitle>Amount</td>
<td class=rowtitle>Type</td>
<td class=rowtitle>Status</td>
</tr>
<tr><td colspan=99><h1>Predecessors</h1></td></tr>
$predecessor
_html
<tr><td colspan=99><h1>Successors</h1></td></tr>
$successor
_html
</table>
</td>
<td width='30%'>
<p>This portlet shows predecessors
(
= financial documents from which this document was created
)
and successors
(
= financial documents created based on this one
)
.</p>
</td>
</td></table>
"
if {
[
expr
$predecessor
_num +
$successor
_num
]
< 1} { set html "" }
set show_html_p
[
expr
(
$predecessor
_num +
$successor
_num
)
> 0
]
sql/postgresql/intranet-invoices-preds-succs.sql
0 → 100644
View file @
82ff01ac
-- Returns a formatted string with links to successor objects
create
or
replace
function
im_invoice_predecessor_links
(
integer
)
returns
varchar
as
$
body
$
declare
p_invoice_id
alias
for
$
1
;
row
RECORD
;
v_result
varchar
;
begin
v_result
:
=
''
;
FOR
row
IN
select
distinct
c_pred
.
cost_id
as
pred_id
,
c_pred
.
cost_name
as
pred_name
from
im_invoice_items
ii
,
im_costs
c_pred
where
ii
.
invoice_id
=
p_invoice_id
and
c_pred
.
cost_id
=
item_source_invoice_id
LOOP
IF
v_result
!=
''
THEN
v_result
=
v_result
||
', '
;
END
IF
;
v_result
=
v_result
||
'<a href=/intranet-invoices/view?invoice_id='
||
row
.
pred_id
||
'>'
||
row
.
pred_name
||
'</a>'
;
END
LOOP
;
return
v_result
;
end
;
$
body
$
language
'plpgsql'
;
create
or
replace
function
im_invoice_successor_links
(
integer
)
returns
varchar
as
$
body
$
declare
p_invoice_id
alias
for
$
1
;
row
RECORD
;
v_result
varchar
;
begin
v_result
:
=
''
;
FOR
row
IN
select
distinct
c_succ
.
cost_id
as
succ_id
,
c_succ
.
cost_name
as
succ_name
from
im_invoice_items
ii
,
im_costs
c_succ
where
ii
.
invoice_id
=
c_succ
.
cost_id
and
ii
.
item_source_invoice_id
=
p_invoice_id
LOOP
IF
v_result
!=
''
THEN
v_result
=
v_result
||
', '
;
END
IF
;
v_result
=
v_result
||
'<a href=/intranet-invoices/view?invoice_id='
||
row
.
succ_id
||
'>'
||
row
.
succ_name
||
'</a>'
;
END
LOOP
;
return
v_result
;
end
;
$
body
$
language
'plpgsql'
;
create
or
replace
function
im_invoice_successor_sum
(
integer
)
returns
numeric
as
$
body
$
declare
p_invoice_id
alias
for
$
1
;
row
RECORD
;
v_result
numeric
;
begin
v_result
:
=
0
.
0
;
FOR
row
IN
select
distinct
c_succ
.
cost_id
as
succ_id
,
c_succ
.
cost_name
as
succ_name
,
c_succ
.
amount
from
im_invoice_items
ii
,
im_costs
c_succ
where
ii
.
invoice_id
=
c_succ
.
cost_id
and
ii
.
item_source_invoice_id
=
p_invoice_id
LOOP
v_result
=
v_result
+
row
.
amount
;
END
LOOP
;
return
v_result
;
end
;
$
body
$
language
'plpgsql'
;
select
im_invoice_predecessor_links
(
447724
);
select
im_invoice_successor_links
(
406832
);
www/invoice-association-action.tcl
View file @
82ff01ac
...
...
@@ -91,7 +91,7 @@ if {"delete" == $action} {
im_audit -object_type "
im_invoice
" -object_id
$invoice
_id -action after_update
ad_returnredirect
$return
_url
ad_
abort_scrip
t
ad_
script_abor
t
}
...
...
@@ -111,7 +111,7 @@ if {"set_invoiced" == $action} {
}
ad_returnredirect
$return
_url
ad_
abort_scrip
t
ad_
script_abor
t
}
...
...
www/list.tcl
View file @
82ff01ac
...
...
@@ -18,6 +18,7 @@ ad_page_contract {
@cvs-id index.tcl,v 3.24.2.9 2000/09/22 01:38:44 kevin Exp
}
{
{
order_by
"Effective Date"
}
{
filter_project_id:integer 0
}
{
cost_status_id:integer
"
[
im_cost_status_created
]
"
}
{
cost_type_id:integer 0
}
{
company_id:integer 0
}
...
...
@@ -79,7 +80,7 @@ set date_format [im_l10n_sql_date_format]
set
default_currency
[
im_parameter -package_id
[
im_package_cost_id
]
"DefaultCurrency"
""
"EUR"
]
set
local_url
"/intranet-invoices/list"
set
cost_status_created
[
im_cost_status_created
]
set
cost_type
[
db_string get_cost_type
"select category from im_categories where category_id
=
:cost_type_id"
-default
[
_ intranet-invoices.Costs
]]
set
cost_type
[
db_string get_cost_type
"select category from im_categories where category_id
=
:cost_type_id"
-default
[
_ intranet-invoices.Costs
]]
set
letter
[
string
toupper
$letter
]
if
{
!
[
im_permission
$user
_id view_invoices
]}
{
...
...
@@ -122,31 +123,47 @@ if {0 == $view_id} {
}
set
extra_selects
[
list
]
set
extra_froms
[
list
]
set
extra_wheres
[
list
]
set
column_sql
"
select column_name,
column_render_tcl,
visible_for,
order_by_clause as column_order_by_clause
from im_view_columns
where view_id = :view_id
and group_id is null
order by
sort_order"
select column_name,
column_render_tcl,
visible_for,
extra_select,
extra_from,
extra_where,
order_by_clause
from im_view_columns
where view_id = :view_id
and group_id is null
order by
sort_order
"
# Get the main view
set
column_headers
[
list
]
set
column_vars
[
list
]
set
order_by_clause
""
db_foreach column_list_sql
$column
_sql
{
set admin_html
""
if
{
$user
_is_admin_p
}
{
set url
[
export_vars -base
"/intranet/admin/views/new-column"
{
column_id return_url
}]
set admin_html
"<a href='
$url
'>
[
im_gif wrench
""
]
</a>"
}
if
{
""
==
$visible
_for ||
[
eval
$visible
_for
]}
{
lappend column_headers
"
$column
_name"
lappend column_vars
"
$column
_render_tcl"
lappend column_headers_admin
$admin
_html
if
{
""
!=
$extra
_select
}
{
lappend extra_selects
[
eval
"set a
\"
$extra
_select
\"
"
]
}
if
{
""
!=
$extra
_from
}
{
lappend extra_froms
$extra
_from
}
if
{
""
!=
$extra
_where
}
{
lappend extra_wheres
$extra
_where
}
if
{
""
!=
$order
_by_clause &&
$order
_by ==
$column
_name
}
{
set view_order_by_clause
$order
_by_clause
}
}
if
{
$order
_by eq
$column
_name
}
{
set order_by_clause
$column
_order_by_clause
}
}
# ---------------------------------------------------------------
...
...
@@ -154,6 +171,17 @@ db_foreach column_list_sql $column_sql {
# ---------------------------------------------------------------
set
criteria
[
list
]
if
{
$filter
_project_id ne
""
&&
$filter
_project_id > 0
}
{
lappend criteria
"ci.project_id in (
select sub_p.project_id
from im_projects main_p,
im_projects sub_p
where main_p.project_id = :filter_project_id and
sub_p.tree_sortkey between main_p.tree_sortkey and tree_right(main_p.tree_sortkey)
)"
}
if
{
$cost
_status_id ne
""
&&
$cost
_status_id > 0
}
{
lappend criteria
"ci.cost_status_id in (
[
join
[
im_sub_categories
$cost
_status_id
]
","
]
)"
}
...
...
@@ -176,6 +204,23 @@ if {"" != $end_date} {
set
extra_select
[
join
$extra
_selects
",
\n\t
"
]
if
{
$extra
_select ne
""
}
{
set extra_select
",
\n\t
$extra
_select"
}
set
extra_from
[
join
$extra
_froms
",
\n\t
"
]
if
{
$extra
_from ne
""
}
{
set extra_from
",
\n\t
$extra
_from"
}
set
extra_where
[
join
$extra
_wheres
"and
\n\t
"
]
if
{
$extra
_where ne
""
}
{
set extra_where
",
\n\t
$extra
_where"
}
# Get the list of user's companies for which he can see invoices
set
company_ids
[
db_list users_companies
"
select
...
...
@@ -200,6 +245,7 @@ if {![im_permission $user_id view_invoices]} {
ns_log Notice
"/intranet-invoices/index: company_where=
$company
_where"
set
counter_reset_expression
""
set
order_by_clause
""
# If filter is set to Customer or Provider Doc's and no order_by is providedwe order by creation date.
# Before order_by was set to default (Document No
)
. This way documents showed up grouped by document types.
...
...
@@ -256,11 +302,6 @@ if { $where_clause ne "" } {
set
payment_amount
""
set
payment_currency
""
set
extra_select
""
set
extra_from
""
set
extra_where
""
# -----------------------------------------------------------------
# Main SQL
# -----------------------------------------------------------------
...
...
@@ -420,6 +461,12 @@ set filter_html "
[
im_company_select -include_empty_p 1 -include_empty_name
"All"
company_id
$company
_id
]
</td>
</tr>
<tr>
<td>
[
_ intranet-core.Project
]
</td>
<td>
[
im_project_select -exclude_subprojects_p 1 -include_empty_p 1 filter_project_id
$filter
_project_id
]
</td>
</tr>
<tr>
<td class=form-label>
[
_ intranet-core.Start_Date
]
</td>
<td class=form-widget>
...
...
www/new-2.tcl
View file @
82ff01ac
...
...
@@ -139,6 +139,7 @@ if {"" == $invoice_currency} { set invoice_currency $default_currency }
set
current_user_id
[
auth::require_login
]
set
admin_p
[
im_user_is_admin_p
$current
_user_id
]
set
user_id
$current
_user_id
set
write_p
[
im_cost_center_write_p
$cost
_center_id
$cost
_type_id
$user
_id
]
# if !$write_p || ![im_permission $user_id add_invoices
]
||
""
==
$cost
_center_id
...
...
@@ -192,10 +193,25 @@ if {$duplicate_p} {
}
}
# ---------------------------------------------------------------
# Check if there is a
single project to which this document refers.
# Check if there is a
workflow ongoing
# ---------------------------------------------------------------
set
wf_case_p
[
db_string wf_case
"select count(*) from wf_cases where object_id = :invoice_id"
]
if
{
$wf
_case_p > 0 && !$admin_p
}
{
ad_return_complaint 1
"<b>
[
lang::message::lookup
""
intranet-invoices.Ongoing_Workflow
"Financial Document Controlled by Workflow"
]
:</b><br>
[
lang::message::lookup
""
intranet-invoices.intranet-invoices.Ongoing_Workflow_msg
"
This financial document is controlled by a workflow,
so normal users are not allowed to change it anymore.<br>
Please notify your system administrator if you think this is not correct.
"
]
"
ad_script_abort
}
# ---------------------------------------------------------------
# Check if there is a single project to which this document refers.
# ---------------------------------------------------------------
# Look for common super-projects for multi-project documents
set
select_project
[
im_invoices_unify_select_projects
$select
_project
]
...
...
www/new-copy.tcl
View file @
82ff01ac
...
...
@@ -132,16 +132,9 @@ if { "" == $project_id || ![info exists project_id] } {
}
# ---------------------------------------------------------------
# set customer_select [im_company_select customer_id $customer_id "" "CustOrIntl"]
# set provider_select [im_company_select provider_id $provider_id "" "Provider"]
# 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"]
set
customer_select
[
im_company_select -tag_attributes
{
id
"customer_id"
}
customer_id
$customer
_id
""
"CustOrIntl"
]
set
provider_select
[
im_company_select -tag_attributes
{
id
"provider_id"
}
provider_id
$provider
_id
""
"Provider"
]
# ---------------------------------------------------------------
# Determine whether it's an Invoice or a Bill
# ---------------------------------------------------------------
...
...
www/view.tcl
View file @
82ff01ac
...
...
@@ -228,9 +228,9 @@ set cost_center_installed_p [apm_package_installed_p "intranet-cost-center"]
# Is there already a workflow controlling the lifecycle of the invoice?
set
wf_case_p
[
db_string wf_case
"select count(*) from wf_cases where object_id = :invoice_id"
]
set
wf_transition_key
[
db_string wf_transition
"select transition_key from wf_tasks where task_id = :task_id"
-default
""
]
if
{
"modify"
eq
$wf
_transition_key
}
{
set wf_case_p 0
}
if
{[
im_user_is_admin_p
$
user
_id
]}
{
set wf_case_p 0
}
if
{
"modify"
eq
$wf
_transition_key
}
{
set wf_case_p 0
}
;
# Transition corresponds to editing the object
if
{[
im_user_is_admin_p
$
current
_user_id
]}
{
set wf_case_p 0
};
# Admins can always override WF
if
{[
im_permission
$current
_user_id wf_reassign_tasks
]}
{
set wf_case_p 0
};
# User can override tasks anyway...
# ---------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment