diff --git a/prisma/migrations/20260105162935_add_stock_view/migration.sql b/prisma/migrations/20260105162935_add_stock_view/migration.sql new file mode 100644 index 0000000..a32cafa --- /dev/null +++ b/prisma/migrations/20260105162935_add_stock_view/migration.sql @@ -0,0 +1,17 @@ +CREATE OR REPLACE VIEW Stock_Available_View AS +SELECT + sb.productId, + sb.inventoryId, + sb.quantity AS physicalQuantity, + COALESCE(SUM(sr.quantity), 0) AS reservedQuantity, + ( + sb.quantity - COALESCE(SUM(sr.quantity), 0) + ) AS availableQuantity +FROM + Stock_Balance sb + LEFT JOIN Stock_Reservations sr ON sr.productId = sb.productId + AND sr.inventoryId = sb.inventoryId +GROUP BY + sb.productId, + sb.inventoryId, + sb.quantity; diff --git a/prisma/migrations/20260105165503_update_order_model/migration.sql b/prisma/migrations/20260105165503_update_order_model/migration.sql new file mode 100644 index 0000000..5086c54 --- /dev/null +++ b/prisma/migrations/20260105165503_update_order_model/migration.sql @@ -0,0 +1,21 @@ +/* + Warnings: + + - You are about to drop the column `expiresAt` on the `Stock_Reservations` table. All the data in the column will be lost. + - Added the required column `posAccountId` to the `Orders` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Orders` ADD COLUMN `posAccountId` INTEGER NOT NULL; + +-- AlterTable +ALTER TABLE `Stock_Reservations` DROP COLUMN `expiresAt`; + +-- CreateIndex +CREATE INDEX `Orders_posAccountId_idx` ON `Orders`(`posAccountId`); + +-- AddForeignKey +ALTER TABLE `Orders` ADD CONSTRAINT `Orders_posAccountId_fkey` FOREIGN KEY (`posAccountId`) REFERENCES `Pos_Accounts`(`id`) ON DELETE RESTRICT ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE `Stock_Reservations` ADD CONSTRAINT `Stock_Reservations_orderId_fkey` FOREIGN KEY (`orderId`) REFERENCES `Orders`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema/inventory.prisma b/prisma/schema/inventory.prisma index 62f67b8..37157d4 100644 --- a/prisma/schema/inventory.prisma +++ b/prisma/schema/inventory.prisma @@ -47,6 +47,7 @@ model PosAccount { inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId]) salesInvoices SalesInvoice[] + orders Order[] @@index([inventoryId]) @@map("Pos_Accounts") diff --git a/prisma/schema/order.prisma b/prisma/schema/order.prisma index d416f08..654b5d7 100644 --- a/prisma/schema/order.prisma +++ b/prisma/schema/order.prisma @@ -1,16 +1,22 @@ model Order { - id Int @id @default(autoincrement()) - orderNumber String @unique @db.VarChar(100) - status OrderStatus @default(PENDING) - totalAmount Decimal @db.Decimal(15, 2) - description String? @db.Text - createdAt DateTime @default(now()) @db.Timestamp(0) - updatedAt DateTime @updatedAt @db.Timestamp(0) - deletedAt DateTime? @db.Timestamp(0) - customerId Int? - customer Customer? @relation(fields: [customerId], references: [id], onUpdate: NoAction) - orderItems OrderItem[] + id Int @id @default(autoincrement()) + orderNumber String @unique @db.VarChar(100) + status OrderStatus @default(PENDING) + totalAmount Decimal @db.Decimal(15, 2) + description String? @db.Text + createdAt DateTime @default(now()) @db.Timestamp(0) + updatedAt DateTime @updatedAt @db.Timestamp(0) + deletedAt DateTime? @db.Timestamp(0) + customerId Int? + posAccountId Int + customer Customer? @relation(fields: [customerId], references: [id], onUpdate: NoAction) + posAccount PosAccount @relation(fields: [posAccountId], references: [id], onUpdate: NoAction) + + orderItems OrderItem[] + stockReservations StockReservation[] + + @@index([posAccountId]) @@index([customerId]) @@map("Orders") } diff --git a/prisma/schema/schema.prisma b/prisma/schema/schema.prisma index 0e3edb1..ba604c2 100644 --- a/prisma/schema/schema.prisma +++ b/prisma/schema/schema.prisma @@ -1,7 +1,8 @@ generator client { - provider = "prisma-client" - output = "../../src/generated/prisma" - moduleFormat = "cjs" + provider = "prisma-client" + output = "../../src/generated/prisma" + moduleFormat = "cjs" + previewFeatures = ["views"] } datasource db { diff --git a/prisma/schema/stock.prisma b/prisma/schema/stock.prisma index 035ca35..f4844b8 100644 --- a/prisma/schema/stock.prisma +++ b/prisma/schema/stock.prisma @@ -63,15 +63,25 @@ model StockAdjustment { model StockReservation { id Int @id @default(autoincrement()) quantity Decimal @db.Decimal(10, 0) - expiresAt DateTime @db.Timestamp(0) createdAt DateTime @default(now()) @db.Timestamp(0) productId Int inventoryId Int orderId Int inventory Inventory @relation(fields: [inventoryId], references: [id]) product Product @relation(fields: [productId], references: [id]) + order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) @@index([inventoryId]) @@index([productId]) @@map("Stock_Reservations") } + +view StockAvailableView { + productId Int + inventoryId Int + physicalQuantity Decimal @db.Decimal(10, 0) + reservedQuantity Decimal @db.Decimal(10, 0) + availableQuantity Decimal @db.Decimal(10, 0) + + @@map("Stock_Available_View") +} diff --git a/prisma/triggers/dump_triggers.sql b/prisma/triggers/dump_triggers.sql index afefe82..649d5ee 100644 --- a/prisma/triggers/dump_triggers.sql +++ b/prisma/triggers/dump_triggers.sql @@ -1,5 +1,5 @@ -- AUTO-GENERATED MYSQL TRIGGER DUMP --- Generated at: 2026-01-04T17:29:18.092Z +-- Generated at: 2026-01-06T16:09:38.959Z -- ------------------------------------------ -- index: 1 @@ -52,44 +52,35 @@ end; -- ------------------------------------------ -- index: 3 --- Trigger: trg_order_item_after_insert --- Event: INSERT --- Table: Order_Items --- ------------------------------------------ -DROP TRIGGER IF EXISTS `trg_order_item_after_insert`; -CREATE DEFINER=`pos`@`%` TRIGGER `trg_order_item_after_insert` AFTER INSERT ON `Order_Items` FOR EACH ROW BEGIN - UPDATE Stock_Reservations SET quantity = quantity + NEW.quantity - WHERE orderId = NEW.orderId AND productId = NEW.productId; -END; - --- ------------------------------------------ --- index: 4 -- Trigger: trg_order_item_after_update -- Event: UPDATE -- Table: Order_Items -- ------------------------------------------ DROP TRIGGER IF EXISTS `trg_order_item_after_update`; CREATE DEFINER=`pos`@`%` TRIGGER `trg_order_item_after_update` AFTER UPDATE ON `Order_Items` FOR EACH ROW BEGIN - UPDATE Stock_Reservations - SET quantity = quantity - OLD.quantity + NEW.quantity - WHERE orderId = NEW.orderId AND productId = NEW.productId; + + UPDATE Stock_Reservations + SET quantity = quantity - OLD.quantity + NEW.quantity + WHERE orderId = NEW.orderId AND productId = NEW.productId; + END; -- ------------------------------------------ --- index: 5 +-- index: 4 -- Trigger: trg_order_item_after_delete -- Event: DELETE -- Table: Order_Items -- ------------------------------------------ DROP TRIGGER IF EXISTS `trg_order_item_after_delete`; CREATE DEFINER=`pos`@`%` TRIGGER `trg_order_item_after_delete` AFTER DELETE ON `Order_Items` FOR EACH ROW BEGIN - UPDATE Stock_Reservations SET quantity = quantity - OLD.quantity + + DELETE From Stock_Reservations WHERE orderId = OLD.orderId AND productId = OLD.productId; END; -- ------------------------------------------ --- index: 6 +-- index: 5 -- Trigger: trg_order_after_cancel -- Event: UPDATE -- Table: Orders @@ -103,7 +94,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_order_after_cancel` AFTER UPDATE ON `Order END; -- ------------------------------------------ --- index: 7 +-- index: 6 -- Trigger: trg_purchase_receipt_item_after_insert -- Event: INSERT -- Table: Purchase_Receipt_Items @@ -166,7 +157,7 @@ DECLARE invId INT; END; -- ------------------------------------------ --- index: 8 +-- index: 7 -- Trigger: trg_pr_payment_after_delete -- Event: DELETE -- Table: Purchase_Receipt_Payments @@ -201,7 +192,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_pr_payment_after_delete` AFTER DELETE ON ` END; -- ------------------------------------------ --- index: 9 +-- index: 8 -- Trigger: trg_sales_invoice_items_before_insert -- Event: INSERT -- Table: Sales_Invoice_Items @@ -220,10 +211,9 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_sales_invoice_items_before_insert` BEFORE WHERE si.id = NEW.invoiceId; - SELECT COALESCE(quantity, 0) INTO current_stock - FROM Stock_Balance sb - WHERE productId = NEW.productId AND sb.inventoryId = inventory_id - LIMIT 1; + SELECT COALESCE(sav.availableQuantity, 0) INTO current_stock + FROM Stock_Available_View sav + WHERE productId = NEW.productId AND sav.inventoryId = inventory_id; @@ -234,7 +224,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_sales_invoice_items_before_insert` BEFORE end; -- ------------------------------------------ --- index: 10 +-- index: 9 -- Trigger: trg_sales_invoice_items_after_insert -- Event: INSERT -- Table: Sales_Invoice_Items @@ -307,7 +297,7 @@ DECLARE pos_id INT; END; -- ------------------------------------------ --- index: 11 +-- index: 10 -- Trigger: trg_pos_account_payment_after_insert -- Event: INSERT -- Table: Sales_Invoice_Payments @@ -343,7 +333,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_pos_account_payment_after_insert` AFTER IN END; -- ------------------------------------------ --- index: 12 +-- index: 11 -- Trigger: trg_sales_invoice_payment_after_insert -- Event: INSERT -- Table: Sales_Invoice_Payments @@ -382,7 +372,7 @@ CREATE DEFINER=`pos`@`%` TRIGGER `trg_sales_invoice_payment_after_insert` AFTER END; -- ------------------------------------------ --- index: 13 +-- index: 12 -- Trigger: trg_stock_sale_insert -- Event: INSERT -- Table: Stock_Movements @@ -417,7 +407,7 @@ END IF; END; -- ------------------------------------------ --- index: 14 +-- index: 13 -- Trigger: trg_stock_purchase_insert -- Event: INSERT -- Table: Stock_Movements @@ -452,7 +442,7 @@ END IF; END; -- ------------------------------------------ --- index: 15 +-- index: 14 -- Trigger: trg_stock_transfer -- Event: INSERT -- Table: Stock_Movements @@ -534,3 +524,25 @@ END IF; END; +-- ------------------------------------------ +-- index: 15 +-- Trigger: trg_no_negative_available_stock +-- Event: INSERT +-- Table: Stock_Reservations +-- ------------------------------------------ +DROP TRIGGER IF EXISTS `trg_no_negative_available_stock`; +CREATE DEFINER=`pos`@`%` TRIGGER `trg_no_negative_available_stock` BEFORE INSERT ON `Stock_Reservations` FOR EACH ROW BEGIN + DECLARE available DECIMAL(14,3); + + SELECT availableQuantity + INTO available + FROM Stock_Available_View + WHERE productId = NEW.productId + AND inventoryId = NEW.inventoryId; + + IF available < NEW.quantity THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'موجودی کافی نیست'; + END IF; +END; + diff --git a/src/app.module.ts b/src/app.module.ts index d8cad37..7001b8e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -12,6 +12,7 @@ import { CardexModule } from './modules/cardex/cardex.module' import { InventoriesModule } from './modules/inventories/inventories.module' import { PosModule } from './modules/pos/pos.module' import { PurchaseReceiptsModule } from './modules/purchase-receipts/purchase-receipts.module' +import { SalesInvoicesModule } from './modules/sales-invoices/sales-invoices.module' import { StatisticsModule } from './modules/statistics/statistics.module' import { SuppliersModule } from './modules/suppliers/suppliers.module' import { PrismaModule } from './prisma/prisma.module' @@ -20,8 +21,6 @@ import { ProductCategoriesModule } from './product-categories/product-categories import { ProductVariantsModule } from './product-variants/product-variants.module' import { ProductsModule } from './products/products.module' import { RolesModule } from './roles/roles.module' -import { SalesInvoiceItemsModule } from './sales-invoice-items/sales-invoice-items.module' -import { SalesInvoicesModule } from './sales-invoices/sales-invoices.module' import { StockAdjustmentsModule } from './stock-adjustments/stock-adjustments.module' import { StockBalanceModule } from './stock-balance/stock-balance.module' import { StockMovementsModule } from './stock-movements/stock-movements.module' @@ -42,7 +41,6 @@ import { UsersModule } from './users/users.module' InventoriesModule, PurchaseReceiptsModule, SalesInvoicesModule, - SalesInvoiceItemsModule, InventoryTransfersModule, InventoryTransferItemsModule, StockMovementsModule, diff --git a/src/generated/prisma/browser.ts b/src/generated/prisma/browser.ts index c2576ff..b902b31 100644 --- a/src/generated/prisma/browser.ts +++ b/src/generated/prisma/browser.ts @@ -182,3 +182,8 @@ export type Supplier = Prisma.SupplierModel * */ export type SupplierLedger = Prisma.SupplierLedgerModel +/** + * Model StockAvailableView + * + */ +export type StockAvailableView = Prisma.StockAvailableViewModel diff --git a/src/generated/prisma/client.ts b/src/generated/prisma/client.ts index f0be311..66206d4 100644 --- a/src/generated/prisma/client.ts +++ b/src/generated/prisma/client.ts @@ -202,3 +202,8 @@ export type Supplier = Prisma.SupplierModel * */ export type SupplierLedger = Prisma.SupplierLedgerModel +/** + * Model StockAvailableView + * + */ +export type StockAvailableView = Prisma.StockAvailableViewModel diff --git a/src/generated/prisma/internal/class.ts b/src/generated/prisma/internal/class.ts index 81f4b0b..6e99380 100644 --- a/src/generated/prisma/internal/class.ts +++ b/src/generated/prisma/internal/class.ts @@ -16,11 +16,13 @@ import type * as Prisma from "./prismaNamespace.js" const config: runtime.GetPrismaClientConfig = { - "previewFeatures": [], + "previewFeatures": [ + "views" + ], "clientVersion": "7.2.0", "engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3", "activeProvider": "mysql", - "inlineSchema": "model 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 refreshTokens RefreshToken[]\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 @unique @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 OtpCode {\n id Int @id @default(autoincrement())\n mobileNumber String @db.VarChar(20)\n code String @db.VarChar(10)\n used Boolean @default(false)\n expiresAt DateTime @db.Timestamp(0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@index([mobileNumber])\n @@map(\"Otp_Codes\")\n}\n\nmodel RefreshToken {\n id Int @id @default(autoincrement())\n tokenHash String @db.VarChar(255)\n userId Int\n revoked Boolean @default(false)\n expiresAt DateTime @db.Timestamp(0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n user User @relation(fields: [userId], references: [id])\n\n @@index([userId])\n @@map(\"Refresh_Tokens\")\n}\n\nmodel BankBranch {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n code String @unique() @db.VarChar(10)\n address String? @db.VarChar(500)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n bankId Int\n\n bank Bank @relation(\"bank_branches\", fields: [bankId], references: [id])\n bankAccounts BankAccount[] @relation(\"Bank_Accounts_branchId_fkey\")\n\n @@map(\"Bank_Branches\")\n}\n\nmodel BankAccount {\n id Int @id @default(autoincrement())\n accountNumber String? @unique @db.VarChar(20)\n cardNumber String? @unique @db.VarChar(16)\n name String @db.VarChar(255)\n iban String? @unique @db.VarChar(34)\n branchId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n branch BankBranch @relation(\"Bank_Accounts_branchId_fkey\", fields: [branchId], references: [id])\n inventoryBankAccounts InventoryBankAccount[]\n purchaseReceiptPayments PurchaseReceiptPayments[]\n bankAccountTransactions BankAccountTransaction[]\n\n @@map(\"Bank_Accounts\")\n}\n\nmodel BankAccountTransaction {\n id Int @id @default(autoincrement())\n bankAccountId Int\n type BankAccountTransactionType\n amount Decimal @db.Decimal(15, 2)\n balanceAfter Decimal @db.Decimal(15, 2)\n referenceId Int\n referenceType BankTransactionRefType\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n\n @@index([bankAccountId])\n @@map(\"Bank_Account_Transactions\")\n}\n\nenum OrderStatus {\n PENDING\n REJECTED\n CANCELED\n DONE\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 PaymentMethodType {\n CASH\n CARD\n BANK\n CHECK\n OTHER\n}\n\nenum LedgerSourceType {\n PURCHASE\n PAYMENT\n ADJUSTMENT\n REFUND\n}\n\nenum PaymentType {\n PAYMENT\n REFUND\n}\n\nenum PurchaseReceiptStatus {\n UNPAID\n PARTIALLY_PAID\n PAID\n}\n\nenum BankAccountTransactionType {\n DEPOSIT\n WITHDRAWAL\n}\n\nenum BankTransactionRefType {\n PURCHASE_PAYMENT\n PURCHASE_REFUND\n POS_SALE\n POS_REFUND\n BANK_TRANSFER\n MANUAL_ADJUSTMENT\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 isPointOfSale Boolean @default(false)\n inventoryTransfersFrom InventoryTransfer[] @relation(\"Inventory_From\")\n inventoryTransfersTo InventoryTransfer[] @relation(\"Inventory_To\")\n purchaseReceipts PurchaseReceipt[]\n stockAdjustments StockAdjustment[] @relation(\"Inventory_Stock_Adjustments\")\n stockBalances StockBalance[] @relation(\"StockBalance_inventory\")\n counterStockMovements StockMovement[] @relation(\"StockMovement_CounterInventory\")\n stockMovements StockMovement[] @relation(\"StockMovement_Inventory\")\n inventoryBankAccounts InventoryBankAccount[]\n stockReservations StockReservation[]\n\n @@map(\"Inventories\")\n}\n\nmodel InventoryBankAccount {\n inventoryId Int\n bankAccountId Int\n\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n posAccounts PosAccount[]\n purchaseReceiptPayments PurchaseReceiptPayments[]\n\n @@id([inventoryId, bankAccountId])\n @@index([bankAccountId])\n @@map(\"Inventory_Bank_Accounts\")\n}\n\nmodel PosAccount {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n code String @unique() @db.VarChar(10)\n description String? @db.VarChar(500)\n bankAccountId Int\n inventoryId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])\n salesInvoices SalesInvoice[]\n\n @@index([inventoryId])\n @@map(\"Pos_Accounts\")\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, 0)\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 Bank {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n shortName String @unique() @db.VarChar(3)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n bankBranches BankBranch[] @relation(\"bank_branches\")\n\n @@map(\"Banks\")\n}\n\nmodel Order {\n id Int @id @default(autoincrement())\n orderNumber String @unique @db.VarChar(100)\n status OrderStatus @default(PENDING)\n totalAmount Decimal @db.Decimal(15, 2)\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 customerId Int?\n customer Customer? @relation(fields: [customerId], references: [id], onUpdate: NoAction)\n orderItems OrderItem[]\n\n @@index([customerId])\n @@map(\"Orders\")\n}\n\nmodel OrderItem {\n id Int @id @default(autoincrement())\n quantity Decimal @db.Decimal(10, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalAmount Decimal @db.Decimal(15, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n orderId Int\n productId Int\n\n order Order @relation(fields: [orderId], references: [id], onUpdate: NoAction)\n product Product @relation(fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([orderId])\n @@index([productId])\n @@map(\"Order_Items\")\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()\n stockMovements StockMovement[] @relation()\n salesInvoices SalesInvoice[]\n\n @@map(\"Customers\")\n}\n\nmodel TriggerLog {\n id Int @id @default(autoincrement())\n message String @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n name String @db.Text\n\n @@map(\"Trigger_Logs\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(15, 2)\n salePrice Decimal @db.Decimal(15, 2)\n description String? @db.Text\n barcode String? @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, 0)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 0)\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() @db.VarChar(100)\n barcode String? @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 salePrice Decimal @default(0.00) @db.Decimal(15, 0)\n minimumStockAlertLevel Decimal @default(1.00) @db.Decimal(10, 0)\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\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 stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockBalances StockBalance[] @relation(\"StockBalance_Product\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n salesInvoiceItems SalesInvoiceItem[]\n stockReservations StockReservation[]\n orderItems OrderItem[]\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 PurchaseReceipt {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(15, 2)\n paidAmount Decimal @default(0.00) @db.Decimal(15, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n status PurchaseReceiptStatus @default(UNPAID)\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 payments PurchaseReceiptPayments[]\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, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalAmount Decimal @db.Decimal(15, 2)\n receiptId Int\n productId Int\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\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 PurchaseReceiptPayments {\n id Int @id @default(autoincrement())\n amount Decimal @db.Decimal(15, 2)\n paymentMethod PaymentMethodType\n type PaymentType\n bankAccountId Int\n receiptId Int\n payedAt DateTime @db.Timestamp(0)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n inventoryBankAccount InventoryBankAccount? @relation(fields: [inventoryBankAccountInventoryId, inventoryBankAccountBankAccountId], references: [inventoryId, bankAccountId])\n inventoryBankAccountInventoryId Int?\n inventoryBankAccountBankAccountId Int?\n\n @@index([receiptId], map: \"Purchase_Receipt_Payments_receiptId_fkey\")\n @@map(\"Purchase_Receipt_Payments\")\n}\n\nmodel SalesInvoice {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(15, 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 posAccountId Int\n customer Customer? @relation(fields: [customerId], references: [id])\n posAccount PosAccount @relation(fields: [posAccountId], references: [id])\n items SalesInvoiceItem[]\n salesInvoicePayments SalesInvoicePayment[]\n\n @@index([customerId])\n @@index([posAccountId])\n @@map(\"Sales_Invoices\")\n}\n\nmodel SalesInvoiceItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 0)\n unitPrice Decimal @default(0.00) @db.Decimal(15, 2)\n totalAmount Decimal @default(0.00) @db.Decimal(15, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n invoiceId Int\n productId Int\n invoice SalesInvoice @relation(fields: [invoiceId], references: [id])\n product Product @relation(fields: [productId], references: [id])\n\n @@index([invoiceId])\n @@index([productId])\n @@map(\"Sales_Invoice_Items\")\n}\n\nmodel SalesInvoicePayment {\n id Int @id @default(autoincrement())\n invoiceId Int\n amount Decimal @db.Decimal(15, 2)\n paymentMethod PaymentMethodType\n paidAt DateTime\n createdAt DateTime @default(now())\n\n invoice SalesInvoice @relation(fields: [invoiceId], references: [id])\n\n @@index([invoiceId])\n @@map(\"Sales_Invoice_Payments\")\n}\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"../../src/generated/prisma\"\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel StockMovement {\n id Int @id @default(autoincrement())\n type MovementType\n quantity Decimal @db.Decimal(10, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalCost Decimal @db.Decimal(15, 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(15, 2)\n supplierId Int?\n remainedInStock Decimal @default(0.00) @db.Decimal(10, 0)\n counterInventoryId Int?\n customerId Int?\n counterInventory Inventory? @relation(\"StockMovement_CounterInventory\", fields: [counterInventoryId], references: [id])\n customer Customer? @relation(fields: [customerId], references: [id])\n inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], references: [id])\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 @@index([counterInventoryId], map: \"Stock_Movements_counterInventoryId_fkey\")\n @@index([customerId], map: \"Stock_Movements_customerId_fkey\")\n @@index([supplierId], map: \"Stock_Movements_supplierId_fkey\")\n @@map(\"Stock_Movements\")\n}\n\nmodel StockBalance {\n quantity Decimal @default(0.000) @db.Decimal(14, 3)\n totalCost Decimal @default(0.00) @db.Decimal(14, 2)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n avgCost Decimal @default(0.00) @db.Decimal(14, 2)\n inventoryId Int\n productId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n id Int @id @default(autoincrement())\n inventory Inventory @relation(\"StockBalance_inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockBalance_Product\", fields: [productId], references: [id])\n\n @@unique([productId, inventoryId])\n @@index([productId])\n @@index([inventoryId])\n @@map(\"Stock_Balance\")\n}\n\nmodel StockAdjustment {\n id Int @id @default(autoincrement())\n adjustedQuantity Decimal @db.Decimal(10, 0)\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\nmodel StockReservation {\n id Int @id @default(autoincrement())\n quantity Decimal @db.Decimal(10, 0)\n expiresAt DateTime @db.Timestamp(0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n orderId Int\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n product Product @relation(fields: [productId], references: [id])\n\n @@index([inventoryId])\n @@index([productId])\n @@map(\"Stock_Reservations\")\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 stockMovements StockMovement[] @relation(\"StockMovement_Supplier\")\n receipts PurchaseReceipt[]\n ledger SupplierLedger[]\n\n @@map(\"Suppliers\")\n}\n\nmodel SupplierLedger {\n id Int @id @default(autoincrement())\n description String? @db.Text\n debit Decimal @default(0) @db.Decimal(15, 2)\n credit Decimal @default(0) @db.Decimal(15, 2)\n balance Decimal @db.Decimal(15, 2)\n sourceType LedgerSourceType\n sourceId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n supplierId Int\n supplier Supplier @relation(fields: [supplierId], references: [id])\n\n @@index([supplierId])\n @@map(\"Supplier_Ledger\")\n}\n", + "inlineSchema": "model 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 refreshTokens RefreshToken[]\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 @unique @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 OtpCode {\n id Int @id @default(autoincrement())\n mobileNumber String @db.VarChar(20)\n code String @db.VarChar(10)\n used Boolean @default(false)\n expiresAt DateTime @db.Timestamp(0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n @@index([mobileNumber])\n @@map(\"Otp_Codes\")\n}\n\nmodel RefreshToken {\n id Int @id @default(autoincrement())\n tokenHash String @db.VarChar(255)\n userId Int\n revoked Boolean @default(false)\n expiresAt DateTime @db.Timestamp(0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n user User @relation(fields: [userId], references: [id])\n\n @@index([userId])\n @@map(\"Refresh_Tokens\")\n}\n\nmodel BankBranch {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n code String @unique() @db.VarChar(10)\n address String? @db.VarChar(500)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n bankId Int\n\n bank Bank @relation(\"bank_branches\", fields: [bankId], references: [id])\n bankAccounts BankAccount[] @relation(\"Bank_Accounts_branchId_fkey\")\n\n @@map(\"Bank_Branches\")\n}\n\nmodel BankAccount {\n id Int @id @default(autoincrement())\n accountNumber String? @unique @db.VarChar(20)\n cardNumber String? @unique @db.VarChar(16)\n name String @db.VarChar(255)\n iban String? @unique @db.VarChar(34)\n branchId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n branch BankBranch @relation(\"Bank_Accounts_branchId_fkey\", fields: [branchId], references: [id])\n inventoryBankAccounts InventoryBankAccount[]\n purchaseReceiptPayments PurchaseReceiptPayments[]\n bankAccountTransactions BankAccountTransaction[]\n\n @@map(\"Bank_Accounts\")\n}\n\nmodel BankAccountTransaction {\n id Int @id @default(autoincrement())\n bankAccountId Int\n type BankAccountTransactionType\n amount Decimal @db.Decimal(15, 2)\n balanceAfter Decimal @db.Decimal(15, 2)\n referenceId Int\n referenceType BankTransactionRefType\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n\n @@index([bankAccountId])\n @@map(\"Bank_Account_Transactions\")\n}\n\nenum OrderStatus {\n PENDING\n REJECTED\n CANCELED\n DONE\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 PaymentMethodType {\n CASH\n CARD\n BANK\n CHECK\n OTHER\n}\n\nenum LedgerSourceType {\n PURCHASE\n PAYMENT\n ADJUSTMENT\n REFUND\n}\n\nenum PaymentType {\n PAYMENT\n REFUND\n}\n\nenum PurchaseReceiptStatus {\n UNPAID\n PARTIALLY_PAID\n PAID\n}\n\nenum BankAccountTransactionType {\n DEPOSIT\n WITHDRAWAL\n}\n\nenum BankTransactionRefType {\n PURCHASE_PAYMENT\n PURCHASE_REFUND\n POS_SALE\n POS_REFUND\n BANK_TRANSFER\n MANUAL_ADJUSTMENT\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 isPointOfSale Boolean @default(false)\n inventoryTransfersFrom InventoryTransfer[] @relation(\"Inventory_From\")\n inventoryTransfersTo InventoryTransfer[] @relation(\"Inventory_To\")\n purchaseReceipts PurchaseReceipt[]\n stockAdjustments StockAdjustment[] @relation(\"Inventory_Stock_Adjustments\")\n stockBalances StockBalance[] @relation(\"StockBalance_inventory\")\n counterStockMovements StockMovement[] @relation(\"StockMovement_CounterInventory\")\n stockMovements StockMovement[] @relation(\"StockMovement_Inventory\")\n inventoryBankAccounts InventoryBankAccount[]\n stockReservations StockReservation[]\n\n @@map(\"Inventories\")\n}\n\nmodel InventoryBankAccount {\n inventoryId Int\n bankAccountId Int\n\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n posAccounts PosAccount[]\n purchaseReceiptPayments PurchaseReceiptPayments[]\n\n @@id([inventoryId, bankAccountId])\n @@index([bankAccountId])\n @@map(\"Inventory_Bank_Accounts\")\n}\n\nmodel PosAccount {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n code String @unique() @db.VarChar(10)\n description String? @db.VarChar(500)\n bankAccountId Int\n inventoryId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])\n salesInvoices SalesInvoice[]\n orders Order[]\n\n @@index([inventoryId])\n @@map(\"Pos_Accounts\")\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, 0)\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 Bank {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n shortName String @unique() @db.VarChar(3)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n deletedAt DateTime? @db.Timestamp(0)\n\n bankBranches BankBranch[] @relation(\"bank_branches\")\n\n @@map(\"Banks\")\n}\n\nmodel Order {\n id Int @id @default(autoincrement())\n orderNumber String @unique @db.VarChar(100)\n status OrderStatus @default(PENDING)\n totalAmount Decimal @db.Decimal(15, 2)\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 customerId Int?\n posAccountId Int\n\n customer Customer? @relation(fields: [customerId], references: [id], onUpdate: NoAction)\n posAccount PosAccount @relation(fields: [posAccountId], references: [id], onUpdate: NoAction)\n\n orderItems OrderItem[]\n stockReservations StockReservation[]\n\n @@index([posAccountId])\n @@index([customerId])\n @@map(\"Orders\")\n}\n\nmodel OrderItem {\n id Int @id @default(autoincrement())\n quantity Decimal @db.Decimal(10, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalAmount Decimal @db.Decimal(15, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n orderId Int\n productId Int\n\n order Order @relation(fields: [orderId], references: [id], onUpdate: NoAction)\n product Product @relation(fields: [productId], references: [id], onUpdate: NoAction)\n\n @@index([orderId])\n @@index([productId])\n @@map(\"Order_Items\")\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()\n stockMovements StockMovement[] @relation()\n salesInvoices SalesInvoice[]\n\n @@map(\"Customers\")\n}\n\nmodel TriggerLog {\n id Int @id @default(autoincrement())\n message String @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n name String @db.Text\n\n @@map(\"Trigger_Logs\")\n}\n\nmodel ProductVariant {\n id Int @id @default(autoincrement())\n name String @db.VarChar(255)\n basePrice Decimal @db.Decimal(15, 2)\n salePrice Decimal @db.Decimal(15, 2)\n description String? @db.Text\n barcode String? @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, 0)\n alertQuantity Decimal? @default(5.00) @db.Decimal(10, 0)\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() @db.VarChar(100)\n barcode String? @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 salePrice Decimal @default(0.00) @db.Decimal(15, 0)\n minimumStockAlertLevel Decimal @default(1.00) @db.Decimal(10, 0)\n inventoryTransferItems InventoryTransferItem[] @relation(\"InventoryTransferItem_Product\")\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 stockAdjustments StockAdjustment[] @relation(\"Product_Stock_Adjustments\")\n stockBalances StockBalance[] @relation(\"StockBalance_Product\")\n stockMovements StockMovement[] @relation(\"StockMovement_Product\")\n salesInvoiceItems SalesInvoiceItem[]\n stockReservations StockReservation[]\n orderItems OrderItem[]\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 PurchaseReceipt {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(15, 2)\n paidAmount Decimal @default(0.00) @db.Decimal(15, 2)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n status PurchaseReceiptStatus @default(UNPAID)\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 payments PurchaseReceiptPayments[]\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, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalAmount Decimal @db.Decimal(15, 2)\n receiptId Int\n productId Int\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\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 PurchaseReceiptPayments {\n id Int @id @default(autoincrement())\n amount Decimal @db.Decimal(15, 2)\n paymentMethod PaymentMethodType\n type PaymentType\n bankAccountId Int\n receiptId Int\n payedAt DateTime @db.Timestamp(0)\n description String? @db.Text\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])\n bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])\n inventoryBankAccount InventoryBankAccount? @relation(fields: [inventoryBankAccountInventoryId, inventoryBankAccountBankAccountId], references: [inventoryId, bankAccountId])\n inventoryBankAccountInventoryId Int?\n inventoryBankAccountBankAccountId Int?\n\n @@index([receiptId], map: \"Purchase_Receipt_Payments_receiptId_fkey\")\n @@map(\"Purchase_Receipt_Payments\")\n}\n\nmodel SalesInvoice {\n id Int @id @default(autoincrement())\n code String @unique @db.VarChar(100)\n totalAmount Decimal @db.Decimal(15, 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 posAccountId Int\n customer Customer? @relation(fields: [customerId], references: [id])\n posAccount PosAccount @relation(fields: [posAccountId], references: [id])\n items SalesInvoiceItem[]\n salesInvoicePayments SalesInvoicePayment[]\n\n @@index([customerId])\n @@index([posAccountId])\n @@map(\"Sales_Invoices\")\n}\n\nmodel SalesInvoiceItem {\n id Int @id @default(autoincrement())\n count Decimal @db.Decimal(10, 0)\n unitPrice Decimal @default(0.00) @db.Decimal(15, 2)\n totalAmount Decimal @default(0.00) @db.Decimal(15, 2)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n invoiceId Int\n productId Int\n invoice SalesInvoice @relation(fields: [invoiceId], references: [id])\n product Product @relation(fields: [productId], references: [id])\n\n @@index([invoiceId])\n @@index([productId])\n @@map(\"Sales_Invoice_Items\")\n}\n\nmodel SalesInvoicePayment {\n id Int @id @default(autoincrement())\n invoiceId Int\n amount Decimal @db.Decimal(15, 2)\n paymentMethod PaymentMethodType\n paidAt DateTime\n createdAt DateTime @default(now())\n\n invoice SalesInvoice @relation(fields: [invoiceId], references: [id])\n\n @@index([invoiceId])\n @@map(\"Sales_Invoice_Payments\")\n}\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"../../src/generated/prisma\"\n moduleFormat = \"cjs\"\n previewFeatures = [\"views\"]\n}\n\ndatasource db {\n provider = \"mysql\"\n}\n\nmodel StockMovement {\n id Int @id @default(autoincrement())\n type MovementType\n quantity Decimal @db.Decimal(10, 0)\n unitPrice Decimal @db.Decimal(15, 2)\n totalCost Decimal @db.Decimal(15, 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(15, 2)\n supplierId Int?\n remainedInStock Decimal @default(0.00) @db.Decimal(10, 0)\n counterInventoryId Int?\n customerId Int?\n counterInventory Inventory? @relation(\"StockMovement_CounterInventory\", fields: [counterInventoryId], references: [id])\n customer Customer? @relation(fields: [customerId], references: [id])\n inventory Inventory @relation(\"StockMovement_Inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockMovement_Product\", fields: [productId], references: [id])\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 @@index([counterInventoryId], map: \"Stock_Movements_counterInventoryId_fkey\")\n @@index([customerId], map: \"Stock_Movements_customerId_fkey\")\n @@index([supplierId], map: \"Stock_Movements_supplierId_fkey\")\n @@map(\"Stock_Movements\")\n}\n\nmodel StockBalance {\n quantity Decimal @default(0.000) @db.Decimal(14, 3)\n totalCost Decimal @default(0.00) @db.Decimal(14, 2)\n updatedAt DateTime @updatedAt @db.Timestamp(0)\n avgCost Decimal @default(0.00) @db.Decimal(14, 2)\n inventoryId Int\n productId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n id Int @id @default(autoincrement())\n inventory Inventory @relation(\"StockBalance_inventory\", fields: [inventoryId], references: [id])\n product Product @relation(\"StockBalance_Product\", fields: [productId], references: [id])\n\n @@unique([productId, inventoryId])\n @@index([productId])\n @@index([inventoryId])\n @@map(\"Stock_Balance\")\n}\n\nmodel StockAdjustment {\n id Int @id @default(autoincrement())\n adjustedQuantity Decimal @db.Decimal(10, 0)\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\nmodel StockReservation {\n id Int @id @default(autoincrement())\n quantity Decimal @db.Decimal(10, 0)\n createdAt DateTime @default(now()) @db.Timestamp(0)\n productId Int\n inventoryId Int\n orderId Int\n inventory Inventory @relation(fields: [inventoryId], references: [id])\n product Product @relation(fields: [productId], references: [id])\n order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)\n\n @@index([inventoryId])\n @@index([productId])\n @@map(\"Stock_Reservations\")\n}\n\nview StockAvailableView {\n productId Int\n inventoryId Int\n physicalQuantity Decimal @db.Decimal(10, 0)\n reservedQuantity Decimal @db.Decimal(10, 0)\n availableQuantity Decimal @db.Decimal(10, 0)\n\n @@map(\"Stock_Available_View\")\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 stockMovements StockMovement[] @relation(\"StockMovement_Supplier\")\n receipts PurchaseReceipt[]\n ledger SupplierLedger[]\n\n @@map(\"Suppliers\")\n}\n\nmodel SupplierLedger {\n id Int @id @default(autoincrement())\n description String? @db.Text\n debit Decimal @default(0) @db.Decimal(15, 2)\n credit Decimal @default(0) @db.Decimal(15, 2)\n balance Decimal @db.Decimal(15, 2)\n sourceType LedgerSourceType\n sourceId Int\n createdAt DateTime @default(now()) @db.Timestamp(0)\n\n supplierId Int\n supplier Supplier @relation(fields: [supplierId], references: [id])\n\n @@index([supplierId])\n @@map(\"Supplier_Ledger\")\n}\n", "runtimeDataModel": { "models": {}, "enums": {}, @@ -28,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\":\"refreshTokens\",\"kind\":\"object\",\"type\":\"RefreshToken\",\"relationName\":\"RefreshTokenToUser\"},{\"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\"},\"OtpCode\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"used\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Otp_Codes\"},\"RefreshToken\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"tokenHash\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"revoked\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"RefreshTokenToUser\"}],\"dbName\":\"Refresh_Tokens\"},\"BankBranch\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bank\",\"kind\":\"object\",\"type\":\"Bank\",\"relationName\":\"bank_branches\"},{\"name\":\"bankAccounts\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"Bank_Accounts_branchId_fkey\"}],\"dbName\":\"Bank_Branches\"},\"BankAccount\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"accountNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"cardNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"iban\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"branchId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"branch\",\"kind\":\"object\",\"type\":\"BankBranch\",\"relationName\":\"Bank_Accounts_branchId_fkey\"},{\"name\":\"inventoryBankAccounts\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"BankAccountToInventoryBankAccount\"},{\"name\":\"purchaseReceiptPayments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"BankAccountToPurchaseReceiptPayments\"},{\"name\":\"bankAccountTransactions\",\"kind\":\"object\",\"type\":\"BankAccountTransaction\",\"relationName\":\"BankAccountToBankAccountTransaction\"}],\"dbName\":\"Bank_Accounts\"},\"BankAccountTransaction\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"BankAccountTransactionType\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balanceAfter\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"referenceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"referenceType\",\"kind\":\"enum\",\"type\":\"BankTransactionRefType\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToBankAccountTransaction\"}],\"dbName\":\"Bank_Account_Transactions\"},\"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\":\"isPointOfSale\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"inventoryTransfersFrom\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_From\"},{\"name\":\"inventoryTransfersTo\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_To\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_inventory\"},{\"name\":\"counterStockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_CounterInventory\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"inventoryBankAccounts\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryToInventoryBankAccount\"},{\"name\":\"stockReservations\",\"kind\":\"object\",\"type\":\"StockReservation\",\"relationName\":\"InventoryToStockReservation\"}],\"dbName\":\"Inventories\"},\"InventoryBankAccount\":{\"fields\":[{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToInventoryBankAccount\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToInventoryBankAccount\"},{\"name\":\"posAccounts\",\"kind\":\"object\",\"type\":\"PosAccount\",\"relationName\":\"InventoryBankAccountToPosAccount\"},{\"name\":\"purchaseReceiptPayments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"InventoryBankAccountToPurchaseReceiptPayments\"}],\"dbName\":\"Inventory_Bank_Accounts\"},\"PosAccount\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inventoryBankAccount\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryBankAccountToPosAccount\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"PosAccountToSalesInvoice\"}],\"dbName\":\"Pos_Accounts\"},\"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\"},\"Bank\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"shortName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankBranches\",\"kind\":\"object\",\"type\":\"BankBranch\",\"relationName\":\"bank_branches\"}],\"dbName\":\"Banks\"},\"Order\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"OrderStatus\"},{\"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\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToOrder\"},{\"name\":\"orderItems\",\"kind\":\"object\",\"type\":\"OrderItem\",\"relationName\":\"OrderToOrderItem\"}],\"dbName\":\"Orders\"},\"OrderItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"orderId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"order\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"OrderToOrderItem\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"OrderItemToProduct\"}],\"dbName\":\"Order_Items\"},\"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\":\"CustomerToOrder\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"CustomerToStockMovement\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"CustomerToSalesInvoice\"}],\"dbName\":\"Customers\"},\"TriggerLog\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"message\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"Trigger_Logs\"},\"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\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"minimumStockAlertLevel\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"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\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_Product\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"ProductToSalesInvoiceItem\"},{\"name\":\"stockReservations\",\"kind\":\"object\",\"type\":\"StockReservation\",\"relationName\":\"ProductToStockReservation\"},{\"name\":\"orderItems\",\"kind\":\"object\",\"type\":\"OrderItem\",\"relationName\":\"OrderItemToProduct\"}],\"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\"},\"PurchaseReceipt\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paidAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"PurchaseReceiptStatus\"},{\"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\"},{\"name\":\"payments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"PurchaseReceiptToPurchaseReceiptPayments\"}],\"dbName\":\"Purchase_Receipts\"},\"PurchaseReceiptItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"}],\"dbName\":\"Purchase_Receipt_Items\"},\"PurchaseReceiptPayments\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"PaymentMethodType\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"PaymentType\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"payedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToPurchaseReceiptPayments\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToPurchaseReceiptPayments\"},{\"name\":\"inventoryBankAccount\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryBankAccountToPurchaseReceiptPayments\"},{\"name\":\"inventoryBankAccountInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryBankAccountBankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"}],\"dbName\":\"Purchase_Receipt_Payments\"},\"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\":\"posAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToSalesInvoice\"},{\"name\":\"posAccount\",\"kind\":\"object\",\"type\":\"PosAccount\",\"relationName\":\"PosAccountToSalesInvoice\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoiceToSalesInvoiceItem\"},{\"name\":\"salesInvoicePayments\",\"kind\":\"object\",\"type\":\"SalesInvoicePayment\",\"relationName\":\"SalesInvoiceToSalesInvoicePayment\"}],\"dbName\":\"Sales_Invoices\"},\"SalesInvoiceItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"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\":\"SalesInvoiceToSalesInvoiceItem\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"ProductToSalesInvoiceItem\"}],\"dbName\":\"Sales_Invoice_Items\"},\"SalesInvoicePayment\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"invoiceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"PaymentMethodType\"},{\"name\":\"paidAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invoice\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"SalesInvoiceToSalesInvoicePayment\"}],\"dbName\":\"Sales_Invoice_Payments\"},\"StockMovement\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"MovementType\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"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\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"remainedInStock\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"counterInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"counterInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_CounterInventory\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToStockMovement\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockBalance_inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockBalance_Product\"}],\"dbName\":\"Stock_Balance\"},\"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\"},\"StockReservation\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToStockReservation\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"ProductToStockReservation\"}],\"dbName\":\"Stock_Reservations\"},\"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\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Supplier\"},{\"name\":\"receipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToSupplier\"},{\"name\":\"ledger\",\"kind\":\"object\",\"type\":\"SupplierLedger\",\"relationName\":\"SupplierToSupplierLedger\"}],\"dbName\":\"Suppliers\"},\"SupplierLedger\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"debit\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"credit\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"sourceType\",\"kind\":\"enum\",\"type\":\"LedgerSourceType\"},{\"name\":\"sourceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"SupplierToSupplierLedger\"}],\"dbName\":\"Supplier_Ledger\"}},\"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\":\"refreshTokens\",\"kind\":\"object\",\"type\":\"RefreshToken\",\"relationName\":\"RefreshTokenToUser\"},{\"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\"},\"OtpCode\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"mobileNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"used\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"Otp_Codes\"},\"RefreshToken\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"tokenHash\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"revoked\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"RefreshTokenToUser\"}],\"dbName\":\"Refresh_Tokens\"},\"BankBranch\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"address\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bank\",\"kind\":\"object\",\"type\":\"Bank\",\"relationName\":\"bank_branches\"},{\"name\":\"bankAccounts\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"Bank_Accounts_branchId_fkey\"}],\"dbName\":\"Bank_Branches\"},\"BankAccount\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"accountNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"cardNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"iban\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"branchId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"branch\",\"kind\":\"object\",\"type\":\"BankBranch\",\"relationName\":\"Bank_Accounts_branchId_fkey\"},{\"name\":\"inventoryBankAccounts\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"BankAccountToInventoryBankAccount\"},{\"name\":\"purchaseReceiptPayments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"BankAccountToPurchaseReceiptPayments\"},{\"name\":\"bankAccountTransactions\",\"kind\":\"object\",\"type\":\"BankAccountTransaction\",\"relationName\":\"BankAccountToBankAccountTransaction\"}],\"dbName\":\"Bank_Accounts\"},\"BankAccountTransaction\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"BankAccountTransactionType\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balanceAfter\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"referenceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"referenceType\",\"kind\":\"enum\",\"type\":\"BankTransactionRefType\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToBankAccountTransaction\"}],\"dbName\":\"Bank_Account_Transactions\"},\"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\":\"isPointOfSale\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"inventoryTransfersFrom\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_From\"},{\"name\":\"inventoryTransfersTo\",\"kind\":\"object\",\"type\":\"InventoryTransfer\",\"relationName\":\"Inventory_To\"},{\"name\":\"purchaseReceipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"InventoryToPurchaseReceipt\"},{\"name\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Inventory_Stock_Adjustments\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_inventory\"},{\"name\":\"counterStockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_CounterInventory\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"inventoryBankAccounts\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryToInventoryBankAccount\"},{\"name\":\"stockReservations\",\"kind\":\"object\",\"type\":\"StockReservation\",\"relationName\":\"InventoryToStockReservation\"}],\"dbName\":\"Inventories\"},\"InventoryBankAccount\":{\"fields\":[{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToInventoryBankAccount\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToInventoryBankAccount\"},{\"name\":\"posAccounts\",\"kind\":\"object\",\"type\":\"PosAccount\",\"relationName\":\"InventoryBankAccountToPosAccount\"},{\"name\":\"purchaseReceiptPayments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"InventoryBankAccountToPurchaseReceiptPayments\"}],\"dbName\":\"Inventory_Bank_Accounts\"},\"PosAccount\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inventoryBankAccount\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryBankAccountToPosAccount\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"PosAccountToSalesInvoice\"},{\"name\":\"orders\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"OrderToPosAccount\"}],\"dbName\":\"Pos_Accounts\"},\"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\"},\"Bank\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"shortName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"bankBranches\",\"kind\":\"object\",\"type\":\"BankBranch\",\"relationName\":\"bank_branches\"}],\"dbName\":\"Banks\"},\"Order\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderNumber\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"OrderStatus\"},{\"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\":\"deletedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"posAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToOrder\"},{\"name\":\"posAccount\",\"kind\":\"object\",\"type\":\"PosAccount\",\"relationName\":\"OrderToPosAccount\"},{\"name\":\"orderItems\",\"kind\":\"object\",\"type\":\"OrderItem\",\"relationName\":\"OrderToOrderItem\"},{\"name\":\"stockReservations\",\"kind\":\"object\",\"type\":\"StockReservation\",\"relationName\":\"OrderToStockReservation\"}],\"dbName\":\"Orders\"},\"OrderItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"orderId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"order\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"OrderToOrderItem\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"OrderItemToProduct\"}],\"dbName\":\"Order_Items\"},\"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\":\"CustomerToOrder\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"CustomerToStockMovement\"},{\"name\":\"salesInvoices\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"CustomerToSalesInvoice\"}],\"dbName\":\"Customers\"},\"TriggerLog\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"message\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"Trigger_Logs\"},\"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\":\"salePrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"minimumStockAlertLevel\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventoryTransferItems\",\"kind\":\"object\",\"type\":\"InventoryTransferItem\",\"relationName\":\"InventoryTransferItem_Product\"},{\"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\":\"stockAdjustments\",\"kind\":\"object\",\"type\":\"StockAdjustment\",\"relationName\":\"Product_Stock_Adjustments\"},{\"name\":\"stockBalances\",\"kind\":\"object\",\"type\":\"StockBalance\",\"relationName\":\"StockBalance_Product\"},{\"name\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"salesInvoiceItems\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"ProductToSalesInvoiceItem\"},{\"name\":\"stockReservations\",\"kind\":\"object\",\"type\":\"StockReservation\",\"relationName\":\"ProductToStockReservation\"},{\"name\":\"orderItems\",\"kind\":\"object\",\"type\":\"OrderItem\",\"relationName\":\"OrderItemToProduct\"}],\"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\"},\"PurchaseReceipt\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"code\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paidAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"status\",\"kind\":\"enum\",\"type\":\"PurchaseReceiptStatus\"},{\"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\"},{\"name\":\"payments\",\"kind\":\"object\",\"type\":\"PurchaseReceiptPayments\",\"relationName\":\"PurchaseReceiptToPurchaseReceiptPayments\"}],\"dbName\":\"Purchase_Receipts\"},\"PurchaseReceiptItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"Product_PurchaseReceiptItems\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceipt_Items\"}],\"dbName\":\"Purchase_Receipt_Items\"},\"PurchaseReceiptPayments\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"PaymentMethodType\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"PaymentType\"},{\"name\":\"bankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"receiptId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"payedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"receipt\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToPurchaseReceiptPayments\"},{\"name\":\"bankAccount\",\"kind\":\"object\",\"type\":\"BankAccount\",\"relationName\":\"BankAccountToPurchaseReceiptPayments\"},{\"name\":\"inventoryBankAccount\",\"kind\":\"object\",\"type\":\"InventoryBankAccount\",\"relationName\":\"InventoryBankAccountToPurchaseReceiptPayments\"},{\"name\":\"inventoryBankAccountInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryBankAccountBankAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"}],\"dbName\":\"Purchase_Receipt_Payments\"},\"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\":\"posAccountId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToSalesInvoice\"},{\"name\":\"posAccount\",\"kind\":\"object\",\"type\":\"PosAccount\",\"relationName\":\"PosAccountToSalesInvoice\"},{\"name\":\"items\",\"kind\":\"object\",\"type\":\"SalesInvoiceItem\",\"relationName\":\"SalesInvoiceToSalesInvoiceItem\"},{\"name\":\"salesInvoicePayments\",\"kind\":\"object\",\"type\":\"SalesInvoicePayment\",\"relationName\":\"SalesInvoiceToSalesInvoicePayment\"}],\"dbName\":\"Sales_Invoices\"},\"SalesInvoiceItem\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"count\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalAmount\",\"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\":\"SalesInvoiceToSalesInvoiceItem\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"ProductToSalesInvoiceItem\"}],\"dbName\":\"Sales_Invoice_Items\"},\"SalesInvoicePayment\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"invoiceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"amount\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"paymentMethod\",\"kind\":\"enum\",\"type\":\"PaymentMethodType\"},{\"name\":\"paidAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invoice\",\"kind\":\"object\",\"type\":\"SalesInvoice\",\"relationName\":\"SalesInvoiceToSalesInvoicePayment\"}],\"dbName\":\"Sales_Invoice_Payments\"},\"StockMovement\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"type\",\"kind\":\"enum\",\"type\":\"MovementType\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"unitPrice\",\"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\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"remainedInStock\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"counterInventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"customerId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"counterInventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_CounterInventory\"},{\"name\":\"customer\",\"kind\":\"object\",\"type\":\"Customer\",\"relationName\":\"CustomerToStockMovement\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockMovement_Inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockMovement_Product\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"StockMovement_Supplier\"}],\"dbName\":\"Stock_Movements\"},\"StockBalance\":{\"fields\":[{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"totalCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"avgCost\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"StockBalance_inventory\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"StockBalance_Product\"}],\"dbName\":\"Stock_Balance\"},\"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\"},\"StockReservation\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"orderId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventory\",\"kind\":\"object\",\"type\":\"Inventory\",\"relationName\":\"InventoryToStockReservation\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"ProductToStockReservation\"},{\"name\":\"order\",\"kind\":\"object\",\"type\":\"Order\",\"relationName\":\"OrderToStockReservation\"}],\"dbName\":\"Stock_Reservations\"},\"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\":\"stockMovements\",\"kind\":\"object\",\"type\":\"StockMovement\",\"relationName\":\"StockMovement_Supplier\"},{\"name\":\"receipts\",\"kind\":\"object\",\"type\":\"PurchaseReceipt\",\"relationName\":\"PurchaseReceiptToSupplier\"},{\"name\":\"ledger\",\"kind\":\"object\",\"type\":\"SupplierLedger\",\"relationName\":\"SupplierToSupplierLedger\"}],\"dbName\":\"Suppliers\"},\"SupplierLedger\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"debit\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"credit\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"balance\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"sourceType\",\"kind\":\"enum\",\"type\":\"LedgerSourceType\"},{\"name\":\"sourceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"supplierId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"supplier\",\"kind\":\"object\",\"type\":\"Supplier\",\"relationName\":\"SupplierToSupplierLedger\"}],\"dbName\":\"Supplier_Ledger\"},\"StockAvailableView\":{\"fields\":[{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"inventoryId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"physicalQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"reservedQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"},{\"name\":\"availableQuantity\",\"kind\":\"scalar\",\"type\":\"Decimal\"}],\"dbName\":\"Stock_Available_View\"}},\"enums\":{},\"types\":{}}") async function decodeBase64AsWasm(wasmBase64: string): Promise { const { Buffer } = await import('node:buffer') @@ -503,6 +505,16 @@ export interface PrismaClient< * ``` */ get supplierLedger(): Prisma.SupplierLedgerDelegate; + + /** + * `prisma.stockAvailableView`: Exposes CRUD operations for the **StockAvailableView** model. + * Example usage: + * ```ts + * // Fetch zero or more StockAvailableViews + * const stockAvailableViews = await prisma.stockAvailableView.findMany() + * ``` + */ + get stockAvailableView(): Prisma.StockAvailableViewDelegate; } export function getPrismaClientClass(): PrismaClientConstructor { diff --git a/src/generated/prisma/internal/prismaNamespace.ts b/src/generated/prisma/internal/prismaNamespace.ts index d3fb9b6..9974b65 100644 --- a/src/generated/prisma/internal/prismaNamespace.ts +++ b/src/generated/prisma/internal/prismaNamespace.ts @@ -416,7 +416,8 @@ export const ModelName = { StockAdjustment: 'StockAdjustment', StockReservation: 'StockReservation', Supplier: 'Supplier', - SupplierLedger: 'SupplierLedger' + SupplierLedger: 'SupplierLedger', + StockAvailableView: 'StockAvailableView' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -432,7 +433,7 @@ export type TypeMap + fields: Prisma.StockAvailableViewFieldRefs + operations: { + findFirst: { + args: Prisma.StockAvailableViewFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.StockAvailableViewFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.StockAvailableViewFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + aggregate: { + args: Prisma.StockAvailableViewAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.StockAvailableViewGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.StockAvailableViewCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } } } & { other: { @@ -2829,7 +2860,8 @@ export const OrderScalarFieldEnum = { createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt', - customerId: 'customerId' + customerId: 'customerId', + posAccountId: 'posAccountId' } as const export type OrderScalarFieldEnum = (typeof OrderScalarFieldEnum)[keyof typeof OrderScalarFieldEnum] @@ -3078,7 +3110,6 @@ export type StockAdjustmentScalarFieldEnum = (typeof StockAdjustmentScalarFieldE export const StockReservationScalarFieldEnum = { id: 'id', quantity: 'quantity', - expiresAt: 'expiresAt', createdAt: 'createdAt', productId: 'productId', inventoryId: 'inventoryId', @@ -3122,6 +3153,17 @@ export const SupplierLedgerScalarFieldEnum = { export type SupplierLedgerScalarFieldEnum = (typeof SupplierLedgerScalarFieldEnum)[keyof typeof SupplierLedgerScalarFieldEnum] +export const StockAvailableViewScalarFieldEnum = { + productId: 'productId', + inventoryId: 'inventoryId', + physicalQuantity: 'physicalQuantity', + reservedQuantity: 'reservedQuantity', + availableQuantity: 'availableQuantity' +} as const + +export type StockAvailableViewScalarFieldEnum = (typeof StockAvailableViewScalarFieldEnum)[keyof typeof StockAvailableViewScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' @@ -3634,6 +3676,7 @@ export type GlobalOmitConfig = { stockReservation?: Prisma.StockReservationOmit supplier?: Prisma.SupplierOmit supplierLedger?: Prisma.SupplierLedgerOmit + stockAvailableView?: Prisma.StockAvailableViewOmit } /* Types for Logging */ diff --git a/src/generated/prisma/internal/prismaNamespaceBrowser.ts b/src/generated/prisma/internal/prismaNamespaceBrowser.ts index 68e1516..9bb2be8 100644 --- a/src/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/src/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -83,7 +83,8 @@ export const ModelName = { StockAdjustment: 'StockAdjustment', StockReservation: 'StockReservation', Supplier: 'Supplier', - SupplierLedger: 'SupplierLedger' + SupplierLedger: 'SupplierLedger', + StockAvailableView: 'StockAvailableView' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -278,7 +279,8 @@ export const OrderScalarFieldEnum = { createdAt: 'createdAt', updatedAt: 'updatedAt', deletedAt: 'deletedAt', - customerId: 'customerId' + customerId: 'customerId', + posAccountId: 'posAccountId' } as const export type OrderScalarFieldEnum = (typeof OrderScalarFieldEnum)[keyof typeof OrderScalarFieldEnum] @@ -527,7 +529,6 @@ export type StockAdjustmentScalarFieldEnum = (typeof StockAdjustmentScalarFieldE export const StockReservationScalarFieldEnum = { id: 'id', quantity: 'quantity', - expiresAt: 'expiresAt', createdAt: 'createdAt', productId: 'productId', inventoryId: 'inventoryId', @@ -571,6 +572,17 @@ export const SupplierLedgerScalarFieldEnum = { export type SupplierLedgerScalarFieldEnum = (typeof SupplierLedgerScalarFieldEnum)[keyof typeof SupplierLedgerScalarFieldEnum] +export const StockAvailableViewScalarFieldEnum = { + productId: 'productId', + inventoryId: 'inventoryId', + physicalQuantity: 'physicalQuantity', + reservedQuantity: 'reservedQuantity', + availableQuantity: 'availableQuantity' +} as const + +export type StockAvailableViewScalarFieldEnum = (typeof StockAvailableViewScalarFieldEnum)[keyof typeof StockAvailableViewScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' diff --git a/src/generated/prisma/models.ts b/src/generated/prisma/models.ts index 2c6dea6..d7eb658 100644 --- a/src/generated/prisma/models.ts +++ b/src/generated/prisma/models.ts @@ -41,4 +41,5 @@ export type * from './models/StockAdjustment.js' export type * from './models/StockReservation.js' export type * from './models/Supplier.js' export type * from './models/SupplierLedger.js' +export type * from './models/StockAvailableView.js' export type * from './commonInputTypes.js' \ No newline at end of file diff --git a/src/generated/prisma/models/Order.ts b/src/generated/prisma/models/Order.ts index 55783e7..4449b64 100644 --- a/src/generated/prisma/models/Order.ts +++ b/src/generated/prisma/models/Order.ts @@ -30,12 +30,14 @@ export type OrderAvgAggregateOutputType = { id: number | null totalAmount: runtime.Decimal | null customerId: number | null + posAccountId: number | null } export type OrderSumAggregateOutputType = { id: number | null totalAmount: runtime.Decimal | null customerId: number | null + posAccountId: number | null } export type OrderMinAggregateOutputType = { @@ -48,6 +50,7 @@ export type OrderMinAggregateOutputType = { updatedAt: Date | null deletedAt: Date | null customerId: number | null + posAccountId: number | null } export type OrderMaxAggregateOutputType = { @@ -60,6 +63,7 @@ export type OrderMaxAggregateOutputType = { updatedAt: Date | null deletedAt: Date | null customerId: number | null + posAccountId: number | null } export type OrderCountAggregateOutputType = { @@ -72,6 +76,7 @@ export type OrderCountAggregateOutputType = { updatedAt: number deletedAt: number customerId: number + posAccountId: number _all: number } @@ -80,12 +85,14 @@ export type OrderAvgAggregateInputType = { id?: true totalAmount?: true customerId?: true + posAccountId?: true } export type OrderSumAggregateInputType = { id?: true totalAmount?: true customerId?: true + posAccountId?: true } export type OrderMinAggregateInputType = { @@ -98,6 +105,7 @@ export type OrderMinAggregateInputType = { updatedAt?: true deletedAt?: true customerId?: true + posAccountId?: true } export type OrderMaxAggregateInputType = { @@ -110,6 +118,7 @@ export type OrderMaxAggregateInputType = { updatedAt?: true deletedAt?: true customerId?: true + posAccountId?: true } export type OrderCountAggregateInputType = { @@ -122,6 +131,7 @@ export type OrderCountAggregateInputType = { updatedAt?: true deletedAt?: true customerId?: true + posAccountId?: true _all?: true } @@ -221,6 +231,7 @@ export type OrderGroupByOutputType = { updatedAt: Date deletedAt: Date | null customerId: number | null + posAccountId: number _count: OrderCountAggregateOutputType | null _avg: OrderAvgAggregateOutputType | null _sum: OrderSumAggregateOutputType | null @@ -256,8 +267,11 @@ export type OrderWhereInput = { updatedAt?: Prisma.DateTimeFilter<"Order"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Order"> | Date | string | null customerId?: Prisma.IntNullableFilter<"Order"> | number | null + posAccountId?: Prisma.IntFilter<"Order"> | number customer?: Prisma.XOR | null + posAccount?: Prisma.XOR orderItems?: Prisma.OrderItemListRelationFilter + stockReservations?: Prisma.StockReservationListRelationFilter } export type OrderOrderByWithRelationInput = { @@ -270,8 +284,11 @@ export type OrderOrderByWithRelationInput = { updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder customerId?: Prisma.SortOrderInput | Prisma.SortOrder + posAccountId?: Prisma.SortOrder customer?: Prisma.CustomerOrderByWithRelationInput + posAccount?: Prisma.PosAccountOrderByWithRelationInput orderItems?: Prisma.OrderItemOrderByRelationAggregateInput + stockReservations?: Prisma.StockReservationOrderByRelationAggregateInput _relevance?: Prisma.OrderOrderByRelevanceInput } @@ -288,8 +305,11 @@ export type OrderWhereUniqueInput = Prisma.AtLeast<{ updatedAt?: Prisma.DateTimeFilter<"Order"> | Date | string deletedAt?: Prisma.DateTimeNullableFilter<"Order"> | Date | string | null customerId?: Prisma.IntNullableFilter<"Order"> | number | null + posAccountId?: Prisma.IntFilter<"Order"> | number customer?: Prisma.XOR | null + posAccount?: Prisma.XOR orderItems?: Prisma.OrderItemListRelationFilter + stockReservations?: Prisma.StockReservationListRelationFilter }, "id" | "orderNumber"> export type OrderOrderByWithAggregationInput = { @@ -302,6 +322,7 @@ export type OrderOrderByWithAggregationInput = { updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder customerId?: Prisma.SortOrderInput | Prisma.SortOrder + posAccountId?: Prisma.SortOrder _count?: Prisma.OrderCountOrderByAggregateInput _avg?: Prisma.OrderAvgOrderByAggregateInput _max?: Prisma.OrderMaxOrderByAggregateInput @@ -322,6 +343,7 @@ export type OrderScalarWhereWithAggregatesInput = { updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Order"> | Date | string deletedAt?: Prisma.DateTimeNullableWithAggregatesFilter<"Order"> | Date | string | null customerId?: Prisma.IntNullableWithAggregatesFilter<"Order"> | number | null + posAccountId?: Prisma.IntWithAggregatesFilter<"Order"> | number } export type OrderCreateInput = { @@ -333,7 +355,9 @@ export type OrderCreateInput = { updatedAt?: Date | string deletedAt?: Date | string | null customer?: Prisma.CustomerCreateNestedOneWithoutOrdersInput + posAccount: Prisma.PosAccountCreateNestedOneWithoutOrdersInput orderItems?: Prisma.OrderItemCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationCreateNestedManyWithoutOrderInput } export type OrderUncheckedCreateInput = { @@ -346,7 +370,9 @@ export type OrderUncheckedCreateInput = { updatedAt?: Date | string deletedAt?: Date | string | null customerId?: number | null + posAccountId: number orderItems?: Prisma.OrderItemUncheckedCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationUncheckedCreateNestedManyWithoutOrderInput } export type OrderUpdateInput = { @@ -358,7 +384,9 @@ export type OrderUpdateInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null customer?: Prisma.CustomerUpdateOneWithoutOrdersNestedInput + posAccount?: Prisma.PosAccountUpdateOneRequiredWithoutOrdersNestedInput orderItems?: Prisma.OrderItemUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUpdateManyWithoutOrderNestedInput } export type OrderUncheckedUpdateInput = { @@ -371,7 +399,9 @@ export type OrderUncheckedUpdateInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number orderItems?: Prisma.OrderItemUncheckedUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUncheckedUpdateManyWithoutOrderNestedInput } export type OrderCreateManyInput = { @@ -384,6 +414,7 @@ export type OrderCreateManyInput = { updatedAt?: Date | string deletedAt?: Date | string | null customerId?: number | null + posAccountId: number } export type OrderUpdateManyMutationInput = { @@ -406,6 +437,17 @@ export type OrderUncheckedUpdateManyInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type OrderListRelationFilter = { + every?: Prisma.OrderWhereInput + some?: Prisma.OrderWhereInput + none?: Prisma.OrderWhereInput +} + +export type OrderOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder } export type OrderOrderByRelevanceInput = { @@ -424,12 +466,14 @@ export type OrderCountOrderByAggregateInput = { updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + posAccountId?: Prisma.SortOrder } export type OrderAvgOrderByAggregateInput = { id?: Prisma.SortOrder totalAmount?: Prisma.SortOrder customerId?: Prisma.SortOrder + posAccountId?: Prisma.SortOrder } export type OrderMaxOrderByAggregateInput = { @@ -442,6 +486,7 @@ export type OrderMaxOrderByAggregateInput = { updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + posAccountId?: Prisma.SortOrder } export type OrderMinOrderByAggregateInput = { @@ -454,12 +499,14 @@ export type OrderMinOrderByAggregateInput = { updatedAt?: Prisma.SortOrder deletedAt?: Prisma.SortOrder customerId?: Prisma.SortOrder + posAccountId?: Prisma.SortOrder } export type OrderSumOrderByAggregateInput = { id?: Prisma.SortOrder totalAmount?: Prisma.SortOrder customerId?: Prisma.SortOrder + posAccountId?: Prisma.SortOrder } export type OrderScalarRelationFilter = { @@ -467,14 +514,46 @@ export type OrderScalarRelationFilter = { isNot?: Prisma.OrderWhereInput } -export type OrderListRelationFilter = { - every?: Prisma.OrderWhereInput - some?: Prisma.OrderWhereInput - none?: Prisma.OrderWhereInput +export type OrderCreateNestedManyWithoutPosAccountInput = { + create?: Prisma.XOR | Prisma.OrderCreateWithoutPosAccountInput[] | Prisma.OrderUncheckedCreateWithoutPosAccountInput[] + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutPosAccountInput | Prisma.OrderCreateOrConnectWithoutPosAccountInput[] + createMany?: Prisma.OrderCreateManyPosAccountInputEnvelope + connect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] } -export type OrderOrderByRelationAggregateInput = { - _count?: Prisma.SortOrder +export type OrderUncheckedCreateNestedManyWithoutPosAccountInput = { + create?: Prisma.XOR | Prisma.OrderCreateWithoutPosAccountInput[] | Prisma.OrderUncheckedCreateWithoutPosAccountInput[] + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutPosAccountInput | Prisma.OrderCreateOrConnectWithoutPosAccountInput[] + createMany?: Prisma.OrderCreateManyPosAccountInputEnvelope + connect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] +} + +export type OrderUpdateManyWithoutPosAccountNestedInput = { + create?: Prisma.XOR | Prisma.OrderCreateWithoutPosAccountInput[] | Prisma.OrderUncheckedCreateWithoutPosAccountInput[] + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutPosAccountInput | Prisma.OrderCreateOrConnectWithoutPosAccountInput[] + upsert?: Prisma.OrderUpsertWithWhereUniqueWithoutPosAccountInput | Prisma.OrderUpsertWithWhereUniqueWithoutPosAccountInput[] + createMany?: Prisma.OrderCreateManyPosAccountInputEnvelope + set?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + disconnect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + delete?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + connect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + update?: Prisma.OrderUpdateWithWhereUniqueWithoutPosAccountInput | Prisma.OrderUpdateWithWhereUniqueWithoutPosAccountInput[] + updateMany?: Prisma.OrderUpdateManyWithWhereWithoutPosAccountInput | Prisma.OrderUpdateManyWithWhereWithoutPosAccountInput[] + deleteMany?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] +} + +export type OrderUncheckedUpdateManyWithoutPosAccountNestedInput = { + create?: Prisma.XOR | Prisma.OrderCreateWithoutPosAccountInput[] | Prisma.OrderUncheckedCreateWithoutPosAccountInput[] + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutPosAccountInput | Prisma.OrderCreateOrConnectWithoutPosAccountInput[] + upsert?: Prisma.OrderUpsertWithWhereUniqueWithoutPosAccountInput | Prisma.OrderUpsertWithWhereUniqueWithoutPosAccountInput[] + createMany?: Prisma.OrderCreateManyPosAccountInputEnvelope + set?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + disconnect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + delete?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + connect?: Prisma.OrderWhereUniqueInput | Prisma.OrderWhereUniqueInput[] + update?: Prisma.OrderUpdateWithWhereUniqueWithoutPosAccountInput | Prisma.OrderUpdateWithWhereUniqueWithoutPosAccountInput[] + updateMany?: Prisma.OrderUpdateManyWithWhereWithoutPosAccountInput | Prisma.OrderUpdateManyWithWhereWithoutPosAccountInput[] + deleteMany?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] } export type EnumOrderStatusFieldUpdateOperationsInput = { @@ -545,6 +624,89 @@ export type OrderUncheckedUpdateManyWithoutCustomerNestedInput = { deleteMany?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] } +export type OrderCreateNestedOneWithoutStockReservationsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutStockReservationsInput + connect?: Prisma.OrderWhereUniqueInput +} + +export type OrderUpdateOneRequiredWithoutStockReservationsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.OrderCreateOrConnectWithoutStockReservationsInput + upsert?: Prisma.OrderUpsertWithoutStockReservationsInput + connect?: Prisma.OrderWhereUniqueInput + update?: Prisma.XOR, Prisma.OrderUncheckedUpdateWithoutStockReservationsInput> +} + +export type OrderCreateWithoutPosAccountInput = { + orderNumber: string + status?: $Enums.OrderStatus + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + customer?: Prisma.CustomerCreateNestedOneWithoutOrdersInput + orderItems?: Prisma.OrderItemCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationCreateNestedManyWithoutOrderInput +} + +export type OrderUncheckedCreateWithoutPosAccountInput = { + id?: number + orderNumber: string + status?: $Enums.OrderStatus + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + customerId?: number | null + orderItems?: Prisma.OrderItemUncheckedCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationUncheckedCreateNestedManyWithoutOrderInput +} + +export type OrderCreateOrConnectWithoutPosAccountInput = { + where: Prisma.OrderWhereUniqueInput + create: Prisma.XOR +} + +export type OrderCreateManyPosAccountInputEnvelope = { + data: Prisma.OrderCreateManyPosAccountInput | Prisma.OrderCreateManyPosAccountInput[] + skipDuplicates?: boolean +} + +export type OrderUpsertWithWhereUniqueWithoutPosAccountInput = { + where: Prisma.OrderWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type OrderUpdateWithWhereUniqueWithoutPosAccountInput = { + where: Prisma.OrderWhereUniqueInput + data: Prisma.XOR +} + +export type OrderUpdateManyWithWhereWithoutPosAccountInput = { + where: Prisma.OrderScalarWhereInput + data: Prisma.XOR +} + +export type OrderScalarWhereInput = { + AND?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] + OR?: Prisma.OrderScalarWhereInput[] + NOT?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] + id?: Prisma.IntFilter<"Order"> | number + orderNumber?: Prisma.StringFilter<"Order"> | string + status?: Prisma.EnumOrderStatusFilter<"Order"> | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFilter<"Order"> | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.StringNullableFilter<"Order"> | string | null + createdAt?: Prisma.DateTimeFilter<"Order"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Order"> | Date | string + deletedAt?: Prisma.DateTimeNullableFilter<"Order"> | Date | string | null + customerId?: Prisma.IntNullableFilter<"Order"> | number | null + posAccountId?: Prisma.IntFilter<"Order"> | number +} + export type OrderCreateWithoutOrderItemsInput = { orderNumber: string status?: $Enums.OrderStatus @@ -554,6 +716,8 @@ export type OrderCreateWithoutOrderItemsInput = { updatedAt?: Date | string deletedAt?: Date | string | null customer?: Prisma.CustomerCreateNestedOneWithoutOrdersInput + posAccount: Prisma.PosAccountCreateNestedOneWithoutOrdersInput + stockReservations?: Prisma.StockReservationCreateNestedManyWithoutOrderInput } export type OrderUncheckedCreateWithoutOrderItemsInput = { @@ -566,6 +730,8 @@ export type OrderUncheckedCreateWithoutOrderItemsInput = { updatedAt?: Date | string deletedAt?: Date | string | null customerId?: number | null + posAccountId: number + stockReservations?: Prisma.StockReservationUncheckedCreateNestedManyWithoutOrderInput } export type OrderCreateOrConnectWithoutOrderItemsInput = { @@ -593,6 +759,8 @@ export type OrderUpdateWithoutOrderItemsInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null customer?: Prisma.CustomerUpdateOneWithoutOrdersNestedInput + posAccount?: Prisma.PosAccountUpdateOneRequiredWithoutOrdersNestedInput + stockReservations?: Prisma.StockReservationUpdateManyWithoutOrderNestedInput } export type OrderUncheckedUpdateWithoutOrderItemsInput = { @@ -605,6 +773,8 @@ export type OrderUncheckedUpdateWithoutOrderItemsInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number + stockReservations?: Prisma.StockReservationUncheckedUpdateManyWithoutOrderNestedInput } export type OrderCreateWithoutCustomerInput = { @@ -615,7 +785,9 @@ export type OrderCreateWithoutCustomerInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + posAccount: Prisma.PosAccountCreateNestedOneWithoutOrdersInput orderItems?: Prisma.OrderItemCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationCreateNestedManyWithoutOrderInput } export type OrderUncheckedCreateWithoutCustomerInput = { @@ -627,7 +799,9 @@ export type OrderUncheckedCreateWithoutCustomerInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + posAccountId: number orderItems?: Prisma.OrderItemUncheckedCreateNestedManyWithoutOrderInput + stockReservations?: Prisma.StockReservationUncheckedCreateNestedManyWithoutOrderInput } export type OrderCreateOrConnectWithoutCustomerInput = { @@ -656,19 +830,125 @@ export type OrderUpdateManyWithWhereWithoutCustomerInput = { data: Prisma.XOR } -export type OrderScalarWhereInput = { - AND?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] - OR?: Prisma.OrderScalarWhereInput[] - NOT?: Prisma.OrderScalarWhereInput | Prisma.OrderScalarWhereInput[] - id?: Prisma.IntFilter<"Order"> | number - orderNumber?: Prisma.StringFilter<"Order"> | string - status?: Prisma.EnumOrderStatusFilter<"Order"> | $Enums.OrderStatus - totalAmount?: Prisma.DecimalFilter<"Order"> | runtime.Decimal | runtime.DecimalJsLike | number | string - description?: Prisma.StringNullableFilter<"Order"> | string | null - createdAt?: Prisma.DateTimeFilter<"Order"> | Date | string - updatedAt?: Prisma.DateTimeFilter<"Order"> | Date | string - deletedAt?: Prisma.DateTimeNullableFilter<"Order"> | Date | string | null - customerId?: Prisma.IntNullableFilter<"Order"> | number | null +export type OrderCreateWithoutStockReservationsInput = { + orderNumber: string + status?: $Enums.OrderStatus + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + customer?: Prisma.CustomerCreateNestedOneWithoutOrdersInput + posAccount: Prisma.PosAccountCreateNestedOneWithoutOrdersInput + orderItems?: Prisma.OrderItemCreateNestedManyWithoutOrderInput +} + +export type OrderUncheckedCreateWithoutStockReservationsInput = { + id?: number + orderNumber: string + status?: $Enums.OrderStatus + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + customerId?: number | null + posAccountId: number + orderItems?: Prisma.OrderItemUncheckedCreateNestedManyWithoutOrderInput +} + +export type OrderCreateOrConnectWithoutStockReservationsInput = { + where: Prisma.OrderWhereUniqueInput + create: Prisma.XOR +} + +export type OrderUpsertWithoutStockReservationsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.OrderWhereInput +} + +export type OrderUpdateToOneWithWhereWithoutStockReservationsInput = { + where?: Prisma.OrderWhereInput + data: Prisma.XOR +} + +export type OrderUpdateWithoutStockReservationsInput = { + orderNumber?: Prisma.StringFieldUpdateOperationsInput | string + status?: Prisma.EnumOrderStatusFieldUpdateOperationsInput | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + customer?: Prisma.CustomerUpdateOneWithoutOrdersNestedInput + posAccount?: Prisma.PosAccountUpdateOneRequiredWithoutOrdersNestedInput + orderItems?: Prisma.OrderItemUpdateManyWithoutOrderNestedInput +} + +export type OrderUncheckedUpdateWithoutStockReservationsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + orderNumber?: Prisma.StringFieldUpdateOperationsInput | string + status?: Prisma.EnumOrderStatusFieldUpdateOperationsInput | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number + orderItems?: Prisma.OrderItemUncheckedUpdateManyWithoutOrderNestedInput +} + +export type OrderCreateManyPosAccountInput = { + id?: number + orderNumber: string + status?: $Enums.OrderStatus + totalAmount: runtime.Decimal | runtime.DecimalJsLike | number | string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + customerId?: number | null +} + +export type OrderUpdateWithoutPosAccountInput = { + orderNumber?: Prisma.StringFieldUpdateOperationsInput | string + status?: Prisma.EnumOrderStatusFieldUpdateOperationsInput | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + customer?: Prisma.CustomerUpdateOneWithoutOrdersNestedInput + orderItems?: Prisma.OrderItemUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUpdateManyWithoutOrderNestedInput +} + +export type OrderUncheckedUpdateWithoutPosAccountInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + orderNumber?: Prisma.StringFieldUpdateOperationsInput | string + status?: Prisma.EnumOrderStatusFieldUpdateOperationsInput | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null + orderItems?: Prisma.OrderItemUncheckedUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUncheckedUpdateManyWithoutOrderNestedInput +} + +export type OrderUncheckedUpdateManyWithoutPosAccountInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + orderNumber?: Prisma.StringFieldUpdateOperationsInput | string + status?: Prisma.EnumOrderStatusFieldUpdateOperationsInput | $Enums.OrderStatus + totalAmount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + customerId?: Prisma.NullableIntFieldUpdateOperationsInput | number | null } export type OrderCreateManyCustomerInput = { @@ -680,6 +960,7 @@ export type OrderCreateManyCustomerInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + posAccountId: number } export type OrderUpdateWithoutCustomerInput = { @@ -690,7 +971,9 @@ export type OrderUpdateWithoutCustomerInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + posAccount?: Prisma.PosAccountUpdateOneRequiredWithoutOrdersNestedInput orderItems?: Prisma.OrderItemUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUpdateManyWithoutOrderNestedInput } export type OrderUncheckedUpdateWithoutCustomerInput = { @@ -702,7 +985,9 @@ export type OrderUncheckedUpdateWithoutCustomerInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number orderItems?: Prisma.OrderItemUncheckedUpdateManyWithoutOrderNestedInput + stockReservations?: Prisma.StockReservationUncheckedUpdateManyWithoutOrderNestedInput } export type OrderUncheckedUpdateManyWithoutCustomerInput = { @@ -714,6 +999,7 @@ export type OrderUncheckedUpdateManyWithoutCustomerInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + posAccountId?: Prisma.IntFieldUpdateOperationsInput | number } @@ -723,10 +1009,12 @@ export type OrderUncheckedUpdateManyWithoutCustomerInput = { export type OrderCountOutputType = { orderItems: number + stockReservations: number } export type OrderCountOutputTypeSelect = { orderItems?: boolean | OrderCountOutputTypeCountOrderItemsArgs + stockReservations?: boolean | OrderCountOutputTypeCountStockReservationsArgs } /** @@ -746,6 +1034,13 @@ export type OrderCountOutputTypeCountOrderItemsArgs = { + where?: Prisma.StockReservationWhereInput +} + export type OrderSelect = runtime.Types.Extensions.GetSelect<{ id?: boolean @@ -757,8 +1052,11 @@ export type OrderSelect + posAccount?: boolean | Prisma.PosAccountDefaultArgs orderItems?: boolean | Prisma.Order$orderItemsArgs + stockReservations?: boolean | Prisma.Order$stockReservationsArgs _count?: boolean | Prisma.OrderCountOutputTypeDefaultArgs }, ExtArgs["result"]["order"]> @@ -774,12 +1072,15 @@ export type OrderSelectScalar = { updatedAt?: boolean deletedAt?: boolean customerId?: boolean + posAccountId?: boolean } -export type OrderOmit = runtime.Types.Extensions.GetOmit<"id" | "orderNumber" | "status" | "totalAmount" | "description" | "createdAt" | "updatedAt" | "deletedAt" | "customerId", ExtArgs["result"]["order"]> +export type OrderOmit = runtime.Types.Extensions.GetOmit<"id" | "orderNumber" | "status" | "totalAmount" | "description" | "createdAt" | "updatedAt" | "deletedAt" | "customerId" | "posAccountId", ExtArgs["result"]["order"]> export type OrderInclude = { customer?: boolean | Prisma.Order$customerArgs + posAccount?: boolean | Prisma.PosAccountDefaultArgs orderItems?: boolean | Prisma.Order$orderItemsArgs + stockReservations?: boolean | Prisma.Order$stockReservationsArgs _count?: boolean | Prisma.OrderCountOutputTypeDefaultArgs } @@ -787,7 +1088,9 @@ export type $OrderPayload | null + posAccount: Prisma.$PosAccountPayload orderItems: Prisma.$OrderItemPayload[] + stockReservations: Prisma.$StockReservationPayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -799,6 +1102,7 @@ export type $OrderPayload composites: {} } @@ -1140,7 +1444,9 @@ readonly fields: OrderFieldRefs; export interface Prisma__OrderClient extends Prisma.PrismaPromise { readonly [Symbol.toStringTag]: "PrismaPromise" customer = {}>(args?: Prisma.Subset>): Prisma.Prisma__CustomerClient, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + posAccount = {}>(args?: Prisma.Subset>): Prisma.Prisma__PosAccountClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> orderItems = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + stockReservations = {}>(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. @@ -1179,6 +1485,7 @@ export interface OrderFieldRefs { readonly updatedAt: Prisma.FieldRef<"Order", 'DateTime'> readonly deletedAt: Prisma.FieldRef<"Order", 'DateTime'> readonly customerId: Prisma.FieldRef<"Order", 'Int'> + readonly posAccountId: Prisma.FieldRef<"Order", 'Int'> } @@ -1564,6 +1871,30 @@ export type Order$orderItemsArgs = { + /** + * Select specific fields to fetch from the StockReservation + */ + select?: Prisma.StockReservationSelect | null + /** + * Omit specific fields from the StockReservation + */ + omit?: Prisma.StockReservationOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.StockReservationInclude | null + where?: Prisma.StockReservationWhereInput + orderBy?: Prisma.StockReservationOrderByWithRelationInput | Prisma.StockReservationOrderByWithRelationInput[] + cursor?: Prisma.StockReservationWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.StockReservationScalarFieldEnum | Prisma.StockReservationScalarFieldEnum[] +} + /** * Order without action */ diff --git a/src/generated/prisma/models/PosAccount.ts b/src/generated/prisma/models/PosAccount.ts index 8bf01a9..e7616e0 100644 --- a/src/generated/prisma/models/PosAccount.ts +++ b/src/generated/prisma/models/PosAccount.ts @@ -258,6 +258,7 @@ export type PosAccountWhereInput = { deletedAt?: Prisma.DateTimeNullableFilter<"PosAccount"> | Date | string | null inventoryBankAccount?: Prisma.XOR salesInvoices?: Prisma.SalesInvoiceListRelationFilter + orders?: Prisma.OrderListRelationFilter } export type PosAccountOrderByWithRelationInput = { @@ -272,6 +273,7 @@ export type PosAccountOrderByWithRelationInput = { deletedAt?: Prisma.SortOrderInput | Prisma.SortOrder inventoryBankAccount?: Prisma.InventoryBankAccountOrderByWithRelationInput salesInvoices?: Prisma.SalesInvoiceOrderByRelationAggregateInput + orders?: Prisma.OrderOrderByRelationAggregateInput _relevance?: Prisma.PosAccountOrderByRelevanceInput } @@ -290,6 +292,7 @@ export type PosAccountWhereUniqueInput = Prisma.AtLeast<{ deletedAt?: Prisma.DateTimeNullableFilter<"PosAccount"> | Date | string | null inventoryBankAccount?: Prisma.XOR salesInvoices?: Prisma.SalesInvoiceListRelationFilter + orders?: Prisma.OrderListRelationFilter }, "id" | "code"> export type PosAccountOrderByWithAggregationInput = { @@ -333,6 +336,7 @@ export type PosAccountCreateInput = { deletedAt?: Date | string | null inventoryBankAccount: Prisma.InventoryBankAccountCreateNestedOneWithoutPosAccountsInput salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutPosAccountInput + orders?: Prisma.OrderCreateNestedManyWithoutPosAccountInput } export type PosAccountUncheckedCreateInput = { @@ -346,6 +350,7 @@ export type PosAccountUncheckedCreateInput = { updatedAt?: Date | string deletedAt?: Date | string | null salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutPosAccountInput + orders?: Prisma.OrderUncheckedCreateNestedManyWithoutPosAccountInput } export type PosAccountUpdateInput = { @@ -357,6 +362,7 @@ export type PosAccountUpdateInput = { deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null inventoryBankAccount?: Prisma.InventoryBankAccountUpdateOneRequiredWithoutPosAccountsNestedInput salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutPosAccountNestedInput + orders?: Prisma.OrderUpdateManyWithoutPosAccountNestedInput } export type PosAccountUncheckedUpdateInput = { @@ -370,6 +376,7 @@ export type PosAccountUncheckedUpdateInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutPosAccountNestedInput + orders?: Prisma.OrderUncheckedUpdateManyWithoutPosAccountNestedInput } export type PosAccountCreateManyInput = { @@ -516,6 +523,20 @@ export type PosAccountUncheckedUpdateManyWithoutInventoryBankAccountNestedInput deleteMany?: Prisma.PosAccountScalarWhereInput | Prisma.PosAccountScalarWhereInput[] } +export type PosAccountCreateNestedOneWithoutOrdersInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.PosAccountCreateOrConnectWithoutOrdersInput + connect?: Prisma.PosAccountWhereUniqueInput +} + +export type PosAccountUpdateOneRequiredWithoutOrdersNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.PosAccountCreateOrConnectWithoutOrdersInput + upsert?: Prisma.PosAccountUpsertWithoutOrdersInput + connect?: Prisma.PosAccountWhereUniqueInput + update?: Prisma.XOR, Prisma.PosAccountUncheckedUpdateWithoutOrdersInput> +} + export type PosAccountCreateNestedOneWithoutSalesInvoicesInput = { create?: Prisma.XOR connectOrCreate?: Prisma.PosAccountCreateOrConnectWithoutSalesInvoicesInput @@ -538,6 +559,7 @@ export type PosAccountCreateWithoutInventoryBankAccountInput = { updatedAt?: Date | string deletedAt?: Date | string | null salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutPosAccountInput + orders?: Prisma.OrderCreateNestedManyWithoutPosAccountInput } export type PosAccountUncheckedCreateWithoutInventoryBankAccountInput = { @@ -549,6 +571,7 @@ export type PosAccountUncheckedCreateWithoutInventoryBankAccountInput = { updatedAt?: Date | string deletedAt?: Date | string | null salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutPosAccountInput + orders?: Prisma.OrderUncheckedCreateNestedManyWithoutPosAccountInput } export type PosAccountCreateOrConnectWithoutInventoryBankAccountInput = { @@ -592,6 +615,70 @@ export type PosAccountScalarWhereInput = { deletedAt?: Prisma.DateTimeNullableFilter<"PosAccount"> | Date | string | null } +export type PosAccountCreateWithoutOrdersInput = { + name: string + code: string + description?: string | null + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + inventoryBankAccount: Prisma.InventoryBankAccountCreateNestedOneWithoutPosAccountsInput + salesInvoices?: Prisma.SalesInvoiceCreateNestedManyWithoutPosAccountInput +} + +export type PosAccountUncheckedCreateWithoutOrdersInput = { + id?: number + name: string + code: string + description?: string | null + bankAccountId: number + inventoryId: number + createdAt?: Date | string + updatedAt?: Date | string + deletedAt?: Date | string | null + salesInvoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutPosAccountInput +} + +export type PosAccountCreateOrConnectWithoutOrdersInput = { + where: Prisma.PosAccountWhereUniqueInput + create: Prisma.XOR +} + +export type PosAccountUpsertWithoutOrdersInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.PosAccountWhereInput +} + +export type PosAccountUpdateToOneWithWhereWithoutOrdersInput = { + where?: Prisma.PosAccountWhereInput + data: Prisma.XOR +} + +export type PosAccountUpdateWithoutOrdersInput = { + name?: Prisma.StringFieldUpdateOperationsInput | string + code?: Prisma.StringFieldUpdateOperationsInput | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + inventoryBankAccount?: Prisma.InventoryBankAccountUpdateOneRequiredWithoutPosAccountsNestedInput + salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutPosAccountNestedInput +} + +export type PosAccountUncheckedUpdateWithoutOrdersInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + name?: Prisma.StringFieldUpdateOperationsInput | string + code?: Prisma.StringFieldUpdateOperationsInput | string + description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + bankAccountId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutPosAccountNestedInput +} + export type PosAccountCreateWithoutSalesInvoicesInput = { name: string code: string @@ -600,6 +687,7 @@ export type PosAccountCreateWithoutSalesInvoicesInput = { updatedAt?: Date | string deletedAt?: Date | string | null inventoryBankAccount: Prisma.InventoryBankAccountCreateNestedOneWithoutPosAccountsInput + orders?: Prisma.OrderCreateNestedManyWithoutPosAccountInput } export type PosAccountUncheckedCreateWithoutSalesInvoicesInput = { @@ -612,6 +700,7 @@ export type PosAccountUncheckedCreateWithoutSalesInvoicesInput = { createdAt?: Date | string updatedAt?: Date | string deletedAt?: Date | string | null + orders?: Prisma.OrderUncheckedCreateNestedManyWithoutPosAccountInput } export type PosAccountCreateOrConnectWithoutSalesInvoicesInput = { @@ -638,6 +727,7 @@ export type PosAccountUpdateWithoutSalesInvoicesInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null inventoryBankAccount?: Prisma.InventoryBankAccountUpdateOneRequiredWithoutPosAccountsNestedInput + orders?: Prisma.OrderUpdateManyWithoutPosAccountNestedInput } export type PosAccountUncheckedUpdateWithoutSalesInvoicesInput = { @@ -650,6 +740,7 @@ export type PosAccountUncheckedUpdateWithoutSalesInvoicesInput = { createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + orders?: Prisma.OrderUncheckedUpdateManyWithoutPosAccountNestedInput } export type PosAccountCreateManyInventoryBankAccountInput = { @@ -670,6 +761,7 @@ export type PosAccountUpdateWithoutInventoryBankAccountInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null salesInvoices?: Prisma.SalesInvoiceUpdateManyWithoutPosAccountNestedInput + orders?: Prisma.OrderUpdateManyWithoutPosAccountNestedInput } export type PosAccountUncheckedUpdateWithoutInventoryBankAccountInput = { @@ -681,6 +773,7 @@ export type PosAccountUncheckedUpdateWithoutInventoryBankAccountInput = { updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null salesInvoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutPosAccountNestedInput + orders?: Prisma.OrderUncheckedUpdateManyWithoutPosAccountNestedInput } export type PosAccountUncheckedUpdateManyWithoutInventoryBankAccountInput = { @@ -700,10 +793,12 @@ export type PosAccountUncheckedUpdateManyWithoutInventoryBankAccountInput = { export type PosAccountCountOutputType = { salesInvoices: number + orders: number } export type PosAccountCountOutputTypeSelect = { salesInvoices?: boolean | PosAccountCountOutputTypeCountSalesInvoicesArgs + orders?: boolean | PosAccountCountOutputTypeCountOrdersArgs } /** @@ -723,6 +818,13 @@ export type PosAccountCountOutputTypeCountSalesInvoicesArgs = { + where?: Prisma.OrderWhereInput +} + export type PosAccountSelect = runtime.Types.Extensions.GetSelect<{ id?: boolean @@ -736,6 +838,7 @@ export type PosAccountSelect salesInvoices?: boolean | Prisma.PosAccount$salesInvoicesArgs + orders?: boolean | Prisma.PosAccount$ordersArgs _count?: boolean | Prisma.PosAccountCountOutputTypeDefaultArgs }, ExtArgs["result"]["posAccount"]> @@ -757,6 +860,7 @@ export type PosAccountOmit = { inventoryBankAccount?: boolean | Prisma.InventoryBankAccountDefaultArgs salesInvoices?: boolean | Prisma.PosAccount$salesInvoicesArgs + orders?: boolean | Prisma.PosAccount$ordersArgs _count?: boolean | Prisma.PosAccountCountOutputTypeDefaultArgs } @@ -765,6 +869,7 @@ export type $PosAccountPayload salesInvoices: Prisma.$SalesInvoicePayload[] + orders: Prisma.$OrderPayload[] } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number @@ -1118,6 +1223,7 @@ export interface Prisma__PosAccountClient = {}>(args?: Prisma.Subset>): Prisma.Prisma__InventoryBankAccountClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> salesInvoices = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + orders = {}>(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. @@ -1522,6 +1628,30 @@ export type PosAccount$salesInvoicesArgs = { + /** + * Select specific fields to fetch from the Order + */ + select?: Prisma.OrderSelect | null + /** + * Omit specific fields from the Order + */ + omit?: Prisma.OrderOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.OrderInclude | null + where?: Prisma.OrderWhereInput + orderBy?: Prisma.OrderOrderByWithRelationInput | Prisma.OrderOrderByWithRelationInput[] + cursor?: Prisma.OrderWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.OrderScalarFieldEnum | Prisma.OrderScalarFieldEnum[] +} + /** * PosAccount without action */ diff --git a/src/generated/prisma/models/StockAvailableView.ts b/src/generated/prisma/models/StockAvailableView.ts new file mode 100644 index 0000000..404d8c7 --- /dev/null +++ b/src/generated/prisma/models/StockAvailableView.ts @@ -0,0 +1,719 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `StockAvailableView` 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 StockAvailableView + * + */ +export type StockAvailableViewModel = runtime.Types.Result.DefaultSelection + +export type AggregateStockAvailableView = { + _count: StockAvailableViewCountAggregateOutputType | null + _avg: StockAvailableViewAvgAggregateOutputType | null + _sum: StockAvailableViewSumAggregateOutputType | null + _min: StockAvailableViewMinAggregateOutputType | null + _max: StockAvailableViewMaxAggregateOutputType | null +} + +export type StockAvailableViewAvgAggregateOutputType = { + productId: number | null + inventoryId: number | null + physicalQuantity: runtime.Decimal | null + reservedQuantity: runtime.Decimal | null + availableQuantity: runtime.Decimal | null +} + +export type StockAvailableViewSumAggregateOutputType = { + productId: number | null + inventoryId: number | null + physicalQuantity: runtime.Decimal | null + reservedQuantity: runtime.Decimal | null + availableQuantity: runtime.Decimal | null +} + +export type StockAvailableViewMinAggregateOutputType = { + productId: number | null + inventoryId: number | null + physicalQuantity: runtime.Decimal | null + reservedQuantity: runtime.Decimal | null + availableQuantity: runtime.Decimal | null +} + +export type StockAvailableViewMaxAggregateOutputType = { + productId: number | null + inventoryId: number | null + physicalQuantity: runtime.Decimal | null + reservedQuantity: runtime.Decimal | null + availableQuantity: runtime.Decimal | null +} + +export type StockAvailableViewCountAggregateOutputType = { + productId: number + inventoryId: number + physicalQuantity: number + reservedQuantity: number + availableQuantity: number + _all: number +} + + +export type StockAvailableViewAvgAggregateInputType = { + productId?: true + inventoryId?: true + physicalQuantity?: true + reservedQuantity?: true + availableQuantity?: true +} + +export type StockAvailableViewSumAggregateInputType = { + productId?: true + inventoryId?: true + physicalQuantity?: true + reservedQuantity?: true + availableQuantity?: true +} + +export type StockAvailableViewMinAggregateInputType = { + productId?: true + inventoryId?: true + physicalQuantity?: true + reservedQuantity?: true + availableQuantity?: true +} + +export type StockAvailableViewMaxAggregateInputType = { + productId?: true + inventoryId?: true + physicalQuantity?: true + reservedQuantity?: true + availableQuantity?: true +} + +export type StockAvailableViewCountAggregateInputType = { + productId?: true + inventoryId?: true + physicalQuantity?: true + reservedQuantity?: true + availableQuantity?: true + _all?: true +} + +export type StockAvailableViewAggregateArgs = { + /** + * Filter which StockAvailableView to aggregate. + */ + where?: Prisma.StockAvailableViewWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of StockAvailableViews to fetch. + */ + orderBy?: Prisma.StockAvailableViewOrderByWithRelationInput | Prisma.StockAvailableViewOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` StockAvailableViews 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` StockAvailableViews. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned StockAvailableViews + **/ + _count?: true | StockAvailableViewCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: StockAvailableViewAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: StockAvailableViewSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: StockAvailableViewMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: StockAvailableViewMaxAggregateInputType +} + +export type GetStockAvailableViewAggregateType = { + [P in keyof T & keyof AggregateStockAvailableView]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type StockAvailableViewGroupByArgs = { + where?: Prisma.StockAvailableViewWhereInput + orderBy?: Prisma.StockAvailableViewOrderByWithAggregationInput | Prisma.StockAvailableViewOrderByWithAggregationInput[] + by: Prisma.StockAvailableViewScalarFieldEnum[] | Prisma.StockAvailableViewScalarFieldEnum + having?: Prisma.StockAvailableViewScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: StockAvailableViewCountAggregateInputType | true + _avg?: StockAvailableViewAvgAggregateInputType + _sum?: StockAvailableViewSumAggregateInputType + _min?: StockAvailableViewMinAggregateInputType + _max?: StockAvailableViewMaxAggregateInputType +} + +export type StockAvailableViewGroupByOutputType = { + productId: number + inventoryId: number + physicalQuantity: runtime.Decimal + reservedQuantity: runtime.Decimal + availableQuantity: runtime.Decimal + _count: StockAvailableViewCountAggregateOutputType | null + _avg: StockAvailableViewAvgAggregateOutputType | null + _sum: StockAvailableViewSumAggregateOutputType | null + _min: StockAvailableViewMinAggregateOutputType | null + _max: StockAvailableViewMaxAggregateOutputType | null +} + +type GetStockAvailableViewGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof StockAvailableViewGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type StockAvailableViewWhereInput = { + AND?: Prisma.StockAvailableViewWhereInput | Prisma.StockAvailableViewWhereInput[] + OR?: Prisma.StockAvailableViewWhereInput[] + NOT?: Prisma.StockAvailableViewWhereInput | Prisma.StockAvailableViewWhereInput[] + productId?: Prisma.IntFilter<"StockAvailableView"> | number + inventoryId?: Prisma.IntFilter<"StockAvailableView"> | number + physicalQuantity?: Prisma.DecimalFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string + reservedQuantity?: Prisma.DecimalFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string + availableQuantity?: Prisma.DecimalFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string +} + +export type StockAvailableViewOrderByWithRelationInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + +export type StockAvailableViewOrderByWithAggregationInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder + _count?: Prisma.StockAvailableViewCountOrderByAggregateInput + _avg?: Prisma.StockAvailableViewAvgOrderByAggregateInput + _max?: Prisma.StockAvailableViewMaxOrderByAggregateInput + _min?: Prisma.StockAvailableViewMinOrderByAggregateInput + _sum?: Prisma.StockAvailableViewSumOrderByAggregateInput +} + +export type StockAvailableViewScalarWhereWithAggregatesInput = { + AND?: Prisma.StockAvailableViewScalarWhereWithAggregatesInput | Prisma.StockAvailableViewScalarWhereWithAggregatesInput[] + OR?: Prisma.StockAvailableViewScalarWhereWithAggregatesInput[] + NOT?: Prisma.StockAvailableViewScalarWhereWithAggregatesInput | Prisma.StockAvailableViewScalarWhereWithAggregatesInput[] + productId?: Prisma.IntWithAggregatesFilter<"StockAvailableView"> | number + inventoryId?: Prisma.IntWithAggregatesFilter<"StockAvailableView"> | number + physicalQuantity?: Prisma.DecimalWithAggregatesFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string + reservedQuantity?: Prisma.DecimalWithAggregatesFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string + availableQuantity?: Prisma.DecimalWithAggregatesFilter<"StockAvailableView"> | runtime.Decimal | runtime.DecimalJsLike | number | string +} + +export type StockAvailableViewCountOrderByAggregateInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + +export type StockAvailableViewAvgOrderByAggregateInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + +export type StockAvailableViewMaxOrderByAggregateInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + +export type StockAvailableViewMinOrderByAggregateInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + +export type StockAvailableViewSumOrderByAggregateInput = { + productId?: Prisma.SortOrder + inventoryId?: Prisma.SortOrder + physicalQuantity?: Prisma.SortOrder + reservedQuantity?: Prisma.SortOrder + availableQuantity?: Prisma.SortOrder +} + + + +export type StockAvailableViewSelect = runtime.Types.Extensions.GetSelect<{ + productId?: boolean + inventoryId?: boolean + physicalQuantity?: boolean + reservedQuantity?: boolean + availableQuantity?: boolean +}, ExtArgs["result"]["stockAvailableView"]> + + + +export type StockAvailableViewSelectScalar = { + productId?: boolean + inventoryId?: boolean + physicalQuantity?: boolean + reservedQuantity?: boolean + availableQuantity?: boolean +} + +export type StockAvailableViewOmit = runtime.Types.Extensions.GetOmit<"productId" | "inventoryId" | "physicalQuantity" | "reservedQuantity" | "availableQuantity", ExtArgs["result"]["stockAvailableView"]> + +export type $StockAvailableViewPayload = { + name: "StockAvailableView" + objects: {} + scalars: runtime.Types.Extensions.GetPayloadResult<{ + productId: number + inventoryId: number + physicalQuantity: runtime.Decimal + reservedQuantity: runtime.Decimal + availableQuantity: runtime.Decimal + }, ExtArgs["result"]["stockAvailableView"]> + composites: {} +} + +export type StockAvailableViewGetPayload = runtime.Types.Result.GetResult + +export type StockAvailableViewCountArgs = + Omit & { + select?: StockAvailableViewCountAggregateInputType | true + } + +export interface StockAvailableViewDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['StockAvailableView'], meta: { name: 'StockAvailableView' } } + /** + * Find the first StockAvailableView 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 {StockAvailableViewFindFirstArgs} args - Arguments to find a StockAvailableView + * @example + * // Get one StockAvailableView + * const stockAvailableView = await prisma.stockAvailableView.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst ? { + orderBy: {} + } : {}, SkipDependenciesValidator extends "skip" extends Prisma.Keys ? { + orderBy: {} + } : {}>(args?: Prisma.SelectSubset> & TakeDependenciesValidator & SkipDependenciesValidator): Prisma.Prisma__StockAvailableViewClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first StockAvailableView 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 {StockAvailableViewFindFirstOrThrowArgs} args - Arguments to find a StockAvailableView + * @example + * // Get one StockAvailableView + * const stockAvailableView = await prisma.stockAvailableView.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow ? { + orderBy: {} + } : {}, SkipDependenciesValidator extends "skip" extends Prisma.Keys ? { + orderBy: {} + } : {}>(args?: Prisma.SelectSubset> & TakeDependenciesValidator & SkipDependenciesValidator): Prisma.Prisma__StockAvailableViewClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more StockAvailableViews 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 {StockAvailableViewFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all StockAvailableViews + * const stockAvailableViews = await prisma.stockAvailableView.findMany() + * + * // Get first 10 StockAvailableViews + * const stockAvailableViews = await prisma.stockAvailableView.findMany({ take: 10 }) + * + * // Only select the `productId` + * const stockAvailableViewWithProductIdOnly = await prisma.stockAvailableView.findMany({ select: { productId: true } }) + * + */ + findMany ? { + orderBy: {} + } : {}, SkipDependenciesValidator extends "skip" extends Prisma.Keys ? { + orderBy: {} + } : {}>(args?: Prisma.SelectSubset> & TakeDependenciesValidator & SkipDependenciesValidator): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + + /** + * Count the number of StockAvailableViews. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {StockAvailableViewCountArgs} args - Arguments to filter StockAvailableViews to count. + * @example + * // Count the number of StockAvailableViews + * const count = await prisma.stockAvailableView.count({ + * where: { + * // ... the filter for the StockAvailableViews 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 StockAvailableView. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {StockAvailableViewAggregateArgs} 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 StockAvailableView. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {StockAvailableViewGroupByArgs} 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 StockAvailableViewGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: StockAvailableViewGroupByArgs['orderBy'] } + : { orderBy?: StockAvailableViewGroupByArgs['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 ? GetStockAvailableViewGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the StockAvailableView model + */ +readonly fields: StockAvailableViewFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for StockAvailableView. + * 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__StockAvailableViewClient 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 StockAvailableView model + */ +export interface StockAvailableViewFieldRefs { + readonly productId: Prisma.FieldRef<"StockAvailableView", 'Int'> + readonly inventoryId: Prisma.FieldRef<"StockAvailableView", 'Int'> + readonly physicalQuantity: Prisma.FieldRef<"StockAvailableView", 'Decimal'> + readonly reservedQuantity: Prisma.FieldRef<"StockAvailableView", 'Decimal'> + readonly availableQuantity: Prisma.FieldRef<"StockAvailableView", 'Decimal'> +} + + +// Custom InputTypes +/** + * StockAvailableView findFirst + */ +export type StockAvailableViewFindFirstArgs = { + /** + * Select specific fields to fetch from the StockAvailableView + */ + select?: Prisma.StockAvailableViewSelect | null + /** + * Omit specific fields from the StockAvailableView + */ + omit?: Prisma.StockAvailableViewOmit | null + /** + * Filter, which StockAvailableView to fetch. + */ + where?: Prisma.StockAvailableViewWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of StockAvailableViews to fetch. + */ + orderBy?: Prisma.StockAvailableViewOrderByWithRelationInput | Prisma.StockAvailableViewOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` StockAvailableViews 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` StockAvailableViews. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of StockAvailableViews. + */ + distinct?: Prisma.StockAvailableViewScalarFieldEnum | Prisma.StockAvailableViewScalarFieldEnum[] +} + +/** + * StockAvailableView findFirstOrThrow + */ +export type StockAvailableViewFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the StockAvailableView + */ + select?: Prisma.StockAvailableViewSelect | null + /** + * Omit specific fields from the StockAvailableView + */ + omit?: Prisma.StockAvailableViewOmit | null + /** + * Filter, which StockAvailableView to fetch. + */ + where?: Prisma.StockAvailableViewWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of StockAvailableViews to fetch. + */ + orderBy?: Prisma.StockAvailableViewOrderByWithRelationInput | Prisma.StockAvailableViewOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` StockAvailableViews 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` StockAvailableViews. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of StockAvailableViews. + */ + distinct?: Prisma.StockAvailableViewScalarFieldEnum | Prisma.StockAvailableViewScalarFieldEnum[] +} + +/** + * StockAvailableView findMany + */ +export type StockAvailableViewFindManyArgs = { + /** + * Select specific fields to fetch from the StockAvailableView + */ + select?: Prisma.StockAvailableViewSelect | null + /** + * Omit specific fields from the StockAvailableView + */ + omit?: Prisma.StockAvailableViewOmit | null + /** + * Filter, which StockAvailableViews to fetch. + */ + where?: Prisma.StockAvailableViewWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of StockAvailableViews to fetch. + */ + orderBy?: Prisma.StockAvailableViewOrderByWithRelationInput | Prisma.StockAvailableViewOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` StockAvailableViews 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` StockAvailableViews. + */ + skip?: number + distinct?: Prisma.StockAvailableViewScalarFieldEnum | Prisma.StockAvailableViewScalarFieldEnum[] +} + +/** + * StockAvailableView without action + */ +export type StockAvailableViewDefaultArgs = { + /** + * Select specific fields to fetch from the StockAvailableView + */ + select?: Prisma.StockAvailableViewSelect | null + /** + * Omit specific fields from the StockAvailableView + */ + omit?: Prisma.StockAvailableViewOmit | null +} diff --git a/src/generated/prisma/models/StockReservation.ts b/src/generated/prisma/models/StockReservation.ts index a108e37..dc3c841 100644 --- a/src/generated/prisma/models/StockReservation.ts +++ b/src/generated/prisma/models/StockReservation.ts @@ -45,7 +45,6 @@ export type StockReservationSumAggregateOutputType = { export type StockReservationMinAggregateOutputType = { id: number | null quantity: runtime.Decimal | null - expiresAt: Date | null createdAt: Date | null productId: number | null inventoryId: number | null @@ -55,7 +54,6 @@ export type StockReservationMinAggregateOutputType = { export type StockReservationMaxAggregateOutputType = { id: number | null quantity: runtime.Decimal | null - expiresAt: Date | null createdAt: Date | null productId: number | null inventoryId: number | null @@ -65,7 +63,6 @@ export type StockReservationMaxAggregateOutputType = { export type StockReservationCountAggregateOutputType = { id: number quantity: number - expiresAt: number createdAt: number productId: number inventoryId: number @@ -93,7 +90,6 @@ export type StockReservationSumAggregateInputType = { export type StockReservationMinAggregateInputType = { id?: true quantity?: true - expiresAt?: true createdAt?: true productId?: true inventoryId?: true @@ -103,7 +99,6 @@ export type StockReservationMinAggregateInputType = { export type StockReservationMaxAggregateInputType = { id?: true quantity?: true - expiresAt?: true createdAt?: true productId?: true inventoryId?: true @@ -113,7 +108,6 @@ export type StockReservationMaxAggregateInputType = { export type StockReservationCountAggregateInputType = { id?: true quantity?: true - expiresAt?: true createdAt?: true productId?: true inventoryId?: true @@ -210,7 +204,6 @@ export type StockReservationGroupByArgs | number quantity?: Prisma.DecimalFilter<"StockReservation"> | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string createdAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string productId?: Prisma.IntFilter<"StockReservation"> | number inventoryId?: Prisma.IntFilter<"StockReservation"> | number orderId?: Prisma.IntFilter<"StockReservation"> | number inventory?: Prisma.XOR product?: Prisma.XOR + order?: Prisma.XOR } export type StockReservationOrderByWithRelationInput = { id?: Prisma.SortOrder quantity?: Prisma.SortOrder - expiresAt?: Prisma.SortOrder createdAt?: Prisma.SortOrder productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder orderId?: Prisma.SortOrder inventory?: Prisma.InventoryOrderByWithRelationInput product?: Prisma.ProductOrderByWithRelationInput + order?: Prisma.OrderOrderByWithRelationInput } export type StockReservationWhereUniqueInput = Prisma.AtLeast<{ @@ -270,19 +263,18 @@ export type StockReservationWhereUniqueInput = Prisma.AtLeast<{ OR?: Prisma.StockReservationWhereInput[] NOT?: Prisma.StockReservationWhereInput | Prisma.StockReservationWhereInput[] quantity?: Prisma.DecimalFilter<"StockReservation"> | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string createdAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string productId?: Prisma.IntFilter<"StockReservation"> | number inventoryId?: Prisma.IntFilter<"StockReservation"> | number orderId?: Prisma.IntFilter<"StockReservation"> | number inventory?: Prisma.XOR product?: Prisma.XOR + order?: Prisma.XOR }, "id"> export type StockReservationOrderByWithAggregationInput = { id?: Prisma.SortOrder quantity?: Prisma.SortOrder - expiresAt?: Prisma.SortOrder createdAt?: Prisma.SortOrder productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder @@ -300,7 +292,6 @@ export type StockReservationScalarWhereWithAggregatesInput = { NOT?: Prisma.StockReservationScalarWhereWithAggregatesInput | Prisma.StockReservationScalarWhereWithAggregatesInput[] id?: Prisma.IntWithAggregatesFilter<"StockReservation"> | number quantity?: Prisma.DecimalWithAggregatesFilter<"StockReservation"> | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeWithAggregatesFilter<"StockReservation"> | Date | string createdAt?: Prisma.DateTimeWithAggregatesFilter<"StockReservation"> | Date | string productId?: Prisma.IntWithAggregatesFilter<"StockReservation"> | number inventoryId?: Prisma.IntWithAggregatesFilter<"StockReservation"> | number @@ -309,17 +300,15 @@ export type StockReservationScalarWhereWithAggregatesInput = { export type StockReservationCreateInput = { quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string - orderId: number inventory: Prisma.InventoryCreateNestedOneWithoutStockReservationsInput product: Prisma.ProductCreateNestedOneWithoutStockReservationsInput + order: Prisma.OrderCreateNestedOneWithoutStockReservationsInput } export type StockReservationUncheckedCreateInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string productId: number inventoryId: number @@ -328,17 +317,15 @@ export type StockReservationUncheckedCreateInput = { export type StockReservationUpdateInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - orderId?: Prisma.IntFieldUpdateOperationsInput | number inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockReservationsNestedInput product?: Prisma.ProductUpdateOneRequiredWithoutStockReservationsNestedInput + order?: Prisma.OrderUpdateOneRequiredWithoutStockReservationsNestedInput } export type StockReservationUncheckedUpdateInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number inventoryId?: Prisma.IntFieldUpdateOperationsInput | number @@ -348,7 +335,6 @@ export type StockReservationUncheckedUpdateInput = { export type StockReservationCreateManyInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string productId: number inventoryId: number @@ -357,15 +343,12 @@ export type StockReservationCreateManyInput = { export type StockReservationUpdateManyMutationInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - orderId?: Prisma.IntFieldUpdateOperationsInput | number } export type StockReservationUncheckedUpdateManyInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number inventoryId?: Prisma.IntFieldUpdateOperationsInput | number @@ -385,7 +368,6 @@ export type StockReservationOrderByRelationAggregateInput = { export type StockReservationCountOrderByAggregateInput = { id?: Prisma.SortOrder quantity?: Prisma.SortOrder - expiresAt?: Prisma.SortOrder createdAt?: Prisma.SortOrder productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder @@ -403,7 +385,6 @@ export type StockReservationAvgOrderByAggregateInput = { export type StockReservationMaxOrderByAggregateInput = { id?: Prisma.SortOrder quantity?: Prisma.SortOrder - expiresAt?: Prisma.SortOrder createdAt?: Prisma.SortOrder productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder @@ -413,7 +394,6 @@ export type StockReservationMaxOrderByAggregateInput = { export type StockReservationMinOrderByAggregateInput = { id?: Prisma.SortOrder quantity?: Prisma.SortOrder - expiresAt?: Prisma.SortOrder createdAt?: Prisma.SortOrder productId?: Prisma.SortOrder inventoryId?: Prisma.SortOrder @@ -470,6 +450,48 @@ export type StockReservationUncheckedUpdateManyWithoutInventoryNestedInput = { deleteMany?: Prisma.StockReservationScalarWhereInput | Prisma.StockReservationScalarWhereInput[] } +export type StockReservationCreateNestedManyWithoutOrderInput = { + create?: Prisma.XOR | Prisma.StockReservationCreateWithoutOrderInput[] | Prisma.StockReservationUncheckedCreateWithoutOrderInput[] + connectOrCreate?: Prisma.StockReservationCreateOrConnectWithoutOrderInput | Prisma.StockReservationCreateOrConnectWithoutOrderInput[] + createMany?: Prisma.StockReservationCreateManyOrderInputEnvelope + connect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] +} + +export type StockReservationUncheckedCreateNestedManyWithoutOrderInput = { + create?: Prisma.XOR | Prisma.StockReservationCreateWithoutOrderInput[] | Prisma.StockReservationUncheckedCreateWithoutOrderInput[] + connectOrCreate?: Prisma.StockReservationCreateOrConnectWithoutOrderInput | Prisma.StockReservationCreateOrConnectWithoutOrderInput[] + createMany?: Prisma.StockReservationCreateManyOrderInputEnvelope + connect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] +} + +export type StockReservationUpdateManyWithoutOrderNestedInput = { + create?: Prisma.XOR | Prisma.StockReservationCreateWithoutOrderInput[] | Prisma.StockReservationUncheckedCreateWithoutOrderInput[] + connectOrCreate?: Prisma.StockReservationCreateOrConnectWithoutOrderInput | Prisma.StockReservationCreateOrConnectWithoutOrderInput[] + upsert?: Prisma.StockReservationUpsertWithWhereUniqueWithoutOrderInput | Prisma.StockReservationUpsertWithWhereUniqueWithoutOrderInput[] + createMany?: Prisma.StockReservationCreateManyOrderInputEnvelope + set?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + disconnect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + delete?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + connect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + update?: Prisma.StockReservationUpdateWithWhereUniqueWithoutOrderInput | Prisma.StockReservationUpdateWithWhereUniqueWithoutOrderInput[] + updateMany?: Prisma.StockReservationUpdateManyWithWhereWithoutOrderInput | Prisma.StockReservationUpdateManyWithWhereWithoutOrderInput[] + deleteMany?: Prisma.StockReservationScalarWhereInput | Prisma.StockReservationScalarWhereInput[] +} + +export type StockReservationUncheckedUpdateManyWithoutOrderNestedInput = { + create?: Prisma.XOR | Prisma.StockReservationCreateWithoutOrderInput[] | Prisma.StockReservationUncheckedCreateWithoutOrderInput[] + connectOrCreate?: Prisma.StockReservationCreateOrConnectWithoutOrderInput | Prisma.StockReservationCreateOrConnectWithoutOrderInput[] + upsert?: Prisma.StockReservationUpsertWithWhereUniqueWithoutOrderInput | Prisma.StockReservationUpsertWithWhereUniqueWithoutOrderInput[] + createMany?: Prisma.StockReservationCreateManyOrderInputEnvelope + set?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + disconnect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + delete?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + connect?: Prisma.StockReservationWhereUniqueInput | Prisma.StockReservationWhereUniqueInput[] + update?: Prisma.StockReservationUpdateWithWhereUniqueWithoutOrderInput | Prisma.StockReservationUpdateWithWhereUniqueWithoutOrderInput[] + updateMany?: Prisma.StockReservationUpdateManyWithWhereWithoutOrderInput | Prisma.StockReservationUpdateManyWithWhereWithoutOrderInput[] + deleteMany?: Prisma.StockReservationScalarWhereInput | Prisma.StockReservationScalarWhereInput[] +} + export type StockReservationCreateNestedManyWithoutProductInput = { create?: Prisma.XOR | Prisma.StockReservationCreateWithoutProductInput[] | Prisma.StockReservationUncheckedCreateWithoutProductInput[] connectOrCreate?: Prisma.StockReservationCreateOrConnectWithoutProductInput | Prisma.StockReservationCreateOrConnectWithoutProductInput[] @@ -514,16 +536,14 @@ export type StockReservationUncheckedUpdateManyWithoutProductNestedInput = { export type StockReservationCreateWithoutInventoryInput = { quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string - orderId: number product: Prisma.ProductCreateNestedOneWithoutStockReservationsInput + order: Prisma.OrderCreateNestedOneWithoutStockReservationsInput } export type StockReservationUncheckedCreateWithoutInventoryInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string productId: number orderId: number @@ -561,25 +581,63 @@ export type StockReservationScalarWhereInput = { NOT?: Prisma.StockReservationScalarWhereInput | Prisma.StockReservationScalarWhereInput[] id?: Prisma.IntFilter<"StockReservation"> | number quantity?: Prisma.DecimalFilter<"StockReservation"> | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string createdAt?: Prisma.DateTimeFilter<"StockReservation"> | Date | string productId?: Prisma.IntFilter<"StockReservation"> | number inventoryId?: Prisma.IntFilter<"StockReservation"> | number orderId?: Prisma.IntFilter<"StockReservation"> | number } +export type StockReservationCreateWithoutOrderInput = { + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + inventory: Prisma.InventoryCreateNestedOneWithoutStockReservationsInput + product: Prisma.ProductCreateNestedOneWithoutStockReservationsInput +} + +export type StockReservationUncheckedCreateWithoutOrderInput = { + id?: number + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + productId: number + inventoryId: number +} + +export type StockReservationCreateOrConnectWithoutOrderInput = { + where: Prisma.StockReservationWhereUniqueInput + create: Prisma.XOR +} + +export type StockReservationCreateManyOrderInputEnvelope = { + data: Prisma.StockReservationCreateManyOrderInput | Prisma.StockReservationCreateManyOrderInput[] + skipDuplicates?: boolean +} + +export type StockReservationUpsertWithWhereUniqueWithoutOrderInput = { + where: Prisma.StockReservationWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type StockReservationUpdateWithWhereUniqueWithoutOrderInput = { + where: Prisma.StockReservationWhereUniqueInput + data: Prisma.XOR +} + +export type StockReservationUpdateManyWithWhereWithoutOrderInput = { + where: Prisma.StockReservationScalarWhereInput + data: Prisma.XOR +} + export type StockReservationCreateWithoutProductInput = { quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string - orderId: number inventory: Prisma.InventoryCreateNestedOneWithoutStockReservationsInput + order: Prisma.OrderCreateNestedOneWithoutStockReservationsInput } export type StockReservationUncheckedCreateWithoutProductInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string inventoryId: number orderId: number @@ -614,7 +672,6 @@ export type StockReservationUpdateManyWithWhereWithoutProductInput = { export type StockReservationCreateManyInventoryInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string productId: number orderId: number @@ -622,16 +679,14 @@ export type StockReservationCreateManyInventoryInput = { export type StockReservationUpdateWithoutInventoryInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - orderId?: Prisma.IntFieldUpdateOperationsInput | number product?: Prisma.ProductUpdateOneRequiredWithoutStockReservationsNestedInput + order?: Prisma.OrderUpdateOneRequiredWithoutStockReservationsNestedInput } export type StockReservationUncheckedUpdateWithoutInventoryInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number orderId?: Prisma.IntFieldUpdateOperationsInput | number @@ -640,16 +695,45 @@ export type StockReservationUncheckedUpdateWithoutInventoryInput = { export type StockReservationUncheckedUpdateManyWithoutInventoryInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string productId?: Prisma.IntFieldUpdateOperationsInput | number orderId?: Prisma.IntFieldUpdateOperationsInput | number } +export type StockReservationCreateManyOrderInput = { + id?: number + quantity: runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Date | string + productId: number + inventoryId: number +} + +export type StockReservationUpdateWithoutOrderInput = { + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockReservationsNestedInput + product?: Prisma.ProductUpdateOneRequiredWithoutStockReservationsNestedInput +} + +export type StockReservationUncheckedUpdateWithoutOrderInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type StockReservationUncheckedUpdateManyWithoutOrderInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + productId?: Prisma.IntFieldUpdateOperationsInput | number + inventoryId?: Prisma.IntFieldUpdateOperationsInput | number +} + export type StockReservationCreateManyProductInput = { id?: number quantity: runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt: Date | string createdAt?: Date | string inventoryId: number orderId: number @@ -657,16 +741,14 @@ export type StockReservationCreateManyProductInput = { export type StockReservationUpdateWithoutProductInput = { quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string - orderId?: Prisma.IntFieldUpdateOperationsInput | number inventory?: Prisma.InventoryUpdateOneRequiredWithoutStockReservationsNestedInput + order?: Prisma.OrderUpdateOneRequiredWithoutStockReservationsNestedInput } export type StockReservationUncheckedUpdateWithoutProductInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string inventoryId?: Prisma.IntFieldUpdateOperationsInput | number orderId?: Prisma.IntFieldUpdateOperationsInput | number @@ -675,7 +757,6 @@ export type StockReservationUncheckedUpdateWithoutProductInput = { export type StockReservationUncheckedUpdateManyWithoutProductInput = { id?: Prisma.IntFieldUpdateOperationsInput | number quantity?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string - expiresAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string inventoryId?: Prisma.IntFieldUpdateOperationsInput | number orderId?: Prisma.IntFieldUpdateOperationsInput | number @@ -686,13 +767,13 @@ export type StockReservationUncheckedUpdateManyWithoutProductInput = { export type StockReservationSelect = runtime.Types.Extensions.GetSelect<{ id?: boolean quantity?: boolean - expiresAt?: boolean createdAt?: boolean productId?: boolean inventoryId?: boolean orderId?: boolean inventory?: boolean | Prisma.InventoryDefaultArgs product?: boolean | Prisma.ProductDefaultArgs + order?: boolean | Prisma.OrderDefaultArgs }, ExtArgs["result"]["stockReservation"]> @@ -700,17 +781,17 @@ export type StockReservationSelect = runtime.Types.Extensions.GetOmit<"id" | "quantity" | "expiresAt" | "createdAt" | "productId" | "inventoryId" | "orderId", ExtArgs["result"]["stockReservation"]> +export type StockReservationOmit = runtime.Types.Extensions.GetOmit<"id" | "quantity" | "createdAt" | "productId" | "inventoryId" | "orderId", ExtArgs["result"]["stockReservation"]> export type StockReservationInclude = { inventory?: boolean | Prisma.InventoryDefaultArgs product?: boolean | Prisma.ProductDefaultArgs + order?: boolean | Prisma.OrderDefaultArgs } export type $StockReservationPayload = { @@ -718,11 +799,11 @@ export type $StockReservationPayload product: Prisma.$ProductPayload + order: Prisma.$OrderPayload } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: number quantity: runtime.Decimal - expiresAt: Date createdAt: Date productId: number inventoryId: number @@ -1069,6 +1150,7 @@ export interface Prisma__StockReservationClient = {}>(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> + order = {}>(args?: Prisma.Subset>): Prisma.Prisma__OrderClient, 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. @@ -1100,7 +1182,6 @@ export interface Prisma__StockReservationClient readonly quantity: Prisma.FieldRef<"StockReservation", 'Decimal'> - readonly expiresAt: Prisma.FieldRef<"StockReservation", 'DateTime'> readonly createdAt: Prisma.FieldRef<"StockReservation", 'DateTime'> readonly productId: Prisma.FieldRef<"StockReservation", 'Int'> readonly inventoryId: Prisma.FieldRef<"StockReservation", 'Int'> diff --git a/src/modules/pos/dto/create-pos.dto.ts b/src/modules/pos/orders/dto/create-order-item.dto.ts similarity index 95% rename from src/modules/pos/dto/create-pos.dto.ts rename to src/modules/pos/orders/dto/create-order-item.dto.ts index 5b0cf11..719c4c0 100644 --- a/src/modules/pos/dto/create-pos.dto.ts +++ b/src/modules/pos/orders/dto/create-order-item.dto.ts @@ -2,7 +2,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' import { Type } from 'class-transformer' import { ArrayMinSize, IsInt, IsNumber, IsOptional, IsString } from 'class-validator' -export class CreateSaleInvoiceDto { +export class CreateOrderDto { @ApiPropertyOptional() @IsOptional() @IsInt() diff --git a/src/modules/pos/orders/orders.controller.ts b/src/modules/pos/orders/orders.controller.ts new file mode 100644 index 0000000..31a2b87 --- /dev/null +++ b/src/modules/pos/orders/orders.controller.ts @@ -0,0 +1,44 @@ +import { Body, Controller, Get, Param, Post } from '@nestjs/common' +import { OrderStatus } from '../../../generated/prisma/enums' +import { CreateOrderDto } from './dto/create-order-item.dto' +import { PosOrdersService } from './orders.service' + +@Controller('pos/:posId/orders') +export class PosOrdersController { + constructor(private readonly posOrdersService: PosOrdersService) {} + + @Get('') + get(@Param('posId') posId: string) { + return this.posOrdersService.getOrders(Number(posId)) + } + + @Get('/held') + getHeld(@Param('posId') posId: string) { + return this.posOrdersService.getOrders(Number(posId), OrderStatus.PENDING) + } + + @Post('') + async createOrder(@Param('posId') posId: string, @Body() dto: CreateOrderDto) { + return this.posOrdersService.createOrder(Number(posId), dto) + } + + @Get('/:orderId') + getOrderDetails(@Param('posId') posId: string, @Param('orderId') orderId: string) { + return this.posOrdersService.getOrderDetails(Number(posId), Number(orderId)) + } + + @Post('/:orderId/reject') + async rejectOrder(@Param('posId') posId: string, @Param('orderId') orderId: string) { + return this.posOrdersService.rejectOrder(Number(posId), Number(orderId)) + } + + @Post('/:orderId/done') + async completeOrder(@Param('posId') posId: string, @Param('orderId') orderId: string) { + return this.posOrdersService.completeOrder(Number(posId), Number(orderId)) + } + + @Post('/:orderId/cancel') + async cancelOrder(@Param('posId') posId: string, @Param('orderId') orderId: string) { + return this.posOrdersService.cancelOrder(Number(posId), Number(orderId)) + } +} diff --git a/src/modules/pos/orders/orders.module.ts b/src/modules/pos/orders/orders.module.ts new file mode 100644 index 0000000..b7d6f94 --- /dev/null +++ b/src/modules/pos/orders/orders.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common' +import { PrismaModule } from '../../../prisma/prisma.module' +import { SalesInvoicesModule } from '../../sales-invoices/sales-invoices.module' +import { PosOrdersController } from './orders.controller' +import { PosOrdersService } from './orders.service' +import { PosOrdersWorkflow } from './orders.workflow' + +@Module({ + imports: [PrismaModule, SalesInvoicesModule], + controllers: [PosOrdersController], + providers: [PosOrdersService, PosOrdersWorkflow], +}) +export class PosOrdersModule {} diff --git a/src/modules/pos/orders/orders.service.ts b/src/modules/pos/orders/orders.service.ts new file mode 100644 index 0000000..5dd4d46 --- /dev/null +++ b/src/modules/pos/orders/orders.service.ts @@ -0,0 +1,145 @@ +import { Injectable } from '@nestjs/common' +import { ResponseMapper } from '../../../common/response/response-mapper' +import { Prisma } from '../../../generated/prisma/client' +import { OrderStatus } from '../../../generated/prisma/enums' +import { OrderCreateInput } from '../../../generated/prisma/models' +import { PrismaService } from '../../../prisma/prisma.service' +import { CreateOrderDto } from './dto/create-order-item.dto' +import { PosOrdersWorkflow } from './orders.workflow' + +@Injectable() +export class PosOrdersService { + constructor( + private prisma: PrismaService, + private posWorkflow: PosOrdersWorkflow, + ) {} + + async createOrder(posId: number, data: CreateOrderDto) { + const { customerId, items, ...rest } = data + const lastCode = await this.prisma.order + .findFirst({ + where: { posAccountId: posId }, + orderBy: { orderNumber: 'desc' }, + select: { orderNumber: true }, + }) + .then(si => si?.orderNumber || '0') + + const newCode = String(Number(lastCode) + 1) + + const totalAmount = data.items.reduce( + (acc, item) => acc + item.count * item.unitPrice, + 0, + ) + + const preparedOrder: OrderCreateInput = { + ...rest, + orderNumber: newCode, + posAccount: { connect: { id: posId } }, + customer: customerId ? { connect: { id: customerId } } : undefined, + totalAmount, + orderItems: { + create: items.map(item => ({ + product: { connect: { id: Number(item.productId) } }, + quantity: item.count, + unitPrice: item.unitPrice, + totalAmount: item.count * item.unitPrice, + })), + }, + } + + const item = await this.prisma.$transaction(async tx => { + const order = await tx.order.create({ data: preparedOrder }) + + await this.posWorkflow.onCreateOrder(tx, order.id, posId) + }) + return ResponseMapper.create(item) + } + + async createAndConfirmOrder(posId: number, data: CreateOrderDto) {} + + async rejectOrder(posAccountId: number, orderId: number) { + const item = await this.prisma.$transaction(async tx => { + const order = await tx.order.update({ + where: { id: orderId, posAccountId }, + data: { status: OrderStatus.REJECTED }, + }) + await this.posWorkflow.onRejectOrder(tx, orderId) + return order + }) + return ResponseMapper.single(item) + } + + async completeOrder(posAccountId: number, orderId: number) { + const item = await this.prisma.$transaction(async tx => { + const order = await tx.order.update({ + where: { id: orderId, posAccountId }, + data: { status: OrderStatus.DONE }, + }) + await this.posWorkflow.onConfirmOrder(tx, orderId) + return order + }) + return ResponseMapper.single(item) + } + + async cancelOrder(posAccountId: number, orderId: number) { + const item = await this.prisma.$transaction(async tx => { + const order = await tx.order.update({ + where: { id: orderId, posAccountId }, + data: { status: OrderStatus.CANCELED }, + }) + await this.posWorkflow.onCancelOrder(tx, orderId) + return order + }) + return ResponseMapper.single(item) + } + + async getOrders(posId: number, status?: OrderStatus) { + const where: Prisma.OrderWhereInput = { + posAccountId: posId, + status, + } + if (status) { + where.status = status + } + const items = await this.prisma.order.findMany({ + where, + include: { + customer: { + select: { + id: true, + firstName: true, + lastName: true, + }, + }, + orderItems: { + include: { + product: true, + }, + }, + }, + orderBy: { createdAt: 'desc' }, + }) + return ResponseMapper.list(items) + } + + async getOrderDetails(posAccountId: number, orderId: number) { + const item = await this.prisma.order.findUniqueOrThrow({ + where: { id: orderId, posAccountId }, + include: { + customer: { + select: { + id: true, + firstName: true, + lastName: true, + }, + }, + orderItems: { + include: { + product: true, + }, + }, + }, + }) + return ResponseMapper.single(item) + } +} diff --git a/src/modules/pos/orders/orders.workflow.ts b/src/modules/pos/orders/orders.workflow.ts new file mode 100644 index 0000000..bf895a8 --- /dev/null +++ b/src/modules/pos/orders/orders.workflow.ts @@ -0,0 +1,87 @@ +import { Injectable } from '@nestjs/common' +import { Prisma } from '../../../generated/prisma/client' +import { SalesInvoicesWorkflow } from '../../sales-invoices/sales-invoices.workflow' + +@Injectable() +export class PosOrdersWorkflow { + constructor(private salesInvoicesWorkflow: SalesInvoicesWorkflow) {} + + async onCreateOrder(tx: Prisma.TransactionClient, orderId: number, posId: number) { + const { inventoryId } = await tx.posAccount.findUniqueOrThrow({ + where: { id: posId }, + select: { inventoryId: true }, + }) + + const orderItems = await tx.orderItem.findMany({ + where: { orderId }, + select: { + product: true, + quantity: true, + }, + }) + + await tx.stockReservation.createMany({ + data: orderItems.map(item => ({ + orderId, + productId: item.product.id, + quantity: item.quantity, + inventoryId, + })), + }) + } + + async onRejectOrder(tx: Prisma.TransactionClient, orderId: number) { + const orderItemIds = await tx.orderItem + .findMany({ + where: { orderId }, + select: { + productId: true, + }, + }) + .then(items => items.map(i => i.productId)) + + await tx.stockReservation.deleteMany({ + where: { + orderId, + productId: { in: orderItemIds }, + }, + }) + } + + async onConfirmOrder(tx: Prisma.TransactionClient, orderId: number) { + const orderItems = await tx.orderItem.findMany({ + where: { orderId }, + select: { + product: true, + quantity: true, + }, + }) + + await tx.stockReservation.deleteMany({ + where: { + orderId, + productId: { in: orderItems.map(i => i.product.id) }, + }, + }) + + await this.salesInvoicesWorkflow.onCreateByOrder(tx, orderId) + } + + async onCancelOrder(tx: Prisma.TransactionClient, orderId: number) { + const orderItemIds = await tx.orderItem + .findMany({ + where: { orderId }, + select: { + productId: true, + }, + }) + .then(items => items.map(i => i.productId)) + + await tx.stockReservation.deleteMany({ + where: { + orderId, + productId: { in: orderItemIds }, + }, + }) + } +} diff --git a/src/modules/pos/pos.controller.ts b/src/modules/pos/pos.controller.ts index cac0275..ad7aba6 100644 --- a/src/modules/pos/pos.controller.ts +++ b/src/modules/pos/pos.controller.ts @@ -1,5 +1,4 @@ -import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common' -import { CreateSaleInvoiceDto } from './dto/create-pos.dto' +import { Controller, Get, Param, Query } from '@nestjs/common' import { PosService } from './pos.service' @Controller('pos') @@ -32,9 +31,4 @@ export class PosController { async getProductCategories(@Param('posId') posId: string) { return this.posService.getProductCategories(Number(posId)) } - - @Post('/:posId/orders/create') - async createOrder(@Param('posId') posId: string, @Body() dto: CreateSaleInvoiceDto) { - return this.posService.createOrder(Number(posId), dto) - } } diff --git a/src/modules/pos/pos.module.ts b/src/modules/pos/pos.module.ts index 5439eea..b62789b 100644 --- a/src/modules/pos/pos.module.ts +++ b/src/modules/pos/pos.module.ts @@ -1,10 +1,11 @@ import { Module } from '@nestjs/common' import { PrismaModule } from '../../prisma/prisma.module' +import { PosOrdersModule } from './orders/orders.module' import { PosController } from './pos.controller' import { PosService } from './pos.service' @Module({ - imports: [PrismaModule], + imports: [PrismaModule, PosOrdersModule], controllers: [PosController], providers: [PosService], }) diff --git a/src/modules/pos/pos.service.ts b/src/modules/pos/pos.service.ts index 52180c1..c0053dc 100644 --- a/src/modules/pos/pos.service.ts +++ b/src/modules/pos/pos.service.ts @@ -1,9 +1,6 @@ import { Injectable } from '@nestjs/common' import { ResponseMapper } from '../../common/response/response-mapper' -import { Prisma } from '../../generated/prisma/client' -import { SalesInvoiceCreateInput } from '../../generated/prisma/models' import { PrismaService } from '../../prisma/prisma.service' -import { CreateSaleInvoiceDto } from './dto/create-pos.dto' @Injectable() export class PosService { @@ -53,67 +50,64 @@ export class PosService { page?: number pageSize?: number q?: string + productIds?: number[] } = {}, ) { - const { isAvailable, page = 1, pageSize = 50, q } = options + const { isAvailable, page = 1, pageSize = 50, q, productIds } = options const pos = await this.prisma.posAccount.findUniqueOrThrow({ where: { id: posId }, select: { inventoryId: true }, }) const inventoryId = pos.inventoryId - const query: Prisma.StockBalanceFindManyArgs = { - where: { - inventoryId, - quantity: - isAvailable === true - ? { gt: 0 } - : isAvailable === false - ? { lte: 0 } - : undefined, - ...(q && { - product: { - OR: [{ name: { contains: q } }, { sku: { contains: q } }], - }, - }), - }, - orderBy: { - quantity: 'desc', - }, + let sql = ` + SELECT sb.productId, sb.quantity - COALESCE(SUM(sr.quantity), 0) as availableQuantity, p.id, p.name, p.sku, p.description, p.salePrice, p.categoryId + FROM Stock_Balance sb + LEFT JOIN Stock_Reservations sr ON sb.productId = sr.productId AND sb.inventoryId = sr.inventoryId + LEFT JOIN Products p ON sb.productId = p.id + WHERE sb.inventoryId = ? + ` + const params: any[] = [inventoryId] + + if (productIds && productIds.length > 0) { + sql += ` AND sb.productId IN (${productIds.map(() => '?').join(',')})` + params.push(...productIds) } - const [items, count] = await this.prisma.$transaction([ - this.prisma.stockBalance.findMany({ - where: query.where, - include: { - product: { - select: { - id: true, - name: true, - sku: true, - salePrice: true, - category: { - select: { id: true, name: true }, - }, - }, - }, - }, - orderBy: { - quantity: 'desc', - }, - skip: (page - 1) * pageSize, - take: pageSize, - }), - this.prisma.stockBalance.count({ where: query.where }), - ]) + if (q) { + sql += ` AND (p.name LIKE ? OR p.sku LIKE ?)` + params.push(`%${q}%`, `%${q}%`) + } - const mapped = items.map(item => ({ - id: item.id, - quantity: Number(item.quantity), - product: item.product, + sql += ` GROUP BY sb.productId` + + if (isAvailable !== undefined) { + sql += isAvailable + ? ` HAVING availableQuantity > 0` + : ` HAVING availableQuantity <= 0` + } + + sql += ` ORDER BY sb.quantity DESC` + + const items = await this.prisma.$queryRawUnsafe(sql, ...params) + + const mapped = (items as any[]).map(item => ({ + id: item.productId, + quantity: Number(item.availableQuantity), + product: { + id: item.id, + name: item.name, + sku: item.sku, + description: item.description, + salePrice: item.salePrice, + categoryId: item.categoryId, + }, })) - return ResponseMapper.paginate(mapped, count, page, pageSize) + const count = mapped.length + const paginated = mapped.slice((page - 1) * pageSize, page * pageSize) + + return ResponseMapper.paginate(paginated, count, page, pageSize) } async getProductCategories(posId: number) { @@ -157,41 +151,4 @@ export class PosService { const categories = Array.from(map.values()) return ResponseMapper.list(categories) } - - async createOrder(posId: number, data: CreateSaleInvoiceDto) { - const { customerId, items, ...res } = data - const lastCode = await this.prisma.salesInvoice - .findFirst({ - where: { posAccountId: posId }, - orderBy: { code: 'desc' }, - select: { code: true }, - }) - .then(si => si?.code || '0') - - const newCode = String(Number(lastCode) + 1) - - const totalAmount = data.items.reduce( - (acc, item) => acc + item.count * item.unitPrice, - 0, - ) - - const preparedOrder: SalesInvoiceCreateInput = { - ...res, - code: newCode, - posAccount: { connect: { id: posId } }, - customer: customerId ? { connect: { id: customerId } } : undefined, - totalAmount: totalAmount, - items: { - create: items.map(item => ({ - product: { connect: { id: Number(item.productId) } }, - count: item.count, - unitPrice: item.unitPrice, - total: item.count * item.unitPrice, - })), - }, - } - - const item = await this.prisma.salesInvoice.create({ data: preparedOrder }) - return ResponseMapper.create(item) - } } diff --git a/src/modules/purchase-receipts/purchase-receipt-items/dto/update-purchase-receipt-item.dto.ts b/src/modules/purchase-receipts/purchase-receipt-items/dto/update-purchase-receipt-item.dto.ts index caa5f27..7c9395f 100644 --- a/src/modules/purchase-receipts/purchase-receipt-items/dto/update-purchase-receipt-item.dto.ts +++ b/src/modules/purchase-receipts/purchase-receipt-items/dto/update-purchase-receipt-item.dto.ts @@ -15,7 +15,7 @@ export class UpdatePurchaseReceiptItemDto { @IsOptional() @Type(() => Number) @IsNumber() - total?: number + totalAmount?: number @IsOptional() @Type(() => Number) diff --git a/src/modules/purchase-receipts/purchase-receipt-items/purchase-receipt-items.service.ts b/src/modules/purchase-receipts/purchase-receipt-items/purchase-receipt-items.service.ts index 1e383a1..90d23d5 100644 --- a/src/modules/purchase-receipts/purchase-receipt-items/purchase-receipt-items.service.ts +++ b/src/modules/purchase-receipts/purchase-receipt-items/purchase-receipt-items.service.ts @@ -19,7 +19,7 @@ export class PurchaseReceiptItemsService { } payload.unitPrice = String(payload.unitPrice) payload.count = String(payload.count) - payload.total = String(payload.total) + payload.totalAmount = String(payload.totalAmount) const item = await this.prisma.purchaseReceiptItem.create({ data: payload }) return ResponseMapper.create(item) } diff --git a/src/sales-invoices/dto/create-sales-invoice.dto.ts b/src/modules/sales-invoices/dto/create-sales-invoice.dto.ts similarity index 100% rename from src/sales-invoices/dto/create-sales-invoice.dto.ts rename to src/modules/sales-invoices/dto/create-sales-invoice.dto.ts diff --git a/src/sales-invoices/dto/update-sales-invoice.dto.ts b/src/modules/sales-invoices/dto/update-sales-invoice.dto.ts similarity index 100% rename from src/sales-invoices/dto/update-sales-invoice.dto.ts rename to src/modules/sales-invoices/dto/update-sales-invoice.dto.ts diff --git a/src/sales-invoices/sales-invoices.controller.ts b/src/modules/sales-invoices/sales-invoices.controller.ts similarity index 50% rename from src/sales-invoices/sales-invoices.controller.ts rename to src/modules/sales-invoices/sales-invoices.controller.ts index 48e65a0..06d402d 100644 --- a/src/sales-invoices/sales-invoices.controller.ts +++ b/src/modules/sales-invoices/sales-invoices.controller.ts @@ -1,16 +1,14 @@ -import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common' -import { CreateSalesInvoiceDto } from './dto/create-sales-invoice.dto' -import { UpdateSalesInvoiceDto } from './dto/update-sales-invoice.dto' +import { Controller, Delete, Get, Param } from '@nestjs/common' import { SalesInvoicesService } from './sales-invoices.service' @Controller('sales-invoices') export class SalesInvoicesController { constructor(private readonly service: SalesInvoicesService) {} - @Post() - create(@Body() dto: CreateSalesInvoiceDto) { - return this.service.create(dto) - } + // @Post() + // create(@Body() dto: CreateSalesInvoiceDto) { + // return this.service.create(dto) + // } @Get() findAll() { @@ -22,10 +20,10 @@ export class SalesInvoicesController { return this.service.findOne(Number(id)) } - @Patch(':id') - update(@Param('id') id: string, @Body() dto: UpdateSalesInvoiceDto) { - return this.service.update(Number(id), dto) - } + // @Patch(':id') + // update(@Param('id') id: string, @Body() dto: UpdateSalesInvoiceDto) { + // return this.service.update(Number(id), dto) + // } @Delete(':id') remove(@Param('id') id: string) { diff --git a/src/sales-invoices/sales-invoices.module.ts b/src/modules/sales-invoices/sales-invoices.module.ts similarity index 57% rename from src/sales-invoices/sales-invoices.module.ts rename to src/modules/sales-invoices/sales-invoices.module.ts index e1ec1ae..76fdced 100644 --- a/src/sales-invoices/sales-invoices.module.ts +++ b/src/modules/sales-invoices/sales-invoices.module.ts @@ -1,11 +1,13 @@ import { Module } from '@nestjs/common' -import { PrismaModule } from '../prisma/prisma.module' +import { PrismaModule } from '../../prisma/prisma.module' import { SalesInvoicesController } from './sales-invoices.controller' import { SalesInvoicesService } from './sales-invoices.service' +import { SalesInvoicesWorkflow } from './sales-invoices.workflow' @Module({ imports: [PrismaModule], controllers: [SalesInvoicesController], - providers: [SalesInvoicesService], + providers: [SalesInvoicesService, SalesInvoicesWorkflow], + exports: [SalesInvoicesWorkflow], }) export class SalesInvoicesModule {} diff --git a/src/modules/sales-invoices/sales-invoices.service.ts b/src/modules/sales-invoices/sales-invoices.service.ts new file mode 100644 index 0000000..278304b --- /dev/null +++ b/src/modules/sales-invoices/sales-invoices.service.ts @@ -0,0 +1,49 @@ +import { Injectable } from '@nestjs/common' +import { ResponseMapper } from '../../common/response/response-mapper' +import { PrismaService } from '../../prisma/prisma.service' + +@Injectable() +export class SalesInvoicesService { + constructor(private prisma: PrismaService) {} + + // async create(dto: CreateSalesInvoiceDto) { + // const payload: any = { ...dto } + // if (Object.prototype.hasOwnProperty.call(payload, 'customerId')) { + // payload.customer = { connect: { id: Number(payload.customerId) } } + // delete payload.customerId + // } + + // const item = await this.prisma.salesInvoice.create({ data: payload }) + // return ResponseMapper.create(item) + // } + + async findAll() { + const items = await this.prisma.salesInvoice.findMany({ include: { customer: true } }) + return ResponseMapper.list(items) + } + + async findOne(id: number) { + const item = await this.prisma.salesInvoice.findUnique({ + where: { id }, + include: { items: true, customer: true }, + }) + if (!item) return null + return ResponseMapper.single(item) + } + + // async update(id: number, data: any) { + // const payload: any = { ...data } + // if (Object.prototype.hasOwnProperty.call(payload, 'customerId')) { + // if (payload.customerId === null) payload.customer = { disconnect: true } + // else payload.customer = { connect: { id: Number(payload.customerId) } } + // delete payload.customerId + // } + // const item = await this.prisma.salesInvoice.update({ where: { id }, data: payload }) + // return ResponseMapper.update(item) + // } + + async remove(id: number) { + const item = await this.prisma.salesInvoice.delete({ where: { id } }) + return ResponseMapper.single(item) + } +} diff --git a/src/modules/sales-invoices/sales-invoices.workflow.ts b/src/modules/sales-invoices/sales-invoices.workflow.ts new file mode 100644 index 0000000..26dcaa8 --- /dev/null +++ b/src/modules/sales-invoices/sales-invoices.workflow.ts @@ -0,0 +1,38 @@ +import { + MovementReferenceType, + MovementType, + Prisma, +} from '../../generated/prisma/client' + +export class SalesInvoicesWorkflow { + constructor() {} + + async onCreateByOrder(tx: Prisma.TransactionClient, orderId: number) { + const { posAccount } = await tx.order.findUniqueOrThrow({ + where: { id: orderId }, + select: { posAccount: { select: { inventoryId: true, id: true } } }, + }) + + const posInventoryId = posAccount.inventoryId + const orderItems = await tx.orderItem.findMany({ + where: { + orderId, + }, + }) + + await tx.stockMovement.createMany({ + data: orderItems.map(item => ({ + productId: item.productId, + orderId, + type: MovementType.OUT, + referenceType: MovementReferenceType.SALES, + referenceId: String(orderId), + quantity: item.quantity, + inventoryId: posInventoryId, + unitPrice: item.unitPrice, + totalCost: item.totalAmount, + avgCost: item.unitPrice, + })), + }) + } +} diff --git a/src/sales-invoice-items/dto/create-sales-invoice-item.dto.ts b/src/sales-invoice-items/dto/create-sales-invoice-item.dto.ts index 10640cc..eb7ea49 100644 --- a/src/sales-invoice-items/dto/create-sales-invoice-item.dto.ts +++ b/src/sales-invoice-items/dto/create-sales-invoice-item.dto.ts @@ -12,7 +12,7 @@ export class CreateSalesInvoiceItemDto { @Type(() => Number) @IsNumber() - total: number + totalAmount: number @Type(() => Number) @IsInt() diff --git a/src/sales-invoice-items/dto/update-sales-invoice-item.dto.ts b/src/sales-invoice-items/dto/update-sales-invoice-item.dto.ts index e07671d..7d5fb36 100644 --- a/src/sales-invoice-items/dto/update-sales-invoice-item.dto.ts +++ b/src/sales-invoice-items/dto/update-sales-invoice-item.dto.ts @@ -15,7 +15,7 @@ export class UpdateSalesInvoiceItemDto { @IsOptional() @Type(() => Number) @IsNumber() - total?: number + totalAmount?: number @IsOptional() @Type(() => Number) diff --git a/src/sales-invoices/sales-invoices.service.ts b/src/sales-invoices/sales-invoices.service.ts deleted file mode 100644 index db50238..0000000 --- a/src/sales-invoices/sales-invoices.service.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Injectable } from '@nestjs/common' -import { ResponseMapper } from '../common/response/response-mapper' -import { PrismaService } from '../prisma/prisma.service' -import { CreateSalesInvoiceDto } from './dto/create-sales-invoice.dto' - -@Injectable() -export class SalesInvoicesService { - constructor(private prisma: PrismaService) {} - - async create(dto: CreateSalesInvoiceDto) { - const payload: any = { ...dto } - if (Object.prototype.hasOwnProperty.call(payload, 'customerId')) { - payload.customer = { connect: { id: Number(payload.customerId) } } - delete payload.customerId - } - - const item = await this.prisma.salesInvoice.create({ data: payload }) - return ResponseMapper.create(item) - } - - async findAll() { - const items = await this.prisma.salesInvoice.findMany({ include: { customer: true } }) - return ResponseMapper.list(items) - } - - async findOne(id: number) { - const item = await this.prisma.salesInvoice.findUnique({ - where: { id }, - include: { items: true, customer: true }, - }) - if (!item) return null - return ResponseMapper.single(item) - } - - async update(id: number, data: any) { - const payload: any = { ...data } - if (Object.prototype.hasOwnProperty.call(payload, 'customerId')) { - if (payload.customerId === null) payload.customer = { disconnect: true } - else payload.customer = { connect: { id: Number(payload.customerId) } } - delete payload.customerId - } - const item = await this.prisma.salesInvoice.update({ where: { id }, data: payload }) - return ResponseMapper.update(item) - } - - async remove(id: number) { - const item = await this.prisma.salesInvoice.delete({ where: { id } }) - return ResponseMapper.single(item) - } -}