use Koha::Acquisition::Orders;
use Koha::Exceptions::Acquisition::Basket;
use Koha::Patrons;
+use C4::Log qw(logaction);
use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
}
);
+ # Log the closure
+ if (C4::Context->preference("AcqLog")) {
+ logaction(
+ 'ACQUISITIONS',
+ 'CLOSE_BASKET',
+ $self->id
+ );
+ }
+
return $self;
}
subtest 'Acquisition logging' => sub {
- plan tests => 6;
+ plan tests => 5;
t::lib::Mocks::mock_preference('AcqLog', 1);
is (scalar @create_logs, 1, 'Basket creation is logged');
Koha::ActionLogs->delete;
- C4::Acquisition::CloseBasket($basketno);
- my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basketno });
- is (scalar @close_logs, 1, 'Basket closure is logged');
-
- Koha::ActionLogs->delete;
C4::Acquisition::ReopenBasket($basketno);
my @reopen_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno });
is (scalar @reopen_logs, 1, 'Basket reopen is logged');
subtest 'close() tests' => sub {
- plan tests => 3;
+ plan tests => 4;
+
+ # Turn on acquisitions logging and ensure the logs are empty
+ t::lib::Mocks::mock_preference('AcqLog', 1);
+ Koha::ActionLogs->delete;
$schema->storage->txn_begin;
'Koha::Exceptions::Acquisition::Basket::AlreadyClosed',
'Trying to close an already closed basket throws an exception';
+ my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basket->id });
+ is (scalar @close_logs, 1, 'Basket closure is logged');
+
$schema->storage->txn_rollback;
};