fix: rename is_archived to is_deleted and update stock response logic
This commit is contained in:
@@ -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({
|
||||
'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
|
||||
|
||||
})
|
||||
base_dict: StockData = {
|
||||
'article': denco_article,
|
||||
'marketplace_product': marketplace_product,
|
||||
'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
|
||||
|
||||
Reference in New Issue
Block a user