Bug 32030: Allow only one controlling license per agreement
Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
64a838ce32
commit
abd80f4c6a
|
|
@ -22,6 +22,7 @@ use MIME::Types;
|
|||
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::Exceptions;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
|
@ -103,6 +104,12 @@ sub agreement_licenses {
|
|||
my ( $self, $agreement_licenses ) = @_;
|
||||
|
||||
if ( $agreement_licenses ) {
|
||||
my $controlling = grep { $_->{status} eq 'controlling' } @$agreement_licenses;
|
||||
if ( $controlling > 1 ) {
|
||||
Koha::Exceptions::DuplicateObject->throw(
|
||||
"Only one controlling license can exist for a given agreement");
|
||||
}
|
||||
|
||||
my $schema = $self->_result->result_source->schema;
|
||||
$schema->txn_do(
|
||||
sub {
|
||||
|
|
|
|||
|
|
@ -305,6 +305,10 @@ export default {
|
|||
errors.push(this.$t("Only one controlling license is allowed"))
|
||||
}
|
||||
|
||||
if (agreement_licenses.filter(al => al.status == 'controlling').length > 1) {
|
||||
errors.push(this.$t("Only one controlling license is allowed"))
|
||||
}
|
||||
|
||||
errors.forEach(function (e) {
|
||||
setWarning(e)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue