Bug 12671: Guess next serial date when there are several issues per unit
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 22 Jul 2014 12:43:16 +0000 (14:43 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 5 May 2015 18:22:10 +0000 (15:22 -0300)
commit8b94c89f0bd73888d7f5146b0be1848cf2c25cbf
treebb710add50148fc0e1cb918d82f8c15eb078ab88
parentbad95fc8b3784e63b219866395d2054a26a30067
Bug 12671: Guess next serial date when there are several issues per unit

This guess uses the following algorithm
1/ Get the number of days remaining from first issue of this unit of
time until the end of the unit of time (using 7 days for week, 28 for
month and 365 for year)
2/ Divide it by the number of issues per unit
3/ Take the integer part of the result, this is the number of days to
add to previous serial published date

This patch also try to guess the date of the first issue of a unit of
time. Before that, it was:
- for week: monday of week
- for month: 1st day of month
- for year: 1st day of year
Now it uses firstacquidate.

Example:
  firstacquidate = 1970-01-07 (wednesday)
  unit = week
  issuesperunit = 2 (2 issues per week)

  From wednesday to sunday, there are 4 days so we add 2 days to get the
  next date.
  The next dates should be:
  - 1970-01-09 (+ 2 days)
  - 1970-01-14 (wednesday of next week)
  - 1970-01-16 (+ 2 days)
  - ... and so on

Test plan:
1/ Go to numbering pattern creation page (Serials -> Manager numbering
patterns -> New numbering pattern)
2/ In "Test prediction pattern" fieldset, set subscription length to 50
issues (this avoid to compute the next 1000 dates, which can take time)
3/ Fill first issue publication date
4/ Choose the frequency you want to test
5/ click on "Test pattern" button
6/ Check that the dates are correct
7/ Repeat steps 3-7 until you think you have tested enough cases

Interesting frequencies to test:
- 1/day
- 1/week
- 2/week
- 6/week (firstacquidate should be monday or tuesday, or the generated
  dates will be the same for all the week)
- 1/month
- 2/month
- 3/month
- 1/year
- 2/year
- 3/year

----------------
Sign off report:
----------------
-Followed the test plan. Unit tests work. Also trying some more strange
 frequencies with our librarians:
 5/year, 43/year, 10/year.
-Received all serials for a subscription and found no errors.
-Received some serials with frequency 2/month pre-patch, getting publication
 date as 1st of every month for each magazine. Having applied the patch,
 publication dates started working mid-subscription for new magazines.
-Works well and fine!
Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Serials.pm
t/db_dependent/Serials/GetNextDate.t