diff --git a/prisma/migrations/20251214090742_init/migration.sql b/prisma/migrations/20251214090742_init/migration.sql new file mode 100644 index 0000000..2751875 --- /dev/null +++ b/prisma/migrations/20251214090742_init/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Products` ADD COLUMN `salePrice` DECIMAL(10, 2) NOT NULL DEFAULT 0.00; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3381822..72d125c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -70,6 +70,7 @@ model Product { createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) + salePrice Decimal @default(0.00) @db.Decimal(10, 2) brandId Int? categoryId Int? inventoryTransferItems InventoryTransferItem[] @relation("InventoryTransferItem_Product") diff --git a/prisma/seed.ts b/prisma/seed.ts index 9b07e58..b278fda 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -33,40 +33,61 @@ async function main() { if ((await prisma.productCategory.count()) === 0) { await prisma.productCategory.createMany({ - data: [{ name: 'دسته‌ی ۱' }, { name: 'دسته‌ی ۲' }, { name: 'دسته‌ی ۳' }], + data: Array.from({ length: 10 }, (_, i) => ({ name: `دسته‌ی ${i + 1}` })), }) } if ((await prisma.productBrand.count()) === 0) { await prisma.productBrand.createMany({ - data: [{ name: 'برند ۱' }, { name: 'برند ۲' }, { name: 'برند ۳' }], + data: Array.from({ length: 10 }, (_, i) => ({ name: `برند ${i + 1}` })), }) } if ((await prisma.supplier.count()) === 0) { await prisma.supplier.createMany({ - data: [ - { - firstName: 'تامین‌', - lastName: 'کننده ۱', - mobileNumber: '09120000001', - email: 'supplier1@example.com', - }, - { - firstName: 'تامین‌', - lastName: 'کننده ۲', - mobileNumber: '09120000002', - email: 'supplier2@example.com', - }, - { - firstName: 'تامین‌', - lastName: 'کننده 3', - mobileNumber: '09120000003', - email: 'supplier3@example.com', - }, - ], + data: Array.from({ length: 20 }, (_, i) => ({ + firstName: 'تامین‌', + lastName: `کننده ${i + 1}`, + mobileNumber: `0912000000${i + 1}`, + email: `supplier${i + 1}@example.com`, + })), }) } + + if ((await prisma.customer.count()) === 0) { + await prisma.customer.createMany({ + data: Array.from({ length: 5 }, (_, i) => ({ + firstName: 'مشتری', + lastName: `${i + 1}`, + mobileNumber: `0913000000${i + 1}`, + email: `customer${i + 1}@example.com`, + })), + }) + } + + if ((await prisma.product.count()) === 0) { + const categories = await prisma.productCategory.findMany() + const brands = await prisma.productBrand.findMany() + await prisma.product.createMany({ + data: Array.from({ length: 100 }, (_, i) => ({ + name: `کالای ${i + 1}`, + sku: `SKU-${1000 + i + 1}`, + salePrice: parseInt((Math.random() * (100 - 10) + 10).toString()) * 10000, + categoryId: categories[i % categories.length].id, + brandId: brands[i % brands.length].id, + })), + }) + } + + // const products = await prisma.product.findMany() + // for (const product of products) { + // await prisma.product.update({ + // where: { id: product.id }, + // data: { + // salePrice: parseInt((Math.random() * (100 - 10) + 10).toString()) * 10000, + // }, + // }) + // } } main() diff --git a/src/app.module.ts b/src/app.module.ts index 0e9a0c6..23193e2 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -5,6 +5,7 @@ import { CustomersModule } from './customers/customers.module' import { InventoriesModule } from './inventories/inventories.module' import { InventoryTransferItemsModule } from './inventory-transfer-items/inventory-transfer-items.module' import { InventoryTransfersModule } from './inventory-transfers/inventory-transfers.module' +import { PosModule } from './pos/pos.module' import { PrismaModule } from './prisma/prisma.module' import { ProductBrandsModule } from './product-brands/product-brands.module' import { ProductCategoriesModule } from './product-categories/product-categories.module' @@ -46,6 +47,7 @@ import { UsersModule } from './users/users.module' StockMovementsModule, StockAdjustmentsModule, StockBalanceModule, + PosModule, ], controllers: [AppController], providers: [AppService], diff --git a/src/generated/prisma/internal/class.ts b/src/generated/prisma/internal/class.ts index 318e403..51cb67d 100644 --- a/src/generated/prisma/internal/class.ts +++ b/src/generated/prisma/internal/class.ts @@ -22,7 +22,7 @@ const config: runtime.GetPrismaClientConfig = { "clientVersion": "7.1.0", "engineVersion": "ab635e6b9d606fa5c8fb8b1a7f909c3c3c1c98ba", "activeProvider": "mysql", - "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n previewFeatures = [\"views\"]\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel User {\n id Int @id @default(autoincrement())\n mobileNumber String @unique @db.Char(11)\n password String\n firstName String\n lastName String\n roleId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n role Role @relation(\"User_Role\", fields: [roleId], references: [id], onUpdate: NoAction)\n\n @@index([roleId], map: \"Users_roleId_fkey\")\n @@map(\"Users\")\n}\n\nmodel Role {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n permissions Json?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n users User[] @relation(\"User_Role\")\n\n @@map(\"Roles\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(10, 2)\n salePrice Decimal @db.Decimal(10, 2)\n description String? @db.Text\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n imageUrl String? @db.VarChar(255)\n unit String? @db.VarChar(10)\n quantity Decimal? @default(0.00) @db.Decimal(10, 2)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 2)\n isActive Boolean @default(true)\n isFeatured Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n product Product @relation(\"Product_Variant\", fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([productId], map: \"Product_Variants_productId_fkey\")\n @@map(\"Product_Variants\")\n}\n\nmodel Product {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n description String? @db.Text\n sku String? @unique(map: \"products_sku_unique\") @db.VarChar(100)\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n brandId Int?\n categoryId Int?\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\n productCharges ProductCharge[] @relation(\"Product_Charges\")\n variants ProductVariant[] @relation(\"Product_Variant\")\n brand ProductBrand? @relation(\"Product_Brand\", fields: [brandId], references: [id], onUpdate: NoAction)\n category ProductCategory? @relation(\"Product_Category\", fields: [categoryId], references: [id], onUpdate: NoAction)\n purchaseReceiptItems PurchaseReceiptItem[] @relation(\"Product_PurchaseReceiptItems\")\n salesInvoiceItems SalesInvoiceItem[] @relation(\"Product_SalesInvoiceItems\")\n stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n\n stockBalances StockBalance[] @relation(\"StockBalance_Product\")\n\n @@index([brandId], map: \"Products_brandId_fkey\")\n @@index([categoryId], map: \"Products_categoryId_fkey\")\n @@map(\"Products\")\n}\n\nmodel ProductBrand {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Brand\")\n\n @@map(\"Product_brands\")\n}\n\nmodel ProductCategory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Category\")\n\n @@map(\"Product_categories\")\n}\n\nmodel Supplier {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productCharges ProductCharge[] @relation(\"Supplier_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockMovements StockMovement[] @relation(\"StockMovement_Supplier\")\n\n @@map(\"Suppliers\")\n}\n\nmodel Customer {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n orders Order[] @relation(\"Customer_Orders\")\n salesInvoices SalesInvoice[] @relation(\"Customer_Sales_Invoices\")\n\n @@map(\"Customers\")\n}\n\nmodel Inventory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n isPointOfSale Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n inventoryTransfersFrom InventoryTransfer[] @relation(\"Inventory_From\")\n inventoryTransfersTo InventoryTransfer[] @relation(\"Inventory_To\")\n productCharges ProductCharge[] @relation(\"Inventory_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockAdjustments StockAdjustment[] @relation(\"Inventory_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Inventory\")\n stockBalances StockBalance[] @relation(\"StockBalance_inventory\")\n\n @@map(\"Inventories\")\n}\n\nmodel Store {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n @@map(\"Stores\")\n}\n\nmodel ProductCharge {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalAmount Decimal @db.Decimal(10, 2)\n isSettled Boolean @default(false)\n buyAt DateTime? @db.Timestamp(0)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n inventoryId Int\n supplierId Int\n inventory Inventory @relation(\"Inventory_Product_Charges\", fields: [inventoryId], references: [id], onUpdate: NoAction)\n product Product @relation(\"Product_Charges\", fields: [productId], references: [id], onUpdate: NoAction)\n supplier Supplier @relation(\"Supplier_Product_Charges\", fields: [supplierId], references: [id], onUpdate: NoAction)\n\n @@index([inventoryId], map: \"Product_Charges_inventoryId_fkey\")\n @@index([productId], map: \"Product_Charges_productId_fkey\")\n @@index([supplierId], map: \"Product_Charges_supplierId_fkey\")\n @@map(\"Product_Charges\")\n}\n\nmodel Order {\n id Int @id @default(autoincrement())\n orderNumber String @unique @db.VarChar(100)\n status OrderStatus @default(pending)\n paymentMethod paymentMethod @default(card)\n totalAmount Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n customerId Int\n customer Customer @relation(\"Customer_Orders\", fields: [customerId], references: [id], onUpdate: NoAction)\n\n @@index([customerId], map: \"Orders_customerId_fkey\")\n @@map(\"Orders\")\n}\n\nmodel PurchaseReceipt {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n supplierId Int\n inventoryId Int\n items PurchaseReceiptItem[] @relation(\"PurchaseReceipt_Items\")\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n supplier Supplier @relation(fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Purchase_Receipts_inventoryId_fkey\")\n @@index([supplierId], map: \"Purchase_Receipts_supplierId_fkey\")\n @@map(\"Purchase_Receipts\")\n}\n\nmodel PurchaseReceiptItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n receiptId Int\n productId Int\n product Product @relation(\"Product_PurchaseReceiptItems\", fields: [productId], references: [id])\n receipt PurchaseReceipt @relation(\"PurchaseReceipt_Items\", fields: [receiptId], references: [id])\n\n @@index([productId], map: \"Purchase_Receipt_Items_productId_fkey\")\n @@index([receiptId], map: \"Purchase_Receipt_Items_receiptId_fkey\")\n @@map(\"Purchase_Receipt_Items\")\n}\n\nmodel SalesInvoice {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n customerId Int?\n items SalesInvoiceItem[] @relation(\"SalesInvoice_Items\")\n customer Customer? @relation(\"Customer_Sales_Invoices\", fields: [customerId], references: [id])\n\n @@index([customerId], map: \"Sales_Invoices_customerId_fkey\")\n @@map(\"Sales_Invoices\")\n}\n\nmodel SalesInvoiceItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n invoiceId Int\n productId Int\n invoice SalesInvoice @relation(\"SalesInvoice_Items\", fields: [invoiceId], references: [id])\n product Product @relation(\"Product_SalesInvoiceItems\", fields: [productId], references: [id])\n\n @@index([invoiceId], map: \"Sales_Invoice_Items_invoiceId_fkey\")\n @@index([productId], map: \"Sales_Invoice_Items_productId_fkey\")\n @@map(\"Sales_Invoice_Items\")\n}\n\nmodel StockMovement {\n id Int @id @default(autoincrement())\n type MovementType\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceType MovementReferenceType\n referenceId String\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n avgCost Decimal @db.Decimal(10, 2)\n remainedInStock Decimal @default(0) @db.Decimal(10, 2)\n inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], references: [id])\n supplierId Int?\n supplier Supplier? @relation(\"StockMovement_Supplier\", fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Movements_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Movements_productId_fkey\")\n @@map(\"Stock_Movements\")\n}\n\nmodel StockBalance {\n id Int @id @default(autoincrement())\n\n productId Int\n inventoryId Int\n\n quantity Decimal @default(0) @db.Decimal(14, 3)\n\n avgCost Decimal @default(0) @db.Decimal(14, 2)\n totalCost Decimal @default(0) @db.Decimal(14, 2)\n\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n\n product Product @relation(\"StockBalance_Product\", fields: [productId], references: [id])\n inventory Inventory @relation(\"StockBalance_inventory\", fields: [inventoryId], references: [id])\n\n @@unique([productId, inventoryId])\n @@index([productId])\n @@index([inventoryId])\n @@map(\"Stock_Balance\")\n}\n\nmodel InventoryTransfer {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n fromInventoryId Int\n toInventoryId Int\n items InventoryTransferItem[] @relation(\"InventoryTransfer_Items\")\n fromInventory Inventory @relation(\"Inventory_From\", fields: [fromInventoryId], references: [id])\n toInventory Inventory @relation(\"Inventory_To\", fields: [toInventoryId], references: [id])\n\n @@index([fromInventoryId], map: \"Inventory_Transfers_fromInventoryId_fkey\")\n @@index([toInventoryId], map: \"Inventory_Transfers_toInventoryId_fkey\")\n @@map(\"Inventory_Transfers\")\n}\n\nmodel InventoryTransferItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n productId Int\n transferId Int\n product Product @relation(\"InventoryTransferItem_Product\", fields: [productId], references: [id])\n transfer InventoryTransfer @relation(\"InventoryTransfer_Items\", fields: [transferId], references: [id])\n\n @@index([productId], map: \"Inventory_Transfer_Items_productId_fkey\")\n @@index([transferId], map: \"Inventory_Transfer_Items_transferId_fkey\")\n @@map(\"Inventory_Transfer_Items\")\n}\n\nmodel StockAdjustment {\n id Int @id @default(autoincrement())\n adjustedQuantity Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n inventory Inventory @relation(\"Inventory_Stock_Adjustments\", fields: [inventoryId], references: [id])\n product Product @relation(\"Product_Stock_Adjustments\", fields: [productId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Adjustments_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Adjustments_productId_fkey\")\n @@map(\"Stock_Adjustments\")\n}\n\nview StockMovements_View {\n id Int @default(0)\n productId Int\n type stock_movements_view_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceId String\n referenceType stock_movements_view_referenceType\n createdAt DateTime @default(now()) @db.Timestamp(0)\n current_stock Decimal?\n current_avg_cost Decimal?\n\n @@map(\"Stock_Movements_View\")\n @@ignore\n}\n\nview inventory_overview {\n ProductId Int\n stock_quantity Decimal\n avgCost Decimal\n totalCost Decimal\n updatedAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Inventory_Overview\")\n}\n\nview stock_cardex {\n productId Int\n movement_id Int @default(0)\n type stock_cardex_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n balance_quantity Decimal?\n balance_avg_cost Decimal?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Stock_Cardex\")\n}\n\nview stock_view {\n productId Int\n inventoryId Int\n stock Decimal? @db.Decimal(32, 2)\n\n @@map(\"Stock_View\")\n}\n\nenum OrderStatus {\n pending\n reject\n done\n}\n\nenum paymentMethod {\n cash\n card\n}\n\nenum MovementType {\n IN\n OUT\n ADJUST\n}\n\nenum MovementReferenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n INVENTORY_TRANSFER\n}\n\nenum stock_cardex_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_referenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n}\n\nmodel TriggerLog {\n id Int @id @default(autoincrement())\n name String @db.Text\n message String @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Trigger_Logs\")\n}\n", + "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n previewFeatures = [\"views\"]\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel User {\n id Int @id @default(autoincrement())\n mobileNumber String @unique @db.Char(11)\n password String\n firstName String\n lastName String\n roleId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n role Role @relation(\"User_Role\", fields: [roleId], references: [id], onUpdate: NoAction)\n\n @@index([roleId], map: \"Users_roleId_fkey\")\n @@map(\"Users\")\n}\n\nmodel Role {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n permissions Json?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n users User[] @relation(\"User_Role\")\n\n @@map(\"Roles\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(10, 2)\n salePrice Decimal @db.Decimal(10, 2)\n description String? @db.Text\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n imageUrl String? @db.VarChar(255)\n unit String? @db.VarChar(10)\n quantity Decimal? @default(0.00) @db.Decimal(10, 2)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 2)\n isActive Boolean @default(true)\n isFeatured Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n product Product @relation(\"Product_Variant\", fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([productId], map: \"Product_Variants_productId_fkey\")\n @@map(\"Product_Variants\")\n}\n\nmodel Product {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n description String? @db.Text\n sku String? @unique(map: \"products_sku_unique\") @db.VarChar(100)\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n salePrice Decimal @default(0.00) @db.Decimal(10, 2)\n brandId Int?\n categoryId Int?\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\n productCharges ProductCharge[] @relation(\"Product_Charges\")\n variants ProductVariant[] @relation(\"Product_Variant\")\n brand ProductBrand? @relation(\"Product_Brand\", fields: [brandId], references: [id], onUpdate: NoAction)\n category ProductCategory? @relation(\"Product_Category\", fields: [categoryId], references: [id], onUpdate: NoAction)\n purchaseReceiptItems PurchaseReceiptItem[] @relation(\"Product_PurchaseReceiptItems\")\n salesInvoiceItems SalesInvoiceItem[] @relation(\"Product_SalesInvoiceItems\")\n stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n\n stockBalances StockBalance[] @relation(\"StockBalance_Product\")\n\n @@index([brandId], map: \"Products_brandId_fkey\")\n @@index([categoryId], map: \"Products_categoryId_fkey\")\n @@map(\"Products\")\n}\n\nmodel ProductBrand {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Brand\")\n\n @@map(\"Product_brands\")\n}\n\nmodel ProductCategory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Category\")\n\n @@map(\"Product_categories\")\n}\n\nmodel Supplier {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productCharges ProductCharge[] @relation(\"Supplier_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockMovements StockMovement[] @relation(\"StockMovement_Supplier\")\n\n @@map(\"Suppliers\")\n}\n\nmodel Customer {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n orders Order[] @relation(\"Customer_Orders\")\n salesInvoices SalesInvoice[] @relation(\"Customer_Sales_Invoices\")\n\n @@map(\"Customers\")\n}\n\nmodel Inventory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n isPointOfSale Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n inventoryTransfersFrom InventoryTransfer[] @relation(\"Inventory_From\")\n inventoryTransfersTo InventoryTransfer[] @relation(\"Inventory_To\")\n productCharges ProductCharge[] @relation(\"Inventory_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockAdjustments StockAdjustment[] @relation(\"Inventory_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Inventory\")\n stockBalances StockBalance[] @relation(\"StockBalance_inventory\")\n\n @@map(\"Inventories\")\n}\n\nmodel Store {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n @@map(\"Stores\")\n}\n\nmodel ProductCharge {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalAmount Decimal @db.Decimal(10, 2)\n isSettled Boolean @default(false)\n buyAt DateTime? @db.Timestamp(0)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n inventoryId Int\n supplierId Int\n inventory Inventory @relation(\"Inventory_Product_Charges\", fields: [inventoryId], references: [id], onUpdate: NoAction)\n product Product @relation(\"Product_Charges\", fields: [productId], references: [id], onUpdate: NoAction)\n supplier Supplier @relation(\"Supplier_Product_Charges\", fields: [supplierId], references: [id], onUpdate: NoAction)\n\n @@index([inventoryId], map: \"Product_Charges_inventoryId_fkey\")\n @@index([productId], map: \"Product_Charges_productId_fkey\")\n @@index([supplierId], map: \"Product_Charges_supplierId_fkey\")\n @@map(\"Product_Charges\")\n}\n\nmodel Order {\n id Int @id @default(autoincrement())\n orderNumber String @unique @db.VarChar(100)\n status OrderStatus @default(pending)\n paymentMethod paymentMethod @default(card)\n totalAmount Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n customerId Int\n customer Customer @relation(\"Customer_Orders\", fields: [customerId], references: [id], onUpdate: NoAction)\n\n @@index([customerId], map: \"Orders_customerId_fkey\")\n @@map(\"Orders\")\n}\n\nmodel PurchaseReceipt {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n supplierId Int\n inventoryId Int\n items PurchaseReceiptItem[] @relation(\"PurchaseReceipt_Items\")\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n supplier Supplier @relation(fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Purchase_Receipts_inventoryId_fkey\")\n @@index([supplierId], map: \"Purchase_Receipts_supplierId_fkey\")\n @@map(\"Purchase_Receipts\")\n}\n\nmodel PurchaseReceiptItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n receiptId Int\n productId Int\n product Product @relation(\"Product_PurchaseReceiptItems\", fields: [productId], references: [id])\n receipt PurchaseReceipt @relation(\"PurchaseReceipt_Items\", fields: [receiptId], references: [id])\n\n @@index([productId], map: \"Purchase_Receipt_Items_productId_fkey\")\n @@index([receiptId], map: \"Purchase_Receipt_Items_receiptId_fkey\")\n @@map(\"Purchase_Receipt_Items\")\n}\n\nmodel SalesInvoice {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n customerId Int?\n items SalesInvoiceItem[] @relation(\"SalesInvoice_Items\")\n customer Customer? @relation(\"Customer_Sales_Invoices\", fields: [customerId], references: [id])\n\n @@index([customerId], map: \"Sales_Invoices_customerId_fkey\")\n @@map(\"Sales_Invoices\")\n}\n\nmodel SalesInvoiceItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n invoiceId Int\n productId Int\n invoice SalesInvoice @relation(\"SalesInvoice_Items\", fields: [invoiceId], references: [id])\n product Product @relation(\"Product_SalesInvoiceItems\", fields: [productId], references: [id])\n\n @@index([invoiceId], map: \"Sales_Invoice_Items_invoiceId_fkey\")\n @@index([productId], map: \"Sales_Invoice_Items_productId_fkey\")\n @@map(\"Sales_Invoice_Items\")\n}\n\nmodel StockMovement {\n id Int @id @default(autoincrement())\n type MovementType\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceType MovementReferenceType\n referenceId String\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n avgCost Decimal @db.Decimal(10, 2)\n remainedInStock Decimal @default(0) @db.Decimal(10, 2)\n inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], references: [id])\n supplierId Int?\n supplier Supplier? @relation(\"StockMovement_Supplier\", fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Movements_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Movements_productId_fkey\")\n @@map(\"Stock_Movements\")\n}\n\nmodel StockBalance {\n id Int @id @default(autoincrement())\n\n productId Int\n inventoryId Int\n\n quantity Decimal @default(0) @db.Decimal(14, 3)\n\n avgCost Decimal @default(0) @db.Decimal(14, 2)\n totalCost Decimal @default(0) @db.Decimal(14, 2)\n\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n\n product Product @relation(\"StockBalance_Product\", fields: [productId], references: [id])\n inventory Inventory @relation(\"StockBalance_inventory\", fields: [inventoryId], references: [id])\n\n @@unique([productId, inventoryId])\n @@index([productId])\n @@index([inventoryId])\n @@map(\"Stock_Balance\")\n}\n\nmodel InventoryTransfer {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n fromInventoryId Int\n toInventoryId Int\n items InventoryTransferItem[] @relation(\"InventoryTransfer_Items\")\n fromInventory Inventory @relation(\"Inventory_From\", fields: [fromInventoryId], references: [id])\n toInventory Inventory @relation(\"Inventory_To\", fields: [toInventoryId], references: [id])\n\n @@index([fromInventoryId], map: \"Inventory_Transfers_fromInventoryId_fkey\")\n @@index([toInventoryId], map: \"Inventory_Transfers_toInventoryId_fkey\")\n @@map(\"Inventory_Transfers\")\n}\n\nmodel InventoryTransferItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n productId Int\n transferId Int\n product Product @relation(\"InventoryTransferItem_Product\", fields: [productId], references: [id])\n transfer InventoryTransfer @relation(\"InventoryTransfer_Items\", fields: [transferId], references: [id])\n\n @@index([productId], map: \"Inventory_Transfer_Items_productId_fkey\")\n @@index([transferId], map: \"Inventory_Transfer_Items_transferId_fkey\")\n @@map(\"Inventory_Transfer_Items\")\n}\n\nmodel StockAdjustment {\n id Int @id @default(autoincrement())\n adjustedQuantity Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n inventory Inventory @relation(\"Inventory_Stock_Adjustments\", fields: [inventoryId], references: [id])\n product Product @relation(\"Product_Stock_Adjustments\", fields: [productId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Adjustments_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Adjustments_productId_fkey\")\n @@map(\"Stock_Adjustments\")\n}\n\nview StockMovements_View {\n id Int @default(0)\n productId Int\n type stock_movements_view_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceId String\n referenceType stock_movements_view_referenceType\n createdAt DateTime @default(now()) @db.Timestamp(0)\n current_stock Decimal?\n current_avg_cost Decimal?\n\n @@map(\"Stock_Movements_View\")\n @@ignore\n}\n\nview inventory_overview {\n ProductId Int\n stock_quantity Decimal\n avgCost Decimal\n totalCost Decimal\n updatedAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Inventory_Overview\")\n}\n\nview stock_cardex {\n productId Int\n movement_id Int @default(0)\n type stock_cardex_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n balance_quantity Decimal?\n balance_avg_cost Decimal?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Stock_Cardex\")\n}\n\nview stock_view {\n productId Int\n inventoryId Int\n stock Decimal? @db.Decimal(32, 2)\n\n @@map(\"Stock_View\")\n}\n\nenum OrderStatus {\n pending\n reject\n done\n}\n\nenum paymentMethod {\n cash\n card\n}\n\nenum MovementType {\n IN\n OUT\n ADJUST\n}\n\nenum MovementReferenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n INVENTORY_TRANSFER\n}\n\nenum stock_cardex_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_referenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n}\n\nmodel TriggerLog {\n id Int @id @default(autoincrement())\n name String @db.Text\n message String @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Trigger_Logs\")\n}\n", "runtimeDataModel": { "models": {}, "enums": {}, @@ -30,7 +30,7 @@ const config: runtime.GetPrismaClientConfig = { } } -config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"roleId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"role\",\"kind\":\"object\",\"type\":\"Role\",\"relationName\":\"User_Role\"}],\"dbName\":\"Users\"},\"Role\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"users\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"User_Role\"}],\"dbName\":\"Roles\"},\"ProductVariant\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"basePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"unit\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"alertQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isFeatured\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Variant\"}],\"dbName\":\"Product_Variants\"},\"Product\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sku\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"brandId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Product_Charges\"},{\"name\":\"variants\",\"kind\":\"object\",\"type\":\"ProductVariant\",\"relationName\":\"Product_Variant\"},{\"name\":\"brand\",\"kind\":\"object\",\"type\":\"ProductBrand\",\"relationName\":\"Product_Brand\"},{\"name\":\"category\",\"kind\":\"object\",\"type\":\"ProductCategory\",\"relationName\":\"Product_Category\"},{\"name\":\"purchaseReceiptItems\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"Product_SalesInvoiceItems\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_Product\"}],\"dbName\":\"Products\"},\"ProductBrand\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Brand\"}],\"dbName\":\"Product_brands\"},\"ProductCategory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Category\"}],\"dbName\":\"Product_categories\"},\"Supplier\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Supplier_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToSupplier\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Suppliers\"},\"Customer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"orders\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"Customer_Orders\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Customers\"},\"Inventory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isPointOfSale\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inventoryTransfersFrom\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_From\"},{\"name\":\"inventoryTransfersTo\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_To\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Inventories\"},\"Store\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stores\"},\"ProductCharge\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isSettled\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"buyAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Charges\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"Supplier_Product_Charges\"}],\"dbName\":\"Product_Charges\"},\"Order\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"OrderStatus\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"paymentMethod\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Orders\"}],\"dbName\":\"Orders\"},\"PurchaseReceipt\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"PurchaseReceipt_Items\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"PurchaseReceiptToSupplier\"}],\"dbName\":\"Purchase_Receipts\"},\"PurchaseReceiptItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"}],\"dbName\":\"Purchase_Receipt_Items\"},\"SalesInvoice\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Sales_Invoices\"},\"SalesInvoiceItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invoiceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"invoice\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_SalesInvoiceItems\"}],\"dbName\":\"Sales_Invoice_Items\"},\"StockMovement\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"MovementType\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"referenceType\",\"kind\":\"enum\",\"type\":\"MovementReferenceType\"},{\"name\":\"referenceId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"remainedInStock\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockBalance_Product\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Stock_Balance\"},\"InventoryTransfer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"fromInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"toInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransfer_Items\"},{\"name\":\"fromInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_From\"},{\"name\":\"toInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_To\"}],\"dbName\":\"Inventory_Transfers\"},\"InventoryTransferItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"transferId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"transfer\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"InventoryTransfer_Items\"}],\"dbName\":\"Inventory_Transfer_Items\"},\"StockAdjustment\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"adjustedQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Stock_Adjustments\"}],\"dbName\":\"Stock_Adjustments\"},\"TriggerLog\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"message\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Trigger_Logs\"},\"inventory_overview\":{\"fields\":[{\"name\":\"ProductId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Inventory_Overview\"},\"stock_cardex\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"movement_id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"stock_cardex_type\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_avg_cost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stock_Cardex\"},\"stock_view\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock\",\"kind\":\"scalar\",\"type\":\"Decimal\"}],\"dbName\":\"Stock_View\"}},\"enums\":{},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"roleId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"role\",\"kind\":\"object\",\"type\":\"Role\",\"relationName\":\"User_Role\"}],\"dbName\":\"Users\"},\"Role\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"users\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"User_Role\"}],\"dbName\":\"Roles\"},\"ProductVariant\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"basePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"unit\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"alertQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isFeatured\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Variant\"}],\"dbName\":\"Product_Variants\"},\"Product\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sku\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"brandId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Product_Charges\"},{\"name\":\"variants\",\"kind\":\"object\",\"type\":\"ProductVariant\",\"relationName\":\"Product_Variant\"},{\"name\":\"brand\",\"kind\":\"object\",\"type\":\"ProductBrand\",\"relationName\":\"Product_Brand\"},{\"name\":\"category\",\"kind\":\"object\",\"type\":\"ProductCategory\",\"relationName\":\"Product_Category\"},{\"name\":\"purchaseReceiptItems\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"Product_SalesInvoiceItems\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_Product\"}],\"dbName\":\"Products\"},\"ProductBrand\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Brand\"}],\"dbName\":\"Product_brands\"},\"ProductCategory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Category\"}],\"dbName\":\"Product_categories\"},\"Supplier\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Supplier_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToSupplier\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Suppliers\"},\"Customer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"orders\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"Customer_Orders\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Customers\"},\"Inventory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isPointOfSale\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inventoryTransfersFrom\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_From\"},{\"name\":\"inventoryTransfersTo\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_To\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Inventories\"},\"Store\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stores\"},\"ProductCharge\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isSettled\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"buyAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Charges\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"Supplier_Product_Charges\"}],\"dbName\":\"Product_Charges\"},\"Order\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"OrderStatus\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"paymentMethod\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Orders\"}],\"dbName\":\"Orders\"},\"PurchaseReceipt\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"PurchaseReceipt_Items\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"PurchaseReceiptToSupplier\"}],\"dbName\":\"Purchase_Receipts\"},\"PurchaseReceiptItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"}],\"dbName\":\"Purchase_Receipt_Items\"},\"SalesInvoice\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Sales_Invoices\"},\"SalesInvoiceItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invoiceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"invoice\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_SalesInvoiceItems\"}],\"dbName\":\"Sales_Invoice_Items\"},\"StockMovement\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"MovementType\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"referenceType\",\"kind\":\"enum\",\"type\":\"MovementReferenceType\"},{\"name\":\"referenceId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"remainedInStock\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockBalance_Product\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Stock_Balance\"},\"InventoryTransfer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"fromInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"toInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransfer_Items\"},{\"name\":\"fromInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_From\"},{\"name\":\"toInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_To\"}],\"dbName\":\"Inventory_Transfers\"},\"InventoryTransferItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"transferId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"transfer\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"InventoryTransfer_Items\"}],\"dbName\":\"Inventory_Transfer_Items\"},\"StockAdjustment\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"adjustedQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Stock_Adjustments\"}],\"dbName\":\"Stock_Adjustments\"},\"TriggerLog\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"message\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Trigger_Logs\"},\"inventory_overview\":{\"fields\":[{\"name\":\"ProductId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Inventory_Overview\"},\"stock_cardex\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"movement_id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"stock_cardex_type\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_avg_cost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stock_Cardex\"},\"stock_view\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock\",\"kind\":\"scalar\",\"type\":\"Decimal\"}],\"dbName\":\"Stock_View\"}},\"enums\":{},\"types\":{}}") async function decodeBase64AsWasm(wasmBase64: string): Promise { const { Buffer } = await import('node:buffer') diff --git a/src/generated/prisma/internal/prismaNamespace.ts b/src/generated/prisma/internal/prismaNamespace.ts index 9adc1b1..a7cf1fe 100644 --- a/src/generated/prisma/internal/prismaNamespace.ts +++ b/src/generated/prisma/internal/prismaNamespace.ts @@ -2068,6 +2068,7 @@ export const ProductScalarFieldEnum = { createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt', + salePrice: 'salePrice', brandId: 'brandId', categoryId: 'categoryId' } as const diff --git a/src/generated/prisma/internal/prismaNamespaceBrowser.ts b/src/generated/prisma/internal/prismaNamespaceBrowser.ts index ec2c164..e097fa8 100644 --- a/src/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/src/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -153,6 +153,7 @@ export const ProductScalarFieldEnum = { createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt', + salePrice: 'salePrice', brandId: 'brandId', categoryId: 'categoryId' } as const diff --git a/src/generated/prisma/models/Product.ts b/src/generated/prisma/models/Product.ts index 28d85c4..c5efb4b 100644 --- a/src/generated/prisma/models/Product.ts +++ b/src/generated/prisma/models/Product.ts @@ -28,12 +28,14 @@ export type AggregateProduct = { export type ProductAvgAggregateOutputType = { id: number | null + salePrice: runtime.Decimal | null brandId: number | null categoryId: number | null } export type ProductSumAggregateOutputType = { id: number | null + salePrice: runtime.Decimal | null brandId: number | null categoryId: number | null } @@ -47,6 +49,7 @@ export type ProductMinAggregateOutputType = { createdAt: Date | null updatedAt: Date | null deletedAt: Date | null + salePrice: runtime.Decimal | null brandId: number | null categoryId: number | null } @@ -60,6 +63,7 @@ export type ProductMaxAggregateOutputType = { createdAt: Date | null updatedAt: Date | null deletedAt: Date | null + salePrice: runtime.Decimal | null brandId: number | null categoryId: number | null } @@ -73,6 +77,7 @@ export type ProductCountAggregateOutputType = { createdAt: number updatedAt: number deletedAt: number + salePrice: number brandId: number categoryId: number _all: number @@ -81,12 +86,14 @@ export type ProductCountAggregateOutputType = { export type ProductAvgAggregateInputType = { id?: true + salePrice?: true brandId?: true categoryId?: true } export type ProductSumAggregateInputType = { id?: true + salePrice?: true brandId?: true categoryId?: true } @@ -100,6 +107,7 @@ export type ProductMinAggregateInputType = { createdAt?: true updatedAt?: true deletedAt?: true + salePrice?: true brandId?: true categoryId?: true } @@ -113,6 +121,7 @@ export type ProductMaxAggregateInputType = { createdAt?: true updatedAt?: true deletedAt?: true + salePrice?: true brandId?: true categoryId?: true } @@ -126,6 +135,7 @@ export type ProductCountAggregateInputType = { createdAt?: true updatedAt?: true deletedAt?: true + salePrice?: true brandId?: true categoryId?: true _all?: true @@ -226,6 +236,7 @@ export type ProductGroupByOutputType = { createdAt: Date updatedAt: Date deletedAt: Date | null + salePrice: runtime.Decimal brandId: number | null categoryId: number | null _count: ProductCountAggregateOutputType | null @@ -262,6 +273,7 @@ export type ProductWhereInput = { createdAt?: Prisma.DateTimeFilter<"Product"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Product"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Product"> | Date | string | null + salePrice?: Prisma.DecimalFilter<"Product"> | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.IntNullableFilter<"Product"> | number | null categoryId?: Prisma.IntNullableFilter<"Product"> | number | null inventoryTransferItems?: Prisma.InventoryTransferItemListRelationFilter @@ -285,6 +297,7 @@ export type ProductOrderByWithRelationInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrderInput | Prisma.SortOrder categoryId?: Prisma.SortOrderInput | Prisma.SortOrder inventoryTransferItems?: Prisma.InventoryTransferItemOrderByRelationAggregateInput @@ -312,6 +325,7 @@ export type ProductWhereUniqueInput = Prisma.AtLeast<{ createdAt?: Prisma.DateTimeFilter<"Product"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Product"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Product"> | Date | string | null + salePrice?: Prisma.DecimalFilter<"Product"> | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.IntNullableFilter<"Product"> | number | null categoryId?: Prisma.IntNullableFilter<"Product"> | number | null inventoryTransferItems?: Prisma.InventoryTransferItemListRelationFilter @@ -335,6 +349,7 @@ export type ProductOrderByWithAggregationInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrderInput | Prisma.SortOrder categoryId?: Prisma.SortOrderInput | Prisma.SortOrder _count?: Prisma.ProductCountOrderByAggregateInput @@ -356,6 +371,7 @@ export type ProductScalarWhereWithAggregatesInput = { createdAt?: Prisma.DateTimeWithAggregatesFilter<"Product"> | Date | string updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Product"> | Date | string deletedAt?: Prisma.DateTimeNullableWithAggregatesFilter<"Product"> | Date | string | null + salePrice?: Prisma.DecimalWithAggregatesFilter<"Product"> | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.IntNullableWithAggregatesFilter<"Product"> | number | null categoryId?: Prisma.IntNullableWithAggregatesFilter<"Product"> | number | null } @@ -368,6 +384,7 @@ export type ProductCreateInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -389,6 +406,7 @@ export type ProductUncheckedCreateInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -409,6 +427,7 @@ export type ProductUpdateInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -430,6 +449,7 @@ export type ProductUncheckedUpdateInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -451,6 +471,7 @@ export type ProductCreateManyInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null } @@ -463,6 +484,7 @@ export type ProductUpdateManyMutationInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string } export type ProductUncheckedUpdateManyInput = { @@ -474,6 +496,7 @@ export type ProductUncheckedUpdateManyInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } @@ -498,12 +521,14 @@ export type ProductCountOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrder categoryId?: Prisma.SortOrder } export type ProductAvgOrderByAggregateInput = { id?: Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrder categoryId?: Prisma.SortOrder } @@ -517,6 +542,7 @@ export type ProductMaxOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrder categoryId?: Prisma.SortOrder } @@ -530,12 +556,14 @@ export type ProductMinOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrder categoryId?: Prisma.SortOrder } export type ProductSumOrderByAggregateInput = { id?: Prisma.SortOrder + salePrice?: Prisma.SortOrder brandId?: Prisma.SortOrder categoryId?: Prisma.SortOrder } @@ -762,6 +790,7 @@ export type ProductCreateWithoutVariantsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput brand?: Prisma.ProductBrandCreateNestedOneWithoutProductsInput @@ -782,6 +811,7 @@ export type ProductUncheckedCreateWithoutVariantsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -817,6 +847,7 @@ export type ProductUpdateWithoutVariantsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput brand?: Prisma.ProductBrandUpdateOneWithoutProductsNestedInput @@ -837,6 +868,7 @@ export type ProductUncheckedUpdateWithoutVariantsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -856,6 +888,7 @@ export type ProductCreateWithoutBrandInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -876,6 +909,7 @@ export type ProductUncheckedCreateWithoutBrandInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutProductInput @@ -925,6 +959,7 @@ export type ProductScalarWhereInput = { createdAt?: Prisma.DateTimeFilter<"Product"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Product"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Product"> | Date | string | null + salePrice?: Prisma.DecimalFilter<"Product"> | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.IntNullableFilter<"Product"> | number | null categoryId?: Prisma.IntNullableFilter<"Product"> | number | null } @@ -937,6 +972,7 @@ export type ProductCreateWithoutCategoryInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -957,6 +993,7 @@ export type ProductUncheckedCreateWithoutCategoryInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutProductInput @@ -1002,6 +1039,7 @@ export type ProductCreateWithoutProductChargesInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput brand?: Prisma.ProductBrandCreateNestedOneWithoutProductsInput @@ -1022,6 +1060,7 @@ export type ProductUncheckedCreateWithoutProductChargesInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1057,6 +1096,7 @@ export type ProductUpdateWithoutProductChargesInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput brand?: Prisma.ProductBrandUpdateOneWithoutProductsNestedInput @@ -1077,6 +1117,7 @@ export type ProductUncheckedUpdateWithoutProductChargesInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1096,6 +1137,7 @@ export type ProductCreateWithoutPurchaseReceiptItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -1116,6 +1158,7 @@ export type ProductUncheckedCreateWithoutPurchaseReceiptItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1151,6 +1194,7 @@ export type ProductUpdateWithoutPurchaseReceiptItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1171,6 +1215,7 @@ export type ProductUncheckedUpdateWithoutPurchaseReceiptItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1190,6 +1235,7 @@ export type ProductCreateWithoutSalesInvoiceItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -1210,6 +1256,7 @@ export type ProductUncheckedCreateWithoutSalesInvoiceItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1245,6 +1292,7 @@ export type ProductUpdateWithoutSalesInvoiceItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1265,6 +1313,7 @@ export type ProductUncheckedUpdateWithoutSalesInvoiceItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1284,6 +1333,7 @@ export type ProductCreateWithoutStockMovementsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -1304,6 +1354,7 @@ export type ProductUncheckedCreateWithoutStockMovementsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1339,6 +1390,7 @@ export type ProductUpdateWithoutStockMovementsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1359,6 +1411,7 @@ export type ProductUncheckedUpdateWithoutStockMovementsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1378,6 +1431,7 @@ export type ProductCreateWithoutStockBalancesInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -1398,6 +1452,7 @@ export type ProductUncheckedCreateWithoutStockBalancesInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1433,6 +1488,7 @@ export type ProductUpdateWithoutStockBalancesInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1453,6 +1509,7 @@ export type ProductUncheckedUpdateWithoutStockBalancesInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1472,6 +1529,7 @@ export type ProductCreateWithoutInventoryTransferItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput brand?: Prisma.ProductBrandCreateNestedOneWithoutProductsInput @@ -1492,6 +1550,7 @@ export type ProductUncheckedCreateWithoutInventoryTransferItemsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutProductInput @@ -1527,6 +1586,7 @@ export type ProductUpdateWithoutInventoryTransferItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput brand?: Prisma.ProductBrandUpdateOneWithoutProductsNestedInput @@ -1547,6 +1607,7 @@ export type ProductUncheckedUpdateWithoutInventoryTransferItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutProductNestedInput @@ -1566,6 +1627,7 @@ export type ProductCreateWithoutStockAdjustmentsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput @@ -1586,6 +1648,7 @@ export type ProductUncheckedCreateWithoutStockAdjustmentsInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null categoryId?: number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput @@ -1621,6 +1684,7 @@ export type ProductUpdateWithoutStockAdjustmentsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1641,6 +1705,7 @@ export type ProductUncheckedUpdateWithoutStockAdjustmentsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput @@ -1661,6 +1726,7 @@ export type ProductCreateManyBrandInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string categoryId?: number | null } @@ -1672,6 +1738,7 @@ export type ProductUpdateWithoutBrandInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1692,6 +1759,7 @@ export type ProductUncheckedUpdateWithoutBrandInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutProductNestedInput @@ -1712,6 +1780,7 @@ export type ProductUncheckedUpdateManyWithoutBrandInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } @@ -1724,6 +1793,7 @@ export type ProductCreateManyCategoryInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + salePrice?: runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: number | null } @@ -1735,6 +1805,7 @@ export type ProductUpdateWithoutCategoryInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput @@ -1755,6 +1826,7 @@ export type ProductUncheckedUpdateWithoutCategoryInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutProductNestedInput @@ -1775,6 +1847,7 @@ export type ProductUncheckedUpdateManyWithoutCategoryInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salePrice?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } @@ -1881,6 +1954,7 @@ export type ProductSelect @@ -1907,11 +1981,12 @@ export type ProductSelectScalar = { createdAt?: boolean updatedAt?: boolean deletedAt?: boolean + salePrice?: boolean brandId?: boolean categoryId?: boolean } -export type ProductOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "description" | "sku" | "barcode" | "createdAt" | "updatedAt" | "deletedAt" | "brandId" | "categoryId", ExtArgs["result"]["product"]> +export type ProductOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "description" | "sku" | "barcode" | "createdAt" | "updatedAt" | "deletedAt" | "salePrice" | "brandId" | "categoryId", ExtArgs["result"]["product"]> export type ProductInclude = { inventoryTransferItems?: boolean | Prisma.Product$inventoryTransferItemsArgs productCharges?: boolean | Prisma.Product$productChargesArgs @@ -1949,6 +2024,7 @@ export type $ProductPayload @@ -2338,6 +2414,7 @@ export interface ProductFieldRefs { readonly createdAt: Prisma.FieldRef<"Product", 'DateTime'> readonly updatedAt: Prisma.FieldRef<"Product", 'DateTime'> readonly deletedAt: Prisma.FieldRef<"Product", 'DateTime'> + readonly salePrice: Prisma.FieldRef<"Product", 'Decimal'> readonly brandId: Prisma.FieldRef<"Product", 'Int'> readonly categoryId: Prisma.FieldRef<"Product", 'Int'> } diff --git a/src/pos/dto/create-pos.dto.ts b/src/pos/dto/create-pos.dto.ts new file mode 100644 index 0000000..bf01e88 --- /dev/null +++ b/src/pos/dto/create-pos.dto.ts @@ -0,0 +1,15 @@ +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' +import { IsOptional, IsString } from 'class-validator' + +export class CreateInventoryDto { + @ApiProperty() + @IsString() + name: string + + @ApiPropertyOptional() + @IsOptional() + @IsString() + location?: string +} + +// export class CreateSaleInvoice extends Prisma. diff --git a/src/pos/dto/update-pos.dto.ts b/src/pos/dto/update-pos.dto.ts new file mode 100644 index 0000000..259366c --- /dev/null +++ b/src/pos/dto/update-pos.dto.ts @@ -0,0 +1,21 @@ +import { ApiPropertyOptional } from '@nestjs/swagger' +import { Type } from 'class-transformer' +import { IsBoolean, IsOptional, IsString } from 'class-validator' + +export class UpdateInventoryDto { + @ApiPropertyOptional() + @IsOptional() + @IsString() + name?: string + + @ApiPropertyOptional() + @IsOptional() + @IsString() + location?: string + + @ApiPropertyOptional() + @IsOptional() + @Type(() => Boolean) + @IsBoolean() + isActive?: boolean +} diff --git a/src/pos/pos.controller.ts b/src/pos/pos.controller.ts new file mode 100644 index 0000000..bc8ffa7 --- /dev/null +++ b/src/pos/pos.controller.ts @@ -0,0 +1,67 @@ +import { Controller, Get } from '@nestjs/common' +import { PosService } from './pos.service' + +@Controller('pos') +export class PosController { + constructor(private readonly posService: PosService) {} + + @Get() + getInfo() { + return this.posService.getInfo() + } + + @Get('/stock') + async getStock() { + const inventoryId = await this.posService.getDefaultInventoryId() + return this.posService.getStock(inventoryId!) + } + + @Get('/product-categories') + async getProductCategories() { + const inventoryId = await this.posService.getDefaultInventoryId() + return this.posService.getProductCategories(inventoryId!) + } + + // @Post() + // create(@Body() dto: CreateInventoryDto) { + // return this.inventoriesService.create(dto) + // } + + // @Get() + // @ApiQuery({ name: 'isPointOfSale', required: false, type: Boolean }) + // findAll(@Query('isPointOfSale') isPointOfSale?: boolean) { + // return this.inventoriesService.findAll(isPointOfSale) + // } + + // @Get(':id') + // findOne(@Param('id') id: string) { + // return this.inventoriesService.findOne(Number(id)) + // } + + // @Patch(':id') + // update(@Param('id') id: string, @Body() dto: UpdateInventoryDto) { + // return this.inventoriesService.update(Number(id), dto) + // } + + // @Delete(':id') + // remove(@Param('id') id: string) { + // return this.inventoriesService.remove(Number(id)) + // } + + // @Get(':id/movements') + // @ApiQuery({ name: 'type', required: false, enum: MovementType }) + // findInventoryMovements(@Param('id') id: string, @Query('type') type?: MovementType) { + // return this.inventoriesService.findInventoryMovements(Number(id), type ?? undefined) + // } + + // @Get(':id/stock') + // @ApiQuery({ name: 'isAvailable', required: false, type: Boolean }) + // getStock(@Param('id') id: string, @Query('isAvailable') isAvailable?: boolean) { + // return this.inventoriesService.getStock(Number(id), isAvailable ?? undefined) + // } + + // @Get(':id/products/:productId/cardex') + // getProductCardex(@Param('id') id: string, @Param('productId') productId: string) { + // return this.inventoriesService.getProductCardex(Number(id), Number(productId)) + // } +} diff --git a/src/pos/pos.module.ts b/src/pos/pos.module.ts new file mode 100644 index 0000000..396359f --- /dev/null +++ b/src/pos/pos.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common' +import { PrismaModule } from '../prisma/prisma.module' +import { PosController } from './pos.controller' +import { PosService } from './pos.service' + +@Module({ + imports: [PrismaModule], + controllers: [PosController], + providers: [PosService], +}) +export class PosModule {} diff --git a/src/pos/pos.service.ts b/src/pos/pos.service.ts new file mode 100644 index 0000000..9fff5c8 --- /dev/null +++ b/src/pos/pos.service.ts @@ -0,0 +1,116 @@ +import { Injectable } from '@nestjs/common' +import { ResponseMapper } from '../common/response/response-mapper' +import { Prisma } from '../generated/prisma/client' +import { PrismaService } from '../prisma/prisma.service' + +@Injectable() +export class PosService { + constructor(private prisma: PrismaService) {} + + async getDefaultInventoryId() { + const inventory = await this.prisma.inventory.findFirst({ + where: { isPointOfSale: true }, + select: { id: true }, + }) + return inventory?.id || null + } + + async getInfo() { + const info = await this.prisma.inventory.findFirst({ + where: { isPointOfSale: true }, + select: { + id: true, + name: true, + }, + }) + + return ResponseMapper.single({ store: info }) + } + + async getStock(inventoryId: number, isAvailable?: boolean, page = 1, pageSize = 50) { + const query: Prisma.StockBalanceFindManyArgs = { + where: { + inventoryId, + quantity: + isAvailable === true + ? { gt: 0 } + : isAvailable === false + ? { lte: 0 } + : undefined, + }, + } + const [items, count] = await this.prisma.$transaction([ + this.prisma.stockBalance.findMany({ + where: query.where, + include: { + product: { + select: { + id: true, + name: true, + sku: true, + salePrice: true, + category: { + select: { id: true, name: true }, + }, + }, + }, + }, + orderBy: { + quantity: 'desc', + }, + skip: (page - 1) * pageSize, + take: pageSize, + }), + this.prisma.stockBalance.count({ where: query.where }), + ]) + + const mapped = items.map(item => ({ + id: item.id, + quantity: Number(item.quantity), + product: item.product, + })) + + return ResponseMapper.paginate(mapped, count, page, pageSize) + } + + async getProductCategories(inventoryId: number) { + const balances = await this.prisma.stockBalance.findMany({ + where: { inventoryId }, + select: { + product: { select: { id: true, category: { select: { id: true, name: true } } } }, + quantity: true, + }, + }) + + const map = new Map< + number, + { id: number; name: string; totalQuantity: number; productCount: number } + >() + + for (const b of balances) { + const product = b.product + const cat = product?.category + if (!cat) continue // skip products without category + const existing = map.get(cat.id) + if (existing) { + existing.totalQuantity += Number(b.quantity) + existing.productCount += 1 + } else { + map.set(cat.id, { + id: cat.id, + name: cat.name, + totalQuantity: Number(b.quantity), + productCount: 1, + }) + } + } + + const categories = Array.from(map.values()) + return ResponseMapper.list(categories) + } + + async createSaleInvoice(data: any) { + const item = await this.prisma.salesInvoice.create({ data }) + return ResponseMapper.create(item) + } +}