rattail.db.model.products

Data Models for Products

class rattail.db.model.products.Brand(**kwargs)[source]

Represents a brand or similar product line.

confirmed

Flag indicating the brand has been “confirmed good” by someone responsible for product maintenance (if applicable). In some cases the source of brand data is a bit “loose” and it can be helpful to have a human review and de-duplicate the brand listing.

name

Brand name, as seen on product packaging etc.

products

List of products for the brand.

class rattail.db.model.products.InventoryAdjustmentReason(**kwargs)[source]

Reasons for adjusting product inventory.

code

Unique code for the reason.

description

Description for the reason.

hidden

Flag indicating that the reason code should not be generally visible for selection by the user etc.

class rattail.db.model.products.PendingProduct(**kwargs)[source]

A “pending” product record, used for new product entry workflow.

created

Timestamp when the record was first created.

product

Reference to the final Product record, if applicable.

resolved

Timestamp when the record was resolved.

resolved_by

Reference to the User who resolved the record.

status_code

Status indicator for the new product record.

user

Reference to the User who first entered the record.

class rattail.db.model.products.Product(**kwargs)[source]

Represents a product for sale and/or purchase.

average_weight

Average weight of a single item “unit”, e.g. the weight of one single apple. Useful for estimating final weight for when a customer orders 3 apples, etc.

brand

Reference to the brand object, if any.

case_size

Case size for the product, i.e. how many units (current product) are included when sold as a case.

cost_for_vendor(vendor, error_if_multiple=False, error_if_none=False)[source]

Locate and return the first cost associated with the given vendor.

Parameters:
  • error_if_multiple – If set, and the product has more than one cost associated with the given vendor, an exception will be raised.

  • error_if_none – If set, and the product has no cost(s) associated with the given vendor, an exception will be raised.

costs_for_vendor(vendor)[source]

Return all costs associated with the given vendor.

default_pack

If set, this flag indicates the product is the “default pack” for its unit item. This flag is only relevant if the product is in fact a pack item; it should be effectively ignored for a unit item.

deleted

Flag to indicate items which have been deleted. Obviously this is implies “false” deletion, where the record is actually kept on file. Whether or not you use this is up to you.

Reference to the DepositLink instance with which the product associates, if any.

UUID of the product’s deposit link, if any.

description

Primary description for the item.

description2

Secondary description for the item.

discontinued

Flag to indicate an item has been discontinued.

discountable

Whether or not the product may be discounted in any way.

family

Reference to the Family instance with which the product associates, if any.

food_stampable

Flag indicating whether food stamps are a valid form of payment for the item.

property full_description

Convenience attribute which returns a more complete description.

Most notably, this includes the brand name and product size.

future_costs

Sequence of future cost records for the product, i.e. which have yet to become “current” costs.

get_default_pack_item()[source]

Returns the “default” pack item for the current product, which is assumed to be a unit item.

get_unit_item()[source]

Returns the unit item for the current product. If this product is a unit item, will return self; otherwise returns self.unit.

gluten_free

Whether the item is gluten-free.

image

Reference to the product’s image, if any.

ingredients

Free-form ingredients for the product.

inventory

Inventory data for the product, if any.

is_pack_item()[source]

Returns True if the product is considered a “pack” item, as opposed to a “unit” item.

is_unit_item()[source]

Returns True if the product is considered a “unit” item, as opposed to a “pack” item.

item_id

Generic ID string for the item.

item_type

Item type code as integer.

kosher

Whether the item is kosher.

last_sold

UTC timestamp of the product’s last sale event.

not_for_sale

Flag to indicate items which are not available for sale.

notes

Generic / free-form notes for the product.

organic

Whether the item is organic.

pack_size

Number of units which constitute the current pack product, if applicable.

packs

List of products which reference the current product as their unit.

property pretty_upc

Product’s UPC as a somewhat human-readable string.

price_required

Indicates that the price must be manually entered by cashier, at check-out.

report_code

Reference to the ReportCode instance with which the product associates, if any.

report_code_uuid

UUID of the product’s report code, if any.

scancode

Scan code (as string) for the product, if any. This is generally intended to match the upc value, though that is not enforced.

size

Free-form / human-friendly size string for the product, e.g. ‘32 oz’

special_order

Whether the product is available for special order.

status_code

Status code for the product. Interpretation of this value is left to the custom app logic.

store_infos

List of store-specific info records for the product.

sugar_free

Whether the item is sugar-free.

tax

Reference to the Tax instance with which the product associates, if any.

tax1

(hack?) Flag indicating whether ‘tax 1’ applies to the item.

tax2

(hack?) Flag indicating whether ‘tax 2’ applies to the item.

tax3

(hack?) Flag indicating whether ‘tax 3’ applies to the item.

tax_uuid

UUID of the product’s tax, if any.

unit

Reference to the unit product upon which this product is based, if any.

unit_of_measure

Code indicating the unit of measure for the product. Value should be one of the keys of the rattail.enum.UNIT_OF_MEASURE dictionary.

unit_size

Unit size for product, as decimal. This refers to the numeric size of a unit of the product, in terms of the unit_of_measure, and may be used for smarter price comparisons etc.

uom_abbreviation

Optional abbreviated unit of measure. This value is intended to contain a human-friendly abbreviation for the unit_of_measure. This value is generally also seen at the end of size.

upc

