activity.models.invoice_reference
Attributes
Classes
A reference pointing to an invoice. References are keys which are used |
|
Defines the methods that need to be implemented by schemas. Schemas |
|
The default schema for customers without specific bank integrations. |
|
The default schema for ESR by Postfinance. In it's default form it is |
|
Customised ESR for Raiffeisen. |
Module Contents
- class activity.models.invoice_reference.InvoiceReference[source]
Bases:
onegov.core.orm.Base
,onegov.core.orm.mixins.TimestampMixin
A reference pointing to an invoice. References are keys which are used outside the application. Usually a code used on an invoice to enter through online-banking.
Each invoice may have multiple references pointing to it. Each refernce is however unique.
There are multiple schemas for references. Each schema generates its own set of references using a Python class and some optional settings given by the user (say a specific bank’s account number).
Each schema may only reference an invoice once.
Though each schema has its own set of references, the references-space is shared between all schemas. In other words, reference ‘foo’ of schema A would conflict with reference ‘foo’ of schema B.
This is because we do not know which schema was used when we encounter a reference.
In reality this should not be a problem as reference schemes provided by banks usually cover a very large space, so multiple schemas are expected to just generate random numbers until one is found that has not been used yet (which should almost always happen on the first try).
- class activity.models.invoice_reference.Schema(**config: object)[source]
Defines the methods that need to be implemented by schemas. Schemas should generate numbers and be able to format them.
Schemas should never be deleted as we want to be able to display past schemas even if a certain schema is no longer in use.
If a new schema comes along that replaces an old one in an incompatible way, the new schema should get a new name and should be added alongside the old one.
- classmethod render_bucket(schema_name: str, schema_config: dict[str, Any] | None = None) str [source]
- link(session: sqlalchemy.orm.Session, invoice: activity.models.invoice.Invoice, optimistic: bool = False, flush: bool = True) InvoiceReference | None [source]
Creates a new
InvoiceReference
for the given invoice.The returned invoice should have a unique reference, so the chance of ending up with a conflict error later down the line are slim.
If the schema already has a linke to the invoice, we skip the creation.
By default we check our constraints before we write to the database. To be faster in performance critical situation we can however also chose to be ‘optimistic’ and forego those checks. Due to the random nature of schema references this should usually work.
The constraints are set on the database, so they will be enforced either way.
Additionally we can forego the session.flush if we want to.
- class activity.models.invoice_reference.FeriennetSchema(**config: object)[source]
Bases:
Schema
The default schema for customers without specific bank integrations.
The generated reference is entered as a note when conducting the online-banking transaction.
- class activity.models.invoice_reference.ESRSchema(**config: object)[source]
Bases:
Schema
The default schema for ESR by Postfinance. In it’s default form it is random and requires no configuration.
A ESR reference has 27 characters from 0-9. The first 26 characters can be chosen freely and the last character is the checksum.
Some banks require that references have certain prefixes/suffixes, but Postfinance who defined the ESR standard does not.