From: Kyle Huckins Date: Wed, 1 Feb 2017 19:23:21 +0000 (-0800) Subject: CAT-111 Holding Maintenance Item Update Bug X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=886c6a85657d1a6978b47c1c8c6a69e143517d47;p=working%2FEvergreen.git CAT-111 Holding Maintenance Item Update Bug Bugfix for CAT-69. Add .length to comparison in copies_to_check for loop in g.gather_copies. Update copies in g.gather_copies. Add FM_ACP_UNFLESHED_BATCH_RETRIEVE.authoritative API and call it in g_stash_and_close();. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm modified: Open-ILS/xul/staff_client/chrome/content/main/constants.js modified: Open-ILS/xul/staff_client/server/cat/update_items.js --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 95c5ee5fc8..edb1a8af1d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -372,12 +372,14 @@ sub biblio_barcode_to_copy { __PACKAGE__->register_method( method => "biblio_id_to_copy", api_name => "open-ils.search.asset.copy.batch.retrieve", + authoritative => 1, ); + sub biblio_id_to_copy { my( $self, $client, $ids ) = @_; + my $e = new_editor(); $logger->info("Fetching copies @$ids"); - return $U->cstorereq( - "open-ils.cstore.direct.asset.copy.search.atomic", { id => $ids } ); + return $e->search_asset_copy({ id => $ids }); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index b2e0864ca8..af3b7c0ecd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -112,6 +112,7 @@ var api = { 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.find_by_barcode.authoritative', 'secure' : false }, 'FM_ACP_FLESHED_BATCH_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve', 'secure' : false }, 'FM_ACP_UNFLESHED_BATCH_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.batch.retrieve', 'secure' : false }, + 'FM_ACP_UNFLESHED_BATCH_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.batch.retrieve.authoritative', 'secure' : false }, 'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve.authoritative', 'secure' : false }, 'FM_ACP_FLESHED_BATCH_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy.fleshed.batch.update' }, 'FM_ACP_TRANSFER_COPIES_BATCH' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.transfer_copies_to_volume' }, diff --git a/Open-ILS/xul/staff_client/server/cat/update_items.js b/Open-ILS/xul/staff_client/server/cat/update_items.js index 5447a2ac24..030a4392ee 100644 --- a/Open-ILS/xul/staff_client/server/cat/update_items.js +++ b/Open-ILS/xul/staff_client/server/cat/update_items.js @@ -1014,7 +1014,7 @@ g.gather_copies = function() { //Either update the volume or find/create a new one, depending on //volumes in if we're working with every copy in a volume or just a few - if(copiesInVolume > currentOrderBarcodes.length) { + if (currentOrderBarcodes.length < copiesInVolume) { var new_volume = g.find_or_create_volume(callnumber, g.map_acn[acn_id].record(), ou_id); g.set_acn_id_for_current_po(barcodes, acn_id, new_volume.id()); new_volume.label(callnumber); @@ -1084,6 +1084,7 @@ g.gather_copies = function() { copies[i].isdeleted(get_db_true()); } } + g.update_copies(copies); // Get the default copy status; default to "In Process" if unset, per 1.6 var normal_ccs = g.data.hash.aous['cat.default_copy_status_normal'] || 5; @@ -1127,6 +1128,25 @@ g.gather_copies = function() { } } +g.update_copies = function(copies) { + // Update copies + var r = g.network.simple_request( + 'FM_ACP_FLESHED_BATCH_UPDATE', + [ ses(),copies, true ] + ); + + if (r.textcode === 'ITEM_BARCODE_EXISTS') { + + alert('error with item update: ' + r.desc+": 1184"); + dont_close = true; + } + + else if (typeof r.ilsevent != 'undefined') { + + alert('error with copy update:' + js2JSON(r)+": 1188"); + } + +} g.stash_and_close = function(param, keepOpen) { oils_unlock_page(); @@ -1182,7 +1202,7 @@ g.stash_and_close = function(param, keepOpen) { } var copies_to_check = g.network.simple_request( - 'FM_ACP_UNFLESHED_BATCH_RETRIEVE', + 'FM_ACP_UNFLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ] ); if (typeof copies_to_check.ilsevent != 'undefined') { @@ -1200,9 +1220,10 @@ g.stash_and_close = function(param, keepOpen) { var altered_copies = []; var remaining_copies = []; - for(var c = 0; c < copies.length; c++) { - for (var i = 0; i < copies_to_check; i++) { + for (var c = 0; c < copies.length; c++) { + for (var i = 0; i < copies_to_check.length; i++) { + //Ensure we have the right call number if (copies_to_check[i].id() == copies[c].id()) { copies[c].call_number(copies_to_check[i].call_number()); break; @@ -1234,22 +1255,7 @@ g.stash_and_close = function(param, keepOpen) { // User clicked 'Save' else { - // Update copies - var r = g.network.simple_request( - 'FM_ACP_FLESHED_BATCH_UPDATE', - [ ses(),altered_copies, true ] - ); - - if (r.textcode === 'ITEM_BARCODE_EXISTS') { - - alert('error with item update: ' + r.desc+": 1184"); - dont_close = true; - } - - else if (typeof r.ilsevent != 'undefined') { - - alert('error with copy update:' + js2JSON(r)+": 1188"); - } + g.update_copies(altered_copies); } try {