https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42334

--- Comment #1 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
The implementation differs from the original description:

1. The class is Koha::Library::Calendar::DateCalculator (Koha::Calendar
   was moved to Koha::Library::Calendar by bug 42310).

2. Only the methods that depend on days_mode move to the calculator:

   - addDuration, addDays, addHours => add_duration( $start, $duration, $unit )
   - next_open_days, prev_open_days
   - get_push_amt (now internal)

   days_between, hours_between, has_business_days_between and
   days_forward stay in Koha::Library::Calendar: they only count open
   days and never use days_mode.

3. Callers get a calculator from the calendar, without loading the
   class:

   my $calculator = $library->calendar->date_calculator(
       { days_mode => $days_mode } );
   my $due_date = $calculator->add_duration( $start, $duration, 'days' );

   days_mode is mandatory. There is no fallback to the useDaysMode system
   preference: callers pass the effective value (the daysmode circulation
   rule or the system preference).

4. days_mode is validated when the calculator is created. Valid values
   are Days, Calendar, Datedue and Dayweek; anything else throws
   Koha::Exceptions::WrongParameter. Before, unknown values silently
   behaved like 'Days'. An atomic update replaces invalid values stored
   in useDaysMode or in daysmode circulation rules with 'Days', which
   keeps the previous behavior, and warns about each one so it can be
   reviewed.

Koha::Library::Calendar also loses days_mode as a constructor
parameter, the unused set_daysmode and clear_weekly_closed_days methods,
and the {test} flag they relied on. It gains library_id and
is_weekly_closure accessors, which the calculator uses instead of
reading the calendar internals.

This depends on bug 43838, which fixes how Dayweek moves dates over
closed days, so the fix can be backported separately before this
refactoring.

Follow-ups, to be filed separately:

- Validate daysmode values in admin/smart-rules.pl and in the
  circulation rules API, so invalid values cannot be stored again.
- A single implementation for "is this day closed" (closed_dates_in_range,
  staticfines.pl using C4::Calendar::isHoliday).
- Remove C4::Calendar once the calendar administration is moved to
  Koha::Library::Calendar.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to