Compare commits

...

2 commits

3 changed files with 35 additions and 8 deletions

View file

@ -5,6 +5,12 @@ All notable changes to pyCOREPOS will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## v0.5.1 (2025-02-20)
### Fix
- add `Product.default_vendor_item` convenience property
## v0.5.0 (2025-02-01)
### Feat

View file

@ -583,6 +583,32 @@ class Product(common.ProductBase, Base):
creator=lambda lc: ProductLikeCode(like_code=lc),
)
vendor_items = orm.relationship(
'VendorItem',
back_populates='product',
primaryjoin='VendorItem.upc == Product.upc',
foreign_keys='VendorItem.upc',
order_by='VendorItem.vendor_item_id',
doc="""
List of :class:`VendorItem` records for this product.
""")
@property
def default_vendor_item(self):
"""
Returns the "default" vendor item record. This will
correspond to the :attr:`default_vendor` if possible.
:rtype: :class:`VendorItem` or ``None``
"""
if self.default_vendor:
for item in self.vendor_items:
if item.vendor_id == self.default_vendor.id:
return item
if self.vendor_items:
return self.vendor_items[0]
@property
def full_description(self):
fields = ['brand', 'description', 'size']
@ -732,17 +758,12 @@ class VendorItem(Base):
upc = sa.Column(sa.String(length=13), nullable=False)
product = orm.relationship(
Product,
back_populates='vendor_items',
primaryjoin=Product.upc == upc,
foreign_keys=[upc],
doc="""
Reference to the :class:`Product` to which this record applies.
""",
backref=orm.backref(
'vendor_items',
order_by=vendor_item_id,
doc="""
List of :class:`VendorItem` records for this product.
"""))
""")
brand = sa.Column(sa.String(length=50), nullable=True)

View file

@ -6,7 +6,7 @@ build-backend = "hatchling.build"
[project]
name = "pyCOREPOS"
version = "0.5.0"
version = "0.5.1"
description = "Python Interface to CORE POS"
readme = "README.md"
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]