fix: rename is_archived to is_deleted and update stock response logic

This commit is contained in:
2025-10-20 21:21:28 +03:00
parent 1bf01ebd09
commit 0263094386
2 changed files with 21 additions and 28 deletions

View File

@@ -20,6 +20,7 @@ class MarketplaceProduct(BaseSiproModel):
mp_price_bought: Mapped[int] = mapped_column()
price_recommended: Mapped[int] = mapped_column()
is_archived: Mapped[bool] = mapped_column()
is_deleted: Mapped[bool] = mapped_column()
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
product: Mapped["Product"] = relationship()

View File

@@ -256,7 +256,7 @@ async def get_stocks_data(
func.coalesce(is_master_subquery.c.is_master, False).label('is_master'),
func.coalesce(slaves_stock_subquery.c.slaves_stock, 0).label('slaves_stock'),
MarketplaceProduct.price_recommended.label('price_recommended'),
MarketplaceProduct.is_archived.label('is_archived'),
MarketplaceProduct.is_deleted.label('is_deleted'),
func.coalesce(fbo_stock_subquery.c.quantity, 0).label('fbo_stock')
)
.select_from(
@@ -318,25 +318,25 @@ async def get_stocks_data(
is_master,
slaves_stock,
price_recommended,
is_archived,
is_deleted,
fbo_stock
) in marketplace_products:
if is_archived or (sell_from_price > price_recommended) or is_paused or reset:
response.append({
base_dict: StockData = {
'article': denco_article,
'full_stock': 0,
'marketplace_product': marketplace_product,
'product_id': marketplace_product.product_id
})
continue
if fbo_stock > 0 and prefer_fbo_over_fbs:
response.append({
'article': denco_article,
'full_stock': 0,
'marketplace_product': marketplace_product,
'product_id': marketplace_product.product_id
})
'product_id': marketplace_product.product_id,
'full_stock': 0
}
zero_stock = any([
is_deleted,
sell_from_price > price_recommended,
is_paused,
result,
fbo_stock > 0 and prefer_fbo_over_fbs,
45 > company.balance
])
if zero_stock:
response.append(base_dict)
continue
is_mix = mix_stock is not None
@@ -359,15 +359,7 @@ async def get_stocks_data(
full_stock = warehouse_stock
if (not sell_mixes) and is_mix:
full_stock = warehouse_stock
if 45 > company.balance:
full_stock = 0
full_stock = max([0, full_stock])
response.append({
'article': denco_article,
'full_stock': full_stock,
'marketplace_product': marketplace_product,
'product_id': marketplace_product.product_id
})
base_dict['full_stock'] = full_stock
response.append(base_dict)
return response