Schedules
schedules
Schedules implement the logic for calculating the scheduled dates for each schedule stored in the database.
The actual schedule database object is the Schedules, and it can be converted by loading the rules appropriately.
Classes:
-
Pattern–Implements a single pattern for a schedule.
-
Schedule–Implements schedules object for calculation.
Pattern
Pattern(
value: int,
type: (
PatternType
| Literal[
"SU", "MO", "TU", "WE", "TH", "FR", "SA", "day"
]
| str
) = DAY,
)
Bases: BaseModel
Implements a single pattern for a schedule.
The pattern controls individual inclusions on the schedule. For example, if you want to make a schedule that runs every month on a specific day, you could additionally add the a pattern for, for example, the 15th of the month. This translates to:
You may also provide the pattern as in days of the week. For the first Tuesday, you would use:
If you want to indicate the last day, you can use -1 for the value:
Parameters:
-
(valueint) –Day of the month or weekday. If set to
-1, it will translate to the last day. -
(typePatternType, default:<PatternType.DAY: 'day'>) –Type of pattern. Can be set to a specific weekday (i.e. Monday) or day of the month.
Source code in actual/schedules.py
Schedule
Bases: BaseModel
Implements schedules object for calculation.
Schedules are a way to define recurring transactions in your budget.
On the database level, schedules are stored as part of a Rule, which then compares if the date found fits within the schedule by using the is_approx method. If it does fit, and the other conditions match (extra conditions are only available via the custom rule edit), the transaction will then be linked with the schedule id (stored in the database for the transaction).
This object is not a database level object, meaning that it needs to be converted first using create_schedule, that will create the correct rule.
Parameters:
-
(startdate) –The date indicating the start date of the recurrence.
-
(intervalint, default:1) –The interval at which the recurrence happens. Defaults to
1if omitted. -
(frequencyFrequency, default:<Frequency.MONTHLY: 'monthly'>) –How often the schedule repeats.
-
(patternslist[Pattern], default:<dynamic>) –Optional patterns to control specific dates for recurrence (e.g., certain weekdays or month days).
-
(skip_weekendbool, default:False) –If true, skips weekends when calculating recurrence dates. This option can be further configured with the
weekend_solve_modeparameter. -
(weekend_solve_modeWeekendSolveMode, default:<WeekendSolveMode.AFTER: 'after'>) –If a calculated date falls on a weekend and
skip_weekendis true, this controls whether the date moves to the before or after weekday. -
(end_modeEndMode, default:<EndMode.NEVER: 'never'>) –Specifies how the recurrence ends: never ends, after a number of occurrences, or on a specific date.
-
(end_occurrencesint | None, default:1) –Used when
end_modeis'after_n_occurrences'. Indicates how many times it should repeat. -
(end_datedate | None, default:None) –Used when
end_modeis'on_date'. The date object indicating when the recurrence should end.
Methods:
-
serialize_model–Converts a schedule to a dict that can be used in a rule.
-
is_approx–This function checks if the input date could fit in the schedule.
-
rruleset–Returns the
rrulesetfrom the dateutil library. This is used internally to calculate the schedule dates.
serialize_model
serialize_model(handler) -> dict
is_approx
This function checks if the input date could fit in the schedule.
It will use the interval as the maximum threshold before and after the specified date to look for. This defaults on Actual to +-2 days.
Source code in actual/schedules.py
rruleset
rruleset() -> rruleset
Returns the rruleset from the dateutil library. This is used internally to calculate the schedule dates.
For information on how to use this object, check the official documentation.