feriennet.collections.billing

Module Contents

Classes

InvoicesByPeriodRow

BillingCollection

BookingInvoiceBridge

Creates invoices from bookings.

class feriennet.collections.billing.InvoicesByPeriodRow[source]

Bases: NamedTuple

id: uuid.UUID[source]
realname: str[source]
username: str[source]
group: str[source]
attendee_id: uuid.UUID | None[source]
text: str[source]
organizer: str | None[source]
family: str | None[source]
paid: bool[source]
has_online_payments: bool[source]
amount: decimal.Decimal[source]
source: str | None[source]
period_id: uuid.UUID[source]
changes: Literal[possible, discouraged, impossible][source]
invoice_id: uuid.UUID[source]
invoice_paid: bool[source]
invoice_amount: decimal.Decimal[source]
invoice_outstanding: decimal.Decimal[source]
invoice_changes: Literal[possible, discouraged, impossible][source]
class feriennet.collections.billing.BillingCollection(request: onegov.feriennet.request.FeriennetRequest, period: onegov.activity.models.Period, username: str | None = None, expand: bool = False, state: Literal[paid, unpaid] | None = None)[source]
class Bill[source]

Bases: NamedTuple

items: tuple[InvoicesByPeriodRow, Ellipsis][source]
first: InvoicesByPeriodRow[source]
id: uuid.UUID[source]
invoice_id: uuid.UUID[source]
title: str[source]
paid: bool[source]
total: decimal.Decimal[source]
outstanding: decimal.Decimal[source]
discourage_changes: bool[source]
disable_changes: bool[source]
has_online_payments: bool[source]
property user_id: UUID | None[source]
property period_id: uuid.UUID[source]
property invoices_by_period_query: sqlalchemy.sql.selectable.Alias[source]
property invoices_by_period: Query[InvoicesByPeriodRow][source]
property bills: dict[str, Bill][source]
property total: decimal.Decimal[source]
property outstanding: decimal.Decimal[source]
for_period(period: onegov.activity.models.Period) typing_extensions.Self[source]
for_username(username: str) typing_extensions.Self[source]
for_expand(expand: bool) typing_extensions.Self[source]
for_state(state: Literal[paid, unpaid] | None) typing_extensions.Self[source]
add_position(users: Collection[str], text: str, amount: decimal.Decimal, group: str) int[source]
add_manual_position(users: Collection[str], text: str, amount: decimal.Decimal) int[source]
include_donation(text: str, user_id: uuid.UUID, amount: decimal.Decimal) onegov.activity.InvoiceItem | None[source]

Includes a donation for the given user and period.

Unlike manual positions, donations are supposed to be off/on per period. Therefore this interface is somewhat different and has an exclude_donation counterpart.

exclude_donation(user_id: uuid.UUID) bool | None[source]
create_invoices(all_inclusive_booking_text: str | None = None) None[source]
class feriennet.collections.billing.BookingInvoiceBridge(session: sqlalchemy.orm.Session, period: onegov.activity.models.Period)[source]

Creates invoices from bookings.

Should be used in a two-phase process, with one exception:

  1. The bookings are processed using process.

  2. Premiums are applied by calling complete.

The exception is if you want to simply process a single booking after the premiums have been processed already. This is an exception for admins which may add bookings after all bills have been processed already.

attendees: dict[uuid.UUID, tuple[str, str]][source]
processed_attendees: set[uuid.UUID][source]
billed_attendees: set[uuid.UUID][source]
process(booking: onegov.activity.Booking) None[source]

Processes a single booking. This may be a tuple that includes the following fields, though a model may also work:

  • Booking.username

  • Booking.cost

  • Booking.occasion_id

  • Booking.attendee_id

complete(all_inclusive_booking_text: str | None) None[source]

Finalises the processed bookings.