From 6d3dadb25acb416dd7b824dc5f1eb6b232de871c 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 --- Koha/ItemType.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm index 3d769a5..d2a23b5 100644 --- a/Koha/ItemType.pm +++ b/Koha/ItemType.pm @@ -37,6 +37,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.1.4