- Properly utilize linked idl field for grid additions.
- Remove excessive fetching.
- Ensure checkin interface Inventory Date displays a static, non-updating timestamp.
Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Changes to be committed:
modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
modified: Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2
modified: Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2
modified: Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
modified: Open-ILS/src/templates/staff/cat/item/t_list.tt2
modified: Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2
modified: Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2
modified: Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js
modified: Open-ILS/web/js/ui/default/staff/cat/services/holdings.js
modified: Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
modified: Open-ILS/web/js/ui/default/staff/circ/services/item.js
return $e->die_event unless $e->checkauth;
my $copies = $$args{copy_list};
- foreach my $copy (@$copies) {
- my $existing_alci = $e->search_asset_last_copy_inventory({copy => $copy})->[0];
+ foreach my $copyid (@$copies) {
+ my $copy = $e->retrieve_asset_copy($copyid);
+ my $alci = $e->search_asset_last_copy_inventory({copy => $copyid})->[0];
- if($existing_alci) {
- $existing_alci->inventory_date('now');
- $existing_alci->inventory_workstation($e->requestor->wsid);
- $e->update_asset_last_copy_inventory($existing_alci) or return $e->die_event;
+ if($alci) {
+ $alci->inventory_date('now');
+ $alci->inventory_workstation($e->requestor->wsid);
+ $e->update_asset_last_copy_inventory($alci) or return $e->die_event;
} else {
my $alci = Fieldmapper::asset::last_copy_inventory->new;
$alci->inventory_date('now');
$alci->inventory_workstation($e->requestor->wsid);
- $alci->copy($copy);
+ $alci->copy($copy->id);
$e->create_asset_last_copy_inventory($alci) or return $e->die_event;
}
+
+ $copy->last_copy_inventory($alci);
}
$e->commit;
return 1;
if($alci->[0]) {
$self->last_copy_inventory->id($alci->[0]->id);
}
- }
+ }
+ $self->copy->last_copy_inventory($self->last_copy_inventory);
for my $evt (@{$self->events}) {
{{item['call_number.record.simple_record.title']}}
</a>
</eg-grid-field>
- <eg-grid-field path="_last_inventory_date" datatype="timestamp" label="[% l('Inventory Date') %]"></eg-grid-field>
- <eg-grid-field path="_last_inventory_workstation" label="[% l('Inventory Workstation') %]"></eg-grid-field>
+ <eg-grid-field path="last_copy_inventory.inventory_date" datatype="timestamp" label="[% l('Inventory Date') %]"></eg-grid-field>
+ <eg-grid-field path="last_copy_inventory.inventory_workstation.name" label="[% l('Inventory Workstation') %]"></eg-grid-field>
</eg-grid>
{{item['call_number.record.simple_record.title']}}
</a>
</eg-grid-field>
- <eg-grid-field path="_last_inventory_date" datatype="timestamp" label="[% l('Inventory Date') %]"></eg-grid-field>
- <eg-grid-field path="_last_inventory_workstation" label="[% l('Inventory Workstation') %]"></eg-grid-field>
+ <eg-grid-field path="last_copy_inventory.inventory_date" datatype="timestamp" label="[% l('Inventory Date') %]"></eg-grid-field>
+ <eg-grid-field path="last_copy_inventory.inventory_workstation.name" label="[% l('Inventory Workstation') %]"></eg-grid-field>
</eg-grid>
{{item['copy_alert_count']}}
<button ng-disabled="item['copy_alert_count'] <= 0" class="btn btn-sm btn-default" ng-click="col.handlers.copyAlertsEdit(item['id'])">[% l('Manage') %]</button>
</eg-grid-field>
- <eg-grid-field label="[% l('Inventory Date') %]" path="_last_inventory_date"></eg-grid-field>
- <eg-grid-field label="[% l('Inventory Workstation') %]" path="_last_inventory_workstation"></eg-grid-field>
+ <eg-grid-field label="[% l('Inventory Date') %]" datatype="timestamp" path="last_copy_inventory.inventory_date"></eg-grid-field>
+ <eg-grid-field label="[% l('Inventory Workstation') %]" path="last_copy_inventory.inventory_workstation.name"></eg-grid-field>
</eg-grid>
</div>
{{item['copy_alert_count']}}
<button ng-disabled="item['copy_alert_count'] <= 0" class="btn btn-sm btn-default" ng-click="col.handlers.copyAlertsEdit(item['id'])">[% l('Manage') %]</button>
</eg-grid-field>
- <eg-grid-field label="[% l('Inventory Date') %]" path="_last_copy_inventory.inventory_date" datatype="timestamp"></eg-grid-field>
- <eg-grid-field label="[% l('Inventory Workstation') %]" path="_last_copy_inventory._inventory_workstation_name"></eg-grid-field>
+ <eg-grid-field label="[% l('Inventory Date') %]" path="last_copy_inventory.inventory_date" datatype="timestamp"></eg-grid-field>
+ <eg-grid-field label="[% l('Inventory Workstation') %]" path="last_copy_inventory.inventory_workstation.name"></eg-grid-field>
</eg-grid>
<div class="flex-row">
<div class="flex-cell">[% l('Inventory Date') %]</div>
- <div class="flex-cell well">{{last_copy_inventory.inventory_date() | date:egDateAndTimeFormat}}</div>
+ <div class="flex-cell well">{{copy.last_copy_inventory().inventory_date() | date:egDateAndTimeFormat}}</div>
<div class="flex-cell">[% l('Inventory Workstation') %]</div>
- <div class="flex-cell well">{{last_copy_inventory.inventory_workstation().name()}}</div>
+ <div class="flex-cell well">{{copy.last_copy_inventory().inventory_workstation().name()}}</div>
<div class="flex-cell"></div>
<div class="flex-cell"></div>
<eg-grid-field path="au.*" parent-idl-class="au" hidden></eg-grid-field>
<eg-grid-field path="transit.*" parent-idl-class="atc" hidden></eg-grid-field>
<eg-grid-field path="hold.*" parent-idl-class="ahr" hidden></eg-grid-field>
- <eg-grid-field path="alci.inventory_date" label="[% l('Inventory Date') %]" datatype="timestamp" parent-idl-class="alci" hidden></eg-grid-field>
- <eg-grid-field path="alci.inventory_workstation" label="[% l('Inventory Workstation')%]" parent-idl-class="alci" hidden>{{item.alci["inventory_workstation.name"]}}</eg-grid-field>
+ <eg-grid-field path="acp.last_copy_inventory.inventory_date" label="[% l('Inventory Date') %]" datatype="timestamp" hidden></eg-grid-field>
+ <eg-grid-field path="acp.last_copy_inventory.inventory_workstation.name" label="[% l('Inventory Workstation')%]" hidden></eg-grid-field>
</eg-grid>
return null;
},
allItemsRetrieved : function() {
- angular.forEach($scope.gridControls.allItems(), function(copy) {
- bucketSvc.fetchRecentInventoryData(copy).then(function(alci) {
- if (alci) {
- copy._last_inventory_date = alci.inventory_date();
- copy._last_inventory_workstation = alci.inventory_workstation().name();
- }
- });
- });
$scope.context.selectPendingBC = true;
}
}
setQuery : function(q) {
if (q) query = q;
return query;
- },
- allItemsRetrieved : function() {
- angular.forEach($scope.gridControls.allItems(), function(copy) {
- bucketSvc.fetchRecentInventoryData(copy).then(function(alci) {
- if (alci) {
- copy._last_inventory_date = alci.inventory_date();
- copy._last_inventory_workstation = alci.inventory_workstation().name();
- }
- });
- });
}
};
};
service.prototype.flesh = {
- flesh : 2,
+ flesh : 3,
flesh_fields : {
- acp : ['status','location','circ_lib','parts','age_protect','copy_alerts'],
- acn : ['prefix','suffix','copies']
+ acp : ['status','location','circ_lib','parts','age_protect','copy_alerts', 'last_copy_inventory'],
+ acn : ['prefix','suffix','copies'],
+ alci : ['inventory_workstation']
}
}
}
});
- //create a virtual field for displaying most recent inventory data
- angular.forEach(svc.copies, function(cp) {
- egCore.pcrud.search('alci',
- {copy: cp.id},
- {flesh: 2, flesh_fields: {alci: ['inventory_workstation']}}
- ).then(function(alci) {
- if (alci) {
- cp._last_inventory_workstation = alci.inventory_workstation().name();
- cp._last_inventory_date = alci.inventory_date();
- }
- });
- });
-
// create virtual field for copy alert count
angular.forEach(svc.copies, function (cp) {
if (cp.copy_alerts) cp.copy_alert_count = cp.copy_alerts.length;
row_item['copy_barcode'] = row_item.acp.barcode();
+ if (row_item.acp.last_copy_inventory().inventory_date() == "now")
+ row_item.acp.last_copy_inventory().inventory_date(Date.now());
+
if (row_item.mbts) {
var amt = Number(row_item.mbts.balance_owed());
if (amt != 0) {
flesh : 4,
flesh_fields : {
acp : ['call_number','location','status','location','floating','circ_modifier',
- 'age_protect','circ_lib','copy_alerts'],
+ 'age_protect','circ_lib','copy_alerts', 'last_copy_inventory'],
acn : ['record','prefix','suffix','label_class'],
- bre : ['simple_record','creator','editor']
+ bre : ['simple_record','creator','editor'],
+ alci : ['inventory_workstation']
},
select : {
// avoid fleshing MARC on the bre
limit : 1
}
- service.inventoryFlesh = {
- flesh : 2,
- flesh_fields : {
- alci : ['inventory_workstation']
- }
- }
-
//Retrieve separate copy, aacs, and accs information
service.getCopy = function(barcode, id) {
if (barcode) {
service.circFlesh).then(function(circ) {return circ});
}
- service.getInventory = function(id) {
- return egCore.pcrud.search('alci', {copy : id },
- service.inventoryFlesh).then(function(alci) {return alci});
- }
-
service.getSummary = function(id) {
return circ_summary = egCore.net.request(
'open-ils.circ',
});
}
- var fetchInventory = function(copy) {
- return service.getInventory(copy.id())
- .then(function(alci) {
- if (alci) {
- copyData.last_copy_inventory = alci;
- return copyData;
- }
- });
- }
-
return fetchCopy(barcode, id).then(function(res) {
if(!res.copy) { return $q.when(); }
- return fetchInventory(copyData.copy).then(function(invRes) {
- return fetchCirc(copyData.copy).then(function(res) {
- if (copyData.circ) {
- return fetchSummary(copyData.circ).then(function() {
- return copyData;
- });
- } else {
+ return fetchCirc(copyData.copy).then(function(res) {
+ if (copyData.circ) {
+ return fetchSummary(copyData.circ).then(function() {
return copyData;
- }
- });
+ });
+ } else {
+ return copyData;
+ }
});
});
var copy;
var circ;
var circ_summary;
- var last_copy_inventory;
var lastRes = {};
return service.retrieveCopyData(barcode, id)
flatCopy._circ_summary.checkout_workstation :
'';
}
- if (copyData.last_copy_inventory) {
- flatCopy._last_copy_inventory = egCore.idl.toHash(copyData.last_copy_inventory, true);
- flatCopy._last_copy_inventory._inventory_workstation_name = copyData.last_copy_inventory.inventory_workstation().name();
- }
flatCopy.index = service.index++;
flatCopy.copy_alert_count = copyData.copy.copy_alerts().filter(function(aca) {
return !aca.ack_time();
return lastRes = {
copy : copyData.copy,
- last_copy_inventory : copyData.last_copy_inventory,
index : flatCopy.index
}
});