From b574b615919a6463708d4c1d7b1153a061c1ea0a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 29 Oct 2015 15:31:39 +0000 Subject: [PATCH] Bug 15084: Make sure the previous active currency is marked as inactive On inserting an active currency, others should be marked as inactive. We can only have 1 active currency at the same time. Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Brendan A Gallagher --- Koha/Acquisition/Currency.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Koha/Acquisition/Currency.pm b/Koha/Acquisition/Currency.pm index dd34cc2046..da0bcd2386 100644 --- a/Koha/Acquisition/Currency.pm +++ b/Koha/Acquisition/Currency.pm @@ -33,6 +33,26 @@ Koha::Acquisition::Currency - Koha Acquisition Currency Object class =cut +=head3 store + +=cut + +sub store { + my ( $self ) = @_; + my $result; + $self->_result->result_source->schema->txn_do( sub { + if ( $self->active ) { + my @currencies = Koha::Acquisition::Currencies->search; + for my $currency ( @currencies ) { + $currency->active(0); + $currency->store; + } + } + $result = $self->SUPER::store; + }); + return $result; +} + =head3 type =cut -- 2.39.5