name => 'call_numbers',
desc => 'hash of item_ids => call_numbers',
type => 'hash'
+ },
+ {
+ name => 'donor_unit_ids',
+ desc => 'hash of unit_ids => 1, keyed with ids of any units giving up items',
+ type => 'hash'
}
],
'return' => {
name => 'call_numbers',
desc => 'hash of item_ids => call_numbers',
type => 'hash'
+ },
+ {
+ name => 'donor_unit_ids',
+ desc => 'hash of unit_ids => 1, keyed with ids of any units giving up items',
+ type => 'hash'
}
],
'return' => {
);
sub unitize_items {
- my ($self, $conn, $auth, $items, $barcodes, $call_numbers) = @_;
+ my ($self, $conn, $auth, $items, $barcodes, $call_numbers, $donor_unit_ids) = @_;
my $editor = new_editor("authtoken" => $auth, "xact" => 1);
return $editor->die_event unless $editor->checkauth;
my $mode = $1;
my %found_unit_ids;
+ if ($donor_unit_ids) { # units giving up items need updating as well
+ %found_unit_ids = %$donor_unit_ids;
+ }
my %found_stream_ids;
my %found_types;
$call_number_string = $call_number_by_unit_id{$unit_id};
$record_id = $sdist->subscription->record_entry;
} else {
+ # XXX: this code assumes you will not have units which mix streams/distributions, but current code does not enforce this
$sunit = $editor->retrieve_serial_unit($unit_id);
- $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_ids_by_unit_id{$unit_id}}}, { "join" => {"sstr" => {}} }]);
+ if ($stream_ids_by_unit_id{$unit_id}) {
+ $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_ids_by_unit_id{$unit_id}}}, { "join" => {"sstr" => {}}, 'limit' => 1 }]);
+ } else {
+ $sdist = $editor->search_serial_distribution([
+ {'+sunit' => {'id' => $unit_id}},
+ { 'join' =>
+ {'sstr' =>
+ { 'join' =>
+ { 'sitem' =>
+ { 'join' => 'sunit' }
+ }
+ }
+ },
+ 'limit' => 1
+ }]);
+ }
$sdist = $sdist->[0];
}
var sstr_id = target.getAttribute('sstr_id');
obj.set_sunit(sunit_id, label, sdist_id, sstr_id);
obj.save_sunit(sunit_id, label, sdist_id, sstr_id);
- if (obj.mode == 'bind') obj.refresh_list('workarea');
+ if (obj.mode == 'bind') {
+ obj.refresh_list('main');
+ obj.refresh_list('workarea');
+ }
} catch(E) {
obj.error.standard_unexpected_error_alert('cmd_set_sunit failed!',E);
}
['command'],
function() {
obj.set_other_sunit();
- if (obj.mode == 'bind') obj.refresh_list('workarea');
+ if (obj.mode == 'bind') {
+ obj.refresh_list('main');
+ obj.refresh_list('workarea');
+ }
}
],
'cmd_predict_items' : [
function() {
try {
JSAN.use('util.functional');
+ var donor_unit_ids = {};
var list = util.functional.map_list(
obj.retrieve_ids,
function (o) {
var item = obj.list_sitem_map[o.sitem_id];
+ if (item.unit()) {
+ donor_unit_ids[item.unit().id()] = 1;
+ }
item.unit(obj.current_sunit_id);
return item;
}
var robj = obj.network.request(
'open-ils.serial',
method,
- [ ses(), list, barcodes, call_numbers ]
+ [ ses(), list, barcodes, call_numbers, donor_unit_ids ]
);
if (typeof robj.ilsevent != 'undefined') throw(robj); //TODO: catch for override