Bug 17512: Improve handling dates in C4::Items
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 27 Oct 2016 13:07:29 +0000 (15:07 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 14 Feb 2017 13:57:49 +0000 (13:57 +0000)
commit137cbd8d09be549c9ae97dfad746a9c52d27b9a6
tree846cf44701783db48dea4e8066faa929a3a63fbc
parente9cd82e4ca754024009608242d7c9930ac248cff
Bug 17512: Improve handling dates in C4::Items

This is a follow-up on the internal server error on 0000-00-00 in the items
column onloan. This patch deals with preventing to have such dates at all
in the date fields of items.

It is accomplished by:
[1] Adding a (private) subroutine _mod_item_dates. It takes an item hash
    and replaces date values if needed.
[2] AddItem and ModItem call _koha_new_item resp. koha_modify_item. In these
    routines a call to the new _mod_item_dates is inserted.
[3] Although the routine is actually private, I have added some unit tests
    to Items.t.

Test plan:
[1] Add a new item. Fill a correct date in dateaccessioned and an invalid
    date in Price effective from (=replacementpricedate).
[2] Verify that dateaccessioned is saved correctly and replacementpricedate
    is still null (does not contain 0000-00-00).
[3] Edit the item again. Fill some text in dateaccessioned and put a correct
    date in replacementpricedate. Verify the results.
[4] Run t/db_dependent/Items.t

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Items.pm
t/db_dependent/Items.t