rechu.models package

Submodules

rechu.models.base module

Base model for receipt cataloging.

class rechu.models.base.Base(**kwargs: Any)[source]

Bases: DeclarativeBase

Base ORM model class for receipt models.

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

rechu.models.product module

Models for product metadata.

class rechu.models.product.DiscountMatch(**kwargs)[source]

Bases: Base

Discount label model for a product matching string.

id: MappedColumn[int]
label: MappedColumn[str]
product: Relationship[Product]
product_id: MappedColumn[int]
class rechu.models.product.LabelMatch(**kwargs)[source]

Bases: Base

Label model for a product matching string.

id: MappedColumn[int]
name: MappedColumn[str]
product: Relationship[Product]
product_id: MappedColumn[int]
class rechu.models.product.PriceMatch(**kwargs)[source]

Bases: Base

Price model for a product matching value, which may be part of a value range or time interval.

id: MappedColumn[int]
indicator: MappedColumn[str | None]
product: Relationship[Product]
product_id: MappedColumn[int]
value: MappedColumn[Price]
class rechu.models.product.Product(**kwargs)[source]

Bases: Base

Product model for metadata.

alcohol: MappedColumn[str | None]
brand: MappedColumn[str | None]
category: MappedColumn[str | None]
description: MappedColumn[str | None]
discounts: Relationship[list[DiscountMatch]]
gtin: MappedColumn[GTIN | None]
id: MappedColumn[int]
labels: Relationship[list[LabelMatch]]
merge(other: Product) bool[source]

Merge attributes of the other product into this one.

This replaces values and the primary key in this product, except for the shop identifier (which is always kept) and the matchers (where unique matchers from the other product are added).

This is similar to a session merge except no database changes are done and the matchers are more deeply merged.

Returns whether the product has changed, with new matchers or different values.

portions: MappedColumn[int | None]
prices: Relationship[list[PriceMatch]]
shop: MappedColumn[str]
sku: MappedColumn[str | None]
type: MappedColumn[str | None]
volume: MappedColumn[Quantity | None]
weight: MappedColumn[Quantity | None]

rechu.models.receipt module

Models for receipt data.

class rechu.models.receipt.Discount(**kwargs)[source]

Bases: Base

Discount model for a discount action mentioned on a receipt.

id: MappedColumn[int]
items: Relationship[list[ProductItem]]
label: MappedColumn[str]
position: MappedColumn[int]
price_decrease: MappedColumn[Price]
receipt: Relationship[Receipt]
receipt_key: MappedColumn[str]
class rechu.models.receipt.ProductItem(**kwargs)[source]

Bases: Base

Product model for a product item mentioned on a receipt.

amount: MappedColumn[float]
discount_indicator: MappedColumn[str | None]
discounts: Relationship[list[Discount]]
id: MappedColumn[int]
label: MappedColumn[str]
position: MappedColumn[int]
price: MappedColumn[Price]
product: Relationship[Product | None]
product_id: MappedColumn[int | None]
quantity: MappedColumn[Quantity]
receipt: Relationship[Receipt]
receipt_key: MappedColumn[str]
unit: MappedColumn[Unit | None]
class rechu.models.receipt.Receipt(**kwargs)[source]

Bases: Base

Receipt model for a receipt from a certain date at a shop with products and possibly discounts.

date: MappedColumn[date]
discounts: Relationship[list[Discount]]
filename: MappedColumn[str]
products: Relationship[list[ProductItem]]
shop: MappedColumn[str]
property total_price: Price

Retrieve the total cost of the receipt after discounts.

updated: MappedColumn[datetime]

rechu.models.shop module

Models for shop metadata.

class rechu.models.shop.Shop(**kwargs)[source]

Bases: Base

Shop metadata model.

key: MappedColumn[str]
name: MappedColumn[str | None]
website: MappedColumn[str | None]
wikidata: MappedColumn[str | None]

Module contents

Models for receipt cataloging.

class rechu.models.Base(**kwargs: Any)[source]

Bases: DeclarativeBase

Base ORM model class for receipt models.

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class rechu.models.Product(**kwargs)[source]

Bases: Base

Product model for metadata.

alcohol: MappedColumn[str | None]
brand: MappedColumn[str | None]
category: MappedColumn[str | None]
description: MappedColumn[str | None]
discounts: Relationship[list[DiscountMatch]]
gtin: MappedColumn[GTIN | None]
id: MappedColumn[int]
labels: Relationship[list[LabelMatch]]
merge(other: Product) bool[source]

Merge attributes of the other product into this one.

This replaces values and the primary key in this product, except for the shop identifier (which is always kept) and the matchers (where unique matchers from the other product are added).

This is similar to a session merge except no database changes are done and the matchers are more deeply merged.

Returns whether the product has changed, with new matchers or different values.

portions: MappedColumn[int | None]
prices: Relationship[list[PriceMatch]]
shop: MappedColumn[str]
sku: MappedColumn[str | None]
type: MappedColumn[str | None]
volume: MappedColumn[Quantity | None]
weight: MappedColumn[Quantity | None]
class rechu.models.Receipt(**kwargs)[source]

Bases: Base

Receipt model for a receipt from a certain date at a shop with products and possibly discounts.

date: MappedColumn[date]
discounts: Relationship[list[Discount]]
filename: MappedColumn[str]
products: Relationship[list[ProductItem]]
shop: MappedColumn[str]
property total_price: Price

Retrieve the total cost of the receipt after discounts.

updated: MappedColumn[datetime]
class rechu.models.Shop(**kwargs)[source]

Bases: Base

Shop metadata model.

key: MappedColumn[str]
name: MappedColumn[str | None]
website: MappedColumn[str | None]
wikidata: MappedColumn[str | None]