Bug 21596: Handle empty string for date_renewed when storing a patron
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 17 Oct 2018 22:51:50 +0000 (19:51 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 18 Oct 2018 14:17:39 +0000 (14:17 +0000)
Incorrect date value: '' for column 'date_renewed'

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/Patron.pm
Koha/Patrons/Import.pm

index f9214a6..4c9f955 100644 (file)
@@ -195,6 +195,7 @@ sub store {
             # We don't want invalid dates in the db (mysql has a bad habit of inserting 0000-00-00)
             $self->dateofbirth(undef) unless $self->dateofbirth;
             $self->debarred(undef)    unless $self->debarred;
+            $self->date_renewed(undef) unless $self->date_renewed;
 
             # Set default values if not set
             $self->sms_provider_id(undef) unless $self->sms_provider_id;
index 1adb32d..712c978 100644 (file)
@@ -513,7 +513,7 @@ be formatted to the chosen date format. Populates the correctly formatted date o
 sub format_dates {
     my ($self, $params) = @_;
 
-    foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry)) {
+    foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed)) {
         my $tempdate = $params->{borrower}->{$date_type} or next();
         my $formatted_date = eval { output_pref( { dt => dt_from_string( $tempdate ), dateonly => 1, dateformat => 'iso' } ); };