I was in the need of something simple, that would allow me to add a field for the minimal point of stock of items and just a report to show me that… so here I go:
-
ADD a Product TAG
-
ADD some values to check that I made things good… LOL
-
ADD this script:
@@StockMinimo:
SELECT [InventoryItemName],
CONVERT(Integer,
CASE WHEN CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000))) <> 0
THEN
CONVERT(Integer,substring(cast([CustomTags] as nvarchar(4000)),CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,
cast([CustomTags] as nvarchar(4000)))+26,CharIndex(‘"’,cast([CustomTags] as nvarchar(4000)),
CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000)))+26)-
CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000)))-26))
ELSE
‘0’
END) as [StockMinimo],
CONVERT(INT,([InStock]+[Added]-[Removed]-[Consumption])*[UnitMultiplier]) as StockFisicoUNFROM [PeriodicConsumptionItems]
LEFT OUTER JOIN [MenuItems] on [MenuItems].[Name] =[PeriodicConsumptionItems].[InventoryItemName]
WHERE [WarehouseConsumptionId] = (SELECT TOP 1 [Id] FROM [PeriodicConsumptions] ORDER BY [Id] DESC)
AND
CONVERT(INT,([InStock]+[Added]-[Removed]-[Consumption])*[UnitMultiplier]) <=
CONVERT(Integer,
CASE WHEN CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000))) <> 0
THEN
CONVERT(Integer,substring(cast([CustomTags] as nvarchar(4000)),CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,
cast([CustomTags] as nvarchar(4000)))+26,CharIndex(‘"’,cast([CustomTags] as nvarchar(4000)),
CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000)))+26)-
CharIndex(‘{“TN”:“StockMinimo”,“TV”:"’,cast([CustomTags] as nvarchar(4000)))-26))
ELSE
‘0’
END)ORDER BY [InventoryItemId]
-
ADD this Report:
[Stock a Reponer:2, 1, 1]
Item|Stock Minimo|Stock Actual
@@StockMinimo
There you go… simple… fast… nothing fancy.
Hope it works!!!
G.