ML stub for fiscal rollover processing.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Feb 2010 02:41:09 +0000 (02:41 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Feb 2010 02:41:09 +0000 (02:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15491 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm

index f96a1be..9f06966 100644 (file)
@@ -1185,5 +1185,54 @@ sub update_po_events {
 }
 
 
+__PACKAGE__->register_method (
+       method          => 'process_fiscal_rollover',
+    api_name    => 'open-ils.acq.fiscal_rollover.process',
+    stream      => 1,
+);
+
+__PACKAGE__->register_method (
+       method          => 'process_fiscal_rollover',
+    api_name    => 'open-ils.acq.fiscal_rollover.process.dry_run',
+    stream      => 1,
+);
+
+sub process_fiscal_rollover {
+    my( $self, $conn, $auth, $org_id, $year, $descendants ) = @_;
+
+    my $e = new_editor(xact=>1, authtoken=>$auth);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed('ADMIN_FUND', $org_id);
+
+    # Create next year's funds
+    $e->json_query({
+        from => [
+            ($descendants) ? 
+                'acq.propagate_funds_by_org_tree' :
+                'acq.propagate_funds_by_org_unit',
+            $year, $e->requestor->id, $org_id
+        ]
+    });
+
+    # Roll the uncumbrances over to the newly create funds
+    $e->json_query({
+        from => [
+            ($descendants) ? 
+                'acq.rollover_funds_by_org_tree' :
+                'acq.rollover_funds_by_org_unit',
+            $year, $e->requestor->id, $org_id
+        ]
+    });
+
+    # TODO
+    # Loop over the newly created funds (funds for $year + 1 for 
+    # selected org units) and stream back the new fund, including 
+    # fund summary and total debits
+
+    $self->api_name =~ /dry_run/ and $e->rollback or $e->commit;
+    return undef;
+}
+
+
 1;