[open-ils-commits] r8719 - in branches/acq-experiment/Open-ILS/src:
extras perlmods/OpenILS/Application/Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 11 15:35:17 EST 2008
Author: erickson
Date: 2008-02-11 15:06:06 -0500 (Mon, 11 Feb 2008)
New Revision: 8719
Modified:
branches/acq-experiment/Open-ILS/src/extras/ils_events.xml
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
added funding_source summary fleshing
Modified: branches/acq-experiment/Open-ILS/src/extras/ils_events.xml
===================================================================
--- branches/acq-experiment/Open-ILS/src/extras/ils_events.xml 2008-02-11 20:00:04 UTC (rev 8718)
+++ branches/acq-experiment/Open-ILS/src/extras/ils_events.xml 2008-02-11 20:06:06 UTC (rev 8719)
@@ -592,6 +592,15 @@
<event code='1654' textcode='ACQ_FUND_SPENT_BALANCE_NOT_FOUND'>
<desc xml:lang='en-US'>The requested acq.fund_spent_balance was not found</desc>
</event>
+ <event code='1655' textcode='ACQ_FUNDING_SOURCE_CREDIT_TOTAL_NOT_FOUND'>
+ <desc xml:lang='en-US'>The requested acq.funding_source_credit_total was not found</desc>
+ </event>
+ <event code='1656' textcode='ACQ_FUNDING_SOURCE_ALLOCATION_TOTAL_NOT_FOUND'>
+ <desc xml:lang='en-US'>The requested acq.funding_source_allocation_total was not found</desc>
+ </event>
+ <event code='1657' textcode='ACQ_FUNDING_SOURCE_BALANCE_NOT_FOUND'>
+ <desc xml:lang='en-US'>The requested acq.funding_source_balance was not found</desc>
+ </event>
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-02-11 20:00:04 UTC (rev 8718)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-02-11 20:06:06 UTC (rev 8719)
@@ -80,12 +80,14 @@
);
sub retrieve_funding_source {
- my($self, $conn, $auth, $funding_source_id) = @_;
+ my($self, $conn, $auth, $funding_source_id, $options) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
my $funding_source = $e->retrieve_acq_funding_source($funding_source_id) or return $e->event;
return $e->event unless $e->allowed(
['ADMIN_FUNDING_SOURCE','MANAGE_FUNDING_SOURCE'], $funding_source->owner, $funding_source);
+ $funding_source->summary(retrieve_funding_source_summary_impl($e, $funding_source))
+ if $$options{flesh_summary};
return $funding_source;
}
@@ -107,19 +109,40 @@
);
sub retrieve_org_funding_sources {
- my($self, $conn, $auth, $org_id_list, $limit_perm) = @_;
+ my($self, $conn, $auth, $org_id_list, $options) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
- $limit_perm ||= 'ADMIN_FUNDING_SOURCE';
+ my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUNDING_SOURCE';
my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
$U->find_highest_work_orgs($e, $limit_perm, {descendants =>1});
return [] unless @$org_ids;
- return $e->search_acq_funding_source({owner => $org_ids});
+ my $sources = $e->search_acq_funding_source({owner => $org_ids});
+
+ if($$options{flesh_summary}) {
+ for my $source (@$sources) {
+ $source->summary(retrieve_funding_source_summary_impl($e, $source));
+ }
+ }
+
+ return $sources;
}
+sub retrieve_funding_source_summary_impl {
+ my($e, $source) = @_;
+ my $at = $e->search_acq_funding_source_allocation_total({funding_source => $source->id})->[0];
+ my $b = $e->search_acq_funding_source_balance({funding_source => $source->id})->[0];
+ my $ct = $e->search_acq_funding_source_credit_total({funding_source => $source->id})->[0];
+ return {
+ allocation_total => ($at) ? $at->amount : 0,
+ balance => ($b) ? $b->amount : 0,
+ credit_total => ($ct) ? $ct->amount : 0,
+ };
+}
+
+
# ---------------------------------------------------------------
# funds
# ---------------------------------------------------------------
More information about the open-ils-commits
mailing list