diff --git a/.vscode/settings.json b/.vscode/settings.json index 7cdc69f..2ba1ef7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,8 @@ "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "editor.formatOnSave": true + "editor.formatOnSave": true, + "cSpell.words": [ + "Cardex" + ] } diff --git a/package.json b/package.json index cd7322c..6a25aef 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "@prisma/client": "^7.1.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.3", + "dayjs": "^1.11.19", "dotenv": "^17.2.3", + "jalaliday": "^3.1.1", "mysql2": "^3.15.3", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3025d50..9e7a3ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,15 @@ importers: class-validator: specifier: ^0.14.3 version: 0.14.3 + dayjs: + specifier: ^1.11.19 + version: 1.11.19 dotenv: specifier: ^17.2.3 version: 17.2.3 + jalaliday: + specifier: ^3.1.1 + version: 3.1.1(dayjs@1.11.19) mysql2: specifier: ^3.15.3 version: 3.15.3 @@ -1770,6 +1776,9 @@ packages: csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} + dayjs@1.11.19: + resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==} + debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} engines: {node: '>=6.0'} @@ -2363,6 +2372,11 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + jalaliday@3.1.1: + resolution: {integrity: sha512-exZzDOfp/32Gj2YkEHNhBBMcltBCTrIe8RXLTfpCvdjYHNfbYSQiNeFVf4RR59FV+2fixUOCEFfzOzyXfgenlg==} + peerDependencies: + dayjs: ^1.11.13 + jest-changed-files@30.2.0: resolution: {integrity: sha512-L8lR1ChrRnSdfeOvTrwZMlnWV8G/LLjQ0nG9MBclwWZidA2N5FviRki0Bvh20WRMOX31/JYvzdqTJrk5oBdydQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -5364,6 +5378,8 @@ snapshots: csstype@3.2.3: {} + dayjs@1.11.19: {} + debug@4.4.3: dependencies: ms: 2.1.3 @@ -5995,6 +6011,10 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + jalaliday@3.1.1(dayjs@1.11.19): + dependencies: + dayjs: 1.11.19 + jest-changed-files@30.2.0: dependencies: execa: 5.1.1 diff --git a/prisma/migrations/20251211143626_init/migration.sql b/prisma/migrations/20251211143626_init/migration.sql new file mode 100644 index 0000000..203d4d4 --- /dev/null +++ b/prisma/migrations/20251211143626_init/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - You are about to alter the column `quantity` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(65,30)` to `Decimal(10,2)`. + - You are about to alter the column `totalCost` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(65,30)` to `Decimal(10,2)`. + - You are about to alter the column `avgCost` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(65,30)` to `Decimal(10,2)`. + +*/ +-- AlterTable +ALTER TABLE `Stock_Balance` MODIFY `quantity` DECIMAL(10, 2) NOT NULL, + MODIFY `totalCost` DECIMAL(10, 2) NOT NULL, + MODIFY `avgCost` DECIMAL(10, 2) NOT NULL; diff --git a/prisma/migrations/20251211153929_init/migration.sql b/prisma/migrations/20251211153929_init/migration.sql new file mode 100644 index 0000000..b5c1d09 --- /dev/null +++ b/prisma/migrations/20251211153929_init/migration.sql @@ -0,0 +1,21 @@ +/* + Warnings: + + - The primary key for the `Stock_Balance` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to drop the column `ProductId` on the `Stock_Balance` table. All the data in the column will be lost. + - Added the required column `inventoryId` to the `Stock_Balance` table without a default value. This is not possible if the table is not empty. + - Added the required column `productId` to the `Stock_Balance` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Stock_Balance` DROP PRIMARY KEY, + DROP COLUMN `ProductId`, + ADD COLUMN `inventoryId` INTEGER NOT NULL, + ADD COLUMN `productId` INTEGER NOT NULL, + ADD PRIMARY KEY (`productId`); + +-- AddForeignKey +ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Products`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_inventoryId_fkey` FOREIGN KEY (`inventoryId`) REFERENCES `Inventories`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20251211173939_init/migration.sql b/prisma/migrations/20251211173939_init/migration.sql new file mode 100644 index 0000000..33bccc5 --- /dev/null +++ b/prisma/migrations/20251211173939_init/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Inventories` ADD COLUMN `isPointOfSale` BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/migrations/20251211190602_init/migration.sql b/prisma/migrations/20251211190602_init/migration.sql new file mode 100644 index 0000000..97d5b8f --- /dev/null +++ b/prisma/migrations/20251211190602_init/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Stock_Movements` MODIFY `referenceType` ENUM('PURCHASE', 'SALES', 'ADJUSTMENT', 'INVENTORY_TRANSFER') NOT NULL; diff --git a/prisma/migrations/20251213115515_init/migration.sql b/prisma/migrations/20251213115515_init/migration.sql new file mode 100644 index 0000000..223aeec --- /dev/null +++ b/prisma/migrations/20251213115515_init/migration.sql @@ -0,0 +1,77 @@ +/* + Warnings: + + - The primary key for the `Stock_Balance` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to alter the column `quantity` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,2)` to `Decimal(14,3)`. + - You are about to alter the column `totalCost` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,2)` to `Decimal(14,2)`. + - You are about to alter the column `avgCost` on the `Stock_Balance` table. The data in that column could be lost. The data in that column will be cast from `Decimal(10,2)` to `Decimal(14,2)`. + - A unique constraint covering the columns `[productId,inventoryId]` on the table `Stock_Balance` will be added. If there are existing duplicate values, this will fail. + - Added the required column `id` to the `Stock_Balance` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE `Stock_Balance` DROP FOREIGN KEY `Stock_Balance_inventoryId_fkey`; + +-- DropForeignKey +ALTER TABLE `Stock_Balance` DROP FOREIGN KEY `Stock_Balance_productId_fkey`; + +-- AlterTable +ALTER TABLE `Products` ADD COLUMN `stockBalanceId` INTEGER NULL; + +-- AlterTable +ALTER TABLE `Stock_Balance` DROP PRIMARY KEY, + ADD COLUMN `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + ADD COLUMN `id` INTEGER NOT NULL AUTO_INCREMENT, + MODIFY `quantity` DECIMAL(14, 3) NOT NULL DEFAULT 0, + MODIFY `totalCost` DECIMAL(14, 2) NOT NULL DEFAULT 0, + MODIFY `updatedAt` DATETIME(3) NOT NULL, + MODIFY `avgCost` DECIMAL(14, 2) NOT NULL DEFAULT 0, + ADD PRIMARY KEY (`id`); + +-- CreateTable +CREATE TABLE `Trigger_Logs` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `message` TEXT NOT NULL, + `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0), + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `_StockBalance_product` ( + `A` INTEGER NOT NULL, + `B` INTEGER NOT NULL, + + UNIQUE INDEX `_StockBalance_product_AB_unique`(`A`, `B`), + INDEX `_StockBalance_product_B_index`(`B`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `_StockBalance_inventory` ( + `A` INTEGER NOT NULL, + `B` INTEGER NOT NULL, + + UNIQUE INDEX `_StockBalance_inventory_AB_unique`(`A`, `B`), + INDEX `_StockBalance_inventory_B_index`(`B`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateIndex +CREATE INDEX `Stock_Balance_productId_idx` ON `Stock_Balance`(`productId`); + +-- CreateIndex +CREATE UNIQUE INDEX `Stock_Balance_productId_inventoryId_key` ON `Stock_Balance`(`productId`, `inventoryId`); + +-- AddForeignKey +ALTER TABLE `_StockBalance_product` ADD CONSTRAINT `_StockBalance_product_A_fkey` FOREIGN KEY (`A`) REFERENCES `Products`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `_StockBalance_product` ADD CONSTRAINT `_StockBalance_product_B_fkey` FOREIGN KEY (`B`) REFERENCES `Stock_Balance`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `_StockBalance_inventory` ADD CONSTRAINT `_StockBalance_inventory_A_fkey` FOREIGN KEY (`A`) REFERENCES `Inventories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `_StockBalance_inventory` ADD CONSTRAINT `_StockBalance_inventory_B_fkey` FOREIGN KEY (`B`) REFERENCES `Stock_Balance`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- RenameIndex +ALTER TABLE `Stock_Balance` RENAME INDEX `Stock_Balance_inventoryId_fkey` TO `Stock_Balance_inventoryId_idx`; diff --git a/prisma/migrations/20251213121359_init/migration.sql b/prisma/migrations/20251213121359_init/migration.sql new file mode 100644 index 0000000..9fc391c --- /dev/null +++ b/prisma/migrations/20251213121359_init/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - Added the required column `name` to the `Trigger_Logs` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Stock_Balance` MODIFY `updatedAt` TIMESTAMP(0) NOT NULL, + MODIFY `createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0); + +-- AlterTable +ALTER TABLE `Trigger_Logs` ADD COLUMN `name` TEXT NOT NULL; diff --git a/prisma/migrations/20251213132032_init/migration.sql b/prisma/migrations/20251213132032_init/migration.sql new file mode 100644 index 0000000..fa991f4 --- /dev/null +++ b/prisma/migrations/20251213132032_init/migration.sql @@ -0,0 +1,40 @@ +/* + Warnings: + + - You are about to drop the column `stockBalanceId` on the `Products` table. All the data in the column will be lost. + - You are about to drop the `_StockBalance_inventory` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `_StockBalance_product` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropForeignKey +ALTER TABLE `_StockBalance_inventory` DROP FOREIGN KEY `_StockBalance_inventory_A_fkey`; + +-- DropForeignKey +ALTER TABLE `_StockBalance_inventory` DROP FOREIGN KEY `_StockBalance_inventory_B_fkey`; + +-- DropForeignKey +ALTER TABLE `_StockBalance_product` DROP FOREIGN KEY `_StockBalance_product_A_fkey`; + +-- DropForeignKey +ALTER TABLE `_StockBalance_product` DROP FOREIGN KEY `_StockBalance_product_B_fkey`; + +-- AlterTable +ALTER TABLE `Products` DROP COLUMN `stockBalanceId`; + +-- AlterTable +ALTER TABLE `Stock_Movements` ADD COLUMN `supplierId` INTEGER NULL; + +-- DropTable +DROP TABLE `_StockBalance_inventory`; + +-- DropTable +DROP TABLE `_StockBalance_product`; + +-- AddForeignKey +ALTER TABLE `Stock_Movements` ADD CONSTRAINT `Stock_Movements_supplierId_fkey` FOREIGN KEY (`supplierId`) REFERENCES `Suppliers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Products`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_inventoryId_fkey` FOREIGN KEY (`inventoryId`) REFERENCES `Inventories`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20251213151216_init/migration.sql b/prisma/migrations/20251213151216_init/migration.sql new file mode 100644 index 0000000..a3812bd --- /dev/null +++ b/prisma/migrations/20251213151216_init/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - Added the required column `remainedInStock` to the `Stock_Movements` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Stock_Movements` ADD COLUMN `remainedInStock` DECIMAL(10, 2) NOT NULL; diff --git a/prisma/migrations/20251213151547_init/migration.sql b/prisma/migrations/20251213151547_init/migration.sql new file mode 100644 index 0000000..13cd5c4 --- /dev/null +++ b/prisma/migrations/20251213151547_init/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Stock_Movements` MODIFY `remainedInStock` DECIMAL(10, 2) NOT NULL DEFAULT 0; diff --git a/prisma/migrations/20251213_create_logs_table.sql b/prisma/migrations/20251213_create_logs_table.sql new file mode 100644 index 0000000..e69de29 diff --git a/prisma/schema.prisma b/prisma/schema.prisma index af1d145..3381822 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -82,6 +82,8 @@ model Product { stockAdjustments StockAdjustment[] @relation("Product_Stock_Adjustments") stockMovements StockMovement[] @relation("StockMovement_Product") + stockBalances StockBalance[] @relation("StockBalance_Product") + @@index([brandId], map: "Products_brandId_fkey") @@index([categoryId], map: "Products_categoryId_fkey") @@map("Products") @@ -129,6 +131,7 @@ model Supplier { deletedAt DateTime? @db.Timestamp(0) productCharges ProductCharge[] @relation("Supplier_Product_Charges") purchaseReceipts PurchaseReceipt[] + stockMovements StockMovement[] @relation("StockMovement_Supplier") @@map("Suppliers") } @@ -158,6 +161,7 @@ model Inventory { name String @db.VarChar(255) location String? @db.VarChar(255) isActive Boolean @default(true) + isPointOfSale Boolean @default(false) createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) @@ -167,6 +171,7 @@ model Inventory { purchaseReceipts PurchaseReceipt[] stockAdjustments StockAdjustment[] @relation("Inventory_Stock_Adjustments") stockMovements StockMovement[] @relation("StockMovement_Inventory") + stockBalances StockBalance[] @relation("StockBalance_inventory") @@map("Inventories") } @@ -290,19 +295,22 @@ model SalesInvoiceItem { } model StockMovement { - id Int @id @default(autoincrement()) - type MovementType - quantity Decimal @db.Decimal(10, 2) - fee Decimal @db.Decimal(10, 2) - totalCost Decimal @db.Decimal(10, 2) - referenceType MovementReferenceType - referenceId String - createdAt DateTime @default(now()) @db.Timestamp(0) - productId Int - inventoryId Int - avgCost Decimal @db.Decimal(10, 2) - inventory Inventory @relation("StockMovement_Inventory", fields: [inventoryId], references: [id]) - product Product @relation("StockMovement_Product", fields: [productId], references: [id]) + id Int @id @default(autoincrement()) + type MovementType + quantity Decimal @db.Decimal(10, 2) + fee Decimal @db.Decimal(10, 2) + totalCost Decimal @db.Decimal(10, 2) + referenceType MovementReferenceType + referenceId String + createdAt DateTime @default(now()) @db.Timestamp(0) + productId Int + inventoryId Int + avgCost Decimal @db.Decimal(10, 2) + remainedInStock Decimal @default(0) @db.Decimal(10, 2) + inventory Inventory @relation("StockMovement_Inventory", fields: [inventoryId], references: [id]) + product Product @relation("StockMovement_Product", fields: [productId], references: [id]) + supplierId Int? + supplier Supplier? @relation("StockMovement_Supplier", fields: [supplierId], references: [id]) @@index([inventoryId], map: "Stock_Movements_inventoryId_fkey") @@index([productId], map: "Stock_Movements_productId_fkey") @@ -310,12 +318,25 @@ model StockMovement { } model StockBalance { - quantity Decimal - totalCost Decimal - updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(0) - ProductId Int @id - avgCost Decimal + id Int @id @default(autoincrement()) + productId Int + inventoryId Int + + quantity Decimal @default(0) @db.Decimal(14, 3) + + avgCost Decimal @default(0) @db.Decimal(14, 2) + totalCost Decimal @default(0) @db.Decimal(14, 2) + + createdAt DateTime @default(now()) @db.Timestamp(0) + updatedAt DateTime @updatedAt @db.Timestamp(0) + + product Product @relation("StockBalance_Product", fields: [productId], references: [id]) + inventory Inventory @relation("StockBalance_inventory", fields: [inventoryId], references: [id]) + + @@unique([productId, inventoryId]) + @@index([productId]) + @@index([inventoryId]) @@map("Stock_Balance") } @@ -432,6 +453,7 @@ enum MovementReferenceType { PURCHASE SALES ADJUSTMENT + INVENTORY_TRANSFER } enum stock_cardex_type { @@ -451,3 +473,12 @@ enum stock_movements_view_referenceType { SALES ADJUSTMENT } + +model TriggerLog { + id Int @id @default(autoincrement()) + name String @db.Text + message String @db.Text + createdAt DateTime @default(now()) @db.Timestamp(0) + + @@map("Trigger_Logs") +} diff --git a/prisma/seed.ts b/prisma/seed.ts index a53829e..9b07e58 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,16 +1,74 @@ import { prisma } from '../src/lib/prisma' async function main() { - console.log('first') + if ((await prisma.role.count()) === 0) { + await prisma.role.upsert({ + where: { id: 0, name: 'Admin' }, + update: {}, + create: { + name: 'Admin', + }, + }) + } - await prisma.role.upsert({ - where: { id: 0, name: 'Admin' }, - update: {}, - create: { - name: 'Admin', - }, - }) + if ((await prisma.inventory.count()) === 0) { + await prisma.inventory.createMany({ + data: [ + { name: 'انبار مرکزی', location: 'تهران', isPointOfSale: false, isActive: true }, + { + name: 'فروشگاه حضوری', + location: 'مرکز شهر', + isPointOfSale: true, + isActive: true, + }, + { + name: 'فروشگاه اینترنتی', + location: 'مرکز شهر', + isPointOfSale: true, + isActive: true, + }, + ], + }) + } + + if ((await prisma.productCategory.count()) === 0) { + await prisma.productCategory.createMany({ + data: [{ name: 'دسته‌ی ۱' }, { name: 'دسته‌ی ۲' }, { name: 'دسته‌ی ۳' }], + }) + } + + if ((await prisma.productBrand.count()) === 0) { + await prisma.productBrand.createMany({ + data: [{ name: 'برند ۱' }, { name: 'برند ۲' }, { name: 'برند ۳' }], + }) + } + + if ((await prisma.supplier.count()) === 0) { + await prisma.supplier.createMany({ + data: [ + { + firstName: 'تامین‌', + lastName: 'کننده ۱', + mobileNumber: '09120000001', + email: 'supplier1@example.com', + }, + { + firstName: 'تامین‌', + lastName: 'کننده ۲', + mobileNumber: '09120000002', + email: 'supplier2@example.com', + }, + { + firstName: 'تامین‌', + lastName: 'کننده 3', + mobileNumber: '09120000003', + email: 'supplier3@example.com', + }, + ], + }) + } } + main() .then(async () => { await prisma.$disconnect() diff --git a/prisma/triggers/dump_triggers.sql b/prisma/triggers/dump_triggers.sql index ce3ac6a..6fed6db 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-10T10:03:36.966Z +-- Generated at: 2025-12-13T15:37:15.132Z -- ------------------------------------------ -- Trigger: trg_transfer_item_after_insert @@ -9,23 +9,34 @@ 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; - SELECT fromInventoryId, toInventoryId INTO fromInv, toInv - FROM Inventory_Transfers WHERE id = NEW.transferId; + DECLARE fromInv INT; + DECLARE toInv INT; + DECLARE _avgCost DECIMAL(10,2); + DECLARE latestQuantityInOrigin DECIMAL(10,2); + DECLARE latestQuantityInDestination DECIMAL(10,2); - -- OUT from source - INSERT INTO Stock_Movements - (type, quantity, referenceType, referenceId, productId, inventoryId, createdAt) - VALUES - ('OUT', NEW.count, 'InventoryTransfer', NEW.transferId, NEW.productId, fromInv, NOW()); + SELECT fromInventoryId, toInventoryId INTO fromInv, toInv + FROM Inventory_Transfers WHERE id = NEW.transferId; - -- IN to destination - INSERT INTO Stock_Movements - (type, quantity, referenceType, referenceId, productId, inventoryId, createdAt) - VALUES - ('IN', NEW.count, 'InventoryTransfer', NEW.transferId, NEW.productId, toInv, NOW()); + 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; -- ------------------------------------------ @@ -34,158 +45,140 @@ end; -- 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 - INSERT INTO Stock_Movements - ( - type, - quantity, - referenceType, - referenceId, - productId, - inventoryId, - createdAt - ) - VALUES - ( - 'IN', - NEW.count, - 'PURCHASE', - NEW.receiptId, - NEW.productId, - (SELECT inventoryId FROM Purchase_Receipts WHERE id = NEW.receiptId), - NOW() - ); -end; +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; --- ------------------------------------------ --- Trigger: trg_purchase_receipt_item_after_update --- Event: UPDATE --- Table: Purchase_Receipt_Items --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_purchase_receipt_item_after_update`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_update` AFTER UPDATE ON `Purchase_Receipt_Items` FOR EACH ROW begin - DELETE FROM Stock_Movements - WHERE referenceType = 'PURCHASE' - AND referenceId = NEW.receiptId - AND productId = NEW.productId; + -- Get inventory & supplier from receipt + SELECT inventoryId, supplierId + INTO invId, suppId + FROM Purchase_Receipts + WHERE id = NEW.receiptId; - INSERT INTO Stock_Movements - ( - type, - quantity, - referenceType, - referenceId, - productId, - inventoryId, - createdAt - ) - VALUES - ( - 'IN', - NEW.count, - 'SALES', - NEW.id, - NEW.productId, - (SELECT inventoryId FROM Stores LIMIT 1), - NOW() - ); -end; - --- ------------------------------------------ --- Trigger: trg_purchase_receipt_item_after_delete --- Event: DELETE --- Table: Purchase_Receipt_Items --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_purchase_receipt_item_after_delete`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_delete` AFTER DELETE ON `Purchase_Receipt_Items` FOR EACH ROW begin - DELETE FROM Stock_Movements - WHERE referenceType = 'PURCHASE' - AND referenceId = OLD.receiptId - AND productId = OLD.productId; -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); - - SELECT stock INTO current_stock - FROM stock_view - WHERE productId = NEW.productId + -- 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; - IF current_stock IS NULL THEN - SET current_stock = 0; - END IF; - - IF NEW.count > current_stock THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'Not enough stock to complete sale.'; - 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 - INSERT INTO Stock_Movements - ( + -- Insert stock movement + INSERT INTO Stock_Movements ( type, quantity, + fee, + totalCost, referenceType, referenceId, productId, inventoryId, + avgCost, + supplierId, + remainedInStock, createdAt ) - VALUES - ( - 'IN', - NEW.count, - 'PURCHASE', - NEW.id, - NEW.productId, - (SELECT inventoryId FROM Sales_Invoices WHERE id = NEW.id), - NOW() - ); -end; + 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_adjustment_after_insert --- Event: INSERT --- Table: Stock_Adjustments --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_adjustment_after_insert`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_adjustment_after_insert` AFTER INSERT ON `Stock_Adjustments` FOR EACH ROW begin - INSERT INTO Stock_Movements - (type, quantity, referenceType, referenceId, productId, inventoryId, createdAt) - VALUES - ('ADJUST', NEW.adjustedQuantity, 'ADJUSTMENT', NEW.id, NEW.productId, NEW.inventoryId, NOW()); -end; - --- ------------------------------------------ --- Trigger: trg_stock_sale_insert +-- Trigger: trg_stock_transfer -- 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 +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 - SET - quantity = quantity - NEW.quantity, - totalCost = quantity * avgCost - WHERE productId = NEW.productId ; + 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; -- ------------------------------------------ @@ -196,13 +189,15 @@ END; 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) + + INSERT INTO Stock_Balance (productId, quantity, avgCost, totalCost, inventoryId, updatedAt) VALUES ( NEW.productId, NEW.quantity, NEW.fee, - NEW.totalCost + NEW.totalCost, + NEW.inventoryId, + NOW() ) ON DUPLICATE KEY UPDATE quantity = quantity + NEW.quantity, @@ -212,115 +207,3 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_insert` AFTER INSERT ON `St END IF; END; --- ------------------------------------------ --- Trigger: trg_stock_movement_after_insert --- Event: INSERT --- Table: Stock_Movements --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_movement_after_insert`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_movement_after_insert` AFTER INSERT ON `Stock_Movements` FOR EACH ROW begin - UPDATE Products pv - SET pv.quantity = ( - SELECT COALESCE(SUM( - CASE - WHEN type = 'IN' THEN quantity - WHEN type = 'OUT' THEN -quantity - WHEN type = 'ADJUST' THEN quantity - END - ), 0) - FROM Stock_Movements - WHERE productId = NEW.productId - ) - WHERE pv.id = NEW.productId; -end; - --- ------------------------------------------ --- Trigger: trg_stock_sale_update --- Event: UPDATE --- Table: Stock_Movements --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_sale_update`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_sale_update` AFTER UPDATE ON `Stock_Movements` FOR EACH ROW BEGIN - IF OLD.referenceType = 'SALES' THEN - UPDATE stock_balance - SET - quantity = quantity + OLD.quantity, - totalCost = (quantity + OLD.quantity) * avgCost - WHERE productId = OLD.productId; - END IF; - - IF NEW.referenceType = 'SALES' THEN - UPDATE stock_balance - SET - quantity = quantity - NEW.quantity, - totalCost = (quantity - NEW.quantity) * avgCost - WHERE productId = NEW.productId; - END IF; -END; - --- ------------------------------------------ --- Trigger: trg_stock_purchase_update --- Event: UPDATE --- Table: Stock_Movements --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_purchase_update`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_update` AFTER UPDATE ON `Stock_Movements` FOR EACH ROW BEGIN - IF OLD.referenceType = 'PURCHASE' THEN - UPDATE stock_balance - SET - quantity = quantity - OLD.quantity, - totalCost = totalCost - (OLD.quantity * OLD.fee) - WHERE productId = OLD.productId; - END IF; - - IF NEW.referenceType = 'PURCHASE' THEN - INSERT INTO stock_balance (productId, quantity, avgCost, totalCost) - VALUES ( - NEW.productId, - NEW.quantity, - NEW.fee, - NEW.totalCost - ) - ON DUPLICATE KEY UPDATE - quantity = quantity + NEW.quantity, - totalCost = totalCost + NEW.totalCost, - avgCost = totalCost / quantity; - END IF; -END; - --- ------------------------------------------ --- Trigger: trg_stock_sale_delete --- Event: DELETE --- Table: Stock_Movements --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_sale_delete`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_sale_delete` AFTER DELETE ON `Stock_Movements` FOR EACH ROW BEGIN - IF OLD.ReferenceType = 'SALES' THEN - UPDATE stock_balance - SET - quantity = quantity + OLD.quantity, - totalCost = (quantity + OLD.quantity) * avgCost - WHERE productId = OLD.productId; - END IF; -END; - --- ------------------------------------------ --- Trigger: trg_stock_purchase_delete --- Event: DELETE --- Table: Stock_Movements --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_stock_purchase_delete`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_delete` AFTER DELETE ON `Stock_Movements` FOR EACH ROW BEGIN - IF OLD.referenceType = 'PURCHASE' THEN - UPDATE stock_balance - SET - quantity = quantity - OLD.quantity, - totalCost = totalCost - (OLD.quantity * OLD.fee), - avgCost = CASE - WHEN quantity - OLD.quantity = 0 THEN 0 - ELSE (totalCost - (OLD.quantity * OLD.fee)) / (quantity - OLD.quantity) - END - WHERE productId = OLD.productId; - END IF; -END; - diff --git a/prisma/triggers/dump_triggers_Backup.sql b/prisma/triggers/dump_triggers_Backup.sql new file mode 100644 index 0000000..94732b9 --- /dev/null +++ b/prisma/triggers/dump_triggers_Backup.sql @@ -0,0 +1,476 @@ +-- AUTO-GENERATED MYSQL TRIGGER DUMP +-- Generated at: 2025-12-10T10:03:36.966Z + +-- ------------------------------------------ +-- Trigger: trg_transfer_item_after_insert +-- Event: INSERT +-- Table: Inventory_Transfer_Items +-- Status: ACTIVE +-- ------------------------------------------ +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); + + SELECT fromInventoryId, toInventoryId INTO fromInv, toInv + FROM Inventory_Transfers WHERE id = NEW.transferId; + + SELECT COALESCE(avgCost, 0) INTO _avgCost FROM Stock_Balance + WHERE ProductId = NEW.productId AND inventoryId = fromInv LIMIT 1; + + + -- OUT from source + INSERT INTO Stock_Movements + (type, quantity, fee, totalCost, avgCost, referenceType, referenceId, productId, inventoryId, createdAt) + VALUES + ('OUT', NEW.count, _avgCost, _avgCost*NEW.count, _avgCost, 'INVENTORY_TRANSFER', NEW.transferId, NEW.productId, fromInv, NOW()); + + -- IN to destination + INSERT INTO Stock_Movements + (type, quantity, fee, totalCost, avgCost, referenceType, referenceId, productId, inventoryId, createdAt) + VALUES + ('IN', NEW.count,_avgCost, _avgCost*NEW.count,_avgCost, 'INVENTORY_TRANSFER', NEW.transferId, NEW.productId, toInv, NOW()); +end; + +-- ------------------------------------------ +-- Trigger: trg_stock_purchase_insert +-- Event: INSERT +-- Table: Stock_Movements +-- Status: ACTIVE +-- ------------------------------------------ +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 + +-- ------------------------------------------ +-- Trigger: trg_stock_transfer +-- Event: INSERT +-- Table: Stock_Movements +-- Status: ACTIVE +-- ------------------------------------------ +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_purchase_receipt_item_after_insert +-- Event: INSERT +-- Table: Purchase_Receipt_Items +-- Status: ACTIVE +-- ------------------------------------------ +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 + INSERT INTO Stock_Movements + ( + type, + quantity, + fee, + totalCost, + referenceType, + referenceId, + productId, + inventoryId, + supplierId, + avgCost, + createdAt + ) + VALUES + ( + 'IN', + NEW.count, + NEW.fee, + NEW.total, + 'PURCHASE', + NEW.receiptId, + NEW.productId, + (SELECT inventoryId FROM Purchase_Receipts WHERE id = NEW.receiptId), + (SELECT supplierId FROM Purchase_Receipts WHERE id = NEW.receiptId), + NEW.total/NEW.count, + NOW() + ); +end + +-- NEW -- + +-- ------------------------------------------ +-- 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 + INSERT INTO Stock_Movements + ( + type, + quantity, + referenceType, + referenceId, + productId, + inventoryId, + createdAt + ) + VALUES + ( + 'IN', + NEW.count, + 'PURCHASE', + NEW.receiptId, + NEW.productId, + (SELECT inventoryId FROM Purchase_Receipts WHERE id = NEW.receiptId), + NOW() + ); +end; + +-- ------------------------------------------ +-- Trigger: trg_purchase_receipt_item_after_update +-- Event: UPDATE +-- Table: Purchase_Receipt_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_purchase_receipt_item_after_update`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_update` AFTER UPDATE ON `Purchase_Receipt_Items` FOR EACH ROW begin + DELETE FROM Stock_Movements + WHERE referenceType = 'PURCHASE' + AND referenceId = NEW.receiptId + AND productId = NEW.productId; + + INSERT INTO Stock_Movements + ( + type, + quantity, + referenceType, + referenceId, + productId, + inventoryId, + createdAt + ) + VALUES + ( + 'IN', + NEW.count, + 'SALES', + NEW.id, + NEW.productId, + (SELECT inventoryId FROM Stores LIMIT 1), + NOW() + ); +end; + +-- ------------------------------------------ +-- Trigger: trg_purchase_receipt_item_after_delete +-- Event: DELETE +-- Table: Purchase_Receipt_Items +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_purchase_receipt_item_after_delete`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_purchase_receipt_item_after_delete` AFTER DELETE ON `Purchase_Receipt_Items` FOR EACH ROW begin + DELETE FROM Stock_Movements + WHERE referenceType = 'PURCHASE' + AND referenceId = OLD.receiptId + AND productId = OLD.productId; +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); + + SELECT stock INTO current_stock + FROM stock_view + WHERE productId = NEW.productId + LIMIT 1; + + IF current_stock IS NULL THEN + SET current_stock = 0; + END IF; + + IF NEW.count > current_stock THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Not enough stock to complete sale.'; + 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 + INSERT INTO Stock_Movements + ( + type, + quantity, + referenceType, + referenceId, + productId, + inventoryId, + createdAt + ) + VALUES + ( + 'IN', + NEW.count, + 'PURCHASE', + NEW.id, + NEW.productId, + (SELECT inventoryId FROM Sales_Invoices WHERE id = NEW.id), + NOW() + ); +end; + +-- ------------------------------------------ +-- Trigger: trg_stock_adjustment_after_insert +-- Event: INSERT +-- Table: Stock_Adjustments +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_adjustment_after_insert`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_adjustment_after_insert` AFTER INSERT ON `Stock_Adjustments` FOR EACH ROW begin + INSERT INTO Stock_Movements + (type, quantity, referenceType, referenceId, productId, inventoryId, createdAt) + VALUES + ('ADJUST', NEW.adjustedQuantity, 'ADJUSTMENT', NEW.id, NEW.productId, NEW.inventoryId, NOW()); +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 + + UPDATE stock_balance + SET + quantity = quantity - NEW.quantity, + totalCost = quantity * avgCost + WHERE productId = NEW.productId ; + + END IF; +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_movement_after_insert +-- Event: INSERT +-- Table: Stock_Movements +-- Status: ARCHIVED +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_movement_after_insert`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_movement_after_insert` AFTER INSERT ON `Stock_Movements` FOR EACH ROW begin + UPDATE Products pv + SET pv.quantity = ( + SELECT COALESCE(SUM( + CASE + WHEN type = 'IN' THEN quantity + WHEN type = 'OUT' THEN -quantity + WHEN type = 'ADJUST' THEN quantity + END + ), 0) + FROM Stock_Movements + WHERE productId = NEW.productId + ) + WHERE pv.id = NEW.productId; +end; + +-- ------------------------------------------ +-- Trigger: trg_stock_sale_update +-- Event: UPDATE +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_sale_update`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_sale_update` AFTER UPDATE ON `Stock_Movements` FOR EACH ROW BEGIN + IF OLD.referenceType = 'SALES' THEN + UPDATE stock_balance + SET + quantity = quantity + OLD.quantity, + totalCost = (quantity + OLD.quantity) * avgCost + WHERE productId = OLD.productId; + END IF; + + IF NEW.referenceType = 'SALES' THEN + UPDATE stock_balance + SET + quantity = quantity - NEW.quantity, + totalCost = (quantity - NEW.quantity) * avgCost + WHERE productId = NEW.productId; + END IF; +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_purchase_update +-- Event: UPDATE +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_purchase_update`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_update` AFTER UPDATE ON `Stock_Movements` FOR EACH ROW BEGIN + IF OLD.referenceType = 'PURCHASE' THEN + UPDATE stock_balance + SET + quantity = quantity - OLD.quantity, + totalCost = totalCost - (OLD.quantity * OLD.fee) + WHERE productId = OLD.productId; + END IF; + + IF NEW.referenceType = 'PURCHASE' THEN + INSERT INTO stock_balance (productId, quantity, avgCost, totalCost) + VALUES ( + NEW.productId, + NEW.quantity, + NEW.fee, + NEW.totalCost + ) + ON DUPLICATE KEY UPDATE + quantity = quantity + NEW.quantity, + totalCost = totalCost + NEW.totalCost, + avgCost = totalCost / quantity; + END IF; +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_sale_delete +-- Event: DELETE +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_sale_delete`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_sale_delete` AFTER DELETE ON `Stock_Movements` FOR EACH ROW BEGIN + IF OLD.ReferenceType = 'SALES' THEN + UPDATE stock_balance + SET + quantity = quantity + OLD.quantity, + totalCost = (quantity + OLD.quantity) * avgCost + WHERE productId = OLD.productId; + END IF; +END; + +-- ------------------------------------------ +-- Trigger: trg_stock_purchase_delete +-- Event: DELETE +-- Table: Stock_Movements +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_stock_purchase_delete`; + +CREATE DEFINER=`pos`@`%` TRIGGER `trg_stock_purchase_delete` AFTER DELETE ON `Stock_Movements` FOR EACH ROW BEGIN + IF OLD.referenceType = 'PURCHASE' THEN + UPDATE stock_balance + SET + quantity = quantity - OLD.quantity, + totalCost = totalCost - (OLD.quantity * OLD.fee), + avgCost = CASE + WHEN quantity - OLD.quantity = 0 THEN 0 + ELSE (totalCost - (OLD.quantity * OLD.fee)) / (quantity - OLD.quantity) + END + WHERE productId = OLD.productId; + END IF; +END; diff --git a/queries/Query_1.sql b/queries/Query_1.sql new file mode 100644 index 0000000..b285df7 --- /dev/null +++ b/queries/Query_1.sql @@ -0,0 +1,3 @@ + +SELECT avgCost FROM Stock_Balance +WHERE ProductId = 1 And inventoryId = 1; \ No newline at end of file diff --git a/src/generated/prisma/browser.ts b/src/generated/prisma/browser.ts index 69b27f8..f9f5cd2 100644 --- a/src/generated/prisma/browser.ts +++ b/src/generated/prisma/browser.ts @@ -122,6 +122,11 @@ export type InventoryTransferItem = Prisma.InventoryTransferItemModel * */ export type StockAdjustment = Prisma.StockAdjustmentModel +/** + * Model TriggerLog + * + */ +export type TriggerLog = Prisma.TriggerLogModel /** * Model inventory_overview * diff --git a/src/generated/prisma/client.ts b/src/generated/prisma/client.ts index 7668600..69f2d17 100644 --- a/src/generated/prisma/client.ts +++ b/src/generated/prisma/client.ts @@ -142,6 +142,11 @@ export type InventoryTransferItem = Prisma.InventoryTransferItemModel * */ export type StockAdjustment = Prisma.StockAdjustmentModel +/** + * Model TriggerLog + * + */ +export type TriggerLog = Prisma.TriggerLogModel /** * Model inventory_overview * diff --git a/src/generated/prisma/enums.ts b/src/generated/prisma/enums.ts index c4034bf..4e67d54 100644 --- a/src/generated/prisma/enums.ts +++ b/src/generated/prisma/enums.ts @@ -38,7 +38,8 @@ export type MovementType = (typeof MovementType)[keyof typeof MovementType] export const MovementReferenceType = { PURCHASE: 'PURCHASE', SALES: 'SALES', - ADJUSTMENT: 'ADJUSTMENT' + ADJUSTMENT: 'ADJUSTMENT', + INVENTORY_TRANSFER: 'INVENTORY_TRANSFER' } as const export type MovementReferenceType = (typeof MovementReferenceType)[keyof typeof MovementReferenceType] diff --git a/src/generated/prisma/internal/class.ts b/src/generated/prisma/internal/class.ts index 3b5e294..318e403 100644 --- a/src/generated/prisma/internal/class.ts +++ b/src/generated/prisma/internal/class.ts @@ -22,7 +22,7 @@ const config: runtime.GetPrismaClientConfig = { "clientVersion": "7.1.0", "engineVersion": "ab635e6b9d606fa5c8fb8b1a7f909c3c3c1c98ba", "activeProvider": "mysql", - "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n previewFeatures = [\"views\"]\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel User {\n id Int @id @default(autoincrement())\n mobileNumber String @unique @db.Char(11)\n password String\n firstName String\n lastName String\n roleId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n role Role @relation(\"User_Role\", fields: [roleId], references: [id], onUpdate: NoAction)\n\n @@index([roleId], map: \"Users_roleId_fkey\")\n @@map(\"Users\")\n}\n\nmodel Role {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n permissions Json?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n users User[] @relation(\"User_Role\")\n\n @@map(\"Roles\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(10, 2)\n salePrice Decimal @db.Decimal(10, 2)\n description String? @db.Text\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n imageUrl String? @db.VarChar(255)\n unit String? @db.VarChar(10)\n quantity Decimal? @default(0.00) @db.Decimal(10, 2)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 2)\n isActive Boolean @default(true)\n isFeatured Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n product Product @relation(\"Product_Variant\", fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([productId], map: \"Product_Variants_productId_fkey\")\n @@map(\"Product_Variants\")\n}\n\nmodel Product {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n description String? @db.Text\n sku String? @unique(map: \"products_sku_unique\") @db.VarChar(100)\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n brandId Int?\n categoryId Int?\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\n productCharges ProductCharge[] @relation(\"Product_Charges\")\n variants ProductVariant[] @relation(\"Product_Variant\")\n brand ProductBrand? @relation(\"Product_Brand\", fields: [brandId], references: [id], onUpdate: NoAction)\n category ProductCategory? @relation(\"Product_Category\", fields: [categoryId], references: [id], onUpdate: NoAction)\n purchaseReceiptItems PurchaseReceiptItem[] @relation(\"Product_PurchaseReceiptItems\")\n salesInvoiceItems SalesInvoiceItem[] @relation(\"Product_SalesInvoiceItems\")\n stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n\n @@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\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 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\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 inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], 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 quantity Decimal\n totalCost Decimal\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(0)\n ProductId Int @id\n avgCost Decimal\n\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}\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", + "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n previewFeatures = [\"views\"]\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel User {\n id Int @id @default(autoincrement())\n mobileNumber String @unique @db.Char(11)\n password String\n firstName String\n lastName String\n roleId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n role Role @relation(\"User_Role\", fields: [roleId], references: [id], onUpdate: NoAction)\n\n @@index([roleId], map: \"Users_roleId_fkey\")\n @@map(\"Users\")\n}\n\nmodel Role {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n permissions Json?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n users User[] @relation(\"User_Role\")\n\n @@map(\"Roles\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(10, 2)\n salePrice Decimal @db.Decimal(10, 2)\n description String? @db.Text\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n imageUrl String? @db.VarChar(255)\n unit String? @db.VarChar(10)\n quantity Decimal? @default(0.00) @db.Decimal(10, 2)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 2)\n isActive Boolean @default(true)\n isFeatured Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n product Product @relation(\"Product_Variant\", fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([productId], map: \"Product_Variants_productId_fkey\")\n @@map(\"Product_Variants\")\n}\n\nmodel Product {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n description String? @db.Text\n sku String? @unique(map: \"products_sku_unique\") @db.VarChar(100)\n barcode String? @unique(map: \"products_barcode_unique\") @db.VarChar(100)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n brandId Int?\n categoryId Int?\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\n productCharges ProductCharge[] @relation(\"Product_Charges\")\n variants ProductVariant[] @relation(\"Product_Variant\")\n brand ProductBrand? @relation(\"Product_Brand\", fields: [brandId], references: [id], onUpdate: NoAction)\n category ProductCategory? @relation(\"Product_Category\", fields: [categoryId], references: [id], onUpdate: NoAction)\n purchaseReceiptItems PurchaseReceiptItem[] @relation(\"Product_PurchaseReceiptItems\")\n salesInvoiceItems SalesInvoiceItem[] @relation(\"Product_SalesInvoiceItems\")\n stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n\n stockBalances StockBalance[] @relation(\"StockBalance_Product\")\n\n @@index([brandId], map: \"Products_brandId_fkey\")\n @@index([categoryId], map: \"Products_categoryId_fkey\")\n @@map(\"Products\")\n}\n\nmodel ProductBrand {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Brand\")\n\n @@map(\"Product_brands\")\n}\n\nmodel ProductCategory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(100)\n description String? @db.Text\n imageUrl String? @db.VarChar(255)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n products Product[] @relation(\"Product_Category\")\n\n @@map(\"Product_categories\")\n}\n\nmodel Supplier {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productCharges ProductCharge[] @relation(\"Supplier_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockMovements StockMovement[] @relation(\"StockMovement_Supplier\")\n\n @@map(\"Suppliers\")\n}\n\nmodel Customer {\n id Int @id @default(autoincrement())\n firstName String @db.VarChar(255)\n lastName String @db.VarChar(255)\n email String? @db.VarChar(255)\n mobileNumber String @unique @db.Char(11)\n address String? @db.Text\n city String? @db.VarChar(100)\n state String? @db.VarChar(100)\n country String? @db.VarChar(100)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n orders Order[] @relation(\"Customer_Orders\")\n salesInvoices SalesInvoice[] @relation(\"Customer_Sales_Invoices\")\n\n @@map(\"Customers\")\n}\n\nmodel Inventory {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n isPointOfSale Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n inventoryTransfersFrom InventoryTransfer[] @relation(\"Inventory_From\")\n inventoryTransfersTo InventoryTransfer[] @relation(\"Inventory_To\")\n productCharges ProductCharge[] @relation(\"Inventory_Product_Charges\")\n purchaseReceipts PurchaseReceipt[]\n stockAdjustments StockAdjustment[] @relation(\"Inventory_Stock_Adjustments\")\n stockMovements StockMovement[] @relation(\"StockMovement_Inventory\")\n stockBalances StockBalance[] @relation(\"StockBalance_inventory\")\n\n @@map(\"Inventories\")\n}\n\nmodel Store {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n location String? @db.VarChar(255)\n isActive Boolean @default(true)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n @@map(\"Stores\")\n}\n\nmodel ProductCharge {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalAmount Decimal @db.Decimal(10, 2)\n isSettled Boolean @default(false)\n buyAt DateTime? @db.Timestamp(0)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n productId Int\n inventoryId Int\n supplierId Int\n inventory Inventory @relation(\"Inventory_Product_Charges\", fields: [inventoryId], references: [id], onUpdate: NoAction)\n product Product @relation(\"Product_Charges\", fields: [productId], references: [id], onUpdate: NoAction)\n supplier Supplier @relation(\"Supplier_Product_Charges\", fields: [supplierId], references: [id], onUpdate: NoAction)\n\n @@index([inventoryId], map: \"Product_Charges_inventoryId_fkey\")\n @@index([productId], map: \"Product_Charges_productId_fkey\")\n @@index([supplierId], map: \"Product_Charges_supplierId_fkey\")\n @@map(\"Product_Charges\")\n}\n\nmodel Order {\n id Int @id @default(autoincrement())\n orderNumber String @unique @db.VarChar(100)\n status OrderStatus @default(pending)\n paymentMethod paymentMethod @default(card)\n totalAmount Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n customerId Int\n customer Customer @relation(\"Customer_Orders\", fields: [customerId], references: [id], onUpdate: NoAction)\n\n @@index([customerId], map: \"Orders_customerId_fkey\")\n @@map(\"Orders\")\n}\n\nmodel PurchaseReceipt {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n supplierId Int\n inventoryId Int\n items PurchaseReceiptItem[] @relation(\"PurchaseReceipt_Items\")\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n supplier Supplier @relation(fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Purchase_Receipts_inventoryId_fkey\")\n @@index([supplierId], map: \"Purchase_Receipts_supplierId_fkey\")\n @@map(\"Purchase_Receipts\")\n}\n\nmodel PurchaseReceiptItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n receiptId Int\n productId Int\n product Product @relation(\"Product_PurchaseReceiptItems\", fields: [productId], references: [id])\n receipt PurchaseReceipt @relation(\"PurchaseReceipt_Items\", fields: [receiptId], references: [id])\n\n @@index([productId], map: \"Purchase_Receipt_Items_productId_fkey\")\n @@index([receiptId], map: \"Purchase_Receipt_Items_receiptId_fkey\")\n @@map(\"Purchase_Receipt_Items\")\n}\n\nmodel SalesInvoice {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(10, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n customerId Int?\n items SalesInvoiceItem[] @relation(\"SalesInvoice_Items\")\n customer Customer? @relation(\"Customer_Sales_Invoices\", fields: [customerId], references: [id])\n\n @@index([customerId], map: \"Sales_Invoices_customerId_fkey\")\n @@map(\"Sales_Invoices\")\n}\n\nmodel SalesInvoiceItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n total Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n invoiceId Int\n productId Int\n invoice SalesInvoice @relation(\"SalesInvoice_Items\", fields: [invoiceId], references: [id])\n product Product @relation(\"Product_SalesInvoiceItems\", fields: [productId], references: [id])\n\n @@index([invoiceId], map: \"Sales_Invoice_Items_invoiceId_fkey\")\n @@index([productId], map: \"Sales_Invoice_Items_productId_fkey\")\n @@map(\"Sales_Invoice_Items\")\n}\n\nmodel StockMovement {\n id Int @id @default(autoincrement())\n type MovementType\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceType MovementReferenceType\n referenceId String\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n avgCost Decimal @db.Decimal(10, 2)\n remainedInStock Decimal @default(0) @db.Decimal(10, 2)\n inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], references: [id])\n supplierId Int?\n supplier Supplier? @relation(\"StockMovement_Supplier\", fields: [supplierId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Movements_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Movements_productId_fkey\")\n @@map(\"Stock_Movements\")\n}\n\nmodel StockBalance {\n id Int @id @default(autoincrement())\n\n productId Int\n inventoryId Int\n\n quantity Decimal @default(0) @db.Decimal(14, 3)\n\n avgCost Decimal @default(0) @db.Decimal(14, 2)\n totalCost Decimal @default(0) @db.Decimal(14, 2)\n\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n\n product Product @relation(\"StockBalance_Product\", fields: [productId], references: [id])\n inventory Inventory @relation(\"StockBalance_inventory\", fields: [inventoryId], references: [id])\n\n @@unique([productId, inventoryId])\n @@index([productId])\n @@index([inventoryId])\n @@map(\"Stock_Balance\")\n}\n\nmodel InventoryTransfer {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n fromInventoryId Int\n toInventoryId Int\n items InventoryTransferItem[] @relation(\"InventoryTransfer_Items\")\n fromInventory Inventory @relation(\"Inventory_From\", fields: [fromInventoryId], references: [id])\n toInventory Inventory @relation(\"Inventory_To\", fields: [toInventoryId], references: [id])\n\n @@index([fromInventoryId], map: \"Inventory_Transfers_fromInventoryId_fkey\")\n @@index([toInventoryId], map: \"Inventory_Transfers_toInventoryId_fkey\")\n @@map(\"Inventory_Transfers\")\n}\n\nmodel InventoryTransferItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 2)\n productId Int\n transferId Int\n product Product @relation(\"InventoryTransferItem_Product\", fields: [productId], references: [id])\n transfer InventoryTransfer @relation(\"InventoryTransfer_Items\", fields: [transferId], references: [id])\n\n @@index([productId], map: \"Inventory_Transfer_Items_productId_fkey\")\n @@index([transferId], map: \"Inventory_Transfer_Items_transferId_fkey\")\n @@map(\"Inventory_Transfer_Items\")\n}\n\nmodel StockAdjustment {\n id Int @id @default(autoincrement())\n adjustedQuantity Decimal @db.Decimal(10, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n inventory Inventory @relation(\"Inventory_Stock_Adjustments\", fields: [inventoryId], references: [id])\n product Product @relation(\"Product_Stock_Adjustments\", fields: [productId], references: [id])\n\n @@index([inventoryId], map: \"Stock_Adjustments_inventoryId_fkey\")\n @@index([productId], map: \"Stock_Adjustments_productId_fkey\")\n @@map(\"Stock_Adjustments\")\n}\n\nview StockMovements_View {\n id Int @default(0)\n productId Int\n type stock_movements_view_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n referenceId String\n referenceType stock_movements_view_referenceType\n createdAt DateTime @default(now()) @db.Timestamp(0)\n current_stock Decimal?\n current_avg_cost Decimal?\n\n @@map(\"Stock_Movements_View\")\n @@ignore\n}\n\nview inventory_overview {\n ProductId Int\n stock_quantity Decimal\n avgCost Decimal\n totalCost Decimal\n updatedAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Inventory_Overview\")\n}\n\nview stock_cardex {\n productId Int\n movement_id Int @default(0)\n type stock_cardex_type\n quantity Decimal @db.Decimal(10, 2)\n fee Decimal @db.Decimal(10, 2)\n totalCost Decimal @db.Decimal(10, 2)\n balance_quantity Decimal?\n balance_avg_cost Decimal?\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Stock_Cardex\")\n}\n\nview stock_view {\n productId Int\n inventoryId Int\n stock Decimal? @db.Decimal(32, 2)\n\n @@map(\"Stock_View\")\n}\n\nenum OrderStatus {\n pending\n reject\n done\n}\n\nenum paymentMethod {\n cash\n card\n}\n\nenum MovementType {\n IN\n OUT\n ADJUST\n}\n\nenum MovementReferenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n INVENTORY_TRANSFER\n}\n\nenum stock_cardex_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_type {\n IN\n OUT\n ADJUST\n}\n\nenum stock_movements_view_referenceType {\n PURCHASE\n SALES\n ADJUSTMENT\n}\n\nmodel TriggerLog {\n id Int @id @default(autoincrement())\n name String @db.Text\n message String @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@map(\"Trigger_Logs\")\n}\n", "runtimeDataModel": { "models": {}, "enums": {}, @@ -30,7 +30,7 @@ const config: runtime.GetPrismaClientConfig = { } } -config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"roleId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"role\",\"kind\":\"object\",\"type\":\"Role\",\"relationName\":\"User_Role\"}],\"dbName\":\"Users\"},\"Role\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"users\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"User_Role\"}],\"dbName\":\"Roles\"},\"ProductVariant\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"basePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"unit\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"alertQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isFeatured\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Variant\"}],\"dbName\":\"Product_Variants\"},\"Product\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sku\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"barcode\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"brandId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Product_Charges\"},{\"name\":\"variants\",\"kind\":\"object\",\"type\":\"ProductVariant\",\"relationName\":\"Product_Variant\"},{\"name\":\"brand\",\"kind\":\"object\",\"type\":\"ProductBrand\",\"relationName\":\"Product_Brand\"},{\"name\":\"category\",\"kind\":\"object\",\"type\":\"ProductCategory\",\"relationName\":\"Product_Category\"},{\"name\":\"purchaseReceiptItems\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"Product_SalesInvoiceItems\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"}],\"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\"}],\"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\":\"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\"}],\"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\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ProductId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"}],\"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\"},\"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\":\"brandId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Product_Charges\"},{\"name\":\"variants\",\"kind\":\"object\",\"type\":\"ProductVariant\",\"relationName\":\"Product_Variant\"},{\"name\":\"brand\",\"kind\":\"object\",\"type\":\"ProductBrand\",\"relationName\":\"Product_Brand\"},{\"name\":\"category\",\"kind\":\"object\",\"type\":\"ProductCategory\",\"relationName\":\"Product_Category\"},{\"name\":\"purchaseReceiptItems\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"Product_SalesInvoiceItems\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_Product\"}],\"dbName\":\"Products\"},\"ProductBrand\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Brand\"}],\"dbName\":\"Product_brands\"},\"ProductCategory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"imageUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Category\"}],\"dbName\":\"Product_categories\"},\"Supplier\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Supplier_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToSupplier\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Suppliers\"},\"Customer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"firstName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"lastName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"city\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"state\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"country\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"orders\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"Customer_Orders\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Customers\"},\"Inventory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"isPointOfSale\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inventoryTransfersFrom\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_From\"},{\"name\":\"inventoryTransfersTo\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_To\"},{\"name\":\"productCharges\",\"kind\":\"object\",\"type\":\"ProductCharge\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Inventories\"},\"Store\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"location\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isActive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stores\"},\"ProductCharge\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"isSettled\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"buyAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Product_Charges\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Charges\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"Supplier_Product_Charges\"}],\"dbName\":\"Product_Charges\"},\"Order\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"OrderStatus\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"paymentMethod\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Orders\"}],\"dbName\":\"Orders\"},\"PurchaseReceipt\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"PurchaseReceiptItem\",\"relationName\":\"PurchaseReceipt_Items\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"PurchaseReceiptToSupplier\"}],\"dbName\":\"Purchase_Receipts\"},\"PurchaseReceiptItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"}],\"dbName\":\"Purchase_Receipt_Items\"},\"SalesInvoice\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"Customer_Sales_Invoices\"}],\"dbName\":\"Sales_Invoices\"},\"SalesInvoiceItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"total\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invoiceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"invoice\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"SalesInvoice_Items\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_SalesInvoiceItems\"}],\"dbName\":\"Sales_Invoice_Items\"},\"StockMovement\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"MovementType\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"referenceType\",\"kind\":\"enum\",\"type\":\"MovementReferenceType\"},{\"name\":\"referenceId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"remainedInStock\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockBalance_Product\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockBalance_inventory\"}],\"dbName\":\"Stock_Balance\"},\"InventoryTransfer\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"fromInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"toInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransfer_Items\"},{\"name\":\"fromInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_From\"},{\"name\":\"toInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_To\"}],\"dbName\":\"Inventory_Transfers\"},\"InventoryTransferItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"transferId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"InventoryTransferItem_Product\"},{\"name\":\"transfer\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"InventoryTransfer_Items\"}],\"dbName\":\"Inventory_Transfer_Items\"},\"StockAdjustment\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"adjustedQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_Stock_Adjustments\"}],\"dbName\":\"Stock_Adjustments\"},\"TriggerLog\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"message\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Trigger_Logs\"},\"inventory_overview\":{\"fields\":[{\"name\":\"ProductId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Inventory_Overview\"},\"stock_cardex\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"movement_id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"stock_cardex_type\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"fee\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance_avg_cost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Stock_Cardex\"},\"stock_view\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"stock\",\"kind\":\"scalar\",\"type\":\"Decimal\"}],\"dbName\":\"Stock_View\"}},\"enums\":{},\"types\":{}}") async function decodeBase64AsWasm(wasmBase64: string): Promise { const { Buffer } = await import('node:buffer') @@ -386,6 +386,16 @@ export interface PrismaClient< */ get stockAdjustment(): Prisma.StockAdjustmentDelegate; + /** + * `prisma.triggerLog`: Exposes CRUD operations for the **TriggerLog** model. + * Example usage: + * ```ts + * // Fetch zero or more TriggerLogs + * const triggerLogs = await prisma.triggerLog.findMany() + * ``` + */ + get triggerLog(): Prisma.TriggerLogDelegate; + /** * `prisma.inventory_overview`: Exposes CRUD operations for the **inventory_overview** model. * Example usage: diff --git a/src/generated/prisma/internal/prismaNamespace.ts b/src/generated/prisma/internal/prismaNamespace.ts index 8014064..9adc1b1 100644 --- a/src/generated/prisma/internal/prismaNamespace.ts +++ b/src/generated/prisma/internal/prismaNamespace.ts @@ -405,6 +405,7 @@ export const ModelName = { InventoryTransfer: 'InventoryTransfer', InventoryTransferItem: 'InventoryTransferItem', StockAdjustment: 'StockAdjustment', + TriggerLog: 'TriggerLog', inventory_overview: 'inventory_overview', stock_cardex: 'stock_cardex', stock_view: 'stock_view' @@ -423,7 +424,7 @@ export type TypeMap + fields: Prisma.TriggerLogFieldRefs + operations: { + findUnique: { + args: Prisma.TriggerLogFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.TriggerLogFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.TriggerLogFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.TriggerLogFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.TriggerLogFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.TriggerLogCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.TriggerLogCreateManyArgs + result: BatchPayload + } + delete: { + args: Prisma.TriggerLogDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.TriggerLogUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.TriggerLogDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.TriggerLogUpdateManyArgs + result: BatchPayload + } + upsert: { + args: Prisma.TriggerLogUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.TriggerLogAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.TriggerLogGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.TriggerLogCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } inventory_overview: { payload: Prisma.$inventory_overviewPayload fields: Prisma.inventory_overviewFieldRefs @@ -2077,6 +2144,7 @@ export const InventoryScalarFieldEnum = { name: 'name', location: 'location', isActive: 'isActive', + isPointOfSale: 'isPointOfSale', createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt' @@ -2197,18 +2265,23 @@ export const StockMovementScalarFieldEnum = { createdAt: 'createdAt', productId: 'productId', inventoryId: 'inventoryId', - avgCost: 'avgCost' + avgCost: 'avgCost', + remainedInStock: 'remainedInStock', + supplierId: 'supplierId' } as const export type StockMovementScalarFieldEnum = (typeof StockMovementScalarFieldEnum)[keyof typeof StockMovementScalarFieldEnum] export const StockBalanceScalarFieldEnum = { + id: 'id', + productId: 'productId', + inventoryId: 'inventoryId', quantity: 'quantity', + avgCost: 'avgCost', totalCost: 'totalCost', - updatedAt: 'updatedAt', - ProductId: 'ProductId', - avgCost: 'avgCost' + createdAt: 'createdAt', + updatedAt: 'updatedAt' } as const export type StockBalanceScalarFieldEnum = (typeof StockBalanceScalarFieldEnum)[keyof typeof StockBalanceScalarFieldEnum] @@ -2247,6 +2320,16 @@ export const StockAdjustmentScalarFieldEnum = { export type StockAdjustmentScalarFieldEnum = (typeof StockAdjustmentScalarFieldEnum)[keyof typeof StockAdjustmentScalarFieldEnum] +export const TriggerLogScalarFieldEnum = { + id: 'id', + name: 'name', + message: 'message', + createdAt: 'createdAt' +} as const + +export type TriggerLogScalarFieldEnum = (typeof TriggerLogScalarFieldEnum)[keyof typeof TriggerLogScalarFieldEnum] + + export const Inventory_overviewScalarFieldEnum = { ProductId: 'ProductId', stock_quantity: 'stock_quantity', @@ -2476,6 +2559,14 @@ export const InventoryTransferOrderByRelevanceFieldEnum = { export type InventoryTransferOrderByRelevanceFieldEnum = (typeof InventoryTransferOrderByRelevanceFieldEnum)[keyof typeof InventoryTransferOrderByRelevanceFieldEnum] +export const TriggerLogOrderByRelevanceFieldEnum = { + name: 'name', + message: 'message' +} as const + +export type TriggerLogOrderByRelevanceFieldEnum = (typeof TriggerLogOrderByRelevanceFieldEnum)[keyof typeof TriggerLogOrderByRelevanceFieldEnum] + + /** * Field references @@ -2688,6 +2779,7 @@ export type GlobalOmitConfig = { inventoryTransfer?: Prisma.InventoryTransferOmit inventoryTransferItem?: Prisma.InventoryTransferItemOmit stockAdjustment?: Prisma.StockAdjustmentOmit + triggerLog?: Prisma.TriggerLogOmit inventory_overview?: Prisma.inventory_overviewOmit stock_cardex?: Prisma.stock_cardexOmit stock_view?: Prisma.stock_viewOmit diff --git a/src/generated/prisma/internal/prismaNamespaceBrowser.ts b/src/generated/prisma/internal/prismaNamespaceBrowser.ts index f54be77..ec2c164 100644 --- a/src/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/src/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -72,6 +72,7 @@ export const ModelName = { InventoryTransfer: 'InventoryTransfer', InventoryTransferItem: 'InventoryTransferItem', StockAdjustment: 'StockAdjustment', + TriggerLog: 'TriggerLog', inventory_overview: 'inventory_overview', stock_cardex: 'stock_cardex', stock_view: 'stock_view' @@ -228,6 +229,7 @@ export const InventoryScalarFieldEnum = { name: 'name', location: 'location', isActive: 'isActive', + isPointOfSale: 'isPointOfSale', createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt' @@ -348,18 +350,23 @@ export const StockMovementScalarFieldEnum = { createdAt: 'createdAt', productId: 'productId', inventoryId: 'inventoryId', - avgCost: 'avgCost' + avgCost: 'avgCost', + remainedInStock: 'remainedInStock', + supplierId: 'supplierId' } as const export type StockMovementScalarFieldEnum = (typeof StockMovementScalarFieldEnum)[keyof typeof StockMovementScalarFieldEnum] export const StockBalanceScalarFieldEnum = { + id: 'id', + productId: 'productId', + inventoryId: 'inventoryId', quantity: 'quantity', + avgCost: 'avgCost', totalCost: 'totalCost', - updatedAt: 'updatedAt', - ProductId: 'ProductId', - avgCost: 'avgCost' + createdAt: 'createdAt', + updatedAt: 'updatedAt' } as const export type StockBalanceScalarFieldEnum = (typeof StockBalanceScalarFieldEnum)[keyof typeof StockBalanceScalarFieldEnum] @@ -398,6 +405,16 @@ export const StockAdjustmentScalarFieldEnum = { export type StockAdjustmentScalarFieldEnum = (typeof StockAdjustmentScalarFieldEnum)[keyof typeof StockAdjustmentScalarFieldEnum] +export const TriggerLogScalarFieldEnum = { + id: 'id', + name: 'name', + message: 'message', + createdAt: 'createdAt' +} as const + +export type TriggerLogScalarFieldEnum = (typeof TriggerLogScalarFieldEnum)[keyof typeof TriggerLogScalarFieldEnum] + + export const Inventory_overviewScalarFieldEnum = { ProductId: 'ProductId', stock_quantity: 'stock_quantity', @@ -626,3 +643,11 @@ export const InventoryTransferOrderByRelevanceFieldEnum = { export type InventoryTransferOrderByRelevanceFieldEnum = (typeof InventoryTransferOrderByRelevanceFieldEnum)[keyof typeof InventoryTransferOrderByRelevanceFieldEnum] + +export const TriggerLogOrderByRelevanceFieldEnum = { + name: 'name', + message: 'message' +} as const + +export type TriggerLogOrderByRelevanceFieldEnum = (typeof TriggerLogOrderByRelevanceFieldEnum)[keyof typeof TriggerLogOrderByRelevanceFieldEnum] + diff --git a/src/generated/prisma/models.ts b/src/generated/prisma/models.ts index 55b9c24..f17a6c6 100644 --- a/src/generated/prisma/models.ts +++ b/src/generated/prisma/models.ts @@ -29,6 +29,7 @@ export type * from './models/StockBalance.js' export type * from './models/InventoryTransfer.js' export type * from './models/InventoryTransferItem.js' export type * from './models/StockAdjustment.js' +export type * from './models/TriggerLog.js' export type * from './models/inventory_overview.js' export type * from './models/stock_cardex.js' export type * from './models/stock_view.js' diff --git a/src/generated/prisma/models/Inventory.ts b/src/generated/prisma/models/Inventory.ts index faff616..50a9bbd 100644 --- a/src/generated/prisma/models/Inventory.ts +++ b/src/generated/prisma/models/Inventory.ts @@ -39,6 +39,7 @@ export type InventoryMinAggregateOutputType = { name: string | null location: string | null isActive: boolean | null + isPointOfSale: boolean | null createdAt: Date | null updatedAt: Date | null deletedAt: Date | null @@ -49,6 +50,7 @@ export type InventoryMaxAggregateOutputType = { name: string | null location: string | null isActive: boolean | null + isPointOfSale: boolean | null createdAt: Date | null updatedAt: Date | null deletedAt: Date | null @@ -59,6 +61,7 @@ export type InventoryCountAggregateOutputType = { name: number location: number isActive: number + isPointOfSale: number createdAt: number updatedAt: number deletedAt: number @@ -79,6 +82,7 @@ export type InventoryMinAggregateInputType = { name?: true location?: true isActive?: true + isPointOfSale?: true createdAt?: true updatedAt?: true deletedAt?: true @@ -89,6 +93,7 @@ export type InventoryMaxAggregateInputType = { name?: true location?: true isActive?: true + isPointOfSale?: true createdAt?: true updatedAt?: true deletedAt?: true @@ -99,6 +104,7 @@ export type InventoryCountAggregateInputType = { name?: true location?: true isActive?: true + isPointOfSale?: true createdAt?: true updatedAt?: true deletedAt?: true @@ -196,6 +202,7 @@ export type InventoryGroupByOutputType = { name: string location: string | null isActive: boolean + isPointOfSale: boolean createdAt: Date updatedAt: Date deletedAt: Date | null @@ -229,6 +236,7 @@ export type InventoryWhereInput = { name?: Prisma.StringFilter<"Inventory"> | string location?: Prisma.StringNullableFilter<"Inventory"> | string | null isActive?: Prisma.BoolFilter<"Inventory"> | boolean + isPointOfSale?: Prisma.BoolFilter<"Inventory"> | boolean createdAt?: Prisma.DateTimeFilter<"Inventory"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Inventory"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Inventory"> | Date | string | null @@ -238,6 +246,7 @@ export type InventoryWhereInput = { purchaseReceipts?: Prisma.PurchaseReceiptListRelationFilter stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter + stockBalances?: Prisma.StockBalanceListRelationFilter } export type InventoryOrderByWithRelationInput = { @@ -245,6 +254,7 @@ export type InventoryOrderByWithRelationInput = { name?: Prisma.SortOrder location?: Prisma.SortOrderInput | Prisma.SortOrder isActive?: Prisma.SortOrder + isPointOfSale?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder @@ -254,6 +264,7 @@ export type InventoryOrderByWithRelationInput = { purchaseReceipts?: Prisma.PurchaseReceiptOrderByRelationAggregateInput stockAdjustments?: Prisma.StockAdjustmentOrderByRelationAggregateInput stockMovements?: Prisma.StockMovementOrderByRelationAggregateInput + stockBalances?: Prisma.StockBalanceOrderByRelationAggregateInput _relevance?: Prisma.InventoryOrderByRelevanceInput } @@ -265,6 +276,7 @@ export type InventoryWhereUniqueInput = Prisma.AtLeast<{ name?: Prisma.StringFilter<"Inventory"> | string location?: Prisma.StringNullableFilter<"Inventory"> | string | null isActive?: Prisma.BoolFilter<"Inventory"> | boolean + isPointOfSale?: Prisma.BoolFilter<"Inventory"> | boolean createdAt?: Prisma.DateTimeFilter<"Inventory"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Inventory"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Inventory"> | Date | string | null @@ -274,6 +286,7 @@ export type InventoryWhereUniqueInput = Prisma.AtLeast<{ purchaseReceipts?: Prisma.PurchaseReceiptListRelationFilter stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter + stockBalances?: Prisma.StockBalanceListRelationFilter }, "id"> export type InventoryOrderByWithAggregationInput = { @@ -281,6 +294,7 @@ export type InventoryOrderByWithAggregationInput = { name?: Prisma.SortOrder location?: Prisma.SortOrderInput | Prisma.SortOrder isActive?: Prisma.SortOrder + isPointOfSale?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder @@ -299,6 +313,7 @@ export type InventoryScalarWhereWithAggregatesInput = { name?: Prisma.StringWithAggregatesFilter<"Inventory"> | string location?: Prisma.StringNullableWithAggregatesFilter<"Inventory"> | string | null isActive?: Prisma.BoolWithAggregatesFilter<"Inventory"> | boolean + isPointOfSale?: Prisma.BoolWithAggregatesFilter<"Inventory"> | boolean createdAt?: Prisma.DateTimeWithAggregatesFilter<"Inventory"> | Date | string updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Inventory"> | Date | string deletedAt?: Prisma.DateTimeNullableWithAggregatesFilter<"Inventory"> | Date | string | null @@ -308,6 +323,7 @@ export type InventoryCreateInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -317,6 +333,7 @@ export type InventoryCreateInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateInput = { @@ -324,6 +341,7 @@ export type InventoryUncheckedCreateInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -333,12 +351,14 @@ export type InventoryUncheckedCreateInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryUpdateInput = { 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 @@ -348,6 +368,7 @@ export type InventoryUpdateInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateInput = { @@ -355,6 +376,7 @@ export type InventoryUncheckedUpdateInput = { 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 @@ -364,6 +386,7 @@ export type InventoryUncheckedUpdateInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateManyInput = { @@ -371,6 +394,7 @@ export type InventoryCreateManyInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -380,6 +404,7 @@ export type InventoryUpdateManyMutationInput = { 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 @@ -390,6 +415,7 @@ export type InventoryUncheckedUpdateManyInput = { 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 @@ -406,6 +432,7 @@ export type InventoryCountOrderByAggregateInput = { name?: Prisma.SortOrder location?: Prisma.SortOrder isActive?: Prisma.SortOrder + isPointOfSale?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder @@ -420,6 +447,7 @@ export type InventoryMaxOrderByAggregateInput = { name?: Prisma.SortOrder location?: Prisma.SortOrder isActive?: Prisma.SortOrder + isPointOfSale?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder @@ -430,6 +458,7 @@ export type InventoryMinOrderByAggregateInput = { name?: Prisma.SortOrder location?: Prisma.SortOrder isActive?: Prisma.SortOrder + isPointOfSale?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder @@ -486,6 +515,20 @@ export type InventoryUpdateOneRequiredWithoutStockMovementsNestedInput = { update?: Prisma.XOR, Prisma.InventoryUncheckedUpdateWithoutStockMovementsInput> } +export type InventoryCreateNestedOneWithoutStockBalancesInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutStockBalancesInput + connect?: Prisma.InventoryWhereUniqueInput +} + +export type InventoryUpdateOneRequiredWithoutStockBalancesNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutStockBalancesInput + upsert?: Prisma.InventoryUpsertWithoutStockBalancesInput + connect?: Prisma.InventoryWhereUniqueInput + update?: Prisma.XOR, Prisma.InventoryUncheckedUpdateWithoutStockBalancesInput> +} + export type InventoryCreateNestedOneWithoutInventoryTransfersFromInput = { create?: Prisma.XOR connectOrCreate?: Prisma.InventoryCreateOrConnectWithoutInventoryTransfersFromInput @@ -532,6 +575,7 @@ export type InventoryCreateWithoutProductChargesInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -540,6 +584,7 @@ export type InventoryCreateWithoutProductChargesInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutProductChargesInput = { @@ -547,6 +592,7 @@ export type InventoryUncheckedCreateWithoutProductChargesInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -555,6 +601,7 @@ export type InventoryUncheckedCreateWithoutProductChargesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutProductChargesInput = { @@ -577,6 +624,7 @@ export type InventoryUpdateWithoutProductChargesInput = { 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 @@ -585,6 +633,7 @@ export type InventoryUpdateWithoutProductChargesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutProductChargesInput = { @@ -592,6 +641,7 @@ export type InventoryUncheckedUpdateWithoutProductChargesInput = { 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 @@ -600,12 +650,14 @@ export type InventoryUncheckedUpdateWithoutProductChargesInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutPurchaseReceiptsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -614,6 +666,7 @@ export type InventoryCreateWithoutPurchaseReceiptsInput = { productCharges?: Prisma.ProductChargeCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutPurchaseReceiptsInput = { @@ -621,6 +674,7 @@ export type InventoryUncheckedCreateWithoutPurchaseReceiptsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -629,6 +683,7 @@ export type InventoryUncheckedCreateWithoutPurchaseReceiptsInput = { productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutPurchaseReceiptsInput = { @@ -651,6 +706,7 @@ export type InventoryUpdateWithoutPurchaseReceiptsInput = { 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 @@ -659,6 +715,7 @@ export type InventoryUpdateWithoutPurchaseReceiptsInput = { productCharges?: Prisma.ProductChargeUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutPurchaseReceiptsInput = { @@ -666,6 +723,7 @@ export type InventoryUncheckedUpdateWithoutPurchaseReceiptsInput = { 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 @@ -674,12 +732,14 @@ export type InventoryUncheckedUpdateWithoutPurchaseReceiptsInput = { productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutStockMovementsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -688,6 +748,7 @@ export type InventoryCreateWithoutStockMovementsInput = { productCharges?: Prisma.ProductChargeCreateNestedManyWithoutInventoryInput purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutStockMovementsInput = { @@ -695,6 +756,7 @@ export type InventoryUncheckedCreateWithoutStockMovementsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -703,6 +765,7 @@ export type InventoryUncheckedCreateWithoutStockMovementsInput = { productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutInventoryInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutStockMovementsInput = { @@ -725,6 +788,7 @@ export type InventoryUpdateWithoutStockMovementsInput = { 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 @@ -733,6 +797,7 @@ export type InventoryUpdateWithoutStockMovementsInput = { productCharges?: Prisma.ProductChargeUpdateManyWithoutInventoryNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutStockMovementsInput = { @@ -740,6 +805,7 @@ export type InventoryUncheckedUpdateWithoutStockMovementsInput = { 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 @@ -748,12 +814,96 @@ export type InventoryUncheckedUpdateWithoutStockMovementsInput = { productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutInventoryNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput +} + +export type InventoryCreateWithoutStockBalancesInput = { + 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 +} + +export type InventoryUncheckedCreateWithoutStockBalancesInput = { + 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 +} + +export type InventoryCreateOrConnectWithoutStockBalancesInput = { + where: Prisma.InventoryWhereUniqueInput + create: Prisma.XOR +} + +export type InventoryUpsertWithoutStockBalancesInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.InventoryWhereInput +} + +export type InventoryUpdateToOneWithWhereWithoutStockBalancesInput = { + where?: Prisma.InventoryWhereInput + data: Prisma.XOR +} + +export type InventoryUpdateWithoutStockBalancesInput = { + 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 +} + +export type InventoryUncheckedUpdateWithoutStockBalancesInput = { + 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 } export type InventoryCreateWithoutInventoryTransfersFromInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -762,6 +912,7 @@ export type InventoryCreateWithoutInventoryTransfersFromInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutInventoryTransfersFromInput = { @@ -769,6 +920,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersFromInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -777,6 +929,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersFromInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutInventoryTransfersFromInput = { @@ -788,6 +941,7 @@ export type InventoryCreateWithoutInventoryTransfersToInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -796,6 +950,7 @@ export type InventoryCreateWithoutInventoryTransfersToInput = { purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutInventoryTransfersToInput = { @@ -803,6 +958,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersToInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -811,6 +967,7 @@ export type InventoryUncheckedCreateWithoutInventoryTransfersToInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutInventoryTransfersToInput = { @@ -833,6 +990,7 @@ export type InventoryUpdateWithoutInventoryTransfersFromInput = { 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 @@ -841,6 +999,7 @@ export type InventoryUpdateWithoutInventoryTransfersFromInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutInventoryTransfersFromInput = { @@ -848,6 +1007,7 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersFromInput = { 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 @@ -856,6 +1016,7 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersFromInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryUpsertWithoutInventoryTransfersToInput = { @@ -873,6 +1034,7 @@ export type InventoryUpdateWithoutInventoryTransfersToInput = { 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 @@ -881,6 +1043,7 @@ export type InventoryUpdateWithoutInventoryTransfersToInput = { purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutInventoryTransfersToInput = { @@ -888,6 +1051,7 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersToInput = { 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 @@ -896,12 +1060,14 @@ export type InventoryUncheckedUpdateWithoutInventoryTransfersToInput = { purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } export type InventoryCreateWithoutStockAdjustmentsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -910,6 +1076,7 @@ export type InventoryCreateWithoutStockAdjustmentsInput = { productCharges?: Prisma.ProductChargeCreateNestedManyWithoutInventoryInput purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutInventoryInput } export type InventoryUncheckedCreateWithoutStockAdjustmentsInput = { @@ -917,6 +1084,7 @@ export type InventoryUncheckedCreateWithoutStockAdjustmentsInput = { name: string location?: string | null isActive?: boolean + isPointOfSale?: boolean createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null @@ -925,6 +1093,7 @@ export type InventoryUncheckedCreateWithoutStockAdjustmentsInput = { productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutInventoryInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutInventoryInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutInventoryInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutInventoryInput } export type InventoryCreateOrConnectWithoutStockAdjustmentsInput = { @@ -947,6 +1116,7 @@ export type InventoryUpdateWithoutStockAdjustmentsInput = { 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 @@ -955,6 +1125,7 @@ export type InventoryUpdateWithoutStockAdjustmentsInput = { productCharges?: Prisma.ProductChargeUpdateManyWithoutInventoryNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutInventoryNestedInput } export type InventoryUncheckedUpdateWithoutStockAdjustmentsInput = { @@ -962,6 +1133,7 @@ export type InventoryUncheckedUpdateWithoutStockAdjustmentsInput = { 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 @@ -970,6 +1142,7 @@ export type InventoryUncheckedUpdateWithoutStockAdjustmentsInput = { productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutInventoryNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutInventoryNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutInventoryNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput } @@ -984,6 +1157,7 @@ export type InventoryCountOutputType = { purchaseReceipts: number stockAdjustments: number stockMovements: number + stockBalances: number } export type InventoryCountOutputTypeSelect = { @@ -993,6 +1167,7 @@ export type InventoryCountOutputTypeSelect = { + where?: Prisma.StockBalanceWhereInput +} + export type InventorySelect = runtime.Types.Extensions.GetSelect<{ id?: boolean name?: boolean location?: boolean isActive?: boolean + isPointOfSale?: boolean createdAt?: boolean updatedAt?: boolean deletedAt?: boolean @@ -1062,6 +1245,7 @@ export type InventorySelect stockAdjustments?: boolean | Prisma.Inventory$stockAdjustmentsArgs stockMovements?: boolean | Prisma.Inventory$stockMovementsArgs + stockBalances?: boolean | Prisma.Inventory$stockBalancesArgs _count?: boolean | Prisma.InventoryCountOutputTypeDefaultArgs }, ExtArgs["result"]["inventory"]> @@ -1072,12 +1256,13 @@ export type InventorySelectScalar = { name?: boolean location?: boolean isActive?: boolean + isPointOfSale?: boolean createdAt?: boolean updatedAt?: boolean deletedAt?: boolean } -export type InventoryOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "location" | "isActive" | "createdAt" | "updatedAt" | "deletedAt", ExtArgs["result"]["inventory"]> +export type InventoryOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "location" | "isActive" | "isPointOfSale" | "createdAt" | "updatedAt" | "deletedAt", ExtArgs["result"]["inventory"]> export type InventoryInclude = { inventoryTransfersFrom?: boolean | Prisma.Inventory$inventoryTransfersFromArgs inventoryTransfersTo?: boolean | Prisma.Inventory$inventoryTransfersToArgs @@ -1085,6 +1270,7 @@ export type InventoryInclude stockAdjustments?: boolean | Prisma.Inventory$stockAdjustmentsArgs stockMovements?: boolean | Prisma.Inventory$stockMovementsArgs + stockBalances?: boolean | Prisma.Inventory$stockBalancesArgs _count?: boolean | Prisma.InventoryCountOutputTypeDefaultArgs } @@ -1097,12 +1283,14 @@ export type $InventoryPayload[] stockAdjustments: Prisma.$StockAdjustmentPayload[] stockMovements: Prisma.$StockMovementPayload[] + stockBalances: Prisma.$StockBalancePayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number name: string location: string | null isActive: boolean + isPointOfSale: boolean createdAt: Date updatedAt: Date deletedAt: Date | null @@ -1452,6 +1640,7 @@ export interface Prisma__InventoryClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> stockAdjustments = {}>(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> /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. @@ -1485,6 +1674,7 @@ export interface InventoryFieldRefs { readonly name: Prisma.FieldRef<"Inventory", 'String'> readonly location: Prisma.FieldRef<"Inventory", 'String'> readonly isActive: Prisma.FieldRef<"Inventory", 'Boolean'> + readonly isPointOfSale: Prisma.FieldRef<"Inventory", 'Boolean'> readonly createdAt: Prisma.FieldRef<"Inventory", 'DateTime'> readonly updatedAt: Prisma.FieldRef<"Inventory", 'DateTime'> readonly deletedAt: Prisma.FieldRef<"Inventory", 'DateTime'> @@ -1974,6 +2164,30 @@ export type Inventory$stockMovementsArgs = { + /** + * Select specific fields to fetch from the StockBalance + */ + select?: Prisma.StockBalanceSelect | null + /** + * Omit specific fields from the StockBalance + */ + omit?: Prisma.StockBalanceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null + where?: Prisma.StockBalanceWhereInput + orderBy?: Prisma.StockBalanceOrderByWithRelationInput | Prisma.StockBalanceOrderByWithRelationInput[] + cursor?: Prisma.StockBalanceWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.StockBalanceScalarFieldEnum | Prisma.StockBalanceScalarFieldEnum[] +} + /** * Inventory without action */ diff --git a/src/generated/prisma/models/Product.ts b/src/generated/prisma/models/Product.ts index e7d29ec..28d85c4 100644 --- a/src/generated/prisma/models/Product.ts +++ b/src/generated/prisma/models/Product.ts @@ -273,6 +273,7 @@ export type ProductWhereInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemListRelationFilter stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter + stockBalances?: Prisma.StockBalanceListRelationFilter } export type ProductOrderByWithRelationInput = { @@ -295,6 +296,7 @@ export type ProductOrderByWithRelationInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemOrderByRelationAggregateInput stockAdjustments?: Prisma.StockAdjustmentOrderByRelationAggregateInput stockMovements?: Prisma.StockMovementOrderByRelationAggregateInput + stockBalances?: Prisma.StockBalanceOrderByRelationAggregateInput _relevance?: Prisma.ProductOrderByRelevanceInput } @@ -321,6 +323,7 @@ export type ProductWhereUniqueInput = Prisma.AtLeast<{ salesInvoiceItems?: Prisma.SalesInvoiceItemListRelationFilter stockAdjustments?: Prisma.StockAdjustmentListRelationFilter stockMovements?: Prisma.StockMovementListRelationFilter + stockBalances?: Prisma.StockBalanceListRelationFilter }, "id" | "sku" | "barcode"> export type ProductOrderByWithAggregationInput = { @@ -374,6 +377,7 @@ export type ProductCreateInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateInput = { @@ -394,6 +398,7 @@ export type ProductUncheckedCreateInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductUpdateInput = { @@ -413,6 +418,7 @@ export type ProductUpdateInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateInput = { @@ -433,6 +439,7 @@ export type ProductUncheckedUpdateInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateManyInput = { @@ -705,6 +712,20 @@ export type ProductUpdateOneRequiredWithoutStockMovementsNestedInput = { update?: Prisma.XOR, Prisma.ProductUncheckedUpdateWithoutStockMovementsInput> } +export type ProductCreateNestedOneWithoutStockBalancesInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.ProductCreateOrConnectWithoutStockBalancesInput + connect?: Prisma.ProductWhereUniqueInput +} + +export type ProductUpdateOneRequiredWithoutStockBalancesNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.ProductCreateOrConnectWithoutStockBalancesInput + upsert?: Prisma.ProductUpsertWithoutStockBalancesInput + connect?: Prisma.ProductWhereUniqueInput + update?: Prisma.XOR, Prisma.ProductUncheckedUpdateWithoutStockBalancesInput> +} + export type ProductCreateNestedOneWithoutInventoryTransferItemsInput = { create?: Prisma.XOR connectOrCreate?: Prisma.ProductCreateOrConnectWithoutInventoryTransferItemsInput @@ -749,6 +770,7 @@ export type ProductCreateWithoutVariantsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutVariantsInput = { @@ -768,6 +790,7 @@ export type ProductUncheckedCreateWithoutVariantsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutVariantsInput = { @@ -802,6 +825,7 @@ export type ProductUpdateWithoutVariantsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutVariantsInput = { @@ -821,6 +845,7 @@ export type ProductUncheckedUpdateWithoutVariantsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutBrandInput = { @@ -839,6 +864,7 @@ export type ProductCreateWithoutBrandInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutBrandInput = { @@ -858,6 +884,7 @@ export type ProductUncheckedCreateWithoutBrandInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutBrandInput = { @@ -918,6 +945,7 @@ export type ProductCreateWithoutCategoryInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutCategoryInput = { @@ -937,6 +965,7 @@ export type ProductUncheckedCreateWithoutCategoryInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutCategoryInput = { @@ -981,6 +1010,7 @@ export type ProductCreateWithoutProductChargesInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutProductChargesInput = { @@ -1000,6 +1030,7 @@ export type ProductUncheckedCreateWithoutProductChargesInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutProductChargesInput = { @@ -1034,6 +1065,7 @@ export type ProductUpdateWithoutProductChargesInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutProductChargesInput = { @@ -1053,6 +1085,7 @@ export type ProductUncheckedUpdateWithoutProductChargesInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutPurchaseReceiptItemsInput = { @@ -1071,6 +1104,7 @@ export type ProductCreateWithoutPurchaseReceiptItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutPurchaseReceiptItemsInput = { @@ -1090,6 +1124,7 @@ export type ProductUncheckedCreateWithoutPurchaseReceiptItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutPurchaseReceiptItemsInput = { @@ -1124,6 +1159,7 @@ export type ProductUpdateWithoutPurchaseReceiptItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutPurchaseReceiptItemsInput = { @@ -1143,6 +1179,7 @@ export type ProductUncheckedUpdateWithoutPurchaseReceiptItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutSalesInvoiceItemsInput = { @@ -1161,6 +1198,7 @@ export type ProductCreateWithoutSalesInvoiceItemsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutSalesInvoiceItemsInput = { @@ -1180,6 +1218,7 @@ export type ProductUncheckedCreateWithoutSalesInvoiceItemsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutSalesInvoiceItemsInput = { @@ -1214,6 +1253,7 @@ export type ProductUpdateWithoutSalesInvoiceItemsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutSalesInvoiceItemsInput = { @@ -1233,6 +1273,7 @@ export type ProductUncheckedUpdateWithoutSalesInvoiceItemsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutStockMovementsInput = { @@ -1251,6 +1292,7 @@ export type ProductCreateWithoutStockMovementsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemCreateNestedManyWithoutProductInput salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutStockMovementsInput = { @@ -1270,6 +1312,7 @@ export type ProductUncheckedCreateWithoutStockMovementsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedCreateNestedManyWithoutProductInput salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutStockMovementsInput = { @@ -1304,6 +1347,7 @@ export type ProductUpdateWithoutStockMovementsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUpdateManyWithoutProductNestedInput salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutStockMovementsInput = { @@ -1323,6 +1367,101 @@ export type ProductUncheckedUpdateWithoutStockMovementsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedUpdateManyWithoutProductNestedInput salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput +} + +export type ProductCreateWithoutStockBalancesInput = { + name: string + description?: string | null + sku?: string | null + barcode?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + inventoryTransferItems?: Prisma.InventoryTransferItemCreateNestedManyWithoutProductInput + productCharges?: Prisma.ProductChargeCreateNestedManyWithoutProductInput + variants?: Prisma.ProductVariantCreateNestedManyWithoutProductInput + brand?: Prisma.ProductBrandCreateNestedOneWithoutProductsInput + category?: Prisma.ProductCategoryCreateNestedOneWithoutProductsInput + purchaseReceiptItems?: Prisma.PurchaseReceiptItemCreateNestedManyWithoutProductInput + salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput + stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput + stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput +} + +export type ProductUncheckedCreateWithoutStockBalancesInput = { + id?: number + name: string + description?: string | null + sku?: string | null + barcode?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + brandId?: number | null + categoryId?: number | null + inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedCreateNestedManyWithoutProductInput + productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutProductInput + variants?: Prisma.ProductVariantUncheckedCreateNestedManyWithoutProductInput + purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedCreateNestedManyWithoutProductInput + salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput + stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput + stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput +} + +export type ProductCreateOrConnectWithoutStockBalancesInput = { + where: Prisma.ProductWhereUniqueInput + create: Prisma.XOR +} + +export type ProductUpsertWithoutStockBalancesInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.ProductWhereInput +} + +export type ProductUpdateToOneWithWhereWithoutStockBalancesInput = { + where?: Prisma.ProductWhereInput + data: Prisma.XOR +} + +export type ProductUpdateWithoutStockBalancesInput = { + name?: Prisma.StringFieldUpdateOperationsInput | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + sku?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + barcode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + inventoryTransferItems?: Prisma.InventoryTransferItemUpdateManyWithoutProductNestedInput + productCharges?: Prisma.ProductChargeUpdateManyWithoutProductNestedInput + variants?: Prisma.ProductVariantUpdateManyWithoutProductNestedInput + brand?: Prisma.ProductBrandUpdateOneWithoutProductsNestedInput + category?: Prisma.ProductCategoryUpdateOneWithoutProductsNestedInput + purchaseReceiptItems?: Prisma.PurchaseReceiptItemUpdateManyWithoutProductNestedInput + salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput + stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput + stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput +} + +export type ProductUncheckedUpdateWithoutStockBalancesInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + name?: Prisma.StringFieldUpdateOperationsInput | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + sku?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + barcode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + brandId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + categoryId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + inventoryTransferItems?: Prisma.InventoryTransferItemUncheckedUpdateManyWithoutProductNestedInput + productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutProductNestedInput + variants?: Prisma.ProductVariantUncheckedUpdateManyWithoutProductNestedInput + purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedUpdateManyWithoutProductNestedInput + salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput + stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput + stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutInventoryTransferItemsInput = { @@ -1341,6 +1480,7 @@ export type ProductCreateWithoutInventoryTransferItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutInventoryTransferItemsInput = { @@ -1360,6 +1500,7 @@ export type ProductUncheckedCreateWithoutInventoryTransferItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockAdjustments?: Prisma.StockAdjustmentUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutInventoryTransferItemsInput = { @@ -1394,6 +1535,7 @@ export type ProductUpdateWithoutInventoryTransferItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutInventoryTransferItemsInput = { @@ -1413,6 +1555,7 @@ export type ProductUncheckedUpdateWithoutInventoryTransferItemsInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateWithoutStockAdjustmentsInput = { @@ -1431,6 +1574,7 @@ export type ProductCreateWithoutStockAdjustmentsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemCreateNestedManyWithoutProductInput salesInvoiceItems?: Prisma.SalesInvoiceItemCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceCreateNestedManyWithoutProductInput } export type ProductUncheckedCreateWithoutStockAdjustmentsInput = { @@ -1450,6 +1594,7 @@ export type ProductUncheckedCreateWithoutStockAdjustmentsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedCreateNestedManyWithoutProductInput salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutProductInput stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutProductInput + stockBalances?: Prisma.StockBalanceUncheckedCreateNestedManyWithoutProductInput } export type ProductCreateOrConnectWithoutStockAdjustmentsInput = { @@ -1484,6 +1629,7 @@ export type ProductUpdateWithoutStockAdjustmentsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUpdateManyWithoutProductNestedInput salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutStockAdjustmentsInput = { @@ -1503,6 +1649,7 @@ export type ProductUncheckedUpdateWithoutStockAdjustmentsInput = { purchaseReceiptItems?: Prisma.PurchaseReceiptItemUncheckedUpdateManyWithoutProductNestedInput salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductCreateManyBrandInput = { @@ -1533,6 +1680,7 @@ export type ProductUpdateWithoutBrandInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutBrandInput = { @@ -1552,6 +1700,7 @@ export type ProductUncheckedUpdateWithoutBrandInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateManyWithoutBrandInput = { @@ -1594,6 +1743,7 @@ export type ProductUpdateWithoutCategoryInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateWithoutCategoryInput = { @@ -1613,6 +1763,7 @@ export type ProductUncheckedUpdateWithoutCategoryInput = { salesInvoiceItems?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutProductNestedInput stockAdjustments?: Prisma.StockAdjustmentUncheckedUpdateManyWithoutProductNestedInput stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutProductNestedInput + stockBalances?: Prisma.StockBalanceUncheckedUpdateManyWithoutProductNestedInput } export type ProductUncheckedUpdateManyWithoutCategoryInput = { @@ -1640,6 +1791,7 @@ export type ProductCountOutputType = { salesInvoiceItems: number stockAdjustments: number stockMovements: number + stockBalances: number } export type ProductCountOutputTypeSelect = { @@ -1650,6 +1802,7 @@ export type ProductCountOutputTypeSelect = { + where?: Prisma.StockBalanceWhereInput +} + export type ProductSelect = runtime.Types.Extensions.GetSelect<{ id?: boolean @@ -1732,6 +1892,7 @@ export type ProductSelect stockAdjustments?: boolean | Prisma.Product$stockAdjustmentsArgs stockMovements?: boolean | Prisma.Product$stockMovementsArgs + stockBalances?: boolean | Prisma.Product$stockBalancesArgs _count?: boolean | Prisma.ProductCountOutputTypeDefaultArgs }, ExtArgs["result"]["product"]> @@ -1761,6 +1922,7 @@ export type ProductInclude stockAdjustments?: boolean | Prisma.Product$stockAdjustmentsArgs stockMovements?: boolean | Prisma.Product$stockMovementsArgs + stockBalances?: boolean | Prisma.Product$stockBalancesArgs _count?: boolean | Prisma.ProductCountOutputTypeDefaultArgs } @@ -1776,6 +1938,7 @@ export type $ProductPayload[] stockAdjustments: Prisma.$StockAdjustmentPayload[] stockMovements: Prisma.$StockMovementPayload[] + stockBalances: Prisma.$StockBalancePayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -2137,6 +2300,7 @@ export interface Prisma__ProductClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> stockAdjustments = {}>(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> /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. @@ -2724,6 +2888,30 @@ export type Product$stockMovementsArgs = { + /** + * Select specific fields to fetch from the StockBalance + */ + select?: Prisma.StockBalanceSelect | null + /** + * Omit specific fields from the StockBalance + */ + omit?: Prisma.StockBalanceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null + where?: Prisma.StockBalanceWhereInput + orderBy?: Prisma.StockBalanceOrderByWithRelationInput | Prisma.StockBalanceOrderByWithRelationInput[] + cursor?: Prisma.StockBalanceWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.StockBalanceScalarFieldEnum | Prisma.StockBalanceScalarFieldEnum[] +} + /** * Product without action */ diff --git a/src/generated/prisma/models/StockBalance.ts b/src/generated/prisma/models/StockBalance.ts index 1d8ef4c..88d7da8 100644 --- a/src/generated/prisma/models/StockBalance.ts +++ b/src/generated/prisma/models/StockBalance.ts @@ -27,81 +27,107 @@ export type AggregateStockBalance = { } export type StockBalanceAvgAggregateOutputType = { + id: number | null + productId: number | null + inventoryId: number | null quantity: runtime.Decimal | null - totalCost: runtime.Decimal | null - ProductId: number | null avgCost: runtime.Decimal | null + totalCost: runtime.Decimal | null } export type StockBalanceSumAggregateOutputType = { + id: number | null + productId: number | null + inventoryId: number | null quantity: runtime.Decimal | null - totalCost: runtime.Decimal | null - ProductId: number | null avgCost: runtime.Decimal | null + totalCost: runtime.Decimal | null } export type StockBalanceMinAggregateOutputType = { + id: number | null + productId: number | null + inventoryId: number | null quantity: runtime.Decimal | null - totalCost: runtime.Decimal | null - updatedAt: Date | null - ProductId: number | null avgCost: runtime.Decimal | null + totalCost: runtime.Decimal | null + createdAt: Date | null + updatedAt: Date | null } export type StockBalanceMaxAggregateOutputType = { + id: number | null + productId: number | null + inventoryId: number | null quantity: runtime.Decimal | null - totalCost: runtime.Decimal | null - updatedAt: Date | null - ProductId: number | null avgCost: runtime.Decimal | null + totalCost: runtime.Decimal | null + createdAt: Date | null + updatedAt: Date | null } export type StockBalanceCountAggregateOutputType = { + id: number + productId: number + inventoryId: number quantity: number - totalCost: number - updatedAt: number - ProductId: number avgCost: number + totalCost: number + createdAt: number + updatedAt: number _all: number } export type StockBalanceAvgAggregateInputType = { + id?: true + productId?: true + inventoryId?: true quantity?: true - totalCost?: true - ProductId?: true avgCost?: true + totalCost?: true } export type StockBalanceSumAggregateInputType = { + id?: true + productId?: true + inventoryId?: true quantity?: true - totalCost?: true - ProductId?: true avgCost?: true + totalCost?: true } export type StockBalanceMinAggregateInputType = { + id?: true + productId?: true + inventoryId?: true quantity?: true - totalCost?: true - updatedAt?: true - ProductId?: true avgCost?: true + totalCost?: true + createdAt?: true + updatedAt?: true } export type StockBalanceMaxAggregateInputType = { + id?: true + productId?: true + inventoryId?: true quantity?: true - totalCost?: true - updatedAt?: true - ProductId?: true avgCost?: true + totalCost?: true + createdAt?: true + updatedAt?: true } export type StockBalanceCountAggregateInputType = { + id?: true + productId?: true + inventoryId?: true quantity?: true - totalCost?: true - updatedAt?: true - ProductId?: true avgCost?: true + totalCost?: true + createdAt?: true + updatedAt?: true _all?: true } @@ -192,11 +218,14 @@ export type StockBalanceGroupByArgs | number + productId?: Prisma.IntFilter<"StockBalance"> | number + inventoryId?: Prisma.IntFilter<"StockBalance"> | number quantity?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string - ProductId?: Prisma.IntFilter<"StockBalance"> | number avgCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string + product?: Prisma.XOR + inventory?: Prisma.XOR } export type StockBalanceOrderByWithRelationInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - updatedAt?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + product?: Prisma.ProductOrderByWithRelationInput + inventory?: Prisma.InventoryOrderByWithRelationInput } export type StockBalanceWhereUniqueInput = Prisma.AtLeast<{ - ProductId?: number + id?: number + productId_inventoryId?: Prisma.StockBalanceProductIdInventoryIdCompoundUniqueInput AND?: Prisma.StockBalanceWhereInput | Prisma.StockBalanceWhereInput[] OR?: Prisma.StockBalanceWhereInput[] NOT?: Prisma.StockBalanceWhereInput | Prisma.StockBalanceWhereInput[] + productId?: Prisma.IntFilter<"StockBalance"> | number + inventoryId?: Prisma.IntFilter<"StockBalance"> | number quantity?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string avgCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string -}, "ProductId"> + totalCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string + product?: Prisma.XOR + inventory?: Prisma.XOR +}, "id" | "productId_inventoryId"> export type StockBalanceOrderByWithAggregationInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - updatedAt?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder _count?: Prisma.StockBalanceCountOrderByAggregateInput _avg?: Prisma.StockBalanceAvgOrderByAggregateInput _max?: Prisma.StockBalanceMaxOrderByAggregateInput @@ -266,138 +314,469 @@ export type StockBalanceScalarWhereWithAggregatesInput = { AND?: Prisma.StockBalanceScalarWhereWithAggregatesInput | Prisma.StockBalanceScalarWhereWithAggregatesInput[] OR?: Prisma.StockBalanceScalarWhereWithAggregatesInput[] NOT?: Prisma.StockBalanceScalarWhereWithAggregatesInput | Prisma.StockBalanceScalarWhereWithAggregatesInput[] + id?: Prisma.IntWithAggregatesFilter<"StockBalance"> | number + productId?: Prisma.IntWithAggregatesFilter<"StockBalance"> | number + inventoryId?: Prisma.IntWithAggregatesFilter<"StockBalance"> | number quantity?: Prisma.DecimalWithAggregatesFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalWithAggregatesFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeWithAggregatesFilter<"StockBalance"> | Date | string - ProductId?: Prisma.IntWithAggregatesFilter<"StockBalance"> | number avgCost?: Prisma.DecimalWithAggregatesFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalWithAggregatesFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeWithAggregatesFilter<"StockBalance"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"StockBalance"> | Date | string } export type StockBalanceCreateInput = { - quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string updatedAt?: Date | string - ProductId: number - avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + product: Prisma.ProductCreateNestedOneWithoutStockBalancesInput + inventory: Prisma.InventoryCreateNestedOneWithoutStockBalancesInput } export type StockBalanceUncheckedCreateInput = { - quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + id?: number + productId: number + inventoryId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string updatedAt?: Date | string - ProductId: number - avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string } export type StockBalanceUpdateInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - ProductId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + product?: Prisma.ProductUpdateOneRequiredWithoutStockBalancesNestedInput + inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockBalancesNestedInput } export type StockBalanceUncheckedUpdateInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - ProductId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string } export type StockBalanceCreateManyInput = { - quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + id?: number + productId: number + inventoryId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string updatedAt?: Date | string - ProductId: number - avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string } export type StockBalanceUpdateManyMutationInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - ProductId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string } export type StockBalanceUncheckedUpdateManyInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - ProductId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type StockBalanceListRelationFilter = { + every?: Prisma.StockBalanceWhereInput + some?: Prisma.StockBalanceWhereInput + none?: Prisma.StockBalanceWhereInput +} + +export type StockBalanceOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type StockBalanceProductIdInventoryIdCompoundUniqueInput = { + productId: number + inventoryId: number } export type StockBalanceCountOrderByAggregateInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - updatedAt?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder } export type StockBalanceAvgOrderByAggregateInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder } export type StockBalanceMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - updatedAt?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder } export type StockBalanceMinOrderByAggregateInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - updatedAt?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder } export type StockBalanceSumOrderByAggregateInput = { + id?: Prisma.SortOrder + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder quantity?: Prisma.SortOrder - totalCost?: Prisma.SortOrder - ProductId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + totalCost?: Prisma.SortOrder +} + +export type StockBalanceCreateNestedManyWithoutProductInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutProductInput[] | Prisma.StockBalanceUncheckedCreateWithoutProductInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutProductInput | Prisma.StockBalanceCreateOrConnectWithoutProductInput[] + createMany?: Prisma.StockBalanceCreateManyProductInputEnvelope + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] +} + +export type StockBalanceUncheckedCreateNestedManyWithoutProductInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutProductInput[] | Prisma.StockBalanceUncheckedCreateWithoutProductInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutProductInput | Prisma.StockBalanceCreateOrConnectWithoutProductInput[] + createMany?: Prisma.StockBalanceCreateManyProductInputEnvelope + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] +} + +export type StockBalanceUpdateManyWithoutProductNestedInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutProductInput[] | Prisma.StockBalanceUncheckedCreateWithoutProductInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutProductInput | Prisma.StockBalanceCreateOrConnectWithoutProductInput[] + upsert?: Prisma.StockBalanceUpsertWithWhereUniqueWithoutProductInput | Prisma.StockBalanceUpsertWithWhereUniqueWithoutProductInput[] + createMany?: Prisma.StockBalanceCreateManyProductInputEnvelope + set?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + disconnect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + delete?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + update?: Prisma.StockBalanceUpdateWithWhereUniqueWithoutProductInput | Prisma.StockBalanceUpdateWithWhereUniqueWithoutProductInput[] + updateMany?: Prisma.StockBalanceUpdateManyWithWhereWithoutProductInput | Prisma.StockBalanceUpdateManyWithWhereWithoutProductInput[] + deleteMany?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] +} + +export type StockBalanceUncheckedUpdateManyWithoutProductNestedInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutProductInput[] | Prisma.StockBalanceUncheckedCreateWithoutProductInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutProductInput | Prisma.StockBalanceCreateOrConnectWithoutProductInput[] + upsert?: Prisma.StockBalanceUpsertWithWhereUniqueWithoutProductInput | Prisma.StockBalanceUpsertWithWhereUniqueWithoutProductInput[] + createMany?: Prisma.StockBalanceCreateManyProductInputEnvelope + set?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + disconnect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + delete?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + update?: Prisma.StockBalanceUpdateWithWhereUniqueWithoutProductInput | Prisma.StockBalanceUpdateWithWhereUniqueWithoutProductInput[] + updateMany?: Prisma.StockBalanceUpdateManyWithWhereWithoutProductInput | Prisma.StockBalanceUpdateManyWithWhereWithoutProductInput[] + deleteMany?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] +} + +export type StockBalanceCreateNestedManyWithoutInventoryInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutInventoryInput[] | Prisma.StockBalanceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutInventoryInput | Prisma.StockBalanceCreateOrConnectWithoutInventoryInput[] + createMany?: Prisma.StockBalanceCreateManyInventoryInputEnvelope + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] +} + +export type StockBalanceUncheckedCreateNestedManyWithoutInventoryInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutInventoryInput[] | Prisma.StockBalanceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutInventoryInput | Prisma.StockBalanceCreateOrConnectWithoutInventoryInput[] + createMany?: Prisma.StockBalanceCreateManyInventoryInputEnvelope + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] +} + +export type StockBalanceUpdateManyWithoutInventoryNestedInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutInventoryInput[] | Prisma.StockBalanceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutInventoryInput | Prisma.StockBalanceCreateOrConnectWithoutInventoryInput[] + upsert?: Prisma.StockBalanceUpsertWithWhereUniqueWithoutInventoryInput | Prisma.StockBalanceUpsertWithWhereUniqueWithoutInventoryInput[] + createMany?: Prisma.StockBalanceCreateManyInventoryInputEnvelope + set?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + disconnect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + delete?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + update?: Prisma.StockBalanceUpdateWithWhereUniqueWithoutInventoryInput | Prisma.StockBalanceUpdateWithWhereUniqueWithoutInventoryInput[] + updateMany?: Prisma.StockBalanceUpdateManyWithWhereWithoutInventoryInput | Prisma.StockBalanceUpdateManyWithWhereWithoutInventoryInput[] + deleteMany?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] +} + +export type StockBalanceUncheckedUpdateManyWithoutInventoryNestedInput = { + create?: Prisma.XOR | Prisma.StockBalanceCreateWithoutInventoryInput[] | Prisma.StockBalanceUncheckedCreateWithoutInventoryInput[] + connectOrCreate?: Prisma.StockBalanceCreateOrConnectWithoutInventoryInput | Prisma.StockBalanceCreateOrConnectWithoutInventoryInput[] + upsert?: Prisma.StockBalanceUpsertWithWhereUniqueWithoutInventoryInput | Prisma.StockBalanceUpsertWithWhereUniqueWithoutInventoryInput[] + createMany?: Prisma.StockBalanceCreateManyInventoryInputEnvelope + set?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + disconnect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + delete?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + connect?: Prisma.StockBalanceWhereUniqueInput | Prisma.StockBalanceWhereUniqueInput[] + update?: Prisma.StockBalanceUpdateWithWhereUniqueWithoutInventoryInput | Prisma.StockBalanceUpdateWithWhereUniqueWithoutInventoryInput[] + updateMany?: Prisma.StockBalanceUpdateManyWithWhereWithoutInventoryInput | Prisma.StockBalanceUpdateManyWithWhereWithoutInventoryInput[] + deleteMany?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] +} + +export type StockBalanceCreateWithoutProductInput = { + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string + inventory: Prisma.InventoryCreateNestedOneWithoutStockBalancesInput +} + +export type StockBalanceUncheckedCreateWithoutProductInput = { + id?: number + inventoryId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type StockBalanceCreateOrConnectWithoutProductInput = { + where: Prisma.StockBalanceWhereUniqueInput + create: Prisma.XOR +} + +export type StockBalanceCreateManyProductInputEnvelope = { + data: Prisma.StockBalanceCreateManyProductInput | Prisma.StockBalanceCreateManyProductInput[] + skipDuplicates?: boolean +} + +export type StockBalanceUpsertWithWhereUniqueWithoutProductInput = { + where: Prisma.StockBalanceWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type StockBalanceUpdateWithWhereUniqueWithoutProductInput = { + where: Prisma.StockBalanceWhereUniqueInput + data: Prisma.XOR +} + +export type StockBalanceUpdateManyWithWhereWithoutProductInput = { + where: Prisma.StockBalanceScalarWhereInput + data: Prisma.XOR +} + +export type StockBalanceScalarWhereInput = { + AND?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] + OR?: Prisma.StockBalanceScalarWhereInput[] + NOT?: Prisma.StockBalanceScalarWhereInput | Prisma.StockBalanceScalarWhereInput[] + id?: Prisma.IntFilter<"StockBalance"> | number + productId?: Prisma.IntFilter<"StockBalance"> | number + inventoryId?: Prisma.IntFilter<"StockBalance"> | number + quantity?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFilter<"StockBalance"> | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"StockBalance"> | Date | string +} + +export type StockBalanceCreateWithoutInventoryInput = { + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string + product: Prisma.ProductCreateNestedOneWithoutStockBalancesInput +} + +export type StockBalanceUncheckedCreateWithoutInventoryInput = { + id?: number + productId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type StockBalanceCreateOrConnectWithoutInventoryInput = { + where: Prisma.StockBalanceWhereUniqueInput + create: Prisma.XOR +} + +export type StockBalanceCreateManyInventoryInputEnvelope = { + data: Prisma.StockBalanceCreateManyInventoryInput | Prisma.StockBalanceCreateManyInventoryInput[] + skipDuplicates?: boolean +} + +export type StockBalanceUpsertWithWhereUniqueWithoutInventoryInput = { + where: Prisma.StockBalanceWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type StockBalanceUpdateWithWhereUniqueWithoutInventoryInput = { + where: Prisma.StockBalanceWhereUniqueInput + data: Prisma.XOR +} + +export type StockBalanceUpdateManyWithWhereWithoutInventoryInput = { + where: Prisma.StockBalanceScalarWhereInput + data: Prisma.XOR +} + +export type StockBalanceCreateManyProductInput = { + id?: number + inventoryId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type StockBalanceUpdateWithoutProductInput = { + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockBalancesNestedInput +} + +export type StockBalanceUncheckedUpdateWithoutProductInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type StockBalanceUncheckedUpdateManyWithoutProductInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type StockBalanceCreateManyInventoryInput = { + id?: number + productId: number + quantity?: runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type StockBalanceUpdateWithoutInventoryInput = { + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + product?: Prisma.ProductUpdateOneRequiredWithoutStockBalancesNestedInput +} + +export type StockBalanceUncheckedUpdateWithoutInventoryInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + productId?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type StockBalanceUncheckedUpdateManyWithoutInventoryInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + productId?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string } export type StockBalanceSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + productId?: boolean + inventoryId?: boolean quantity?: boolean - totalCost?: boolean - updatedAt?: boolean - ProductId?: boolean avgCost?: boolean + totalCost?: boolean + createdAt?: boolean + updatedAt?: boolean + product?: boolean | Prisma.ProductDefaultArgs + inventory?: boolean | Prisma.InventoryDefaultArgs }, ExtArgs["result"]["stockBalance"]> export type StockBalanceSelectScalar = { + id?: boolean + productId?: boolean + inventoryId?: boolean quantity?: boolean - totalCost?: boolean - updatedAt?: boolean - ProductId?: boolean avgCost?: boolean + totalCost?: boolean + createdAt?: boolean + updatedAt?: boolean } -export type StockBalanceOmit = runtime.Types.Extensions.GetOmit<"quantity" | "totalCost" | "updatedAt" | "ProductId" | "avgCost", ExtArgs["result"]["stockBalance"]> +export type StockBalanceOmit = runtime.Types.Extensions.GetOmit<"id" | "productId" | "inventoryId" | "quantity" | "avgCost" | "totalCost" | "createdAt" | "updatedAt", ExtArgs["result"]["stockBalance"]> +export type StockBalanceInclude = { + product?: boolean | Prisma.ProductDefaultArgs + inventory?: boolean | Prisma.InventoryDefaultArgs +} export type $StockBalancePayload = { name: "StockBalance" - objects: {} + objects: { + product: Prisma.$ProductPayload + inventory: Prisma.$InventoryPayload + } scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: number + productId: number + inventoryId: number quantity: runtime.Decimal - totalCost: runtime.Decimal - updatedAt: Date - ProductId: number avgCost: runtime.Decimal + totalCost: runtime.Decimal + createdAt: Date + updatedAt: Date }, ExtArgs["result"]["stockBalance"]> composites: {} } @@ -481,8 +860,8 @@ export interface StockBalanceDelegate(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> @@ -738,6 +1117,8 @@ readonly fields: StockBalanceFieldRefs; */ export interface Prisma__StockBalanceClient extends Prisma.PrismaPromise { readonly [Symbol.toStringTag]: "PrismaPromise" + product = {}>(args?: Prisma.Subset>): Prisma.Prisma__ProductClient, 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. @@ -767,11 +1148,14 @@ export interface Prisma__StockBalanceClient + readonly productId: Prisma.FieldRef<"StockBalance", 'Int'> + readonly inventoryId: Prisma.FieldRef<"StockBalance", 'Int'> readonly quantity: Prisma.FieldRef<"StockBalance", 'Decimal'> - readonly totalCost: Prisma.FieldRef<"StockBalance", 'Decimal'> - readonly updatedAt: Prisma.FieldRef<"StockBalance", 'DateTime'> - readonly ProductId: Prisma.FieldRef<"StockBalance", 'Int'> readonly avgCost: Prisma.FieldRef<"StockBalance", 'Decimal'> + readonly totalCost: Prisma.FieldRef<"StockBalance", 'Decimal'> + readonly createdAt: Prisma.FieldRef<"StockBalance", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"StockBalance", 'DateTime'> } @@ -788,6 +1172,10 @@ export type StockBalanceFindUniqueArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter, which StockBalance to fetch. */ @@ -806,6 +1194,10 @@ export type StockBalanceFindUniqueOrThrowArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter, which StockBalance to fetch. */ @@ -824,6 +1216,10 @@ export type StockBalanceFindFirstArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter, which StockBalance to fetch. */ @@ -872,6 +1268,10 @@ export type StockBalanceFindFirstOrThrowArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter, which StockBalance to fetch. */ @@ -920,6 +1320,10 @@ export type StockBalanceFindManyArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter, which StockBalances to fetch. */ @@ -963,6 +1367,10 @@ export type StockBalanceCreateArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * The data needed to create a StockBalance. */ @@ -992,6 +1400,10 @@ export type StockBalanceUpdateArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * The data needed to update a StockBalance. */ @@ -1032,6 +1444,10 @@ export type StockBalanceUpsertArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * The filter to search for the StockBalance to update in case it exists. */ @@ -1058,6 +1474,10 @@ export type StockBalanceDeleteArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null /** * Filter which StockBalance to delete. */ @@ -1090,4 +1510,8 @@ export type StockBalanceDefaultArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockBalanceInclude | null } diff --git a/src/generated/prisma/models/StockMovement.ts b/src/generated/prisma/models/StockMovement.ts index 26508d4..ad68358 100644 --- a/src/generated/prisma/models/StockMovement.ts +++ b/src/generated/prisma/models/StockMovement.ts @@ -34,6 +34,8 @@ export type StockMovementAvgAggregateOutputType = { productId: number | null inventoryId: number | null avgCost: runtime.Decimal | null + remainedInStock: runtime.Decimal | null + supplierId: number | null } export type StockMovementSumAggregateOutputType = { @@ -44,6 +46,8 @@ export type StockMovementSumAggregateOutputType = { productId: number | null inventoryId: number | null avgCost: runtime.Decimal | null + remainedInStock: runtime.Decimal | null + supplierId: number | null } export type StockMovementMinAggregateOutputType = { @@ -58,6 +62,8 @@ export type StockMovementMinAggregateOutputType = { productId: number | null inventoryId: number | null avgCost: runtime.Decimal | null + remainedInStock: runtime.Decimal | null + supplierId: number | null } export type StockMovementMaxAggregateOutputType = { @@ -72,6 +78,8 @@ export type StockMovementMaxAggregateOutputType = { productId: number | null inventoryId: number | null avgCost: runtime.Decimal | null + remainedInStock: runtime.Decimal | null + supplierId: number | null } export type StockMovementCountAggregateOutputType = { @@ -86,6 +94,8 @@ export type StockMovementCountAggregateOutputType = { productId: number inventoryId: number avgCost: number + remainedInStock: number + supplierId: number _all: number } @@ -98,6 +108,8 @@ export type StockMovementAvgAggregateInputType = { productId?: true inventoryId?: true avgCost?: true + remainedInStock?: true + supplierId?: true } export type StockMovementSumAggregateInputType = { @@ -108,6 +120,8 @@ export type StockMovementSumAggregateInputType = { productId?: true inventoryId?: true avgCost?: true + remainedInStock?: true + supplierId?: true } export type StockMovementMinAggregateInputType = { @@ -122,6 +136,8 @@ export type StockMovementMinAggregateInputType = { productId?: true inventoryId?: true avgCost?: true + remainedInStock?: true + supplierId?: true } export type StockMovementMaxAggregateInputType = { @@ -136,6 +152,8 @@ export type StockMovementMaxAggregateInputType = { productId?: true inventoryId?: true avgCost?: true + remainedInStock?: true + supplierId?: true } export type StockMovementCountAggregateInputType = { @@ -150,6 +168,8 @@ export type StockMovementCountAggregateInputType = { productId?: true inventoryId?: true avgCost?: true + remainedInStock?: true + supplierId?: true _all?: true } @@ -251,6 +271,8 @@ export type StockMovementGroupByOutputType = { productId: number inventoryId: number avgCost: runtime.Decimal + remainedInStock: runtime.Decimal + supplierId: number | null _count: StockMovementCountAggregateOutputType | null _avg: StockMovementAvgAggregateOutputType | null _sum: StockMovementSumAggregateOutputType | null @@ -288,8 +310,11 @@ export type StockMovementWhereInput = { productId?: Prisma.IntFilter<"StockMovement"> | number inventoryId?: Prisma.IntFilter<"StockMovement"> | number avgCost?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.IntNullableFilter<"StockMovement"> | number | null inventory?: Prisma.XOR product?: Prisma.XOR + supplier?: Prisma.XOR | null } export type StockMovementOrderByWithRelationInput = { @@ -304,8 +329,11 @@ export type StockMovementOrderByWithRelationInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrderInput | Prisma.SortOrder inventory?: Prisma.InventoryOrderByWithRelationInput product?: Prisma.ProductOrderByWithRelationInput + supplier?: Prisma.SupplierOrderByWithRelationInput _relevance?: Prisma.StockMovementOrderByRelevanceInput } @@ -324,8 +352,11 @@ export type StockMovementWhereUniqueInput = Prisma.AtLeast<{ productId?: Prisma.IntFilter<"StockMovement"> | number inventoryId?: Prisma.IntFilter<"StockMovement"> | number avgCost?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.IntNullableFilter<"StockMovement"> | number | null inventory?: Prisma.XOR product?: Prisma.XOR + supplier?: Prisma.XOR | null }, "id"> export type StockMovementOrderByWithAggregationInput = { @@ -340,6 +371,8 @@ export type StockMovementOrderByWithAggregationInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrderInput | Prisma.SortOrder _count?: Prisma.StockMovementCountOrderByAggregateInput _avg?: Prisma.StockMovementAvgOrderByAggregateInput _max?: Prisma.StockMovementMaxOrderByAggregateInput @@ -362,6 +395,8 @@ export type StockMovementScalarWhereWithAggregatesInput = { productId?: Prisma.IntWithAggregatesFilter<"StockMovement"> | number inventoryId?: Prisma.IntWithAggregatesFilter<"StockMovement"> | number avgCost?: Prisma.DecimalWithAggregatesFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalWithAggregatesFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.IntNullableWithAggregatesFilter<"StockMovement"> | number | null } export type StockMovementCreateInput = { @@ -373,8 +408,10 @@ export type StockMovementCreateInput = { referenceId: string createdAt?: Date | string avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string inventory: Prisma.InventoryCreateNestedOneWithoutStockMovementsInput product: Prisma.ProductCreateNestedOneWithoutStockMovementsInput + supplier?: Prisma.SupplierCreateNestedOneWithoutStockMovementsInput } export type StockMovementUncheckedCreateInput = { @@ -389,6 +426,8 @@ export type StockMovementUncheckedCreateInput = { productId: number inventoryId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementUpdateInput = { @@ -400,8 +439,10 @@ export type StockMovementUpdateInput = { referenceId?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockMovementsNestedInput product?: Prisma.ProductUpdateOneRequiredWithoutStockMovementsNestedInput + supplier?: Prisma.SupplierUpdateOneWithoutStockMovementsNestedInput } export type StockMovementUncheckedUpdateInput = { @@ -416,6 +457,8 @@ export type StockMovementUncheckedUpdateInput = { productId?: Prisma.IntFieldUpdateOperationsInput | number inventoryId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } export type StockMovementCreateManyInput = { @@ -430,6 +473,8 @@ export type StockMovementCreateManyInput = { productId: number inventoryId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementUpdateManyMutationInput = { @@ -441,6 +486,7 @@ export type StockMovementUpdateManyMutationInput = { referenceId?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string } export type StockMovementUncheckedUpdateManyInput = { @@ -455,6 +501,8 @@ export type StockMovementUncheckedUpdateManyInput = { productId?: Prisma.IntFieldUpdateOperationsInput | number inventoryId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } export type StockMovementListRelationFilter = { @@ -485,6 +533,8 @@ export type StockMovementCountOrderByAggregateInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrder } export type StockMovementAvgOrderByAggregateInput = { @@ -495,6 +545,8 @@ export type StockMovementAvgOrderByAggregateInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrder } export type StockMovementMaxOrderByAggregateInput = { @@ -509,6 +561,8 @@ export type StockMovementMaxOrderByAggregateInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrder } export type StockMovementMinOrderByAggregateInput = { @@ -523,6 +577,8 @@ export type StockMovementMinOrderByAggregateInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrder } export type StockMovementSumOrderByAggregateInput = { @@ -533,6 +589,8 @@ export type StockMovementSumOrderByAggregateInput = { productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder avgCost?: Prisma.SortOrder + remainedInStock?: Prisma.SortOrder + supplierId?: Prisma.SortOrder } export type StockMovementCreateNestedManyWithoutProductInput = { @@ -577,6 +635,48 @@ export type StockMovementUncheckedUpdateManyWithoutProductNestedInput = { deleteMany?: Prisma.StockMovementScalarWhereInput | Prisma.StockMovementScalarWhereInput[] } +export type StockMovementCreateNestedManyWithoutSupplierInput = { + create?: Prisma.XOR | Prisma.StockMovementCreateWithoutSupplierInput[] | Prisma.StockMovementUncheckedCreateWithoutSupplierInput[] + connectOrCreate?: Prisma.StockMovementCreateOrConnectWithoutSupplierInput | Prisma.StockMovementCreateOrConnectWithoutSupplierInput[] + createMany?: Prisma.StockMovementCreateManySupplierInputEnvelope + connect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] +} + +export type StockMovementUncheckedCreateNestedManyWithoutSupplierInput = { + create?: Prisma.XOR | Prisma.StockMovementCreateWithoutSupplierInput[] | Prisma.StockMovementUncheckedCreateWithoutSupplierInput[] + connectOrCreate?: Prisma.StockMovementCreateOrConnectWithoutSupplierInput | Prisma.StockMovementCreateOrConnectWithoutSupplierInput[] + createMany?: Prisma.StockMovementCreateManySupplierInputEnvelope + connect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] +} + +export type StockMovementUpdateManyWithoutSupplierNestedInput = { + create?: Prisma.XOR | Prisma.StockMovementCreateWithoutSupplierInput[] | Prisma.StockMovementUncheckedCreateWithoutSupplierInput[] + connectOrCreate?: Prisma.StockMovementCreateOrConnectWithoutSupplierInput | Prisma.StockMovementCreateOrConnectWithoutSupplierInput[] + upsert?: Prisma.StockMovementUpsertWithWhereUniqueWithoutSupplierInput | Prisma.StockMovementUpsertWithWhereUniqueWithoutSupplierInput[] + createMany?: Prisma.StockMovementCreateManySupplierInputEnvelope + set?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + disconnect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + delete?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + connect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + update?: Prisma.StockMovementUpdateWithWhereUniqueWithoutSupplierInput | Prisma.StockMovementUpdateWithWhereUniqueWithoutSupplierInput[] + updateMany?: Prisma.StockMovementUpdateManyWithWhereWithoutSupplierInput | Prisma.StockMovementUpdateManyWithWhereWithoutSupplierInput[] + deleteMany?: Prisma.StockMovementScalarWhereInput | Prisma.StockMovementScalarWhereInput[] +} + +export type StockMovementUncheckedUpdateManyWithoutSupplierNestedInput = { + create?: Prisma.XOR | Prisma.StockMovementCreateWithoutSupplierInput[] | Prisma.StockMovementUncheckedCreateWithoutSupplierInput[] + connectOrCreate?: Prisma.StockMovementCreateOrConnectWithoutSupplierInput | Prisma.StockMovementCreateOrConnectWithoutSupplierInput[] + upsert?: Prisma.StockMovementUpsertWithWhereUniqueWithoutSupplierInput | Prisma.StockMovementUpsertWithWhereUniqueWithoutSupplierInput[] + createMany?: Prisma.StockMovementCreateManySupplierInputEnvelope + set?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + disconnect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + delete?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + connect?: Prisma.StockMovementWhereUniqueInput | Prisma.StockMovementWhereUniqueInput[] + update?: Prisma.StockMovementUpdateWithWhereUniqueWithoutSupplierInput | Prisma.StockMovementUpdateWithWhereUniqueWithoutSupplierInput[] + updateMany?: Prisma.StockMovementUpdateManyWithWhereWithoutSupplierInput | Prisma.StockMovementUpdateManyWithWhereWithoutSupplierInput[] + deleteMany?: Prisma.StockMovementScalarWhereInput | Prisma.StockMovementScalarWhereInput[] +} + export type StockMovementCreateNestedManyWithoutInventoryInput = { create?: Prisma.XOR | Prisma.StockMovementCreateWithoutInventoryInput[] | Prisma.StockMovementUncheckedCreateWithoutInventoryInput[] connectOrCreate?: Prisma.StockMovementCreateOrConnectWithoutInventoryInput | Prisma.StockMovementCreateOrConnectWithoutInventoryInput[] @@ -636,7 +736,9 @@ export type StockMovementCreateWithoutProductInput = { referenceId: string createdAt?: Date | string avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string inventory: Prisma.InventoryCreateNestedOneWithoutStockMovementsInput + supplier?: Prisma.SupplierCreateNestedOneWithoutStockMovementsInput } export type StockMovementUncheckedCreateWithoutProductInput = { @@ -650,6 +752,8 @@ export type StockMovementUncheckedCreateWithoutProductInput = { createdAt?: Date | string inventoryId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementCreateOrConnectWithoutProductInput = { @@ -693,6 +797,63 @@ export type StockMovementScalarWhereInput = { productId?: Prisma.IntFilter<"StockMovement"> | number inventoryId?: Prisma.IntFilter<"StockMovement"> | number avgCost?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFilter<"StockMovement"> | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.IntNullableFilter<"StockMovement"> | number | null +} + +export type StockMovementCreateWithoutSupplierInput = { + type: $Enums.MovementType + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + fee: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType: $Enums.MovementReferenceType + referenceId: string + createdAt?: Date | string + avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + inventory: Prisma.InventoryCreateNestedOneWithoutStockMovementsInput + product: Prisma.ProductCreateNestedOneWithoutStockMovementsInput +} + +export type StockMovementUncheckedCreateWithoutSupplierInput = { + id?: number + type: $Enums.MovementType + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + fee: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType: $Enums.MovementReferenceType + referenceId: string + createdAt?: Date | string + productId: number + inventoryId: number + avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string +} + +export type StockMovementCreateOrConnectWithoutSupplierInput = { + where: Prisma.StockMovementWhereUniqueInput + create: Prisma.XOR +} + +export type StockMovementCreateManySupplierInputEnvelope = { + data: Prisma.StockMovementCreateManySupplierInput | Prisma.StockMovementCreateManySupplierInput[] + skipDuplicates?: boolean +} + +export type StockMovementUpsertWithWhereUniqueWithoutSupplierInput = { + where: Prisma.StockMovementWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type StockMovementUpdateWithWhereUniqueWithoutSupplierInput = { + where: Prisma.StockMovementWhereUniqueInput + data: Prisma.XOR +} + +export type StockMovementUpdateManyWithWhereWithoutSupplierInput = { + where: Prisma.StockMovementScalarWhereInput + data: Prisma.XOR } export type StockMovementCreateWithoutInventoryInput = { @@ -704,7 +865,9 @@ export type StockMovementCreateWithoutInventoryInput = { referenceId: string createdAt?: Date | string avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string product: Prisma.ProductCreateNestedOneWithoutStockMovementsInput + supplier?: Prisma.SupplierCreateNestedOneWithoutStockMovementsInput } export type StockMovementUncheckedCreateWithoutInventoryInput = { @@ -718,6 +881,8 @@ export type StockMovementUncheckedCreateWithoutInventoryInput = { createdAt?: Date | string productId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementCreateOrConnectWithoutInventoryInput = { @@ -757,6 +922,8 @@ export type StockMovementCreateManyProductInput = { createdAt?: Date | string inventoryId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementUpdateWithoutProductInput = { @@ -768,7 +935,9 @@ export type StockMovementUpdateWithoutProductInput = { referenceId?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockMovementsNestedInput + supplier?: Prisma.SupplierUpdateOneWithoutStockMovementsNestedInput } export type StockMovementUncheckedUpdateWithoutProductInput = { @@ -782,6 +951,8 @@ export type StockMovementUncheckedUpdateWithoutProductInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string inventoryId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } export type StockMovementUncheckedUpdateManyWithoutProductInput = { @@ -795,6 +966,67 @@ export type StockMovementUncheckedUpdateManyWithoutProductInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string inventoryId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null +} + +export type StockMovementCreateManySupplierInput = { + id?: number + type: $Enums.MovementType + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + fee: runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost: runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType: $Enums.MovementReferenceType + referenceId: string + createdAt?: Date | string + productId: number + inventoryId: number + avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string +} + +export type StockMovementUpdateWithoutSupplierInput = { + type?: Prisma.EnumMovementTypeFieldUpdateOperationsInput | $Enums.MovementType + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + fee?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType?: Prisma.EnumMovementReferenceTypeFieldUpdateOperationsInput | $Enums.MovementReferenceType + referenceId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockMovementsNestedInput + product?: Prisma.ProductUpdateOneRequiredWithoutStockMovementsNestedInput +} + +export type StockMovementUncheckedUpdateWithoutSupplierInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + type?: Prisma.EnumMovementTypeFieldUpdateOperationsInput | $Enums.MovementType + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + fee?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType?: Prisma.EnumMovementReferenceTypeFieldUpdateOperationsInput | $Enums.MovementReferenceType + referenceId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string +} + +export type StockMovementUncheckedUpdateManyWithoutSupplierInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + type?: Prisma.EnumMovementTypeFieldUpdateOperationsInput | $Enums.MovementType + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + fee?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + totalCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + referenceType?: Prisma.EnumMovementReferenceTypeFieldUpdateOperationsInput | $Enums.MovementReferenceType + referenceId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number + avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string } export type StockMovementCreateManyInventoryInput = { @@ -808,6 +1040,8 @@ export type StockMovementCreateManyInventoryInput = { createdAt?: Date | string productId: number avgCost: runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: number | null } export type StockMovementUpdateWithoutInventoryInput = { @@ -819,7 +1053,9 @@ export type StockMovementUpdateWithoutInventoryInput = { referenceId?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string product?: Prisma.ProductUpdateOneRequiredWithoutStockMovementsNestedInput + supplier?: Prisma.SupplierUpdateOneWithoutStockMovementsNestedInput } export type StockMovementUncheckedUpdateWithoutInventoryInput = { @@ -833,6 +1069,8 @@ export type StockMovementUncheckedUpdateWithoutInventoryInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } export type StockMovementUncheckedUpdateManyWithoutInventoryInput = { @@ -846,6 +1084,8 @@ export type StockMovementUncheckedUpdateManyWithoutInventoryInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number avgCost?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + remainedInStock?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + supplierId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } @@ -862,8 +1102,11 @@ export type StockMovementSelect product?: boolean | Prisma.ProductDefaultArgs + supplier?: boolean | Prisma.StockMovement$supplierArgs }, ExtArgs["result"]["stockMovement"]> @@ -880,12 +1123,15 @@ export type StockMovementSelectScalar = { productId?: boolean inventoryId?: boolean avgCost?: boolean + remainedInStock?: boolean + supplierId?: boolean } -export type StockMovementOmit = runtime.Types.Extensions.GetOmit<"id" | "type" | "quantity" | "fee" | "totalCost" | "referenceType" | "referenceId" | "createdAt" | "productId" | "inventoryId" | "avgCost", ExtArgs["result"]["stockMovement"]> +export type StockMovementOmit = runtime.Types.Extensions.GetOmit<"id" | "type" | "quantity" | "fee" | "totalCost" | "referenceType" | "referenceId" | "createdAt" | "productId" | "inventoryId" | "avgCost" | "remainedInStock" | "supplierId", ExtArgs["result"]["stockMovement"]> export type StockMovementInclude = { inventory?: boolean | Prisma.InventoryDefaultArgs product?: boolean | Prisma.ProductDefaultArgs + supplier?: boolean | Prisma.StockMovement$supplierArgs } export type $StockMovementPayload = { @@ -893,6 +1139,7 @@ export type $StockMovementPayload product: Prisma.$ProductPayload + supplier: Prisma.$SupplierPayload | null } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -906,6 +1153,8 @@ export type $StockMovementPayload composites: {} } @@ -1248,6 +1497,7 @@ export interface Prisma__StockMovementClient = {}>(args?: Prisma.Subset>): Prisma.Prisma__InventoryClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> product = {}>(args?: Prisma.Subset>): Prisma.Prisma__ProductClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + supplier = {}>(args?: Prisma.Subset>): Prisma.Prisma__SupplierClient, 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. @@ -1288,6 +1538,8 @@ export interface StockMovementFieldRefs { readonly productId: Prisma.FieldRef<"StockMovement", 'Int'> readonly inventoryId: Prisma.FieldRef<"StockMovement", 'Int'> readonly avgCost: Prisma.FieldRef<"StockMovement", 'Decimal'> + readonly remainedInStock: Prisma.FieldRef<"StockMovement", 'Decimal'> + readonly supplierId: Prisma.FieldRef<"StockMovement", 'Int'> } @@ -1630,6 +1882,25 @@ export type StockMovementDeleteManyArgs = { + /** + * Select specific fields to fetch from the Supplier + */ + select?: Prisma.SupplierSelect | null + /** + * Omit specific fields from the Supplier + */ + omit?: Prisma.SupplierOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SupplierInclude | null + where?: Prisma.SupplierWhereInput +} + /** * StockMovement without action */ diff --git a/src/generated/prisma/models/Supplier.ts b/src/generated/prisma/models/Supplier.ts index 994b18f..e91de76 100644 --- a/src/generated/prisma/models/Supplier.ts +++ b/src/generated/prisma/models/Supplier.ts @@ -282,6 +282,7 @@ export type SupplierWhereInput = { deletedAt?: Prisma.DateTimeNullableFilter<"Supplier"> | Date | string | null productCharges?: Prisma.ProductChargeListRelationFilter purchaseReceipts?: Prisma.PurchaseReceiptListRelationFilter + stockMovements?: Prisma.StockMovementListRelationFilter } export type SupplierOrderByWithRelationInput = { @@ -300,6 +301,7 @@ export type SupplierOrderByWithRelationInput = { deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder productCharges?: Prisma.ProductChargeOrderByRelationAggregateInput purchaseReceipts?: Prisma.PurchaseReceiptOrderByRelationAggregateInput + stockMovements?: Prisma.StockMovementOrderByRelationAggregateInput _relevance?: Prisma.SupplierOrderByRelevanceInput } @@ -322,6 +324,7 @@ export type SupplierWhereUniqueInput = Prisma.AtLeast<{ deletedAt?: Prisma.DateTimeNullableFilter<"Supplier"> | Date | string | null productCharges?: Prisma.ProductChargeListRelationFilter purchaseReceipts?: Prisma.PurchaseReceiptListRelationFilter + stockMovements?: Prisma.StockMovementListRelationFilter }, "id" | "mobileNumber"> export type SupplierOrderByWithAggregationInput = { @@ -379,6 +382,7 @@ export type SupplierCreateInput = { deletedAt?: Date | string | null productCharges?: Prisma.ProductChargeCreateNestedManyWithoutSupplierInput purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementCreateNestedManyWithoutSupplierInput } export type SupplierUncheckedCreateInput = { @@ -397,6 +401,7 @@ export type SupplierUncheckedCreateInput = { deletedAt?: Date | string | null productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutSupplierInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutSupplierInput } export type SupplierUpdateInput = { @@ -414,6 +419,7 @@ export type SupplierUpdateInput = { deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null productCharges?: Prisma.ProductChargeUpdateManyWithoutSupplierNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUpdateManyWithoutSupplierNestedInput } export type SupplierUncheckedUpdateInput = { @@ -432,6 +438,7 @@ export type SupplierUncheckedUpdateInput = { deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutSupplierNestedInput purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutSupplierNestedInput } export type SupplierCreateManyInput = { @@ -548,6 +555,11 @@ export type SupplierScalarRelationFilter = { isNot?: Prisma.SupplierWhereInput } +export type SupplierNullableScalarRelationFilter = { + is?: Prisma.SupplierWhereInput | null + isNot?: Prisma.SupplierWhereInput | null +} + export type SupplierCreateNestedOneWithoutProductChargesInput = { create?: Prisma.XOR connectOrCreate?: Prisma.SupplierCreateOrConnectWithoutProductChargesInput @@ -576,6 +588,22 @@ export type SupplierUpdateOneRequiredWithoutPurchaseReceiptsNestedInput = { update?: Prisma.XOR, Prisma.SupplierUncheckedUpdateWithoutPurchaseReceiptsInput> } +export type SupplierCreateNestedOneWithoutStockMovementsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.SupplierCreateOrConnectWithoutStockMovementsInput + connect?: Prisma.SupplierWhereUniqueInput +} + +export type SupplierUpdateOneWithoutStockMovementsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.SupplierCreateOrConnectWithoutStockMovementsInput + upsert?: Prisma.SupplierUpsertWithoutStockMovementsInput + disconnect?: Prisma.SupplierWhereInput | boolean + delete?: Prisma.SupplierWhereInput | boolean + connect?: Prisma.SupplierWhereUniqueInput + update?: Prisma.XOR, Prisma.SupplierUncheckedUpdateWithoutStockMovementsInput> +} + export type SupplierCreateWithoutProductChargesInput = { firstName: string lastName: string @@ -590,6 +618,7 @@ export type SupplierCreateWithoutProductChargesInput = { updatedAt?: Date | string deletedAt?: Date | string | null purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementCreateNestedManyWithoutSupplierInput } export type SupplierUncheckedCreateWithoutProductChargesInput = { @@ -607,6 +636,7 @@ export type SupplierUncheckedCreateWithoutProductChargesInput = { updatedAt?: Date | string deletedAt?: Date | string | null purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutSupplierInput } export type SupplierCreateOrConnectWithoutProductChargesInput = { @@ -639,6 +669,7 @@ export type SupplierUpdateWithoutProductChargesInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUpdateManyWithoutSupplierNestedInput } export type SupplierUncheckedUpdateWithoutProductChargesInput = { @@ -656,6 +687,7 @@ export type SupplierUncheckedUpdateWithoutProductChargesInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutSupplierNestedInput } export type SupplierCreateWithoutPurchaseReceiptsInput = { @@ -672,6 +704,7 @@ export type SupplierCreateWithoutPurchaseReceiptsInput = { updatedAt?: Date | string deletedAt?: Date | string | null productCharges?: Prisma.ProductChargeCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementCreateNestedManyWithoutSupplierInput } export type SupplierUncheckedCreateWithoutPurchaseReceiptsInput = { @@ -689,6 +722,7 @@ export type SupplierUncheckedCreateWithoutPurchaseReceiptsInput = { updatedAt?: Date | string deletedAt?: Date | string | null productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutSupplierInput + stockMovements?: Prisma.StockMovementUncheckedCreateNestedManyWithoutSupplierInput } export type SupplierCreateOrConnectWithoutPurchaseReceiptsInput = { @@ -721,6 +755,7 @@ export type SupplierUpdateWithoutPurchaseReceiptsInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null productCharges?: Prisma.ProductChargeUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUpdateManyWithoutSupplierNestedInput } export type SupplierUncheckedUpdateWithoutPurchaseReceiptsInput = { @@ -738,6 +773,93 @@ export type SupplierUncheckedUpdateWithoutPurchaseReceiptsInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutSupplierNestedInput + stockMovements?: Prisma.StockMovementUncheckedUpdateManyWithoutSupplierNestedInput +} + +export type SupplierCreateWithoutStockMovementsInput = { + firstName: string + lastName: string + email?: string | null + mobileNumber: string + address?: string | null + city?: string | null + state?: string | null + country?: string | null + isActive?: boolean + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + productCharges?: Prisma.ProductChargeCreateNestedManyWithoutSupplierInput + purchaseReceipts?: Prisma.PurchaseReceiptCreateNestedManyWithoutSupplierInput +} + +export type SupplierUncheckedCreateWithoutStockMovementsInput = { + id?: number + firstName: string + lastName: string + email?: string | null + mobileNumber: string + address?: string | null + city?: string | null + state?: string | null + country?: string | null + isActive?: boolean + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + productCharges?: Prisma.ProductChargeUncheckedCreateNestedManyWithoutSupplierInput + purchaseReceipts?: Prisma.PurchaseReceiptUncheckedCreateNestedManyWithoutSupplierInput +} + +export type SupplierCreateOrConnectWithoutStockMovementsInput = { + where: Prisma.SupplierWhereUniqueInput + create: Prisma.XOR +} + +export type SupplierUpsertWithoutStockMovementsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.SupplierWhereInput +} + +export type SupplierUpdateToOneWithWhereWithoutStockMovementsInput = { + where?: Prisma.SupplierWhereInput + data: Prisma.XOR +} + +export type SupplierUpdateWithoutStockMovementsInput = { + firstName?: Prisma.StringFieldUpdateOperationsInput | string + lastName?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + mobileNumber?: Prisma.StringFieldUpdateOperationsInput | string + address?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + city?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + state?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + country?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isActive?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + productCharges?: Prisma.ProductChargeUpdateManyWithoutSupplierNestedInput + purchaseReceipts?: Prisma.PurchaseReceiptUpdateManyWithoutSupplierNestedInput +} + +export type SupplierUncheckedUpdateWithoutStockMovementsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + firstName?: Prisma.StringFieldUpdateOperationsInput | string + lastName?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + mobileNumber?: Prisma.StringFieldUpdateOperationsInput | string + address?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + city?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + state?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + country?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isActive?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + productCharges?: Prisma.ProductChargeUncheckedUpdateManyWithoutSupplierNestedInput + purchaseReceipts?: Prisma.PurchaseReceiptUncheckedUpdateManyWithoutSupplierNestedInput } @@ -748,11 +870,13 @@ export type SupplierUncheckedUpdateWithoutPurchaseReceiptsInput = { export type SupplierCountOutputType = { productCharges: number purchaseReceipts: number + stockMovements: number } export type SupplierCountOutputTypeSelect = { productCharges?: boolean | SupplierCountOutputTypeCountProductChargesArgs purchaseReceipts?: boolean | SupplierCountOutputTypeCountPurchaseReceiptsArgs + stockMovements?: boolean | SupplierCountOutputTypeCountStockMovementsArgs } /** @@ -779,6 +903,13 @@ export type SupplierCountOutputTypeCountPurchaseReceiptsArgs = { + where?: Prisma.StockMovementWhereInput +} + export type SupplierSelect = runtime.Types.Extensions.GetSelect<{ id?: boolean @@ -796,6 +927,7 @@ export type SupplierSelect purchaseReceipts?: boolean | Prisma.Supplier$purchaseReceiptsArgs + stockMovements?: boolean | Prisma.Supplier$stockMovementsArgs _count?: boolean | Prisma.SupplierCountOutputTypeDefaultArgs }, ExtArgs["result"]["supplier"]> @@ -821,6 +953,7 @@ export type SupplierOmit = { productCharges?: boolean | Prisma.Supplier$productChargesArgs purchaseReceipts?: boolean | Prisma.Supplier$purchaseReceiptsArgs + stockMovements?: boolean | Prisma.Supplier$stockMovementsArgs _count?: boolean | Prisma.SupplierCountOutputTypeDefaultArgs } @@ -829,6 +962,7 @@ export type $SupplierPayload[] purchaseReceipts: Prisma.$PurchaseReceiptPayload[] + stockMovements: Prisma.$StockMovementPayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -1186,6 +1320,7 @@ export interface Prisma__SupplierClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> purchaseReceipts = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + stockMovements = {}>(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. @@ -1618,6 +1753,30 @@ export type Supplier$purchaseReceiptsArgs = { + /** + * Select specific fields to fetch from the StockMovement + */ + select?: Prisma.StockMovementSelect | null + /** + * Omit specific fields from the StockMovement + */ + omit?: Prisma.StockMovementOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockMovementInclude | null + where?: Prisma.StockMovementWhereInput + orderBy?: Prisma.StockMovementOrderByWithRelationInput | Prisma.StockMovementOrderByWithRelationInput[] + cursor?: Prisma.StockMovementWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.StockMovementScalarFieldEnum | Prisma.StockMovementScalarFieldEnum[] +} + /** * Supplier without action */ diff --git a/src/generated/prisma/models/TriggerLog.ts b/src/generated/prisma/models/TriggerLog.ts new file mode 100644 index 0000000..bc57e4a --- /dev/null +++ b/src/generated/prisma/models/TriggerLog.ts @@ -0,0 +1,1053 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `TriggerLog` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.js" +import type * as Prisma from "../internal/prismaNamespace.js" + +/** + * Model TriggerLog + * + */ +export type TriggerLogModel = runtime.Types.Result.DefaultSelection + +export type AggregateTriggerLog = { + _count: TriggerLogCountAggregateOutputType | null + _avg: TriggerLogAvgAggregateOutputType | null + _sum: TriggerLogSumAggregateOutputType | null + _min: TriggerLogMinAggregateOutputType | null + _max: TriggerLogMaxAggregateOutputType | null +} + +export type TriggerLogAvgAggregateOutputType = { + id: number | null +} + +export type TriggerLogSumAggregateOutputType = { + id: number | null +} + +export type TriggerLogMinAggregateOutputType = { + id: number | null + name: string | null + message: string | null + createdAt: Date | null +} + +export type TriggerLogMaxAggregateOutputType = { + id: number | null + name: string | null + message: string | null + createdAt: Date | null +} + +export type TriggerLogCountAggregateOutputType = { + id: number + name: number + message: number + createdAt: number + _all: number +} + + +export type TriggerLogAvgAggregateInputType = { + id?: true +} + +export type TriggerLogSumAggregateInputType = { + id?: true +} + +export type TriggerLogMinAggregateInputType = { + id?: true + name?: true + message?: true + createdAt?: true +} + +export type TriggerLogMaxAggregateInputType = { + id?: true + name?: true + message?: true + createdAt?: true +} + +export type TriggerLogCountAggregateInputType = { + id?: true + name?: true + message?: true + createdAt?: true + _all?: true +} + +export type TriggerLogAggregateArgs = { + /** + * Filter which TriggerLog to aggregate. + */ + where?: Prisma.TriggerLogWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of TriggerLogs to fetch. + */ + orderBy?: Prisma.TriggerLogOrderByWithRelationInput | Prisma.TriggerLogOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.TriggerLogWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` TriggerLogs from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` TriggerLogs. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned TriggerLogs + **/ + _count?: true | TriggerLogCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: TriggerLogAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: TriggerLogSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: TriggerLogMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: TriggerLogMaxAggregateInputType +} + +export type GetTriggerLogAggregateType = { + [P in keyof T & keyof AggregateTriggerLog]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type TriggerLogGroupByArgs = { + where?: Prisma.TriggerLogWhereInput + orderBy?: Prisma.TriggerLogOrderByWithAggregationInput | Prisma.TriggerLogOrderByWithAggregationInput[] + by: Prisma.TriggerLogScalarFieldEnum[] | Prisma.TriggerLogScalarFieldEnum + having?: Prisma.TriggerLogScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: TriggerLogCountAggregateInputType | true + _avg?: TriggerLogAvgAggregateInputType + _sum?: TriggerLogSumAggregateInputType + _min?: TriggerLogMinAggregateInputType + _max?: TriggerLogMaxAggregateInputType +} + +export type TriggerLogGroupByOutputType = { + id: number + name: string + message: string + createdAt: Date + _count: TriggerLogCountAggregateOutputType | null + _avg: TriggerLogAvgAggregateOutputType | null + _sum: TriggerLogSumAggregateOutputType | null + _min: TriggerLogMinAggregateOutputType | null + _max: TriggerLogMaxAggregateOutputType | null +} + +type GetTriggerLogGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof TriggerLogGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type TriggerLogWhereInput = { + AND?: Prisma.TriggerLogWhereInput | Prisma.TriggerLogWhereInput[] + OR?: Prisma.TriggerLogWhereInput[] + NOT?: Prisma.TriggerLogWhereInput | Prisma.TriggerLogWhereInput[] + id?: Prisma.IntFilter<"TriggerLog"> | number + name?: Prisma.StringFilter<"TriggerLog"> | string + message?: Prisma.StringFilter<"TriggerLog"> | string + createdAt?: Prisma.DateTimeFilter<"TriggerLog"> | Date | string +} + +export type TriggerLogOrderByWithRelationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + message?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + _relevance?: Prisma.TriggerLogOrderByRelevanceInput +} + +export type TriggerLogWhereUniqueInput = Prisma.AtLeast<{ + id?: number + AND?: Prisma.TriggerLogWhereInput | Prisma.TriggerLogWhereInput[] + OR?: Prisma.TriggerLogWhereInput[] + NOT?: Prisma.TriggerLogWhereInput | Prisma.TriggerLogWhereInput[] + name?: Prisma.StringFilter<"TriggerLog"> | string + message?: Prisma.StringFilter<"TriggerLog"> | string + createdAt?: Prisma.DateTimeFilter<"TriggerLog"> | Date | string +}, "id"> + +export type TriggerLogOrderByWithAggregationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + message?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + _count?: Prisma.TriggerLogCountOrderByAggregateInput + _avg?: Prisma.TriggerLogAvgOrderByAggregateInput + _max?: Prisma.TriggerLogMaxOrderByAggregateInput + _min?: Prisma.TriggerLogMinOrderByAggregateInput + _sum?: Prisma.TriggerLogSumOrderByAggregateInput +} + +export type TriggerLogScalarWhereWithAggregatesInput = { + AND?: Prisma.TriggerLogScalarWhereWithAggregatesInput | Prisma.TriggerLogScalarWhereWithAggregatesInput[] + OR?: Prisma.TriggerLogScalarWhereWithAggregatesInput[] + NOT?: Prisma.TriggerLogScalarWhereWithAggregatesInput | Prisma.TriggerLogScalarWhereWithAggregatesInput[] + id?: Prisma.IntWithAggregatesFilter<"TriggerLog"> | number + name?: Prisma.StringWithAggregatesFilter<"TriggerLog"> | string + message?: Prisma.StringWithAggregatesFilter<"TriggerLog"> | string + createdAt?: Prisma.DateTimeWithAggregatesFilter<"TriggerLog"> | Date | string +} + +export type TriggerLogCreateInput = { + name: string + message: string + createdAt?: Date | string +} + +export type TriggerLogUncheckedCreateInput = { + id?: number + name: string + message: string + createdAt?: Date | string +} + +export type TriggerLogUpdateInput = { + name?: Prisma.StringFieldUpdateOperationsInput | string + message?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type TriggerLogUncheckedUpdateInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + name?: Prisma.StringFieldUpdateOperationsInput | string + message?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type TriggerLogCreateManyInput = { + id?: number + name: string + message: string + createdAt?: Date | string +} + +export type TriggerLogUpdateManyMutationInput = { + name?: Prisma.StringFieldUpdateOperationsInput | string + message?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type TriggerLogUncheckedUpdateManyInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + name?: Prisma.StringFieldUpdateOperationsInput | string + message?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type TriggerLogOrderByRelevanceInput = { + fields: Prisma.TriggerLogOrderByRelevanceFieldEnum | Prisma.TriggerLogOrderByRelevanceFieldEnum[] + sort: Prisma.SortOrder + search: string +} + +export type TriggerLogCountOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + message?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type TriggerLogAvgOrderByAggregateInput = { + id?: Prisma.SortOrder +} + +export type TriggerLogMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + message?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type TriggerLogMinOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + message?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type TriggerLogSumOrderByAggregateInput = { + id?: Prisma.SortOrder +} + + + +export type TriggerLogSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + message?: boolean + createdAt?: boolean +}, ExtArgs["result"]["triggerLog"]> + + + +export type TriggerLogSelectScalar = { + id?: boolean + name?: boolean + message?: boolean + createdAt?: boolean +} + +export type TriggerLogOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "message" | "createdAt", ExtArgs["result"]["triggerLog"]> + +export type $TriggerLogPayload = { + name: "TriggerLog" + objects: {} + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: number + name: string + message: string + createdAt: Date + }, ExtArgs["result"]["triggerLog"]> + composites: {} +} + +export type TriggerLogGetPayload = runtime.Types.Result.GetResult + +export type TriggerLogCountArgs = + Omit & { + select?: TriggerLogCountAggregateInputType | true + } + +export interface TriggerLogDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['TriggerLog'], meta: { name: 'TriggerLog' } } + /** + * Find zero or one TriggerLog that matches the filter. + * @param {TriggerLogFindUniqueArgs} args - Arguments to find a TriggerLog + * @example + * // Get one TriggerLog + * const triggerLog = await prisma.triggerLog.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one TriggerLog that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {TriggerLogFindUniqueOrThrowArgs} args - Arguments to find a TriggerLog + * @example + * // Get one TriggerLog + * const triggerLog = await prisma.triggerLog.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first TriggerLog that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogFindFirstArgs} args - Arguments to find a TriggerLog + * @example + * // Get one TriggerLog + * const triggerLog = await prisma.triggerLog.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first TriggerLog that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogFindFirstOrThrowArgs} args - Arguments to find a TriggerLog + * @example + * // Get one TriggerLog + * const triggerLog = await prisma.triggerLog.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more TriggerLogs that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all TriggerLogs + * const triggerLogs = await prisma.triggerLog.findMany() + * + * // Get first 10 TriggerLogs + * const triggerLogs = await prisma.triggerLog.findMany({ take: 10 }) + * + * // Only select the `id` + * const triggerLogWithIdOnly = await prisma.triggerLog.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a TriggerLog. + * @param {TriggerLogCreateArgs} args - Arguments to create a TriggerLog. + * @example + * // Create one TriggerLog + * const TriggerLog = await prisma.triggerLog.create({ + * data: { + * // ... data to create a TriggerLog + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many TriggerLogs. + * @param {TriggerLogCreateManyArgs} args - Arguments to create many TriggerLogs. + * @example + * // Create many TriggerLogs + * const triggerLog = await prisma.triggerLog.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Delete a TriggerLog. + * @param {TriggerLogDeleteArgs} args - Arguments to delete one TriggerLog. + * @example + * // Delete one TriggerLog + * const TriggerLog = await prisma.triggerLog.delete({ + * where: { + * // ... filter to delete one TriggerLog + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one TriggerLog. + * @param {TriggerLogUpdateArgs} args - Arguments to update one TriggerLog. + * @example + * // Update one TriggerLog + * const triggerLog = await prisma.triggerLog.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more TriggerLogs. + * @param {TriggerLogDeleteManyArgs} args - Arguments to filter TriggerLogs to delete. + * @example + * // Delete a few TriggerLogs + * const { count } = await prisma.triggerLog.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more TriggerLogs. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many TriggerLogs + * const triggerLog = await prisma.triggerLog.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create or update one TriggerLog. + * @param {TriggerLogUpsertArgs} args - Arguments to update or create a TriggerLog. + * @example + * // Update or create a TriggerLog + * const triggerLog = await prisma.triggerLog.upsert({ + * create: { + * // ... data to create a TriggerLog + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the TriggerLog we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__TriggerLogClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of TriggerLogs. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogCountArgs} args - Arguments to filter TriggerLogs to count. + * @example + * // Count the number of TriggerLogs + * const count = await prisma.triggerLog.count({ + * where: { + * // ... the filter for the TriggerLogs we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a TriggerLog. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by TriggerLog. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {TriggerLogGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends TriggerLogGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: TriggerLogGroupByArgs['orderBy'] } + : { orderBy?: TriggerLogGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetTriggerLogGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the TriggerLog model + */ +readonly fields: TriggerLogFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for TriggerLog. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__TriggerLogClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the TriggerLog model + */ +export interface TriggerLogFieldRefs { + readonly id: Prisma.FieldRef<"TriggerLog", 'Int'> + readonly name: Prisma.FieldRef<"TriggerLog", 'String'> + readonly message: Prisma.FieldRef<"TriggerLog", 'String'> + readonly createdAt: Prisma.FieldRef<"TriggerLog", 'DateTime'> +} + + +// Custom InputTypes +/** + * TriggerLog findUnique + */ +export type TriggerLogFindUniqueArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter, which TriggerLog to fetch. + */ + where: Prisma.TriggerLogWhereUniqueInput +} + +/** + * TriggerLog findUniqueOrThrow + */ +export type TriggerLogFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter, which TriggerLog to fetch. + */ + where: Prisma.TriggerLogWhereUniqueInput +} + +/** + * TriggerLog findFirst + */ +export type TriggerLogFindFirstArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter, which TriggerLog to fetch. + */ + where?: Prisma.TriggerLogWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of TriggerLogs to fetch. + */ + orderBy?: Prisma.TriggerLogOrderByWithRelationInput | Prisma.TriggerLogOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for TriggerLogs. + */ + cursor?: Prisma.TriggerLogWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` TriggerLogs from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` TriggerLogs. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of TriggerLogs. + */ + distinct?: Prisma.TriggerLogScalarFieldEnum | Prisma.TriggerLogScalarFieldEnum[] +} + +/** + * TriggerLog findFirstOrThrow + */ +export type TriggerLogFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter, which TriggerLog to fetch. + */ + where?: Prisma.TriggerLogWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of TriggerLogs to fetch. + */ + orderBy?: Prisma.TriggerLogOrderByWithRelationInput | Prisma.TriggerLogOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for TriggerLogs. + */ + cursor?: Prisma.TriggerLogWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` TriggerLogs from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` TriggerLogs. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of TriggerLogs. + */ + distinct?: Prisma.TriggerLogScalarFieldEnum | Prisma.TriggerLogScalarFieldEnum[] +} + +/** + * TriggerLog findMany + */ +export type TriggerLogFindManyArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter, which TriggerLogs to fetch. + */ + where?: Prisma.TriggerLogWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of TriggerLogs to fetch. + */ + orderBy?: Prisma.TriggerLogOrderByWithRelationInput | Prisma.TriggerLogOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing TriggerLogs. + */ + cursor?: Prisma.TriggerLogWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` TriggerLogs from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` TriggerLogs. + */ + skip?: number + distinct?: Prisma.TriggerLogScalarFieldEnum | Prisma.TriggerLogScalarFieldEnum[] +} + +/** + * TriggerLog create + */ +export type TriggerLogCreateArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * The data needed to create a TriggerLog. + */ + data: Prisma.XOR +} + +/** + * TriggerLog createMany + */ +export type TriggerLogCreateManyArgs = { + /** + * The data used to create many TriggerLogs. + */ + data: Prisma.TriggerLogCreateManyInput | Prisma.TriggerLogCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * TriggerLog update + */ +export type TriggerLogUpdateArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * The data needed to update a TriggerLog. + */ + data: Prisma.XOR + /** + * Choose, which TriggerLog to update. + */ + where: Prisma.TriggerLogWhereUniqueInput +} + +/** + * TriggerLog updateMany + */ +export type TriggerLogUpdateManyArgs = { + /** + * The data used to update TriggerLogs. + */ + data: Prisma.XOR + /** + * Filter which TriggerLogs to update + */ + where?: Prisma.TriggerLogWhereInput + /** + * Limit how many TriggerLogs to update. + */ + limit?: number +} + +/** + * TriggerLog upsert + */ +export type TriggerLogUpsertArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * The filter to search for the TriggerLog to update in case it exists. + */ + where: Prisma.TriggerLogWhereUniqueInput + /** + * In case the TriggerLog found by the `where` argument doesn't exist, create a new TriggerLog with this data. + */ + create: Prisma.XOR + /** + * In case the TriggerLog was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * TriggerLog delete + */ +export type TriggerLogDeleteArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null + /** + * Filter which TriggerLog to delete. + */ + where: Prisma.TriggerLogWhereUniqueInput +} + +/** + * TriggerLog deleteMany + */ +export type TriggerLogDeleteManyArgs = { + /** + * Filter which TriggerLogs to delete + */ + where?: Prisma.TriggerLogWhereInput + /** + * Limit how many TriggerLogs to delete. + */ + limit?: number +} + +/** + * TriggerLog without action + */ +export type TriggerLogDefaultArgs = { + /** + * Select specific fields to fetch from the TriggerLog + */ + select?: Prisma.TriggerLogSelect | null + /** + * Omit specific fields from the TriggerLog + */ + omit?: Prisma.TriggerLogOmit | null +} diff --git a/src/inventories/dto/create-inventory.dto.ts b/src/inventories/dto/create-inventory.dto.ts index 81d04a3..53264b2 100644 --- a/src/inventories/dto/create-inventory.dto.ts +++ b/src/inventories/dto/create-inventory.dto.ts @@ -1,9 +1,12 @@ +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' import { IsOptional, IsString } from 'class-validator' export class CreateInventoryDto { + @ApiProperty() @IsString() name: string + @ApiPropertyOptional() @IsOptional() @IsString() location?: string diff --git a/src/inventories/dto/update-inventory.dto.ts b/src/inventories/dto/update-inventory.dto.ts index de8c2ce..259366c 100644 --- a/src/inventories/dto/update-inventory.dto.ts +++ b/src/inventories/dto/update-inventory.dto.ts @@ -1,15 +1,19 @@ +import { ApiPropertyOptional } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsBoolean, IsOptional, IsString } from 'class-validator' export class UpdateInventoryDto { + @ApiPropertyOptional() @IsOptional() @IsString() name?: string + @ApiPropertyOptional() @IsOptional() @IsString() location?: string + @ApiPropertyOptional() @IsOptional() @Type(() => Boolean) @IsBoolean() diff --git a/src/inventories/inventories.controller.ts b/src/inventories/inventories.controller.ts index 5cc8f88..a35c50f 100644 --- a/src/inventories/inventories.controller.ts +++ b/src/inventories/inventories.controller.ts @@ -1,4 +1,6 @@ -import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common' +import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common' +import { ApiQuery } from '@nestjs/swagger' +import { MovementType } from '../generated/prisma/enums' import { CreateInventoryDto } from './dto/create-inventory.dto' import { UpdateInventoryDto } from './dto/update-inventory.dto' import { InventoriesService } from './inventories.service' @@ -13,8 +15,9 @@ export class InventoriesController { } @Get() - findAll() { - return this.inventoriesService.findAll() + @ApiQuery({ name: 'isPointOfSale', required: false, type: Boolean }) + findAll(@Query('isPointOfSale') isPointOfSale?: boolean) { + return this.inventoriesService.findAll(isPointOfSale) } @Get(':id') @@ -32,8 +35,20 @@ export class InventoriesController { return this.inventoriesService.remove(Number(id)) } - @Get(':id/stock-movements') - findStockMovements(@Param('id') id: string) { - return this.inventoriesService.findStockMovements(Number(id)) + @Get(':id/movements') + @ApiQuery({ name: 'type', required: false, enum: MovementType }) + findInventoryMovements(@Param('id') id: string, @Query('type') type?: MovementType) { + return this.inventoriesService.findInventoryMovements(Number(id), type ?? undefined) + } + + @Get(':id/stock') + @ApiQuery({ name: 'isAvailable', required: false, type: Boolean }) + getStock(@Param('id') id: string, @Query('isAvailable') isAvailable?: boolean) { + return this.inventoriesService.getStock(Number(id), isAvailable ?? undefined) + } + + @Get(':id/products/:productId/cardex') + getProductCardex(@Param('id') id: string, @Param('productId') productId: string) { + return this.inventoriesService.getProductCardex(Number(id), Number(productId)) } } diff --git a/src/inventories/inventories.service.ts b/src/inventories/inventories.service.ts index 5664e18..1fe73eb 100644 --- a/src/inventories/inventories.service.ts +++ b/src/inventories/inventories.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common' import { ResponseMapper } from '../common/response/response-mapper' +import { MovementType } from '../generated/prisma/enums' import { PrismaService } from '../prisma/prisma.service' @Injectable() @@ -10,8 +11,10 @@ export class InventoriesService { return ResponseMapper.create(item) } - async findAll() { - const items = await this.prisma.inventory.findMany() + async findAll(isPointOfSale?: boolean) { + const items = await this.prisma.inventory.findMany({ + where: isPointOfSale !== undefined ? { isPointOfSale } : undefined, + }) return ResponseMapper.list(items) } @@ -19,10 +22,28 @@ export class InventoriesService { async findOne(id: number) { const item = await this.prisma.inventory.findUnique({ where: { id }, - include: { purchaseReceipts: true }, + include: { + stockBalances: { + where: { quantity: { gt: 0 } }, + select: { quantity: true, totalCost: true }, + }, + }, }) if (!item) return null - return ResponseMapper.single(item) + + const { stockBalances, ...rest } = item + return ResponseMapper.single({ + ...rest, + availableProductTypes: stockBalances.length, + availableProductCount: stockBalances.reduce( + (acc, sb) => acc + Number(sb.quantity), + 0, + ), + availableProductsCost: stockBalances.reduce( + (acc, sb) => acc + Number(sb.totalCost), + 0, + ), + }) } async update(id: number, data: any) { @@ -35,20 +56,133 @@ export class InventoriesService { return ResponseMapper.single(item) } - async findStockMovements(inventoryId: number) { - // Return a flat list of stock movements, each including its product info + async findInventoryMovements( + inventoryId: number, + type?: MovementType, + page = 1, + pageSize = 10, + ) { + const groups = await this.prisma.stockMovement.groupBy({ + by: ['referenceId'], + where: { inventoryId, type }, + _count: { id: true }, + orderBy: { referenceId: 'desc' }, + skip: (page - 1) * pageSize, + take: pageSize, + }) + + const result = await Promise.all( + groups.map(async group => { + const movements = await this.prisma.stockMovement.findMany({ + where: { inventoryId, referenceId: group.referenceId }, + include: { product: true }, + }) + let info = null as any + const mapped = movements.map(movement => { + const { id, quantity, fee, totalCost, avgCost, product } = movement + if (info === null) { + info = { + date: movement.createdAt, + type: movement.type, + quantity: Number(movement.quantity), + fee: Number(movement.fee), + totalCost: Number(movement.totalCost), + referenceType: movement.referenceType, + referenceId: movement.referenceId, + createdAt: movement.createdAt, + } + } else { + info.quantity += Number(movement.quantity) + info.fee += Number(movement.fee) + info.totalCost += Number(movement.totalCost) + } + return { + id, + quantity: Number(quantity), + fee: Number(fee), + totalCost: Number(totalCost), + avgCost: Number(avgCost), + product, + } + }) + return { + receiptId: group.referenceId, + count: group._count.id, + info, + movements: mapped, + } + }), + ) + return ResponseMapper.list(result) + } + + async getStock(inventoryId: number, isAvailable?: boolean, page = 1, pageSize = 10) { + console.log(isAvailable) + + const items = await this.prisma.stockBalance.findMany({ + where: { + inventoryId, + quantity: + isAvailable === true + ? { gt: 0 } + : isAvailable === false + ? { lte: 0 } + : undefined, + }, + include: { + product: true, + }, + orderBy: { + updatedAt: 'desc', + }, + skip: (page - 1) * pageSize, + take: pageSize, + }) + + const mapped = items.map(item => ({ + id: item.id, + quantity: Number(item.quantity), + avgCost: Number(item.avgCost), + product: item.product, + })) + + return ResponseMapper.list(mapped) + } + + async getProductCardex(inventoryId: number, productId: number) { + console.log(productId, inventoryId) + const movements = await this.prisma.stockMovement.findMany({ - where: { inventoryId }, - include: { product: true }, - }) - // Map each movement to have a 'products' array (even if only one product) - const mapped = movements.map(movement => { - const { product, ...rest } = movement - return { - ...rest, - products: product ? [product] : [], - } + 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, + quantity: Number(movement.quantity), + fee: Number(movement.fee), + totalCost: Number(movement.totalCost), + avgCost: Number(movement.avgCost), + referenceType: movement.referenceType, + referenceId: movement.referenceId, + createdAt: movement.createdAt, + remainedInStock: movement.remainedInStock, + inventory: { + id: movement.inventory.id, + name: movement.inventory.name, + }, + supplier: movement.supplier + ? { + id: movement.supplier.id, + name: movement.supplier.firstName + ' ' + movement.supplier.lastName, + } + : null, + })) + return ResponseMapper.list(mapped) } } diff --git a/src/inventory-transfer-items/dto/create-inventory-transfer-item.dto.ts b/src/inventory-transfer-items/dto/create-inventory-transfer-item.dto.ts index b042197..b883e9e 100644 --- a/src/inventory-transfer-items/dto/create-inventory-transfer-item.dto.ts +++ b/src/inventory-transfer-items/dto/create-inventory-transfer-item.dto.ts @@ -1,15 +1,19 @@ +import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsInt, IsNumber } from 'class-validator' export class CreateInventoryTransferItemDto { + @ApiProperty() @Type(() => Number) @IsNumber() count: number + @ApiProperty() @Type(() => Number) @IsInt() productId: number + @ApiProperty() @Type(() => Number) @IsInt() transferId: number diff --git a/src/inventory-transfer-items/dto/update-inventory-transfer-item.dto.ts b/src/inventory-transfer-items/dto/update-inventory-transfer-item.dto.ts index 91ab9af..d54b1cf 100644 --- a/src/inventory-transfer-items/dto/update-inventory-transfer-item.dto.ts +++ b/src/inventory-transfer-items/dto/update-inventory-transfer-item.dto.ts @@ -1,17 +1,21 @@ +import { ApiPropertyOptional } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsInt, IsNumber, IsOptional } from 'class-validator' export class UpdateInventoryTransferItemDto { + @ApiPropertyOptional() @IsOptional() @Type(() => Number) @IsNumber() count?: number + @ApiPropertyOptional() @IsOptional() @Type(() => Number) @IsInt() productId?: number + @ApiPropertyOptional() @IsOptional() @Type(() => Number) @IsInt() diff --git a/src/inventory-transfers/dto/create-inventory-transfer.dto.ts b/src/inventory-transfers/dto/create-inventory-transfer.dto.ts index dff57ac..4411cc3 100644 --- a/src/inventory-transfers/dto/create-inventory-transfer.dto.ts +++ b/src/inventory-transfers/dto/create-inventory-transfer.dto.ts @@ -1,19 +1,30 @@ +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsInt, IsOptional, IsString } from 'class-validator' +import { ArrayMinSize, IsInt, IsOptional, IsString } from 'class-validator' +import { CreateInventoryTransferItemDto } from '../../inventory-transfer-items/dto/create-inventory-transfer-item.dto' export class CreateInventoryTransferDto { + @ApiProperty() @IsString() code: string + @ApiPropertyOptional() @IsOptional() @IsString() description?: string + @ApiProperty() @Type(() => Number) @IsInt() fromInventoryId: number + @ApiProperty() @Type(() => Number) @IsInt() toInventoryId: number + + @ApiProperty({ type: [CreateInventoryTransferItemDto] }) + @Type(() => Array) + @ArrayMinSize(1) + items: Array> } diff --git a/src/inventory-transfers/dto/update-inventory-transfer.dto.ts b/src/inventory-transfers/dto/update-inventory-transfer.dto.ts index 5d5765c..f433db3 100644 --- a/src/inventory-transfers/dto/update-inventory-transfer.dto.ts +++ b/src/inventory-transfers/dto/update-inventory-transfer.dto.ts @@ -1,20 +1,25 @@ +import { ApiPropertyOptional } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsInt, IsOptional, IsString } from 'class-validator' export class UpdateInventoryTransferDto { + @ApiPropertyOptional() @IsOptional() @IsString() code?: string + @ApiPropertyOptional() @IsOptional() @IsString() description?: string + @ApiPropertyOptional() @IsOptional() @Type(() => Number) @IsInt() fromInventoryId?: number | null + @ApiPropertyOptional() @IsOptional() @Type(() => Number) @IsInt() diff --git a/src/inventory-transfers/inventory-transfers.controller.ts b/src/inventory-transfers/inventory-transfers.controller.ts index 947112e..37d02c9 100644 --- a/src/inventory-transfers/inventory-transfers.controller.ts +++ b/src/inventory-transfers/inventory-transfers.controller.ts @@ -3,7 +3,7 @@ import { CreateInventoryTransferDto } from './dto/create-inventory-transfer.dto' import { UpdateInventoryTransferDto } from './dto/update-inventory-transfer.dto' import { InventoryTransfersService } from './inventory-transfers.service' -@Controller('inventory-transfers') +@Controller('inventories/transfers') export class InventoryTransfersController { constructor(private readonly service: InventoryTransfersService) {} diff --git a/src/inventory-transfers/inventory-transfers.service.ts b/src/inventory-transfers/inventory-transfers.service.ts index 2279211..ec8798b 100644 --- a/src/inventory-transfers/inventory-transfers.service.ts +++ b/src/inventory-transfers/inventory-transfers.service.ts @@ -18,6 +18,15 @@ export class InventoryTransfersService { delete payload.toInventoryId } + if (Object.prototype.hasOwnProperty.call(payload, 'items')) { + payload.items = { + create: payload.items.map((item: any) => ({ + product: { connect: { id: Number(item.productId) } }, + count: item.count, + })), + } + } + const item = await this.prisma.inventoryTransfer.create({ data: payload }) return ResponseMapper.create(item) } diff --git a/src/products/products.service.ts b/src/products/products.service.ts index 2c2b879..b109815 100644 --- a/src/products/products.service.ts +++ b/src/products/products.service.ts @@ -30,8 +30,9 @@ export class ProductsService { async findAll() { const items = await this.prisma.product.findMany({ - include: { brand: true, category: true }, + include: { brand: true, category: true, stockBalances: true }, }) + const mapped = items.map(p => { const { brandId, categoryId, ...rest } = p as any const brand: ShortEntity | null = p.brand @@ -40,7 +41,12 @@ export class ProductsService { const category: ShortEntity | null = p.category ? { id: p.category.id, name: p.category.name } : null - return { ...rest, brand, category } + const stock = + p.stockBalances && p.stockBalances.length > 0 + ? p.stockBalances.reduce((acc, sb) => acc + Number(sb.quantity), 0) + : 0 + + return { ...rest, brand, category, stock } }) return ResponseMapper.list(mapped) } @@ -48,7 +54,7 @@ export class ProductsService { async findOne(id: number) { const p = await this.prisma.product.findUnique({ where: { id }, - include: { brand: true, category: true, productCharges: true }, + include: { brand: true, category: true, stockBalances: true }, }) if (!p) return null @@ -63,7 +69,15 @@ export class ProductsService { ...rest, brand, category, - count: p.productCharges.reduce((acc, charge) => acc + Number(charge.count), 0.0), + stock: + p.stockBalances && p.stockBalances.length > 0 + ? p.stockBalances.reduce((acc, sb) => acc + Number(sb.quantity), 0) + : 0, + avgCost: + p.stockBalances && p.stockBalances.length > 0 + ? p.stockBalances.reduce((acc, sb) => acc + Number(sb.avgCost), 0) / + p.stockBalances.length + : 0, }) } diff --git a/src/purchase-receipts/purchase-receipts.service.ts b/src/purchase-receipts/purchase-receipts.service.ts index 60bdd68..4f508d1 100644 --- a/src/purchase-receipts/purchase-receipts.service.ts +++ b/src/purchase-receipts/purchase-receipts.service.ts @@ -25,7 +25,6 @@ export class PurchaseReceiptsService { description: item.description ?? null, product: { connect: { id: item.productId } }, } - console.log(`[create] Step 3: Mapped item ${idx}:`, mapped) return mapped }), } diff --git a/src/stock-balance/stock-balance.controller.ts b/src/stock-balance/stock-balance.controller.ts index 1e63d16..414b59b 100644 --- a/src/stock-balance/stock-balance.controller.ts +++ b/src/stock-balance/stock-balance.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Param } from '@nestjs/common' +import { Controller, Get } from '@nestjs/common' import { StockBalanceService } from './stock-balance.service' @Controller('stock-balance') @@ -10,8 +10,8 @@ export class StockBalanceController { return this.service.findAll() } - @Get(':itemId') - findOne(@Param('itemId') itemId: string) { - return this.service.findOne(Number(itemId)) - } + // @Get(':itemId') + // findOne(@Param('itemId') itemId: string) { + // return this.service.findOne(Number(itemId)) + // } } diff --git a/src/stock-balance/stock-balance.service.ts b/src/stock-balance/stock-balance.service.ts index 73ae291..ae60681 100644 --- a/src/stock-balance/stock-balance.service.ts +++ b/src/stock-balance/stock-balance.service.ts @@ -11,9 +11,9 @@ export class StockBalanceService { return ResponseMapper.list(items) } - async findOne(ProductId: number) { - const item = await this.prisma.stockBalance.findUnique({ where: { ProductId } }) - if (!item) return null - return ResponseMapper.single(item) - } + // async findOne(productId: number) { + // const item = await this.prisma.stockBalance.findUnique({ where: { productId: productId } }) + // if (!item) return null + // return ResponseMapper.single(item) + // } }