comitting initial fund / budget, etc. code
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Jan 2008 22:02:22 +0000 (22:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Jan 2008 22:02:22 +0000 (22:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8357 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
new file mode 100644 (file)
index 0000000..8ff5513
--- /dev/null
@@ -0,0 +1,77 @@
+package OpenILS::Application::Acq::Financials;
+use base qw/OpenILS::Application::Acq/;
+use strict; use warnings;
+
+use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::CStoreEditor q/:funcs/;
+use OpenILS::Const qw/:const/;
+use OpenSRF::Utils::SettingsClient;
+use OpenILS::Event;
+
+my $BAD_PARAMS = OpenILS::Event->new('BAD_PARAMS');
+
+__PACKAGE__->register_method(
+       method => 'create_fund',
+       api_name        => 'open-ils.acq.fund.create',
+       signature => q/
+        Creates a new fund
+               @param auth Authentication token
+               @pararm fund
+       /
+);
+
+sub create_fund {
+    my($self, $conn, $auth, $fund) = @_;
+    my $e = new_editor(xact=>1, authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed('CREATE_FUND', $fund->owner);
+    $e->create_acq_fund($fund) or return $e->die_event;
+    $e->commit;
+    return $fund->id;
+}
+
+__PACKAGE__->register_method(
+       method => 'retrieve_fund',
+       api_name        => 'open-ils.acq.fund.retrieve',
+       signature => q/
+        Retrieves a fund by ID
+               @param auth Authentication token
+               @pararm fund_id
+       /
+);
+
+sub retrieve_fund {
+    my($self, $conn, $auth, $fund_id) = @_;
+    my $e = new_editor(authtoken=>$auth);
+    return $e->event unless $e->checkauth;
+    my $fund = $e->retrieve_acq_fund($fund_id) or return $e->event;
+    return $e->event unless $e->allowed('VIEW_FUND', $fund->owner);
+    return $fund;
+}
+
+__PACKAGE__->register_method(
+       method => 'retrieve_org_funds',
+       api_name        => 'open-ils.acq.fund.org.retrieve',
+       signature => q/
+        Retrieves all the funds associated with an org unit
+               @param auth Authentication token
+               @pararm org_id
+        @param options Hash of options.  Options include "children", 
+            which includes the funds for the requested org and
+            all descendant orgs.
+       /
+);
+
+sub retrieve_org_fund {
+    my($self, $conn, $auth, $org_id, $options) = @_;
+    my $e = new_editor(authtoken=>$auth);
+    return $e->event unless $e->checkauth;
+    return $e->event unless $e->allowed('VIEW_FUND', $org_id);
+    my $fund = $e->retrieve_acq_fund($fund_id) or return $e->event;
+    # XXX add descendant logic
+    return $fund;
+}
+
+
+