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)
committerMason James <mtj@kohaaloha.com>
Wed, 22 Feb 2017 20:36:21 +0000 (09:36 +1300)
commit14b0f64e79e861e97426709a2a7aedd0feccb449
treef44b2bba8752ac975df41ccbad4fc968749d8403
parent0ac1c9e32148a9bdca96ea62d4b5616ba4a2f974
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: Mason James <mtj@kohaaloha.com>
C4/Items.pm
t/db_dependent/Items.t