Proper GPC value for the product, if any.

vegan

Whether the item is vegan.

vegetarian

Whether the item is vegetarian.

volatile

“Volatile” data record for the product, if any.

weighed

Whether or not the product must be weighed to determine its final price.

class rattail.db.model.products.ProductCode(**kwargs)[source]

Represents an arbitrary “code” for a product.

code

Alternate code value for the product, to be used for lookup.

class rattail.db.model.products.ProductCost(**kwargs)[source]

Represents a source from which a product may be obtained via purchase.

case_cost

Case cost for the item, if known.

case_size

Number of units which constitute a “case” in the context of this vendor catalog item. May be a fractional quantity, e.g. 17.5LB.

code

Vendor order code for the item, if applicable.

discontinued

Flag to indicate if the cost record has been discontinued, presumably by the vendor.

discount_amount

Dollar amount of the “current” discount for the cost, if applicable.

discount_cost

Discounted (effective) unit cost for the item, while current discount is in effect (if applicable).

discount_ends

Date and time when the “current” discount for the cost ends, if applicable. Note that this should never be a “past” value, since only the current discount should be part of this record.

discount_percent

Percentage amount of the “current” discount for the cost, if applicable.

discount_starts

Date and time when the “current” discount for the cost begins, if applicable. Note that this should never be a “future” value, since only the current discount should be part of this record.

effective

Date and time when the cost became effective, if known.

unit_cost

Unit cost for the item, if known.

class rattail.db.model.products.ProductFutureCost(**kwargs)[source]

Represents a future cost record, i.e. an otherwise normal / complete cost record, but which will become effective at some later date/time.

Note that this is meant to be more of a “queue” table in practice, i.e. records which exist here should eventually be applied to the ProductCost table, at which point the future record(s) would be deleted.

case_cost

Case cost for the item, if known.

case_quantity

Number of units which constitute a “case” in the context of this vendor catalog item. May be a fractional quantity, e.g. 17.5LB.

cost

Reference to the “current” cost record to which this future cost record will be applied (when the time comes), if applicable. If this is None, then a new “current” cost record would be created instead.

discontinued

Flag to indicate if the cost record has been discontinued, presumably by the vendor.

ends

Date and time when the cost stops being effective, if applicable. This often will be null, in which case the cost becomes “permanently” effective, i.e. until a newer cost is brought in.

order_code

Vendor order code for the item, if applicable.

product

Reference to the product to which the cost record pertains.

starts

Date and time when the cost becomes effective.

unit_cost

Unit cost for the item, if known.

vendor

Reference to the vendor to which the cost record pertains.

class rattail.db.model.products.ProductImage(**kwargs)[source]

Contains an image for a product.

product

Reference to the product which is shown by the image.

class rattail.db.model.products.ProductInventory(**kwargs)[source]

Inventory data for a product. Assumption at this point is that this data will be accurate only in the context of the “local” node (store etc.). Tracking inventory for multiple nodes is not yet supported in the “host” sense; however each node may track its own inventory (only).

on_hand

Unit quantity of product which is currently on hand.

on_order

Unit quantity of product which is currently on order.

product

Product to which this inventory record pertains.

class rattail.db.model.products.ProductPrice(**kwargs)[source]

Represents a price for a product.

active_now()[source]

Returns boolean indicating whether the price is currently active, i.e. “now” falls within time window defined by starts and ends. Note that if the price has no start and/or end time, this will return True.

class rattail.db.model.products.ProductStoreInfo(**kwargs)[source]

General store-specific info for a product.

product

Product to which this info record pertains.

recently_active

Flag indicating the product has seen “recent activity” at the store. How this is populated and/or interpreted is up to custom app logic.

store

Store to which this info record pertains.

class rattail.db.model.products.ProductVolatile(**kwargs)[source]

This is the place to find “volatile” data for a given product, or at least it should be… As of this writing there are a couple other places to look but hopefully this table can eventually be “the” place.

Whether any given value in a given record, applies to the “current” app node only, or if it applies to all nodes, is up to app logic.

Note that a custom app should (most likely) not bother “extending” this table, but rather should create a separate table with similar pattern.

product

Product to which this “volatile” data record pertains.

true_cost

“True” unit cost for the item, if known. This might include certain “allowances” (discounts) currently in effect etc.; really anything which might not be reflected in “official” unit cost for the product. Usually, this value is quite easily calculated and so this field serves as more of a cache, for sake of SQL access to the values.

true_margin

“True” profit margin for the “regular” unit price vs. the “true” unit cost (true_cost). This is expressed as a human-friendly percentage value, e.g. 37.5 (instead of 0.375) for 37.5% margin.

class rattail.db.model.products.Tax(**kwargs)[source]

Represents a sales tax rate to be applied to products.

code

Unique “code” for the tax rate.

description

Human-friendly description for the tax rate.

rate

Percentage rate for the tax, e.g. 8.25.

class rattail.db.model.products.UnitOfMeasure(**kwargs)[source]

Maps a UOM abbreviation used by the organization, to the proper UOM code used internally by Rattail.

Note that the SIL code is similar, but apparently different, from the codes defined by GS1.

abbreviation

UOM abbreviation as it is used by the organization, e.g. ‘OZ’.

notes

Misc. notes for this mapping.

sil_code

SIL code for the UOM, as used internally by Rattail, e.g. ‘48’.