fixup! WIP
All checks were successful
Run tests / run-tests (push) Successful in 46s

This commit is contained in:
2025-12-09 15:17:52 +09:00
parent e7453d0fdd
commit 0504cc1a1e
7 changed files with 85 additions and 38 deletions

View File

@@ -63,6 +63,7 @@ def _product_price_query(
TransactionType.BUY_PRODUCT,
TransactionType.ADD_PRODUCT,
TransactionType.ADJUST_STOCK,
TransactionType.JOINT,
]
),
Transaction.product_id == product_id,
@@ -117,6 +118,10 @@ def _product_price_query(
trx_subset.c.type_ == TransactionType.BUY_PRODUCT,
recursive_cte.c.product_count - trx_subset.c.product_count,
),
(
trx_subset.c.type_ == TransactionType.JOINT,
recursive_cte.c.product_count - trx_subset.c.product_count,
),
# Someone adds the product -> product count is increased.
(
trx_subset.c.type_ == TransactionType.ADD_PRODUCT,

View File

@@ -37,6 +37,10 @@ def _product_stock_query(
Transaction.type_ == TransactionType.ADJUST_STOCK,
Transaction.product_count,
),
(
Transaction.type_ == TransactionType.JOINT,
-Transaction.product_count,
),
else_=0,
)
)
@@ -46,6 +50,7 @@ def _product_stock_query(
TransactionType.BUY_PRODUCT,
TransactionType.ADD_PRODUCT,
TransactionType.ADJUST_STOCK,
TransactionType.JOINT,
]
),
Transaction.product_id == product_id,

View File

@@ -80,6 +80,10 @@ def _user_balance_query(
TransactionType.ADJUST_BALANCE,
TransactionType.BUY_PRODUCT,
TransactionType.TRANSFER,
# TODO: join this with the JOINT transactions, and determine
# how much the current user paid for the product.
TransactionType.JOINT_BUY_PRODUCT,
]
),
),