From 6c2eeaa43443e0591eebbf00f48dacfff005b647 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Oct 2018 08:32:59 -0300 Subject: [PATCH] Bug 21599: Fix item type creation by defining default values Same as what we have in Koha::Patron->new, empty strings should not be inserted in integer or date column type DBD::mysql::st execute failed: Incorrect decimal value: '' for column 'defaultreplacecost' at row 1 [for Statement "INSERT INTO `itemtypes` ( `checkinmsg`, `checkinmsgtype`, `defaultreplacecost`, `description`, `hideinopac`, `imageurl`, `itemtype`, `notforloan`, `processfee`, `rentalcharge`, `searchcategory`, `sip_media_type`, `summary`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="", 1="message", 2="", 3="xx", 4=0, 5='', 6="XX", 7=0, 8="", 9="", 10="", 11=undef, 12=""] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832. Test plan: Create a new itemtype Signed-off-by: Claire Gravely Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 33c142ba3b7cfd37dd90569de2a5802849b09ef5) Signed-off-by: Martin Renvoize --- Koha/ItemType.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm index 24be0d2297..ec685296de 100644 --- a/Koha/ItemType.pm +++ b/Koha/ItemType.pm @@ -36,6 +36,18 @@ Koha::ItemType - Koha Item type Object class =cut +sub store { + my ($self) = @_; + + $self->rentalcharge(undef) if $self->rentalcharge eq ''; + $self->defaultreplacecost(undef) if $self->defaultreplacecost eq ''; + $self->processfee(undef) if $self->processfee eq ''; + $self->notforloan(0) unless $self->notforloan; + $self->hideinopac(0) unless $self->hideinopac; + + return $self->SUPER::store; +} + =head3 image_location =cut -- 2.39.5