phronCare/Database/Procedures/PhLSM_Stock_GetAvailabilityByStockItemIds.sql
leandro 0b99a89bc1
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 4m3s
refactor(database): organizar scripts SQL en estructura Database
- Se crea carpeta Database con subcarpetas Procedures, Types y Verifications
- Se reubican scripts SQL fuera de la raíz
- Se alinea estructura física con Solution Explorer
Closes #19
2026-03-19 10:17:02 -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