From 73a7c1d86c15576c962dd54608d9a6d6e24e624d Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Sat, 1 Jun 2024 13:31:55 +0200 Subject: [PATCH] New field 'move_event' for moving occurence-date if not a business day --- locale/de.po | 20 ++++++++++++++++++++ locale/en.po | 20 ++++++++++++++++++++ planner.py | 19 +++++++++++++++++++ tests/planner.py | 1 + view/planner_form.xml | 4 ++++ 5 files changed, 64 insertions(+) diff --git a/locale/de.po b/locale/de.po index 80480d3..c7404e3 100644 --- a/locale/de.po +++ b/locale/de.po @@ -322,6 +322,26 @@ msgctxt "field:cashbook.planner,party:" msgid "Party" msgstr "Partei" +msgctxt "field:cashbook.planner,move_event:" +msgid "If no business day" +msgstr "Wenn kein Werktag" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "unchanged" +msgstr "unverändert" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "Business day before original date" +msgstr "Geschäftstag vor ursprünglichem Datum" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "Business day after original date" +msgstr "Geschäftstag nach ursprünglichem Datum" + +msgctxt "help:cashbook.planner,move_event:" +msgid "If the date of execution falls on a weekend or holiday, it can be moved to a business day." +msgstr "Wenn das Datum der Ausführung auf ein Wochenende oder Feiertag fällt, kann es auf einen Geschäftstag verschoben werden." + ############################ # cashbook.planner.nextrun # diff --git a/locale/en.po b/locale/en.po index c743815..9ec77a4 100644 --- a/locale/en.po +++ b/locale/en.po @@ -298,6 +298,26 @@ msgctxt "field:cashbook.planner,party:" msgid "Party" msgstr "Party" +msgctxt "field:cashbook.planner,move_event:" +msgid "If no business day" +msgstr "If no business day" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "unchanged" +msgstr "unchanged" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "Business day before original date" +msgstr "Business day before original date" + +msgctxt "selection:cashbook.planner,move_event:" +msgid "Business day after original date" +msgstr "Business day after original date" + +msgctxt "help:cashbook.planner,move_event:" +msgid "If the date of execution falls on a weekend or holiday, it can be moved to a business day." +msgstr "If the date of execution falls on a weekend or holiday, it can be moved to a business day." + msgctxt "model:cashbook.planner.nextrun,name:" msgid "Next Execution Date" msgstr "Next Execution Date" diff --git a/planner.py b/planner.py index c1b4824..1acfadd 100644 --- a/planner.py +++ b/planner.py @@ -34,6 +34,11 @@ SEL_WEEKDAY = [ ('0', 'Monday'), ('1', 'Tuesday'), ('2', 'Wednesday'), ('3', 'Thursday'), ('4', 'Friday'), ('5', 'Saturday'), ('6', 'Sunday')] +SEL_MOVE_EVENT = [ + ('nop', 'unchanged'), + ('before', 'Business day before original date'), + ('after', 'Business day after original date') +] class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView): @@ -101,6 +106,10 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView): nextrun_date = fields.Function(fields.Date( string='Next Execution Date', readonly=True), 'on_change_with_nextrun_date', searcher='search_nextrun_date') + move_event = fields.Selection( + string='If no business day', required=True, selection=SEL_MOVE_EVENT, + help='If the date of execution falls on a weekend or holiday, ' + + 'it can be moved to a business day.') bookingtype = fields.Selection( string='Type', selection=sel_bookingtype, required=True, @@ -442,6 +451,16 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView): """ return [('nextrun.date',) + tuple(clause[1:])] + @classmethod + def default_move_event(cls): + """ 'no operation' as default for + business-day occurence + + Returns: + str: nop + """ + return 'nop' + @classmethod def default_wfcheck(cls): """ False as default for wf-state 'checked' diff --git a/tests/planner.py b/tests/planner.py index 7638279..d9ad9e7 100644 --- a/tests/planner.py +++ b/tests/planner.py @@ -60,6 +60,7 @@ class PlannerTestCase(object): self.assertEqual(job.monthday, 1) self.assertEqual(job.interval, 1) self.assertEqual(job.setpos, None) + self.assertEqual(job.move_event, 'nop') self.assertEqual( job.nextdates, '05/01/2022 | 06/01/2022 | 07/01/2022 | 08/01/2022 |' + diff --git a/view/planner_form.xml b/view/planner_form.xml index d15d0ff..86e826f 100644 --- a/view/planner_form.xml +++ b/view/planner_form.xml @@ -35,6 +35,10 @@ full copyright notices and license terms. -->