pay.utils
Classes
A single price. |
|
The metadata of a full invoice. |
|
Built-in immutable sequence. |
Functions
|
Rounds the given amount to the nearest multiple of base. |
|
Module Contents
- pay.utils.round_amount(amount: decimal.Decimal, base: decimal.Decimal) decimal.Decimal[source]
Rounds the given amount to the nearest multiple of base.
- class pay.utils.Price[source]
Bases:
_PriceBaseA single price.
The amount includes the fee. To get the net amount use the net_amount property.
- class pay.utils.InvoiceItemMeta[source]
-
- static total(items: collections.abc.Iterable[InvoiceItemMeta]) decimal.Decimal[source]
- static total_vat(items: collections.abc.Iterable[InvoiceItemMeta]) decimal.Decimal[source]
- class pay.utils.InvoiceMeta[source]
The metadata of a full invoice.
Contains the freshly generated invoice items, an optional rounding base and an optional reference to an already existing invoice, which may contain manually added items that need to be considered for the rounding.
Iterating over this yields the generated items plus, if necessary, an extra item that rounds the invoice total to a multiple of the rounding base.
- items: list[InvoiceItemMeta][source]
- property rounding_item: InvoiceItemMeta | None[source]
- __iter__() collections.abc.Iterator[InvoiceItemMeta][source]
- property total: decimal.Decimal[source]
The total amount including the rounding item as well as any manual items on an existing invoice, mirroring
Invoice.total_amount.
- property total_excluding_manual_entries: decimal.Decimal[source]
The total of the generated items and the rounding item, excluding manual items on an existing invoice, mirroring
Invoice.total_excluding_manual_entries.
- class pay.utils.InvoiceDiscountMeta[source]
Bases:
_InvoiceDiscountMetaBaseBuilt-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.
- apply_discount(total: decimal.Decimal, remainder: decimal.Decimal) InvoiceItemMeta[source]