feat(shopping): alışveriş listeleri, stok eşiği önerileri ve akıllı mağaza önerisi motoru
- shoppingLists koleksiyonu (ürün tipi / marka / serbest metin kalemleri), migration 015 - planShopping saf fonksiyonu: paket yuvarlama, zahmet ve hacimli cezası, teslimat, yemek kartı önceliği, ek mağaza eşiği - eşik önerileri onay/red (red stok yenilenene kadar), ürün tipine hacimli işareti - fiyat servisinde ortak loadTypeOffers; seed listeleri ve testler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -33,6 +33,8 @@ type SeedProduct = {
|
||||
waste?: { every: number; pct: number; reason: "spoiled" | "expired" | "damaged" };
|
||||
/** Bu günden (gün önce) sonra yeniden alınmaz: bugün azalmış görünür. */
|
||||
stopRefillDaysAgo?: number;
|
||||
/** Ağır/hacimli (akıllı öneride taşıma cezası). */
|
||||
bulky?: boolean;
|
||||
/** Her n. sayımda küçük eksik (−%, hedefin yüzdesi). */
|
||||
countDrift?: { everyCounts: number; pct: number };
|
||||
};
|
||||
@@ -184,6 +186,7 @@ export const PRODUCTS: SeedProduct[] = [
|
||||
},
|
||||
{
|
||||
ref: "toz-deterjan",
|
||||
bulky: true,
|
||||
category: "genel-temizlik.camasir",
|
||||
name: "Toz Deterjan",
|
||||
unit: "yıkama",
|
||||
@@ -195,6 +198,7 @@ export const PRODUCTS: SeedProduct[] = [
|
||||
},
|
||||
{
|
||||
ref: "yumusatici",
|
||||
bulky: true,
|
||||
category: "genel-temizlik.camasir",
|
||||
name: "Yumuşatıcı",
|
||||
unit: "lt",
|
||||
@@ -206,6 +210,7 @@ export const PRODUCTS: SeedProduct[] = [
|
||||
},
|
||||
{
|
||||
ref: "camasir-suyu",
|
||||
bulky: true,
|
||||
category: "genel-temizlik.genel",
|
||||
name: "Çamaşır Suyu",
|
||||
unit: "lt",
|
||||
@@ -217,6 +222,7 @@ export const PRODUCTS: SeedProduct[] = [
|
||||
},
|
||||
{
|
||||
ref: "tuvalet-kagidi",
|
||||
bulky: true,
|
||||
category: "genel-temizlik.genel",
|
||||
name: "Tuvalet Kağıdı",
|
||||
unit: "rulo",
|
||||
@@ -359,7 +365,15 @@ export async function seedStock(
|
||||
const today = todayIstanbul();
|
||||
let created = 0;
|
||||
for (const p of PRODUCTS) {
|
||||
if (await ProductTypeModel.exists({ householdId, seedRef: p.ref })) continue;
|
||||
if (await ProductTypeModel.exists({ householdId, seedRef: p.ref })) {
|
||||
// Faz 13 öncesi seed'lenmiş veritabanında hacimli işaretini tamamla.
|
||||
if (p.bulky)
|
||||
await ProductTypeModel.updateOne(
|
||||
{ householdId, seedRef: p.ref, bulky: { $exists: false } },
|
||||
{ $set: { bulky: true } },
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const doc = await ProductTypeModel.create({
|
||||
householdId,
|
||||
categoryId: catByKey.get(p.category)!,
|
||||
@@ -370,6 +384,7 @@ export async function seedStock(
|
||||
thresholdPct: p.threshold ?? 20,
|
||||
location: p.location,
|
||||
step: p.step ?? K,
|
||||
bulky: p.bulky ?? false,
|
||||
seedRef: p.ref,
|
||||
createdBy: actor,
|
||||
updatedBy: actor,
|
||||
|
||||
Reference in New Issue
Block a user