Bug 34109: Check mandatory item fields when creating during recipt

This patch adds a check of mandatory item fields before saving during order receipt.
We check both when adding the item initially, and when submitting the order, as it will use
the values from the open form.

To test:
* Go to administration > frameworks > ACQ > MARC structure > 952
* Set callnumber (o) or barcode (p) to mandatory
* In acquisition:
* Create a basket with "create items on order" and "is standing"
  "standing" helps as you can do multiple receives testing different things,
  but is optional
* Add an order line
* Receive shipment
* Verify the mandatory fields show in the item form
* Set itemtype = Music
* Save with the fields blank
* Item row is added, no warning
* Edit the item, change the item type to blank
* Click 'Confirm' for the order without closing the item edit form
* Verify the item was added with itemtype Books (on sample data) and empty mandatory field
* Apply patch
* Repeat above, however, you should not be able to submit the item or order until mandatory fields are filled

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-08-04 14:13:25 +00:00 committed by Tomas Cohen Arazi
parent 021d083a9a
commit eaab32eb0e
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 32 additions and 1 deletions

View File

@ -1337,6 +1337,23 @@
});
$('.modal-save').click(function() {
//We need to validate the item forms here - if one is opened with missing subfields at
//confirm, it would be submitted without this
var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
_alertString +="-------------------------------------------------------------------\n\n";
var empty_mandatory_fields = 0;
$('div[id^="itemblock"]').each(function(){
var item_form = $(this);
var empty_item_mandatory = CheckMandatorySubfields(item_form);
empty_mandatory_fields += empty_item_mandatory;
});
if (empty_mandatory_fields > 0) {
_alertString +="\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields);
alert(_alertString);
return false;
}
var saved_rows = save_row();
if(Object.keys(saved_rows).length) $('.save').prop('disabled', false);
$("#order_edit").modal('hide');

View File

@ -1,7 +1,21 @@
/* global __ */
/* exported addItem checkCount showItem deleteItemBlock clearItemBlock check_additem */
function addItem( node, unique_item_fields ) {
var index = $(node).closest("div").attr('id');
var item_form = $(node).closest("div");
var index = item_form.attr("id");
//We need to verify the item form before saving
var empty_item_mandatory = CheckMandatorySubfields(item_form);
if (empty_item_mandatory > 0) {
var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
_alertString +="-------------------------------------------------------------------\n\n";
_alertString +=
"\n- " + _("%s item mandatory fields empty").format(empty_item_mandatory);
alert(_alertString);
return false;
}
var current_qty = parseInt($("#quantity").val());
var max_qty;
if($("#quantity_to_receive").length != 0){