From 4b8f92a7565f03f4074c0a6a5a176d7d109339f8 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 24 Sep 2018 07:45:08 +0000 Subject: [PATCH] Bug 21401: Take transaction library from userenv when not defined Test plan: 1) Apply the patch 2) Run database update 3) prove t/db_dependent/Account.t Signed-off-by: Michal Denar --- Koha/Account/Offset.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Koha/Account/Offset.pm b/Koha/Account/Offset.pm index f456d16..7b64338 100644 --- a/Koha/Account/Offset.pm +++ b/Koha/Account/Offset.pm @@ -36,6 +36,19 @@ Account offsets are used to track the changes in account lines =cut +=head3 new + +=cut + +sub new { + my ($class, $params) = @_; + + $params->{transaction_library} //= + defined C4::Context->userenv ? C4::Context->userenv->{branch} : undef; + + return $class->SUPER::new($params); +} + =head3 debit my $debit = $account_offset->debit; -- 2.1.4