Updating StockItem history

Added post-deployment script that updates StockItem history table with lineary increasing prices and lineary decreasing taxes and lead times.
This commit is contained in:
Jovan Popovic
2018-10-12 15:52:19 +02:00
parent c27f06a91d
commit 986298a12e
3 changed files with 23 additions and 0 deletions
@@ -172,6 +172,7 @@ EXEC DataLoadSimulation.DailyProcessToCreateHistory
GO
:r .\pds400-ins-unkown-orderline.sql
:r .\pds410-update-archive-tables.sql
/*
There is one other stored procedure you may find useful:
@@ -0,0 +1,21 @@
-- NOTE: This script should be moved to MakeTemporalChanges procedure, but currently it doesn't work there.
-- jovanpop creating a separate file here.
-- @TODO: Investigate how to move it there.
PRINT N'Updating StockItems history...'
GO
EXEC DataloadSimulation.DeactivatetemporalTablesBeforeDataLoad;
GO
UPDATE Warehouse.StockItems_Archive
SET UnitPrice = s.UnitPrice * (1 - .05 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
RecommendedRetailPrice = s.RecommendedRetailPrice * (1 - .03 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
TaxRate = s.TaxRate * (1 + .02 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
QuantityPerOuter = CEILING(s.QuantityPerOuter * (1 + .05 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 ))),
LeadTimeDays = CEILING(s.LeadTimeDays * (1 + .03 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 ))),
TypicalWeightPerUnit = CEILING(s.TypicalWeightPerUnit * (1 + .02 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )))
FROM Warehouse.StockItems_Archive sa
JOIN Warehouse.StockItems s
ON sa.StockItemID = s.StockItemID;
GO
EXEC DataloadSimulation.ReActivatetemporalTablesAfterDataLoad;
GO
@@ -844,5 +844,6 @@
<None Include="PostDeploymentScripts\pds105-ins-dls-ficticiousnamepool.sql" />
<None Include="PostDeploymentScripts\pds106-ins-dls-areacode.sql" />
<None Include="PostDeploymentScripts\pds400-ins-unkown-orderline.sql" />
<None Include="PostDeploymentScripts\pds410-update-archive-tables.sql" />
</ItemGroup>
</Project>