phronCare/PhLSM_Stock_GetAvailabilityByStockItemIds.sql
leandro 6d0a72c01d
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 20m38s
feat(expeditions): prevent reuse of stockitem_id in active expeditions
Closes #5
2026-03-11 23:35:51 -03:00

36 lines
948 B
Transact-SQL

USE [phronCare_OperationsHub]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Procedure: PhLSM_Stock_GetAvailabilityByStockItemIds
-- Module: Logistics / Stock (PhLSM)
-- Purpose: Returns quantity and availability data
-- for the requested stock items.
-- Author: Leandro Rojas
-- Created: 2026-03-09
-- =============================================
CREATE OR ALTER PROCEDURE [dbo].[PhLSM_Stock_GetAvailabilityByStockItemIds]
(
@StockItemIds dbo.PhLSM_StockItemIdList READONLY
)
AS
BEGIN
SET NOCOUNT ON;
SELECT
si.id AS StockitemId,
si.quantity AS Quantity,
ISNULL(si.reserved_quantity, 0) AS ReservedQuantity,
si.quantity - ISNULL(si.reserved_quantity, 0) AS AvailableQuantity,
si.serial AS Serial
FROM dbo.PhLSM_StockItem si
INNER JOIN @StockItemIds ids
ON ids.stockitem_id = si.id;
END
GO