diff --git a/package.json b/package.json index 6a25aef..9d631c1 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "generate:permissions": "tsx scripts/generate-permissions.ts", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "pullDBTriggers": "tsx scripts/pull-triggers.ts", "start": "nest start", "start:debug": "nest start --debug --watch", "start:dev": "nest start --watch", diff --git a/prisma/migrations/20251215085308_init/migration.sql b/prisma/migrations/20251215085308_init/migration.sql new file mode 100644 index 0000000..657de4b --- /dev/null +++ b/prisma/migrations/20251215085308_init/migration.sql @@ -0,0 +1,226 @@ +/* +Warnings: + +- Added the required column `inventoryId` to the `Sales_Invoices` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Sales_Invoices` +ADD COLUMN `inventoryId` INTEGER NOT NULL; + +-- CreateIndex +CREATE INDEX `Sales_Invoices_inventoryId_fkey` ON `Sales_Invoices` (`inventoryId`); + +-- AddForeignKey +ALTER TABLE `Sales_Invoices` +ADD CONSTRAINT `Sales_Invoices_inventoryId_fkey` FOREIGN KEY (`inventoryId`) REFERENCES `Inventories` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- ------------------------------------------ +-- Trigger: trg_transfer_item_after_insert +-- Event: INSERT +-- Table: Inventory_Transfer_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_transfer_item_after_insert`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_transfer_item_after_insert` AFTER INSERT ON `Inventory_Transfer_Items` FOR EACH ROW begin + + + DECLARE fromInv INT; + DECLARE toInv INT; + DECLARE _avgCost DECIMAL(10,2); + DECLARE latestQuantityInOrigin DECIMAL(10,2); + DECLARE latestQuantityInDestination DECIMAL(10,2); + + SELECT fromInventoryId, toInventoryId INTO fromInv, toInv + FROM Inventory_Transfers WHERE id = NEW.transferId; + + SELECT COALESCE(avgCost, 0), COALESCE(quantity, 0) INTO _avgCost, latestQuantityInOrigin FROM Stock_Balance + WHERE ProductId = NEW.productId AND inventoryId = fromInv LIMIT 1; + + SELECT COALESCE(quantity, 0) INTO latestQuantityInDestination FROM Stock_Balance + WHERE ProductId = NEW.productId AND inventoryId = toInv LIMIT 1; + + + -- OUT from source + INSERT INTO Stock_Movements + (type, quantity, fee, totalCost, avgCost, referenceType, referenceId, productId, inventoryId, createdAt, remainedInStock) + VALUES + ('OUT', NEW.count, _avgCost, _avgCost*NEW.count, _avgCost, 'INVENTORY_TRANSFER', NEW.transferId, NEW.productId, fromInv, NOW(), latestQuantityInOrigin-NEW.count); + + -- IN to destination + INSERT INTO Stock_Movements + (type, quantity, fee, totalCost, avgCost, referenceType, referenceId, productId, inventoryId, createdAt, remainedInStock) + VALUES + ('IN', NEW.count,_avgCost, _avgCost*NEW.count,_avgCost, 'INVENTORY_TRANSFER', NEW.transferId, NEW.productId, toInv, NOW(), latestQuantityInOrigin-NEW.count); +end; + +-- ------------------------------------------ +-- Trigger: trg_purchase_receipt_item_after_insert +-- Event: INSERT +-- Table: Purchase_Receipt_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_purchase_receipt_item_after_insert`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_insert` AFTER INSERT ON `Purchase_Receipt_Items` FOR EACH ROW BEGIN + DECLARE latestQuantity DECIMAL(10,2) DEFAULT 0; + DECLARE invId INT; + DECLARE suppId INT; + + -- Get inventory & supplier from receipt + SELECT inventoryId, supplierId + INTO invId, suppId + FROM Purchase_Receipts + WHERE id = NEW.receiptId; + + -- Get current stock quantity (if exists) + SELECT COALESCE(quantity, 0) + INTO latestQuantity + FROM Stock_Balance sb + WHERE sb.inventoryId = invId + AND sb.productId = NEW.productId + LIMIT 1; + + -- Insert stock movement + INSERT INTO Stock_Movements ( + type, + quantity, + fee, + totalCost, + referenceType, + referenceId, + productId, + inventoryId, + avgCost, + supplierId, + remainedInStock, + createdAt + ) + VALUES ( + 'IN', + NEW.count, + NEW.fee, + NEW.total, + 'PURCHASE', + NEW.receiptId, + NEW.productId, + invId, + CASE + WHEN NEW.count = 0 THEN 0 + ELSE NEW.total / NEW.count + END, + suppId, + latestQuantity + NEW.count, + NOW() + ); +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_transfer +-- Event: INSERT +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_transfer`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_transfer` AFTER INSERT ON `Stock_Movements` FOR EACH ROW BEGIN + + IF NEW.referenceType = 'INVENTORY_TRANSFER' THEN + + IF NEW.type = 'IN' THEN + INSERT INTO Stock_Balance ( + productId, + inventoryId, + quantity, + totalCost, + avgCost, + updatedAt + ) + VALUES ( + NEW.productId, + NEW.inventoryId, + NEW.quantity, + NEW.totalCost, + CASE + WHEN NEW.quantity = 0 THEN 0 + ELSE NEW.totalCost / NEW.quantity + END, + NOW() + ) + ON DUPLICATE KEY UPDATE + quantity = quantity + NEW.quantity, + totalCost = totalCost + NEW.totalCost, + avgCost = CASE + WHEN (quantity + NEW.quantity) = 0 THEN 0 + ELSE (totalCost + NEW.totalCost) / (quantity + NEW.quantity) + END, + updatedAt = NOW(); + END IF; + + + IF NEW.type = 'OUT' THEN + + + IF EXISTS( + SELECT 1 FROM Stock_Balance sb + WHERE sb.productId = NEW.productId + AND sb.inventoryId = NEW.inventoryId + ) THEN + + + UPDATE Stock_Balance sb + SET + sb.quantity = sb.quantity - NEW.quantity, + sb.totalCost = sb.totalCost - (sb.avgCost * NEW.quantity), + sb.updatedAt = NOW() + WHERE sb.productId = NEW.productId + AND sb.inventoryId = NEW.inventoryId; + + ELSE + INSERT INTO Stock_Balance ( + productId, + inventoryId, + quantity, + totalCost, + avgCost, + updatedAt + ) + VALUES ( + NEW.productId, + NEW.inventoryId, + -NEW.quantity, + -COALESCE(NEW.fee, 0) * NEW.quantity, + COALESCE(NEW.fee, 0), + NOW() + ); + END IF; + + END IF; + + END IF; +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_purchase_insert +-- Event: INSERT +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_purchase_insert`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_insert` AFTER INSERT ON `Stock_Movements` FOR EACH ROW BEGIN + IF NEW.referenceType = 'PURCHASE' THEN + + INSERT INTO Stock_Balance (productId, quantity, avgCost, totalCost, inventoryId, updatedAt) + VALUES ( + NEW.productId, + NEW.quantity, + NEW.fee, + NEW.totalCost, + NEW.inventoryId, + NOW() + ) + ON DUPLICATE KEY UPDATE + quantity = quantity + NEW.quantity, + totalCost = totalCost + NEW.totalCost, + avgCost = totalCost / quantity; + + END IF; +END; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 72d125c..5e70722 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -173,6 +173,7 @@ model Inventory { stockAdjustments StockAdjustment[] @relation("Inventory_Stock_Adjustments") stockMovements StockMovement[] @relation("StockMovement_Inventory") stockBalances StockBalance[] @relation("StockBalance_inventory") + salesInvoices SalesInvoice[] @relation("Inventory_SalesInvoices") @@map("Inventories") } @@ -256,8 +257,8 @@ model PurchaseReceiptItem { createdAt DateTime @default(now()) @db.Timestamp(0) receiptId Int productId Int - product Product @relation("Product_PurchaseReceiptItems", fields: [productId], references: [id]) receipt PurchaseReceipt @relation("PurchaseReceipt_Items", fields: [receiptId], references: [id]) + product Product @relation("Product_PurchaseReceiptItems", fields: [productId], references: [id]) @@index([productId], map: "Purchase_Receipt_Items_productId_fkey") @@index([receiptId], map: "Purchase_Receipt_Items_receiptId_fkey") @@ -272,9 +273,12 @@ model SalesInvoice { createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) customerId Int? + inventoryId Int items SalesInvoiceItem[] @relation("SalesInvoice_Items") customer Customer? @relation("Customer_Sales_Invoices", fields: [customerId], references: [id]) + inventory Inventory @relation("Inventory_SalesInvoices", fields: [inventoryId], references: [id]) + @@index([inventoryId], map: "Sales_Invoices_inventoryId_fkey") @@index([customerId], map: "Sales_Invoices_customerId_fkey") @@map("Sales_Invoices") } diff --git a/prisma/seed.ts b/prisma/seed.ts index b278fda..671542a 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -45,7 +45,7 @@ async function main() { if ((await prisma.supplier.count()) === 0) { await prisma.supplier.createMany({ - data: Array.from({ length: 20 }, (_, i) => ({ + data: Array.from({ length: 9 }, (_, i) => ({ firstName: 'تامین‌', lastName: `کننده ${i + 1}`, mobileNumber: `0912000000${i + 1}`, diff --git a/prisma/triggers/dump_triggers.sql b/prisma/triggers/dump_triggers.sql index 6fed6db..872fe6d 100644 --- a/prisma/triggers/dump_triggers.sql +++ b/prisma/triggers/dump_triggers.sql @@ -1,5 +1,5 @@ -- AUTO-GENERATED MYSQL TRIGGER DUMP --- Generated at: 2025-12-13T15:37:15.132Z +-- Generated at: 2025-12-15T15:21:49.148Z -- ------------------------------------------ -- Trigger: trg_transfer_item_after_insert @@ -21,7 +21,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_transfer_item_after_insert` AFTER INSERT O SELECT COALESCE(avgCost, 0), COALESCE(quantity, 0) INTO _avgCost, latestQuantityInOrigin FROM Stock_Balance WHERE ProductId = NEW.productId AND inventoryId = fromInv LIMIT 1; - + SELECT COALESCE(quantity, 0) INTO latestQuantityInDestination FROM Stock_Balance WHERE ProductId = NEW.productId AND inventoryId = toInv LIMIT 1; @@ -98,6 +98,89 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_insert` AFTER ); END; +-- ------------------------------------------ +-- Trigger: trg_sales_invoice_items_before_insert +-- Event: INSERT +-- Table: Sales_Invoice_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_sales_invoice_items_before_insert`; +CREATE DEFINER=`pos`@`%` TRIGGER `trg_sales_invoice_items_before_insert` BEFORE INSERT ON `Sales_Invoice_Items` FOR EACH ROW begin + DECLARE current_stock DECIMAL(10,2); + DECLARE inventory_id INT; + + + SELECT inventoryId INTO inventory_id + FROM Sales_Invoices si + WHERE si.id = NEW.invoiceId + LIMIT 1; + + SELECT COALESCE(quantity, 0) INTO current_stock + FROM Stock_Balance sb + WHERE productId = NEW.productId AND sb.inventoryId = inventory_id + LIMIT 1; + + + + IF NEW.count > current_stock THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'موجودی کالا در انبار کافی نیست.'; + END IF; +end; + +-- ------------------------------------------ +-- Trigger: trg_sales_invoice_items_after_insert +-- Event: INSERT +-- Table: Sales_Invoice_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_sales_invoice_items_after_insert`; +CREATE DEFINER=`pos`@`%` TRIGGER `trg_sales_invoice_items_after_insert` AFTER INSERT ON `Sales_Invoice_Items` FOR EACH ROW begin + DECLARE current_stock DECIMAL(10,2); + DECLARE inventory_id INT; + + + SELECT inventoryId INTO inventory_id + FROM Sales_Invoices si + WHERE si.id = NEW.invoiceId + LIMIT 1; + + SELECT COALESCE(quantity, 0) INTO current_stock + FROM Stock_Balance sb + WHERE productId = NEW.productId AND sb.inventoryId = inventory_id + LIMIT 1; + + + + INSERT INTO Stock_Movements ( + type, + quantity, + fee, + totalCost, + referenceType, + referenceId, + productId, + inventoryId, + avgCost, + remainedInStock, + createdAt + ) + VALUES ( + 'OUT', + NEW.count, + NEW.fee, + NEW.total, + 'SALES', + NEW.invoiceId, + NEW.productId, + inventory_id, + CASE + WHEN NEW.count = 0 THEN 0 + ELSE NEW.total / NEW.count + END, + current_stock + NEW.count, + NOW() + ); +end; + -- ------------------------------------------ -- Trigger: trg_stock_transfer -- Event: INSERT @@ -148,7 +231,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_transfer` AFTER INSERT ON `Stock_Mov AND sb.inventoryId = NEW.inventoryId ) THEN - + UPDATE Stock_Balance sb SET sb.quantity = sb.quantity - NEW.quantity, @@ -207,3 +290,29 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_insert` AFTER INSERT ON `St END IF; END; +-- ------------------------------------------ +-- Trigger: trg_stock_sale_insert +-- Event: INSERT +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_sale_insert`; +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_sale_insert` AFTER INSERT ON `Stock_Movements` FOR EACH ROW BEGIN + IF NEW.referenceType = 'SALES' THEN + + INSERT INTO Stock_Balance (productId, quantity, avgCost, totalCost, inventoryId, updatedAt) + VALUES ( + NEW.productId, + NEW.quantity, + NEW.fee, + NEW.totalCost, + NEW.inventoryId, + NOW() + ) + ON DUPLICATE KEY UPDATE + quantity = quantity - NEW.quantity, + totalCost = totalCost - NEW.totalCost, + avgCost = totalCost / quantity; + + END IF; +END; + diff --git a/scripts/dump-triggers.ts b/scripts/dump-triggers.ts index e4cdbc6..d361d88 100644 --- a/scripts/dump-triggers.ts +++ b/scripts/dump-triggers.ts @@ -18,6 +18,8 @@ async function main() { console.log('📌 Fetching triggers...') const [triggers] = (await conn.execute('SHOW TRIGGERS')) as [Array, any] + console.log(triggers.length) + if (triggers.length === 0) { console.log('⚠️ No triggers found in the database.') return diff --git a/src/generated/prisma/internal/class.ts b/src/generated/prisma/internal/class.ts index 51cb67d..4eeb0ca 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 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", + "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 salesInvoices SalesInvoice[] @relation(\"Inventory_SalesInvoices\")\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 receipt PurchaseReceipt @relation(\"PurchaseReceipt_Items\", fields: [receiptId], references: [id])\n product Product @relation(\"Product_PurchaseReceiptItems\", fields: [productId], 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 inventoryId Int\n items SalesInvoiceItem[] @relation(\"SalesInvoice_Items\")\n customer Customer? @relation(\"Customer_Sales_Invoices\", fields: [customerId], references: [id])\n inventory Inventory @relation(\"Inventory_SalesInvoices\", fields: [inventoryId], references: [id])\n\n @@index([inventoryId], map: \"Sales_Invoices_inventoryId_fkey\")\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\":\"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\":{}}") +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\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"Inventory_SalesInvoices\"}],\"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\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"}],\"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\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Sales_Invoices\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_SalesInvoices\"}],\"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 a7cf1fe..a8668d4 100644 --- a/src/generated/prisma/internal/prismaNamespace.ts +++ b/src/generated/prisma/internal/prismaNamespace.ts @@ -2236,7 +2236,8 @@ export const SalesInvoiceScalarFieldEnum = { description: 'description', createdAt: 'createdAt', updatedAt: 'updatedAt', - customerId: 'customerId' + customerId: 'customerId', + inventoryId: 'inventoryId' } as const export type SalesInvoiceScalarFieldEnum = (typeof SalesInvoiceScalarFieldEnum)[keyof typeof SalesInvoiceScalarFieldEnum] diff --git a/src/generated/prisma/internal/prismaNamespaceBrowser.ts b/src/generated/prisma/internal/prismaNamespaceBrowser.ts index e097fa8..76a5a2b 100644 --- a/src/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/src/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -321,7 +321,8 @@ export const SalesInvoiceScalarFieldEnum = { description: 'description', createdAt: 'createdAt', updatedAt: 'updatedAt', - customerId: 'customerId' + customerId: 'customerId', + inventoryId: 'inventoryId' } as const export type SalesInvoiceScalarFieldEnum = (typeof SalesInvoiceScalarFieldEnum)[keyof typeof SalesInvoiceScalarFieldEnum] diff --git a/src/generated/prisma/models/Inventory.ts b/src/generated/prisma/models/Inventory.ts index 50a9bbd..7e31e71 100644 --- a/src/generated/prisma/models/Inventory.ts +++ b/src/generated/prisma/models/Inventory.ts @@ -247,6 +247,7 @@ export type InventoryWhereInput = { stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter stockBalances?: Prisma.StockBalanceListRelationFilter + salesInvoices?: Prisma.SalesInvoiceListRelationFilter } export type InventoryOrderByWithRelationInput = { @@ -265,6 +266,7 @@ export type InventoryOrderByWithRelationInput = { stockAdjustments?: Prisma.StockAdjustmentOrderByRelationAggregateInput stockMovements?: Prisma.StockMovementOrderByRelationAggregateInput stockBalances?: Prisma.StockBalanceOrderByRelationAggregateInput + salesInvoices?: Prisma.SalesInvoiceOrderByRelationAggregateInput _relevance?: Prisma.InventoryOrderByRelevanceInput } @@ -287,6 +289,7 @@ export type InventoryWhereUniqueInput = Prisma.AtLeast<{ stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter stockBalances?: Prisma.StockBalanceListRelationFilter + salesInvoices?: Prisma.SalesInvoiceListRelationFilter }, "id"> export type InventoryOrderByWithAggregationInput = { @@ -334,6 +337,7 @@ export type InventoryCreateInput = { stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateInput = { @@ -352,6 +356,7 @@ export type InventoryUncheckedCreateInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryUpdateInput = { @@ -369,6 +374,7 @@ export type InventoryUpdateInput = { stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateInput = { @@ -387,6 +393,7 @@ export type InventoryUncheckedUpdateInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateManyInput = { @@ -501,6 +508,20 @@ export type InventoryUpdateOneRequiredWithoutPurchaseReceiptsNestedInput = { update?: Prisma.XOR, Prisma.InventoryUncheckedUpdateWithoutPurchaseReceiptsInput> } +export type InventoryCreateNestedOneWithoutSalesInvoicesInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutSalesInvoicesInput + connect?: Prisma.InventoryWhereUniqueInput +} + +export type InventoryUpdateOneRequiredWithoutSalesInvoicesNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutSalesInvoicesInput + upsert?: Prisma.InventoryUpsertWithoutSalesInvoicesInput + connect?: Prisma.InventoryWhereUniqueInput + update?: Prisma.XOR, Prisma.InventoryUncheckedUpdateWithoutSalesInvoicesInput> +} + export type InventoryCreateNestedOneWithoutStockMovementsInput = { create?: Prisma.XOR connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutStockMovementsInput @@ -585,6 +606,7 @@ export type InventoryCreateWithoutProductChargesInput = { stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutProductChargesInput = { @@ -602,6 +624,7 @@ export type InventoryUncheckedCreateWithoutProductChargesInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutProductChargesInput = { @@ -634,6 +657,7 @@ export type InventoryUpdateWithoutProductChargesInput = { stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutProductChargesInput = { @@ -651,6 +675,7 @@ export type InventoryUncheckedUpdateWithoutProductChargesInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutPurchaseReceiptsInput = { @@ -667,6 +692,7 @@ export type InventoryCreateWithoutPurchaseReceiptsInput = { stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutPurchaseReceiptsInput = { @@ -684,6 +710,7 @@ export type InventoryUncheckedCreateWithoutPurchaseReceiptsInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutPurchaseReceiptsInput = { @@ -716,6 +743,7 @@ export type InventoryUpdateWithoutPurchaseReceiptsInput = { stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutPurchaseReceiptsInput = { @@ -733,6 +761,93 @@ export type InventoryUncheckedUpdateWithoutPurchaseReceiptsInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput +} + +export type InventoryCreateWithoutSalesInvoicesInput = { + name: string + location?: string | null + isActive?: boolean + isPointOfSale?: boolean + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + inventoryTransfersFrom?: Prisma.InventoryTransferCreateNestedManyWithoutFromInventoryInput + inventoryTransfersTo?: Prisma.InventoryTransferCreateNestedManyWithoutToInventoryInput + productCharges?: Prisma.ProductChargeCreateNestedManyWithoutInventoryInput + purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput + stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput + stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput +} + +export type InventoryUncheckedCreateWithoutSalesInvoicesInput = { + id?: number + name: string + location?: string | null + isActive?: boolean + isPointOfSale?: boolean + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + inventoryTransfersFrom?: Prisma.InventoryTransferUncheckedCreateNestedManyWithoutFromInventoryInput + inventoryTransfersTo?: Prisma.InventoryTransferUncheckedCreateNestedManyWithoutToInventoryInput + productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutInventoryInput + purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput + stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput + stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput +} + +export type InventoryCreateOrConnectWithoutSalesInvoicesInput = { + where: Prisma.InventoryWhereUniqueInput + create: Prisma.XOR +} + +export type InventoryUpsertWithoutSalesInvoicesInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.InventoryWhereInput +} + +export type InventoryUpdateToOneWithWhereWithoutSalesInvoicesInput = { + where?: Prisma.InventoryWhereInput + data: Prisma.XOR +} + +export type InventoryUpdateWithoutSalesInvoicesInput = { + name?: Prisma.StringFieldUpdateOperationsInput | string + location?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isActive?: Prisma.BoolFieldUpdateOperationsInput | boolean + isPointOfSale?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + inventoryTransfersFrom?: Prisma.InventoryTransferUpdateManyWithoutFromInventoryNestedInput + inventoryTransfersTo?: Prisma.InventoryTransferUpdateManyWithoutToInventoryNestedInput + productCharges?: Prisma.ProductChargeUpdateManyWithoutInventoryNestedInput + purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput + stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput + stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput +} + +export type InventoryUncheckedUpdateWithoutSalesInvoicesInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + name?: Prisma.StringFieldUpdateOperationsInput | string + location?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isActive?: Prisma.BoolFieldUpdateOperationsInput | boolean + isPointOfSale?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + inventoryTransfersFrom?: Prisma.InventoryTransferUncheckedUpdateManyWithoutFromInventoryNestedInput + inventoryTransfersTo?: Prisma.InventoryTransferUncheckedUpdateManyWithoutToInventoryNestedInput + productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutInventoryNestedInput + purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput + stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput + stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutStockMovementsInput = { @@ -749,6 +864,7 @@ export type InventoryCreateWithoutStockMovementsInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutStockMovementsInput = { @@ -766,6 +882,7 @@ export type InventoryUncheckedCreateWithoutStockMovementsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutStockMovementsInput = { @@ -798,6 +915,7 @@ export type InventoryUpdateWithoutStockMovementsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutStockMovementsInput = { @@ -815,6 +933,7 @@ export type InventoryUncheckedUpdateWithoutStockMovementsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutStockBalancesInput = { @@ -831,6 +950,7 @@ export type InventoryCreateWithoutStockBalancesInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutStockBalancesInput = { @@ -848,6 +968,7 @@ export type InventoryUncheckedCreateWithoutStockBalancesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutStockBalancesInput = { @@ -880,6 +1001,7 @@ export type InventoryUpdateWithoutStockBalancesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutStockBalancesInput = { @@ -897,6 +1019,7 @@ export type InventoryUncheckedUpdateWithoutStockBalancesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutInventoryTransfersFromInput = { @@ -913,6 +1036,7 @@ export type InventoryCreateWithoutInventoryTransfersFromInput = { stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutInventoryTransfersFromInput = { @@ -930,6 +1054,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersFromInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutInventoryTransfersFromInput = { @@ -951,6 +1076,7 @@ export type InventoryCreateWithoutInventoryTransfersToInput = { stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutInventoryTransfersToInput = { @@ -968,6 +1094,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersToInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutInventoryTransfersToInput = { @@ -1000,6 +1127,7 @@ export type InventoryUpdateWithoutInventoryTransfersFromInput = { stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutInventoryTransfersFromInput = { @@ -1017,6 +1145,7 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersFromInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryUpsertWithoutInventoryTransfersToInput = { @@ -1044,6 +1173,7 @@ export type InventoryUpdateWithoutInventoryTransfersToInput = { stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutInventoryTransfersToInput = { @@ -1061,6 +1191,7 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersToInput = { stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutStockAdjustmentsInput = { @@ -1077,6 +1208,7 @@ export type InventoryCreateWithoutStockAdjustmentsInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutStockAdjustmentsInput = { @@ -1094,6 +1226,7 @@ export type InventoryUncheckedCreateWithoutStockAdjustmentsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutStockAdjustmentsInput = { @@ -1126,6 +1259,7 @@ export type InventoryUpdateWithoutStockAdjustmentsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutStockAdjustmentsInput = { @@ -1143,6 +1277,7 @@ export type InventoryUncheckedUpdateWithoutStockAdjustmentsInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput } @@ -1158,6 +1293,7 @@ export type InventoryCountOutputType = { stockAdjustments: number stockMovements: number stockBalances: number + salesInvoices: number } export type InventoryCountOutputTypeSelect = { @@ -1168,6 +1304,7 @@ export type InventoryCountOutputTypeSelect = { + where?: Prisma.SalesInvoiceWhereInput +} + export type InventorySelect = runtime.Types.Extensions.GetSelect<{ id?: boolean @@ -1246,6 +1390,7 @@ export type InventorySelect stockMovements?: boolean | Prisma.Inventory$stockMovementsArgs stockBalances?: boolean | Prisma.Inventory$stockBalancesArgs + salesInvoices?: boolean | Prisma.Inventory$salesInvoicesArgs _count?: boolean | Prisma.InventoryCountOutputTypeDefaultArgs }, ExtArgs["result"]["inventory"]> @@ -1271,6 +1416,7 @@ export type InventoryInclude stockMovements?: boolean | Prisma.Inventory$stockMovementsArgs stockBalances?: boolean | Prisma.Inventory$stockBalancesArgs + salesInvoices?: boolean | Prisma.Inventory$salesInvoicesArgs _count?: boolean | Prisma.InventoryCountOutputTypeDefaultArgs } @@ -1284,6 +1430,7 @@ export type $InventoryPayload[] stockMovements: Prisma.$StockMovementPayload[] stockBalances: Prisma.$StockBalancePayload[] + salesInvoices: Prisma.$SalesInvoicePayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -1641,6 +1788,7 @@ export interface Prisma__InventoryClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> stockMovements = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> stockBalances = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + salesInvoices = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. @@ -2188,6 +2336,30 @@ export type Inventory$stockBalancesArgs = { + /** + * Select specific fields to fetch from the SalesInvoice + */ + select?: Prisma.SalesInvoiceSelect | null + /** + * Omit specific fields from the SalesInvoice + */ + omit?: Prisma.SalesInvoiceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SalesInvoiceInclude | null + where?: Prisma.SalesInvoiceWhereInput + orderBy?: Prisma.SalesInvoiceOrderByWithRelationInput | Prisma.SalesInvoiceOrderByWithRelationInput[] + cursor?: Prisma.SalesInvoiceWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.SalesInvoiceScalarFieldEnum | Prisma.SalesInvoiceScalarFieldEnum[] +} + /** * Inventory without action */ diff --git a/src/generated/prisma/models/PurchaseReceiptItem.ts b/src/generated/prisma/models/PurchaseReceiptItem.ts index c9b34e2..63865ca 100644 --- a/src/generated/prisma/models/PurchaseReceiptItem.ts +++ b/src/generated/prisma/models/PurchaseReceiptItem.ts @@ -260,8 +260,8 @@ export type PurchaseReceiptItemWhereInput = { createdAt?: Prisma.DateTimeFilter<"PurchaseReceiptItem"> | Date | string receiptId?: Prisma.IntFilter<"PurchaseReceiptItem"> | number productId?: Prisma.IntFilter<"PurchaseReceiptItem"> | number - product?: Prisma.XOR receipt?: Prisma.XOR + product?: Prisma.XOR } export type PurchaseReceiptItemOrderByWithRelationInput = { @@ -273,8 +273,8 @@ export type PurchaseReceiptItemOrderByWithRelationInput = { createdAt?: Prisma.SortOrder receiptId?: Prisma.SortOrder productId?: Prisma.SortOrder - product?: Prisma.ProductOrderByWithRelationInput receipt?: Prisma.PurchaseReceiptOrderByWithRelationInput + product?: Prisma.ProductOrderByWithRelationInput _relevance?: Prisma.PurchaseReceiptItemOrderByRelevanceInput } @@ -290,8 +290,8 @@ export type PurchaseReceiptItemWhereUniqueInput = Prisma.AtLeast<{ createdAt?: Prisma.DateTimeFilter<"PurchaseReceiptItem"> | Date | string receiptId?: Prisma.IntFilter<"PurchaseReceiptItem"> | number productId?: Prisma.IntFilter<"PurchaseReceiptItem"> | number - product?: Prisma.XOR receipt?: Prisma.XOR + product?: Prisma.XOR }, "id"> export type PurchaseReceiptItemOrderByWithAggregationInput = { @@ -330,8 +330,8 @@ export type PurchaseReceiptItemCreateInput = { total: runtime.Decimal | runtime.DecimalJsLike | number | string description?: string | null createdAt?: Date | string - product: Prisma.ProductCreateNestedOneWithoutPurchaseReceiptItemsInput receipt: Prisma.PurchaseReceiptCreateNestedOneWithoutItemsInput + product: Prisma.ProductCreateNestedOneWithoutPurchaseReceiptItemsInput } export type PurchaseReceiptItemUncheckedCreateInput = { @@ -351,8 +351,8 @@ export type PurchaseReceiptItemUpdateInput = { total?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - product?: Prisma.ProductUpdateOneRequiredWithoutPurchaseReceiptItemsNestedInput receipt?: Prisma.PurchaseReceiptUpdateOneRequiredWithoutItemsNestedInput + product?: Prisma.ProductUpdateOneRequiredWithoutPurchaseReceiptItemsNestedInput } export type PurchaseReceiptItemUncheckedUpdateInput = { @@ -740,8 +740,8 @@ export type PurchaseReceiptItemSelect receipt?: boolean | Prisma.PurchaseReceiptDefaultArgs + product?: boolean | Prisma.ProductDefaultArgs }, ExtArgs["result"]["purchaseReceiptItem"]> @@ -759,15 +759,15 @@ export type PurchaseReceiptItemSelectScalar = { export type PurchaseReceiptItemOmit = runtime.Types.Extensions.GetOmit<"id" | "count" | "fee" | "total" | "description" | "createdAt" | "receiptId" | "productId", ExtArgs["result"]["purchaseReceiptItem"]> export type PurchaseReceiptItemInclude = { - product?: boolean | Prisma.ProductDefaultArgs receipt?: boolean | Prisma.PurchaseReceiptDefaultArgs + product?: boolean | Prisma.ProductDefaultArgs } export type $PurchaseReceiptItemPayload = { name: "PurchaseReceiptItem" objects: { - product: Prisma.$ProductPayload receipt: Prisma.$PurchaseReceiptPayload + product: Prisma.$ProductPayload } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -1118,8 +1118,8 @@ readonly fields: PurchaseReceiptItemFieldRefs; */ export interface Prisma__PurchaseReceiptItemClient extends Prisma.PrismaPromise { readonly [Symbol.toStringTag]: "PrismaPromise" - product = {}>(args?: Prisma.Subset>): Prisma.Prisma__ProductClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> receipt = {}>(args?: Prisma.Subset>): Prisma.Prisma__PurchaseReceiptClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + product = {}>(args?: Prisma.Subset>): Prisma.Prisma__ProductClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. diff --git a/src/generated/prisma/models/SalesInvoice.ts b/src/generated/prisma/models/SalesInvoice.ts index 03d841e..af2ddfb 100644 --- a/src/generated/prisma/models/SalesInvoice.ts +++ b/src/generated/prisma/models/SalesInvoice.ts @@ -30,12 +30,14 @@ export type SalesInvoiceAvgAggregateOutputType = { id: number | null totalAmount: runtime.Decimal | null customerId: number | null + inventoryId: number | null } export type SalesInvoiceSumAggregateOutputType = { id: number | null totalAmount: runtime.Decimal | null customerId: number | null + inventoryId: number | null } export type SalesInvoiceMinAggregateOutputType = { @@ -46,6 +48,7 @@ export type SalesInvoiceMinAggregateOutputType = { createdAt: Date | null updatedAt: Date | null customerId: number | null + inventoryId: number | null } export type SalesInvoiceMaxAggregateOutputType = { @@ -56,6 +59,7 @@ export type SalesInvoiceMaxAggregateOutputType = { createdAt: Date | null updatedAt: Date | null customerId: number | null + inventoryId: number | null } export type SalesInvoiceCountAggregateOutputType = { @@ -66,6 +70,7 @@ export type SalesInvoiceCountAggregateOutputType = { createdAt: number updatedAt: number customerId: number + inventoryId: number _all: number } @@ -74,12 +79,14 @@ export type SalesInvoiceAvgAggregateInputType = { id?: true totalAmount?: true customerId?: true + inventoryId?: true } export type SalesInvoiceSumAggregateInputType = { id?: true totalAmount?: true customerId?: true + inventoryId?: true } export type SalesInvoiceMinAggregateInputType = { @@ -90,6 +97,7 @@ export type SalesInvoiceMinAggregateInputType = { createdAt?: true updatedAt?: true customerId?: true + inventoryId?: true } export type SalesInvoiceMaxAggregateInputType = { @@ -100,6 +108,7 @@ export type SalesInvoiceMaxAggregateInputType = { createdAt?: true updatedAt?: true customerId?: true + inventoryId?: true } export type SalesInvoiceCountAggregateInputType = { @@ -110,6 +119,7 @@ export type SalesInvoiceCountAggregateInputType = { createdAt?: true updatedAt?: true customerId?: true + inventoryId?: true _all?: true } @@ -207,6 +217,7 @@ export type SalesInvoiceGroupByOutputType = { createdAt: Date updatedAt: Date customerId: number | null + inventoryId: number _count: SalesInvoiceCountAggregateOutputType | null _avg: SalesInvoiceAvgAggregateOutputType | null _sum: SalesInvoiceSumAggregateOutputType | null @@ -240,8 +251,10 @@ export type SalesInvoiceWhereInput = { createdAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string updatedAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string customerId?: Prisma.IntNullableFilter<"SalesInvoice"> | number | null + inventoryId?: Prisma.IntFilter<"SalesInvoice"> | number items?: Prisma.SalesInvoiceItemListRelationFilter customer?: Prisma.XOR | null + inventory?: Prisma.XOR } export type SalesInvoiceOrderByWithRelationInput = { @@ -252,8 +265,10 @@ export type SalesInvoiceOrderByWithRelationInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder customerId?: Prisma.SortOrderInput | Prisma.SortOrder + inventoryId?: Prisma.SortOrder items?: Prisma.SalesInvoiceItemOrderByRelationAggregateInput customer?: Prisma.CustomerOrderByWithRelationInput + inventory?: Prisma.InventoryOrderByWithRelationInput _relevance?: Prisma.SalesInvoiceOrderByRelevanceInput } @@ -268,8 +283,10 @@ export type SalesInvoiceWhereUniqueInput = Prisma.AtLeast<{ createdAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string updatedAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string customerId?: Prisma.IntNullableFilter<"SalesInvoice"> | number | null + inventoryId?: Prisma.IntFilter<"SalesInvoice"> | number items?: Prisma.SalesInvoiceItemListRelationFilter customer?: Prisma.XOR | null + inventory?: Prisma.XOR }, "id" | "code"> export type SalesInvoiceOrderByWithAggregationInput = { @@ -280,6 +297,7 @@ export type SalesInvoiceOrderByWithAggregationInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder customerId?: Prisma.SortOrderInput | Prisma.SortOrder + inventoryId?: Prisma.SortOrder _count?: Prisma.SalesInvoiceCountOrderByAggregateInput _avg?: Prisma.SalesInvoiceAvgOrderByAggregateInput _max?: Prisma.SalesInvoiceMaxOrderByAggregateInput @@ -298,6 +316,7 @@ export type SalesInvoiceScalarWhereWithAggregatesInput = { createdAt?: Prisma.DateTimeWithAggregatesFilter<"SalesInvoice"> | Date | string updatedAt?: Prisma.DateTimeWithAggregatesFilter<"SalesInvoice"> | Date | string customerId?: Prisma.IntNullableWithAggregatesFilter<"SalesInvoice"> | number | null + inventoryId?: Prisma.IntWithAggregatesFilter<"SalesInvoice"> | number } export type SalesInvoiceCreateInput = { @@ -308,6 +327,7 @@ export type SalesInvoiceCreateInput = { updatedAt?: Date | string items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput customer?: Prisma.CustomerCreateNestedOneWithoutSalesInvoicesInput + inventory: Prisma.InventoryCreateNestedOneWithoutSalesInvoicesInput } export type SalesInvoiceUncheckedCreateInput = { @@ -318,6 +338,7 @@ export type SalesInvoiceUncheckedCreateInput = { createdAt?: Date | string updatedAt?: Date | string customerId?: number | null + inventoryId: number items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutInvoiceInput } @@ -329,6 +350,7 @@ export type SalesInvoiceUpdateInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput customer?: Prisma.CustomerUpdateOneWithoutSalesInvoicesNestedInput + inventory?: Prisma.InventoryUpdateOneRequiredWithoutSalesInvoicesNestedInput } export type SalesInvoiceUncheckedUpdateInput = { @@ -339,6 +361,7 @@ export type SalesInvoiceUncheckedUpdateInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutInvoiceNestedInput } @@ -350,6 +373,7 @@ export type SalesInvoiceCreateManyInput = { createdAt?: Date | string updatedAt?: Date | string customerId?: number | null + inventoryId: number } export type SalesInvoiceUpdateManyMutationInput = { @@ -368,6 +392,7 @@ export type SalesInvoiceUncheckedUpdateManyInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number } export type SalesInvoiceListRelationFilter = { @@ -394,12 +419,14 @@ export type SalesInvoiceCountOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder } export type SalesInvoiceAvgOrderByAggregateInput = { id?: Prisma.SortOrder totalAmount?: Prisma.SortOrder customerId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder } export type SalesInvoiceMaxOrderByAggregateInput = { @@ -410,6 +437,7 @@ export type SalesInvoiceMaxOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder } export type SalesInvoiceMinOrderByAggregateInput = { @@ -420,12 +448,14 @@ export type SalesInvoiceMinOrderByAggregateInput = { createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder } export type SalesInvoiceSumOrderByAggregateInput = { id?: Prisma.SortOrder totalAmount?: Prisma.SortOrder customerId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder } export type SalesInvoiceScalarRelationFilter = { @@ -475,6 +505,48 @@ export type SalesInvoiceUncheckedUpdateManyWithoutCustomerNestedInput = { deleteMany?: Prisma.SalesInvoiceScalarWhereInput | Prisma.SalesInvoiceScalarWhereInput[] } +export type SalesInvoiceCreateNestedManyWithoutInventoryInput = { + create?: Prisma.XOR | Prisma.SalesInvoiceCreateWithoutInventoryInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput | Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput[] + createMany?: Prisma.SalesInvoiceCreateManyInventoryInputEnvelope + connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] +} + +export type SalesInvoiceUncheckedCreateNestedManyWithoutInventoryInput = { + create?: Prisma.XOR | Prisma.SalesInvoiceCreateWithoutInventoryInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput | Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput[] + createMany?: Prisma.SalesInvoiceCreateManyInventoryInputEnvelope + connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] +} + +export type SalesInvoiceUpdateManyWithoutInventoryNestedInput = { + create?: Prisma.XOR | Prisma.SalesInvoiceCreateWithoutInventoryInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput | Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput[] + upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutInventoryInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutInventoryInput[] + createMany?: Prisma.SalesInvoiceCreateManyInventoryInputEnvelope + set?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + disconnect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + delete?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutInventoryInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutInventoryInput[] + updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutInventoryInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutInventoryInput[] + deleteMany?: Prisma.SalesInvoiceScalarWhereInput | Prisma.SalesInvoiceScalarWhereInput[] +} + +export type SalesInvoiceUncheckedUpdateManyWithoutInventoryNestedInput = { + create?: Prisma.XOR | Prisma.SalesInvoiceCreateWithoutInventoryInput[] | Prisma.SalesInvoiceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput | Prisma.SalesInvoiceCreateOrConnectWithoutInventoryInput[] + upsert?: Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutInventoryInput | Prisma.SalesInvoiceUpsertWithWhereUniqueWithoutInventoryInput[] + createMany?: Prisma.SalesInvoiceCreateManyInventoryInputEnvelope + set?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + disconnect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + delete?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + connect?: Prisma.SalesInvoiceWhereUniqueInput | Prisma.SalesInvoiceWhereUniqueInput[] + update?: Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutInventoryInput | Prisma.SalesInvoiceUpdateWithWhereUniqueWithoutInventoryInput[] + updateMany?: Prisma.SalesInvoiceUpdateManyWithWhereWithoutInventoryInput | Prisma.SalesInvoiceUpdateManyWithWhereWithoutInventoryInput[] + deleteMany?: Prisma.SalesInvoiceScalarWhereInput | Prisma.SalesInvoiceScalarWhereInput[] +} + export type SalesInvoiceCreateNestedOneWithoutItemsInput = { create?: Prisma.XOR connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutItemsInput @@ -496,6 +568,7 @@ export type SalesInvoiceCreateWithoutCustomerInput = { createdAt?: Date | string updatedAt?: Date | string items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput + inventory: Prisma.InventoryCreateNestedOneWithoutSalesInvoicesInput } export type SalesInvoiceUncheckedCreateWithoutCustomerInput = { @@ -505,6 +578,7 @@ export type SalesInvoiceUncheckedCreateWithoutCustomerInput = { description?: string | null createdAt?: Date | string updatedAt?: Date | string + inventoryId: number items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutInvoiceInput } @@ -545,6 +619,54 @@ export type SalesInvoiceScalarWhereInput = { createdAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string updatedAt?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string customerId?: Prisma.IntNullableFilter<"SalesInvoice"> | number | null + inventoryId?: Prisma.IntFilter<"SalesInvoice"> | number +} + +export type SalesInvoiceCreateWithoutInventoryInput = { + code: string + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutInvoiceInput + customer?: Prisma.CustomerCreateNestedOneWithoutSalesInvoicesInput +} + +export type SalesInvoiceUncheckedCreateWithoutInventoryInput = { + id?: number + code: string + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + customerId?: number | null + items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutInvoiceInput +} + +export type SalesInvoiceCreateOrConnectWithoutInventoryInput = { + where: Prisma.SalesInvoiceWhereUniqueInput + create: Prisma.XOR +} + +export type SalesInvoiceCreateManyInventoryInputEnvelope = { + data: Prisma.SalesInvoiceCreateManyInventoryInput | Prisma.SalesInvoiceCreateManyInventoryInput[] + skipDuplicates?: boolean +} + +export type SalesInvoiceUpsertWithWhereUniqueWithoutInventoryInput = { + where: Prisma.SalesInvoiceWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type SalesInvoiceUpdateWithWhereUniqueWithoutInventoryInput = { + where: Prisma.SalesInvoiceWhereUniqueInput + data: Prisma.XOR +} + +export type SalesInvoiceUpdateManyWithWhereWithoutInventoryInput = { + where: Prisma.SalesInvoiceScalarWhereInput + data: Prisma.XOR } export type SalesInvoiceCreateWithoutItemsInput = { @@ -554,6 +676,7 @@ export type SalesInvoiceCreateWithoutItemsInput = { createdAt?: Date | string updatedAt?: Date | string customer?: Prisma.CustomerCreateNestedOneWithoutSalesInvoicesInput + inventory: Prisma.InventoryCreateNestedOneWithoutSalesInvoicesInput } export type SalesInvoiceUncheckedCreateWithoutItemsInput = { @@ -564,6 +687,7 @@ export type SalesInvoiceUncheckedCreateWithoutItemsInput = { createdAt?: Date | string updatedAt?: Date | string customerId?: number | null + inventoryId: number } export type SalesInvoiceCreateOrConnectWithoutItemsInput = { @@ -589,6 +713,7 @@ export type SalesInvoiceUpdateWithoutItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string customer?: Prisma.CustomerUpdateOneWithoutSalesInvoicesNestedInput + inventory?: Prisma.InventoryUpdateOneRequiredWithoutSalesInvoicesNestedInput } export type SalesInvoiceUncheckedUpdateWithoutItemsInput = { @@ -599,6 +724,7 @@ export type SalesInvoiceUncheckedUpdateWithoutItemsInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number } export type SalesInvoiceCreateManyCustomerInput = { @@ -608,6 +734,7 @@ export type SalesInvoiceCreateManyCustomerInput = { description?: string | null createdAt?: Date | string updatedAt?: Date | string + inventoryId: number } export type SalesInvoiceUpdateWithoutCustomerInput = { @@ -617,6 +744,7 @@ export type SalesInvoiceUpdateWithoutCustomerInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput + inventory?: Prisma.InventoryUpdateOneRequiredWithoutSalesInvoicesNestedInput } export type SalesInvoiceUncheckedUpdateWithoutCustomerInput = { @@ -626,6 +754,7 @@ export type SalesInvoiceUncheckedUpdateWithoutCustomerInput = { description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutInvoiceNestedInput } @@ -636,6 +765,48 @@ export type SalesInvoiceUncheckedUpdateManyWithoutCustomerInput = { description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type SalesInvoiceCreateManyInventoryInput = { + id?: number + code: string + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + customerId?: number | null +} + +export type SalesInvoiceUpdateWithoutInventoryInput = { + code?: Prisma.StringFieldUpdateOperationsInput | string + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + items?: Prisma.SalesInvoiceItemUpdateManyWithoutInvoiceNestedInput + customer?: Prisma.CustomerUpdateOneWithoutSalesInvoicesNestedInput +} + +export type SalesInvoiceUncheckedUpdateWithoutInventoryInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + code?: Prisma.StringFieldUpdateOperationsInput | string + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutInvoiceNestedInput +} + +export type SalesInvoiceUncheckedUpdateManyWithoutInventoryInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + code?: Prisma.StringFieldUpdateOperationsInput | string + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } @@ -677,8 +848,10 @@ export type SalesInvoiceSelect customer?: boolean | Prisma.SalesInvoice$customerArgs + inventory?: boolean | Prisma.InventoryDefaultArgs _count?: boolean | Prisma.SalesInvoiceCountOutputTypeDefaultArgs }, ExtArgs["result"]["salesInvoice"]> @@ -692,12 +865,14 @@ export type SalesInvoiceSelectScalar = { createdAt?: boolean updatedAt?: boolean customerId?: boolean + inventoryId?: boolean } -export type SalesInvoiceOmit = runtime.Types.Extensions.GetOmit<"id" | "code" | "totalAmount" | "description" | "createdAt" | "updatedAt" | "customerId", ExtArgs["result"]["salesInvoice"]> +export type SalesInvoiceOmit = runtime.Types.Extensions.GetOmit<"id" | "code" | "totalAmount" | "description" | "createdAt" | "updatedAt" | "customerId" | "inventoryId", ExtArgs["result"]["salesInvoice"]> export type SalesInvoiceInclude = { items?: boolean | Prisma.SalesInvoice$itemsArgs customer?: boolean | Prisma.SalesInvoice$customerArgs + inventory?: boolean | Prisma.InventoryDefaultArgs _count?: boolean | Prisma.SalesInvoiceCountOutputTypeDefaultArgs } @@ -706,6 +881,7 @@ export type $SalesInvoicePayload[] customer: Prisma.$CustomerPayload | null + inventory: Prisma.$InventoryPayload } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -715,6 +891,7 @@ export type $SalesInvoicePayload composites: {} } @@ -1057,6 +1234,7 @@ export interface Prisma__SalesInvoiceClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> customer = {}>(args?: Prisma.Subset>): Prisma.Prisma__CustomerClient, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + inventory = {}>(args?: Prisma.Subset>): Prisma.Prisma__InventoryClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. @@ -1093,6 +1271,7 @@ export interface SalesInvoiceFieldRefs { readonly createdAt: Prisma.FieldRef<"SalesInvoice", 'DateTime'> readonly updatedAt: Prisma.FieldRef<"SalesInvoice", 'DateTime'> readonly customerId: Prisma.FieldRef<"SalesInvoice", 'Int'> + readonly inventoryId: Prisma.FieldRef<"SalesInvoice", 'Int'> } diff --git a/src/inventories/inventories.service.ts b/src/inventories/inventories.service.ts index 1fe73eb..0d7227c 100644 --- a/src/inventories/inventories.service.ts +++ b/src/inventories/inventories.service.ts @@ -74,7 +74,7 @@ export class InventoriesService { const result = await Promise.all( groups.map(async group => { const movements = await this.prisma.stockMovement.findMany({ - where: { inventoryId, referenceId: group.referenceId }, + where: { inventoryId, referenceId: group.referenceId, type }, include: { product: true }, }) let info = null as any @@ -117,8 +117,6 @@ export class InventoriesService { } async getStock(inventoryId: number, isAvailable?: boolean, page = 1, pageSize = 10) { - console.log(isAvailable) - const items = await this.prisma.stockBalance.findMany({ where: { inventoryId, @@ -150,16 +148,12 @@ export class InventoriesService { } async getProductCardex(inventoryId: number, productId: number) { - console.log(productId, inventoryId) - const movements = await this.prisma.stockMovement.findMany({ where: { productId, inventoryId }, orderBy: { createdAt: 'asc' }, include: { inventory: true, supplier: true }, }) - console.log(movements[0]?.inventoryId) - const mapped = movements.map(movement => ({ id: movement.id, type: movement.type, diff --git a/src/pos/dto/create-pos.dto.ts b/src/pos/dto/create-pos.dto.ts index bf01e88..64d6bb2 100644 --- a/src/pos/dto/create-pos.dto.ts +++ b/src/pos/dto/create-pos.dto.ts @@ -1,15 +1,27 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' -import { IsOptional, IsString } from 'class-validator' +import { ArrayMinSize, IsNumber, IsOptional } from 'class-validator' -export class CreateInventoryDto { +export class CreateOrderDto { @ApiProperty() - @IsString() - name: string + @IsNumber() + @IsOptional() + customerId?: number @ApiPropertyOptional() - @IsOptional() - @IsString() - location?: string + @ArrayMinSize(1) + items: CreateOrderItemDto[] } -// export class CreateSaleInvoice extends Prisma. +export class CreateOrderItemDto { + @ApiProperty() + @IsNumber() + productId: number + + @ApiProperty() + @IsNumber() + count: number + + @ApiProperty() + @IsNumber() + fee: number +} diff --git a/src/pos/pos.controller.ts b/src/pos/pos.controller.ts index bc8ffa7..cdbf3ac 100644 --- a/src/pos/pos.controller.ts +++ b/src/pos/pos.controller.ts @@ -1,4 +1,5 @@ -import { Controller, Get } from '@nestjs/common' +import { Body, Controller, Get, Post } from '@nestjs/common' +import { CreateOrderDto } from './dto/create-pos.dto' import { PosService } from './pos.service' @Controller('pos') @@ -22,6 +23,13 @@ export class PosController { return this.posService.getProductCategories(inventoryId!) } + @Post('/orders/create') + async createOrder(@Body() dto: CreateOrderDto) { + const inventoryId = await this.posService.getDefaultInventoryId() + + return this.posService.createOrder(dto, inventoryId!) + } + // @Post() // create(@Body() dto: CreateInventoryDto) { // return this.inventoriesService.create(dto) diff --git a/src/pos/pos.service.ts b/src/pos/pos.service.ts index 9fff5c8..b4e90f5 100644 --- a/src/pos/pos.service.ts +++ b/src/pos/pos.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common' import { ResponseMapper } from '../common/response/response-mapper' import { Prisma } from '../generated/prisma/client' import { PrismaService } from '../prisma/prisma.service' +import { CreateOrderDto } from './dto/create-pos.dto' @Injectable() export class PosService { @@ -109,8 +110,38 @@ export class PosService { return ResponseMapper.list(categories) } - async createSaleInvoice(data: any) { - const item = await this.prisma.salesInvoice.create({ data }) + async createOrder(data: CreateOrderDto, inventoryId: number) { + const { customerId, ...res } = data + const preparedOrder = { ...res } as any + const lastCode = await this.prisma.salesInvoice + .findFirst({ + orderBy: { code: 'desc' }, + select: { code: true }, + }) + .then(si => si?.code || '0') + + preparedOrder.code = String(Number(lastCode) + 1) + + preparedOrder.totalAmount = data.items.reduce( + (acc, item) => acc + Number(item.fee), + 0, + ) + + preparedOrder.inventory = { connect: { id: inventoryId } } + preparedOrder.customer = { connect: { id: customerId } } + + if (Object.prototype.hasOwnProperty.call(preparedOrder, 'items')) { + preparedOrder.items = { + create: preparedOrder.items.map((item: any) => ({ + product: { connect: { id: Number(item.productId) } }, + count: item.count, + fee: item.fee, + total: item.count * item.fee, + })), + } + } + + const item = await this.prisma.salesInvoice.create({ data: preparedOrder }) return ResponseMapper.create(item) } }