sub activate_purchase_order {
my($self, $conn, $auth, $po_id, $vandelay, $options) = @_;
$options ||= {};
+ $$options{dry_run} = ($self->api_name =~ /\.dry_run/) ? 1 : 0;
- my $dry_run = ($self->api_name =~ /\.dry_run/) ? 1 : 0;
my $e = new_editor(authtoken=>$auth);
return $e->die_event unless $e->checkauth;
my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
- my $die_event = activate_purchase_order_impl($mgr, $po_id, $vandelay, $dry_run, $options);
+ my $die_event = activate_purchase_order_impl($mgr, $po_id, $vandelay, $options);
return $e->die_event if $die_event;
$conn->respond_complete(1);
- $mgr->run_post_response_hooks unless $dry_run;
+ $mgr->run_post_response_hooks unless $$options{dry_run};
return undef;
}
# xacts managed within
sub activate_purchase_order_impl {
- my ($mgr, $po_id, $vandelay, $dry_run, $options) = @_;
+ my ($mgr, $po_id, $vandelay, $options) = @_;
+ $options ||= {};
+ my $dry_run = $$options{dry_run};
+ my $no_assets = $$options{no_assets};
# read-only until lineitem asset creation
my $e = $mgr->editor;
my $li_ids = $e->search_acq_lineitem($query, {idlist => 1});
- my $vl_resp; # imported li's and the queue the managing queue
- if (!$dry_run) {
+ my $vl_resp; # imported li's and the managing queue
+ unless ($dry_run or $no_assets) {
$e->rollback; # read-only thus far
+
+ # list_assets manages its own transactions
$vl_resp = create_lineitem_list_assets($mgr, $li_ids, $vandelay)
or return OpenILS::Event->new('ACQ_LI_IMPORT_FAILED');
$e->xact_begin;
for my $li_id (@$li_ids) {
my $li = $e->retrieve_acq_lineitem($li_id);
- if (!$li->eg_bib_id and !$dry_run) {
+ unless ($li->eg_bib_id or $dry_run or $no_assets) {
# we encountered a lineitem that was not successfully imported.
# we cannot continue. rollback and report.
$e->rollback;
$li->state('on-order');
$li->claim_policy($provider->default_claim_policy)
if $provider->default_claim_policy and !$li->claim_policy;
- create_lineitem_debits($mgr, $li, $dry_run, $options) or return $e->die_event;
+ create_lineitem_debits($mgr, $li, $dry_run) or return $e->die_event;
update_lineitem($mgr, $li) or return $e->die_event;
$mgr->post_process( sub { create_lineitem_status_events($mgr, $li->id, 'aur.ordered'); });
$mgr->respond;
<th>[% l('Activatable?') %]</th>
<td>
<span id="acq-po-activate-checking"></span>
- <span class="hidden" id="acq-po-activate-link"><span dojoType="dijit.form.Button" onClick="activatePo()" jsId="activatePoButton">[% l('Activate Order') %]</span></span>
+ <span class="hidden" id="acq-po-activate-links" style='padding: 5px'>
+ <span dojoType="dijit.form.Button" onClick="activatePo()" jsId="activatePoButton">
+ [% l('Activate Order') %]
+ </span>
+ <span style='padding: 5px;'> / </span>
+ <span dojoType="dijit.form.Button" onClick="activatePo(true)" jsId="activatePoNoAssetsButton">
+ [% l('Activate Without Loading Items') %]
+ </span>
+ </span>
</td>
</tr>
<tr>
"PO_COULD_ACTIVATE" : "Yes.",
"PO_WARNING_NO_BLOCK_ACTIVATION" : "Yes; fund ${0} (${1}) would be encumbered beyond its warning level.",
"PO_STOP_BLOCKS_ACTIVATION" : "No; fund ${0} (${1}) would be encumbered beyond its stop level.",
+ "PO_ALREADY_ACTIVATED" : "Activated",
"PO_FUND_WARNING_CONFIRM" : "Are you sure? Did you see the warning about over-encumbering a fund?",
"CONFIRM_FUNDS_AT_STOP" : "One or more of the selected funds has a balance below its stop level.\nYou may not be able to activate purchase orders incorporating these copies.\nContinue?",
"CONFIRM_FUNDS_AT_WARNING" : "One or more of the selected funds has a balance below its warning level.\nContinue?",
if (PO.lineitem_count() > 1)
openils.Util.show("acq-po-split");
} else {
- dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO;
+ if (PO.order_date()) {
+ dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.PO_ALREADY_ACTIVATED;
+ } else {
+ dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO;
+ }
}
// XXX we probably don't *always* need to do this...
function checkCouldActivatePo() {
var d = dojo.byId("acq-po-activate-checking");
- var a = dojo.byId("acq-po-activate-link"); /* <span> not <a> now, but no diff */
+ var a = dojo.byId("acq-po-activate-links"); /* <span> not <a> now, but no diff */
d.innerHTML = localeStrings.PO_CHECKING;
var warnings = [];
var stops = [];
);
}
-function activatePo() {
+function activatePo(noAssets) {
activatePoButton.attr("disabled", true);
+ activatePoNoAssetsButton.attr("disabled", true);
if (openils.Util.isTrue(PO.prepayment_required())) {
if (!confirm(localeStrings.PREPAYMENT_REQUIRED_REMINDER)) {
}
}
- liTable.showAssetCreator(activatePoStage2);
+ if (noAssets) {
+ // no need for AssetCreator when assets are not desired
+ activatePoStage2(true);
+ } else {
+ liTable.showAssetCreator(activatePoStage2);
+ }
}
-function activatePoStage2() {
+function activatePoStage2(noAssets) {
var want_refresh = false;
progressDialog.show(true);
openils.User.authtoken,
PO.id(),
null, // vandelay options
- {zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked}
+ {
+ no_assets : noAssets, // no bibs/volumes/copies required
+ zero_copy_activate : dojo.byId('acq-po-activate-zero-copies').checked
+ }
],
"onresponse": function(r) {
progressDialog.hide();