Sprtch / despinassy

🗄️ Database Schema collection and shared library repository
MIT License
0 stars 0 forks source link

Add 'relationship' for Inventory transaction #17

Open tperale opened 3 years ago

tperale commented 3 years ago

In the Inventory table add a transaction field that filters all the ScannerTransaction that referred to this inventory entry modification.

The relationship will be used in huron API to retrieve the inventory id transactions (in /api/inventory/<id>/transactions). So far the following code snippet is used to filter the ScannerTransaction that refer to a specific inventory entry.

ts = ScannerTransaction.query.filter(
    ScannerTransaction.value == x.part.barcode
).filter(ScannerTransaction.mode == ScannerModeEnum.INVENTORYMODE).filter(
    ScannerTransaction.created_at >= Inventory.created_at).order_by(
        ScannerTransaction.created_at.desc())

This snippet should be added as a relationship of the Inventory table.