feat: implement purchase receipt items management with create, update, find, and delete functionalities

feat: add purchase receipts management with create, update, find, and delete functionalities

feat: implement sales invoice items management with create, update, find, and delete functionalities

feat: add sales invoices management with create, update, find, and delete functionalities

feat: implement stock adjustments management with create, update, find, and delete functionalities

feat: add stock balance retrieval functionality

feat: implement stock movements management with create, update, find, and delete functionalities
This commit is contained in:
2025-12-09 13:59:07 +03:30
parent a782d61890
commit 807f6c2087
98 changed files with 26109 additions and 501 deletions
+17
View File
@@ -0,0 +1,17 @@
SELECT
`sm`.`id` AS `id`,
`sm`.`productId` AS `productId`,
`sm`.`type` AS `type`,
`sm`.`quantity` AS `quantity`,
`sm`.`fee` AS `fee`,
`sm`.`totalCost` AS `totalCost`,
`sm`.`referenceId` AS `referenceId`,
`sm`.`referenceType` AS `referenceType`,
`sm`.`createdAt` AS `createdAt`,
`sb`.`quantity` AS `current_stock`,
`sb`.`avgCost` AS `current_avg_cost`
FROM
(
`pos`.`Stock_Movements` `sm`
LEFT JOIN `pos`.`stock_balance` `sb` ON((`sb`.`ProductId` = `sm`.`productId`))
)
+8
View File
@@ -0,0 +1,8 @@
SELECT
`pos`.`stock_balance`.`ProductId` AS `ProductId`,
`pos`.`stock_balance`.`quantity` AS `stock_quantity`,
`pos`.`stock_balance`.`avgCost` AS `avgCost`,
`pos`.`stock_balance`.`totalCost` AS `totalCost`,
`pos`.`stock_balance`.`updatedAt` AS `updatedAt`
FROM
`pos`.`stock_balance`
+18
View File
@@ -0,0 +1,18 @@
SELECT
`sm`.`productId` AS `productId`,
`sm`.`id` AS `movement_id`,
`sm`.`type` AS `type`,
`sm`.`quantity` AS `quantity`,
`sm`.`fee` AS `fee`,
`sm`.`totalCost` AS `totalCost`,
`sb`.`quantity` AS `balance_quantity`,
`sb`.`avgCost` AS `balance_avg_cost`,
`sm`.`createdAt` AS `createdAt`
FROM
(
`pos`.`Stock_Movements` `sm`
LEFT JOIN `pos`.`stock_balance` `sb` ON((`sb`.`ProductId` = `sm`.`productId`))
)
ORDER BY
`sm`.`productId`,
`sm`.`createdAt`
+18
View File
@@ -0,0 +1,18 @@
SELECT
`pos`.`Stock_Movements`.`productId` AS `productId`,
`pos`.`Stock_Movements`.`inventoryId` AS `inventoryId`,
sum(
(
CASE
WHEN (`pos`.`Stock_Movements`.`type` = 'IN') THEN `pos`.`Stock_Movements`.`quantity`
WHEN (`pos`.`Stock_Movements`.`type` = 'OUT') THEN -(`pos`.`Stock_Movements`.`quantity`)
WHEN (`pos`.`Stock_Movements`.`type` = 'ADJUST') THEN `pos`.`Stock_Movements`.`quantity`
ELSE 0
END
)
) AS `stock`
FROM
`pos`.`Stock_Movements`
GROUP BY
`pos`.`Stock_Movements`.`productId`,
`pos`.`Stock_Movements`.`inventoryId`