[open-ils-commits] r8482 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jan 23 13:21:48 EST 2008
Author: erickson
Date: 2008-01-23 12:55:11 -0500 (Wed, 23 Jan 2008)
New Revision: 8482
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
expanded the fund retrieval with ancestor/descendant/full_path options
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-01-23 16:30:52 UTC (rev 8481)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-01-23 17:55:11 UTC (rev 8482)
@@ -18,23 +18,26 @@
# any descendents
# ---------------------------------------------------------------
sub org_descendants {
- my($e, $org_id) = @_;
+ my $org_id = shift;
+ my $org_list = $U->simplereq(
+ 'open-ils.storage',
+ 'open-ils.storage.actor.org_unit.descendants.atomic', $org_id);
+ my @org_ids;
+ push(@org_ids, $_->id) for @$org_list;
+ return \@org_ids;
+}
- my $org = $e->retrieve_actor_org_unit(
- [$org_id, {flesh=>1, flesh_fields=>{aou=>['ou_type']}}]) or return $e->event;
-
+sub org_ancestors {
+ my $org_id = shift;
my $org_list = $U->simplereq(
'open-ils.storage',
- 'open-ils.storage.actor.org_unit.descendants.atomic',
- $org_id, $org->ou_type->depth);
-
+ 'open-ils.storage.actor.org_unit.ancestors.atomic', $org_id);
my @org_ids;
push(@org_ids, $_->id) for @$org_list;
return \@org_ids;
}
-
__PACKAGE__->register_method(
method => 'create_fund',
api_name => 'open-ils.acq.fund.create',
@@ -113,8 +116,10 @@
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'Org Unit ID', type => 'number'},
- {desc => 'Hash or options, including "children", which, if true,
- includes funds for descendant orgs in addition to the requested org',
+ {desc => 'Hash or options, including "descendants",
+ includes funds for descendant orgs in addition to the requested org;
+ "ancestor", includes ancestor org funds;
+ "full_path", includes orgs for ancestors and descendants',
type => 'hash'},
],
return => {desc => 'The fund objects on success, Event on failure'}
@@ -128,9 +133,16 @@
return $e->event unless $e->allowed('VIEW_FUND', $org_id);
my $search = {owner => $org_id};
- $search = {owner => org_descendents($e, $org_id)} if $$options{children};
+ if($$options{full_path}) {
+ my $orglist = org_descendants($org_id);
+ push(@$orglist, @{org_ancestors($org_id)});
+ $search = {owner => $orglist};
+ } else {
+ $search = {owner => org_descendants($org_id)} if $$options{descendants};
+ $search = {owner => org_ancestors($org_id)} if $$options{ancestors};
+ }
+
my $funds = $e->search_acq_fund($search) or return $e->event;
-
return $funds;
}
More information about the open-ils-commits
mailing list