feat: add inventoryId to SalesInvoice and related models; implement createOrder functionality in POS service

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