winterthur.daycare

Attributes

SERVICE_DAYS

SERVICE_DAYS_LABELS

FORMAT

Classes

Daycare

Service

Built-in immutable sequence.

Services

Result

Block

DirectoryDaycareAdapter

Settings

SubsidyResult

Built-in immutable sequence.

DaycareSubsidyCalculator

DaycareServicesWidget

DaycareServicesField

DaycareSubsidyCalculatorForm

Functions

round_to(n, precision) → decimal.Decimal

format_precise(amount) → str

format_1_cent(amount) → str

format_5_cents(amount) → str

Module Contents

winterthur.daycare.SERVICE_DAYS[source]
winterthur.daycare.SERVICE_DAYS_LABELS[source]
winterthur.daycare.FORMAT = '#,##0.00########'[source]
winterthur.daycare.round_to(n: decimal.Decimal, precision: str) → decimal.Decimal[source]
winterthur.daycare.format_precise(amount: decimal.Decimal | None) → str[source]
winterthur.daycare.format_1_cent(amount: decimal.Decimal) → str[source]
winterthur.daycare.format_5_cents(amount: decimal.Decimal) → str[source]
class winterthur.daycare.Daycare(id: uuid.UUID, title: str, rate: decimal.Decimal | float | str, weeks: int)[source]
id[source]
title[source]
rate[source]
weeks[source]
property factor: decimal.Decimal[source]
class winterthur.daycare.Service[source]

Bases: NamedTuple

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

id: str[source]
title: str[source]
percentage: decimal.Decimal[source]
days: ordered_set.OrderedSet[int][source]
class winterthur.daycare.Services(definition: str | None)[source]
selected: dict[str, set[int]][source]
classmethod from_org(org: onegov.org.models.Organisation) → Self[source]
classmethod from_session(session: sqlalchemy.orm.Session) → Self[source]
static parse_definition(definition: str) → collections.abc.Iterator[tuple[str, Service]][source]
select(service_id: str, day: int) → None[source]
deselect(service_id: str, day: int) → None[source]
is_selected(service_id: str, day: int) → bool[source]
property total: decimal.Decimal | Literal[0][source]

The total percentage of used services.

class winterthur.daycare.Result(title: str, amount: decimal.Decimal | None = None, note: str | None = None, operation: str | None = None, important: bool = False, currency: str | None = 'CHF', output_format: collections.abc.Callable[[decimal.Decimal], str] | None = None)[source]
title[source]
amount = None[source]
note = ''[source]
operation = None[source]
important = False[source]
currency = 'CHF'[source]
output_format[source]
__bool__() → bool[source]
property readable_amount: str[source]
class winterthur.daycare.Block(id: str, title: str)[source]
results: list[Result][source]
id[source]
title[source]
total[source]
op(title: str, amount: decimal.Decimal | None = None, note: str | None = None, operation: str | None = None, important: bool = False, currency: str | None = 'CHF', output_format: collections.abc.Callable[[decimal.Decimal], str] | None = None, total_places: int = 2, amount_places: int = 2) → decimal.Decimal[source]
class winterthur.daycare.DirectoryDaycareAdapter(directory: onegov.org.models.ExtendedDirectory)[source]
directory[source]
property fieldmap: dict[str, str | None][source]
as_daycare(entry: onegov.org.models.ExtendedDirectoryEntry) → Daycare[source]
class winterthur.daycare.Settings(organisation: onegov.org.models.Organisation)[source]
directory: str[source]
max_income: decimal.Decimal[source]
max_rate: decimal.Decimal[source]
max_subsidy: decimal.Decimal[source]
max_wealth: decimal.Decimal[source]
min_income: decimal.Decimal[source]
min_rate: decimal.Decimal[source]
rebate: decimal.Decimal[source]
services: str[source]
wealth_premium: decimal.Decimal[source]
explanation: markupsafe.Markup[source]
is_valid() → bool[source]
factor(daycare: Daycare) → decimal.Decimal[source]
class winterthur.daycare.SubsidyResult[source]

Bases: NamedTuple

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

blocks: tuple[Block, ...][source]
parent_share_per_month: str[source]
city_share_per_month: str[source]
total_per_month: str[source]
agenda: tuple[tuple[str, str | None, str], ...][source]
class winterthur.daycare.DaycareSubsidyCalculator(session: sqlalchemy.orm.Session)[source]
session[source]
property organisation: onegov.org.models.Organisation[source]
property settings: Settings[source]
property directory: onegov.org.models.ExtendedDirectory[source]
property daycares: dict[str, Daycare][source]
daycare_by_title(title: str) → Daycare[source]
calculate_precisely(daycare: Daycare, services: Services, income: decimal.Decimal, wealth: decimal.Decimal, rebate: bool) → SubsidyResult[source]

Creates a detailed calculation of the subsidy paid by Winterthur.

The reslt is a list of tables with explanations.

Parameters:
  • daycare – The selected daycare (a Daycare instance).

  • services – Services used (a Services instance)

  • income – The income as a decimal.

  • wealth – The wealth as decimal.

  • rebate – True if a rebate is applied

Note, due to the specific nature of the content here, which is probably not going to be translated, we use German. For consistency we want to limit this, but with Winterthur these kinds of things crop up as the wording is quite specific and adding translations would just make this a lot harder.

calculate[source]
class winterthur.daycare.DaycareServicesWidget[source]
template[source]
__call__(field: DaycareServicesField, **kwargs: Any) → markupsafe.Markup[source]
is_selected(service: Service, day: int) → bool[source]
day_label(day: int) → str[source]
property days: ordered_set.OrderedSet[int][source]
class winterthur.daycare.DaycareServicesField[source]

Bases: wtforms.fields.Field

widget[source]
property services: Services[source]
process_formdata(valuelist: list[Any]) → None[source]
pre_validate(form: wtforms.form.BaseForm) → None[source]
class winterthur.daycare.DaycareSubsidyCalculatorForm[source]

Bases: onegov.form.Form

model: DaycareSubsidyCalculator[source]
daycare[source]
services[source]
income[source]
wealth[source]
rebate[source]
on_request() → None[source]
property daycare_choices: collections.abc.Iterator[wtforms.SelectChoice][source]
property selected_daycare: Daycare | None[source]