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 <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
=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