[open-ils-commits] r8773 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 19 09:56:04 EST 2008
Author: erickson
Date: 2008-02-19 09:25:48 -0500 (Tue, 19 Feb 2008)
New Revision: 8773
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Provider.pm
Log:
Removed up-front creation of BAD_PARAMS to prevent compile-time warnings
added some initial purchase order an po_lineitem creation code, needs work
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-19 13:54:39 UTC (rev 8772)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-02-19 14:25:48 UTC (rev 8773)
@@ -1,5 +1,5 @@
package OpenILS::Application::Acq::Financials;
-use base qw/OpenILS::Application::Acq/;
+use base qw/OpenILS::Application/;
use strict; use warnings;
use OpenSRF::Utils::Logger qw(:logger);
@@ -11,9 +11,6 @@
use OpenILS::Application::AppUtils;
my $U = 'OpenILS::Application::AppUtils';
-my $BAD_PARAMS = OpenILS::Event->new('BAD_PARAMS');
-
-
# ----------------------------------------------------------------------------
# Funding Sources
# ----------------------------------------------------------------------------
@@ -122,7 +119,8 @@
return $e->event unless $e->checkauth;
my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUNDING_SOURCE';
- return $BAD_PARAMS unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_FUNDING_SOURCE/;
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_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});
@@ -287,7 +285,8 @@
return $e->event unless $e->checkauth;
my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUND';
- return $BAD_PARAMS unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_FUND/;
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_FUND/;
my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
$U->find_highest_work_orgs($e, $limit_perm, {descendants =>1});
@@ -460,7 +459,7 @@
}
);
-sub retrieve_fund_alloc {
+sub retrieve_funding_source_allocations {
my($self, $conn, $auth, $fund_alloc_id) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
@@ -476,9 +475,6 @@
return $fund_alloc;
}
-
-
-
# ----------------------------------------------------------------------------
# Currency
# ----------------------------------------------------------------------------
@@ -504,4 +500,97 @@
}
+# ----------------------------------------------------------------------------
+# Purchase Orders
+# ----------------------------------------------------------------------------
+
+__PACKAGE__->register_method(
+ method => 'create_purchase_order',
+ api_name => 'open-ils.acq.purchase_order.create',
+ signature => {
+ desc => 'Creates a new purchase order',
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'purchase_order to create', type => 'object'}
+ ],
+ return => {desc => 'The purchase order id, Event on failure'}
+ }
+);
+
+sub create_purchase_order {
+ my($self, $conn, $auth, $p_order) = @_;
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+ $p_order->owner($e->requestor->id);
+
+ if($p_order->default_fund) {
+ # if a default fund is provided, make sure the requestor
+ # actually has permission to spend from that fund
+ my $fund = $e->retrieve_acq_fund($p_order->default_fund)
+ or return $e->die_event;
+ return $e->die_event unless $e->allowed('MANAGE_FUND', $fund->org, $fund);
+ }
+
+ my $provider = $e->retrieve_acq_provider($p_order->provider)
+ or return $e->die_event;
+
+ return $e->die_event unless $e->allowed('MANAGE_PROVIDER', $provider->owner, $provider);
+
+ $e->create_acq_purchase_order($p_order) or return $e->die_event;
+ $e->commit;
+ return $p_order->id;
+}
+
+
+__PACKAGE__->register_method(
+ method => 'create_po_lineitem',
+ api_name => 'open-ils.acq.po_lineitem.create',
+ signature => {
+ desc => 'Creates a new purchase order line item',
+ params => [
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'purchase order line item to create', type => 'object'}
+ ],
+ return => {desc => 'The purchase order line item id, Event on failure'}
+ }
+);
+
+sub create_po_lineitem {
+ my($self, $conn, $auth, $po_li, $options) = @_;
+ my $e = new_editor(xact=>1, authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
+
+ my $po = $e->retrieve_acq_purchase_order($po_li->purchase_order)
+ or return $e->die_event;
+
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $e->requestor->id == $po->owner;
+
+ if($$options{picklist_entry}) {
+ # if a picklist_entry ID is provided, use that as the basis for this item
+ my $ple = $e->retrieve_acq_picklist_entry($$options{picklist_entry})
+ or return $e->die_event;
+ $po_li->marc($ple->marc);
+ $po_li->eg_bib_id($ple->eg_bib_id);
+ }
+
+ if($po_li->fund) {
+ # check fund perms if using the non-default fund
+ my $fund = $e->retrieve_acq_fund($po_li->fund)
+ or return $e->die_event;
+ return $e->die_event unless $e->allowed('MANAGE_FUND', $fund->org, $fund);
+ }
+
+ my $provider = $e->retrieve_acq_provider($po->provider)
+ or return $e->die_event;
+
+ return $e->die_event unless $e->allowed('MANAGE_PROVIDER', $provider->owner, $provider);
+
+ $e->create_acq_po_lineitem($po_li) or return $e->die_event;
+ return $po_li->id;
+}
+
+
+
+
1;
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm 2008-02-19 13:54:39 UTC (rev 8772)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm 2008-02-19 14:25:48 UTC (rev 8773)
@@ -1,5 +1,5 @@
package OpenILS::Application::Acq::Picklist;
-use base qw/OpenILS::Application::Acq/;
+use base qw/OpenILS::Application/;
use strict; use warnings;
use OpenSRF::Utils::Logger qw(:logger);
@@ -9,9 +9,7 @@
use OpenSRF::Utils::SettingsClient;
use OpenILS::Event;
-my $BAD_PARAMS = OpenILS::Event->new('BAD_PARAMS');
-
__PACKAGE__->register_method(
method => 'create_picklist',
api_name => 'open-ils.acq.picklist.create',
@@ -30,7 +28,8 @@
my $e = new_editor(xact=>1, authtoken=>$auth);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('CREATE_PICKLIST');
- return $BAD_PARAMS unless $e->requestor->id == $picklist->owner;
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $e->requestor->id == $picklist->owner;
$e->create_acq_picklist($picklist) or return $e->die_event;
$e->commit;
return $picklist->id;
@@ -58,7 +57,7 @@
# don't let them change the owner
my $o_picklist = $e->retrieve_acq_picklist($picklist->id)
or return $e->die_event;
- return $BAD_PARAMS if (
+ return OpenILS::Event->new('BAD_PARAMS') if (
$o_picklist->owner != $picklist->owner or
$picklist->owner != $e->requestor->id );
@@ -92,7 +91,11 @@
$picklist->entry_count(retrieve_picklist_entry_count($e, $picklist_id))
if $$options{flesh_entry_count};
- return $BAD_PARAMS unless $e->requestor->id == $picklist->owner;
+ if($e->requestor->id != $picklist->owner) {
+ return $e->event unless
+ $e->allowed('VIEW_PICKLIST', undef, $picklist);
+ }
+
return $picklist;
}
@@ -237,7 +240,8 @@
my $picklist = $e->retrieve_acq_picklist($picklist_id)
or return $e->die_event;
# don't let anyone delete someone else's picklist
- return $BAD_PARAMS if $picklist->owner != $e->requestor->id;
+ return OpenILS::Event->new('BAD_PARAMS')
+ if $picklist->owner != $e->requestor->id;
$e->delete_acq_picklist($picklist) or return $e->die_event;
$e->commit;
@@ -270,7 +274,8 @@
my $picklist = $e->retrieve_acq_picklist($entry->picklist)
or return $e->die_event;
- return $BAD_PARAMS unless $picklist->owner == $e->requestor->id;
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $picklist->owner == $e->requestor->id;
# indicate the picklist was updated
$picklist->edit_time('now');
@@ -315,7 +320,8 @@
my $picklist = $e->retrieve_acq_picklist($pl_entry->picklist)
or return $e->event;
- return $BAD_PARAMS if $picklist->owner != $e->requestor->id;
+ return OpenILS::Event->new('BAD_PARAMS')
+ if $picklist->owner != $e->requestor->id;
return $pl_entry;
}
@@ -346,7 +352,8 @@
or return $e->die_event;
# don't let anyone delete someone else's picklist entry
- return $BAD_PARAMS if $picklist->owner != $e->requestor->id;
+ return OpenILS::Event->new('BAD_PARAMS')
+ if $picklist->owner != $e->requestor->id;
$e->delete_acq_picklist_entry($pl_entry) or return $e->die_event;
$e->commit;
@@ -381,7 +388,8 @@
]) or return $e->die_event;
# don't let anyone update someone else's picklist entry
- return $BAD_PARAMS if $orig_entry->picklist->owner != $e->requestor->id;
+ return OpenILS::Event->new('BAD_PARAMS')
+ if $orig_entry->picklist->owner != $e->requestor->id;
$e->update_acq_picklist_entry($pl_entry) or return $e->die_event;
$e->commit;
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Provider.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Provider.pm 2008-02-19 13:54:39 UTC (rev 8772)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Provider.pm 2008-02-19 14:25:48 UTC (rev 8773)
@@ -1,5 +1,5 @@
package OpenILS::Application::Acq::Provider;
-use base qw/OpenILS::Application::Acq/;
+use base qw/OpenILS::Application/;
use strict; use warnings;
use OpenILS::Event;
@@ -11,9 +11,7 @@
use OpenILS::Application::AppUtils;
my $U = 'OpenILS::Application::AppUtils';
-my $BAD_PARAMS = OpenILS::Event->new('BAD_PARAMS');
-
__PACKAGE__->register_method(
method => 'create_provider',
api_name => 'open-ils.acq.provider.create',
@@ -87,7 +85,8 @@
my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_PROVIDER';
- return $BAD_PARAMS unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_PROVIDER/;
+ return OpenILS::Event->new('BAD_PARAMS')
+ unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_PROVIDER/;
my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
$U->find_highest_work_orgs($e, $limit_perm, {descendants =>1});
More information about the open-ils-commits
mailing list