fix: rename is_archived to is_deleted and update stock response logic
This commit is contained in:
@@ -20,6 +20,7 @@ class MarketplaceProduct(BaseSiproModel):
|
|||||||
mp_price_bought: Mapped[int] = mapped_column()
|
mp_price_bought: Mapped[int] = mapped_column()
|
||||||
price_recommended: Mapped[int] = mapped_column()
|
price_recommended: Mapped[int] = mapped_column()
|
||||||
is_archived: Mapped[bool] = mapped_column()
|
is_archived: Mapped[bool] = mapped_column()
|
||||||
|
is_deleted: Mapped[bool] = mapped_column()
|
||||||
|
|
||||||
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
product_id: Mapped[int] = mapped_column(ForeignKey("products.id"))
|
||||||
product: Mapped["Product"] = relationship()
|
product: Mapped["Product"] = relationship()
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ async def get_stocks_data(
|
|||||||
func.coalesce(is_master_subquery.c.is_master, False).label('is_master'),
|
func.coalesce(is_master_subquery.c.is_master, False).label('is_master'),
|
||||||
func.coalesce(slaves_stock_subquery.c.slaves_stock, 0).label('slaves_stock'),
|
func.coalesce(slaves_stock_subquery.c.slaves_stock, 0).label('slaves_stock'),
|
||||||
MarketplaceProduct.price_recommended.label('price_recommended'),
|
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')
|
func.coalesce(fbo_stock_subquery.c.quantity, 0).label('fbo_stock')
|
||||||
)
|
)
|
||||||
.select_from(
|
.select_from(
|
||||||
@@ -318,25 +318,25 @@ async def get_stocks_data(
|
|||||||
is_master,
|
is_master,
|
||||||
slaves_stock,
|
slaves_stock,
|
||||||
price_recommended,
|
price_recommended,
|
||||||
is_archived,
|
is_deleted,
|
||||||
fbo_stock
|
fbo_stock
|
||||||
) in marketplace_products:
|
) in marketplace_products:
|
||||||
if is_archived or (sell_from_price > price_recommended) or is_paused or reset:
|
base_dict: StockData = {
|
||||||
response.append({
|
|
||||||
'article': denco_article,
|
'article': denco_article,
|
||||||
'full_stock': 0,
|
|
||||||
'marketplace_product': marketplace_product,
|
'marketplace_product': marketplace_product,
|
||||||
'product_id': marketplace_product.product_id
|
'product_id': marketplace_product.product_id,
|
||||||
})
|
'full_stock': 0
|
||||||
continue
|
}
|
||||||
if fbo_stock > 0 and prefer_fbo_over_fbs:
|
zero_stock = any([
|
||||||
response.append({
|
is_deleted,
|
||||||
'article': denco_article,
|
sell_from_price > price_recommended,
|
||||||
'full_stock': 0,
|
is_paused,
|
||||||
'marketplace_product': marketplace_product,
|
result,
|
||||||
'product_id': marketplace_product.product_id
|
fbo_stock > 0 and prefer_fbo_over_fbs,
|
||||||
|
45 > company.balance
|
||||||
})
|
])
|
||||||
|
if zero_stock:
|
||||||
|
response.append(base_dict)
|
||||||
continue
|
continue
|
||||||
is_mix = mix_stock is not None
|
is_mix = mix_stock is not None
|
||||||
|
|
||||||
@@ -359,15 +359,7 @@ async def get_stocks_data(
|
|||||||
full_stock = warehouse_stock
|
full_stock = warehouse_stock
|
||||||
if (not sell_mixes) and is_mix:
|
if (not sell_mixes) and is_mix:
|
||||||
full_stock = warehouse_stock
|
full_stock = warehouse_stock
|
||||||
if 45 > company.balance:
|
|
||||||
full_stock = 0
|
|
||||||
full_stock = max([0, full_stock])
|
full_stock = max([0, full_stock])
|
||||||
|
base_dict['full_stock'] = full_stock
|
||||||
response.append({
|
response.append(base_dict)
|
||||||
'article': denco_article,
|
|
||||||
'full_stock': full_stock,
|
|
||||||
'marketplace_product': marketplace_product,
|
|
||||||
'product_id': marketplace_product.product_id
|
|
||||||
|
|
||||||
})
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user