Bug 19036: (QA follow-up) Use Koha::DateUtils
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 25 Jun 2020 09:16:45 +0000 (10:16 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 20 Aug 2020 10:31:59 +0000 (12:31 +0200)
This patch replaced raw DateTime->now calls with dt_from_string from
Koha::DateUtils

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/Account/Line.pm
t/db_dependent/Koha/Account.t

index d4fbd6b..98d7ef3 100644 (file)
@@ -27,6 +27,7 @@ use Koha::Account::CreditType;
 use Koha::Account::DebitType;
 use Koha::Account::Offsets;
 use Koha::Database;
+use Koha::DateUtils;
 use Koha::Exceptions::Account;
 use Koha::Items;
 
@@ -905,7 +906,7 @@ sub store {
             $max //= 0;
             $self->credit_number($max + 1);
         } elsif ($AutoCreditNumber eq 'annual') {
-            my $now = DateTime->now;
+            my $now = dt_from_string;
             my $prefix = sprintf('%d-', $now->year);
             my $max = $rs->search({
                 -and => [
@@ -920,7 +921,7 @@ sub store {
             my $userenv = C4::Context->userenv;
             if ($userenv) {
                 my $branch = $userenv->{branch};
-                my $now = DateTime->now;
+                my $now = dt_from_string;
                 my $prefix = sprintf('%s%d%02d', $branch, $now->year, $now->month);
                 my $pattern = $prefix;
                 $pattern =~ s/([\?%_])/\\$1/g;
index c6341c0..4a8ef7c 100755 (executable)
@@ -1065,7 +1065,7 @@ subtest 'Koha::Account::pay() generates credit number' => sub {
     my $context = Test::MockModule->new('C4::Context');
     $context->mock( 'userenv', { branch => $library->id } );
 
-    my $now = DateTime->now;
+    my $now = dt_from_string;
     my $year = $now->year;
     my $month = $now->month;
     my ($accountlines_id, $accountline);