you have to change these line:
LEFT OUTER JOIN [PeriodicConsumptions] on [WarehouseConsumptionId] = [PeriodicConsumptions].[Id]
) as SOURCE_TABLE
for this line:
LEFT OUTER JOIN [PeriodicConsumptions] on [PeriodicConsumptionId] = [PeriodicConsumptions].[Id]
) as SOURCE_TABLE
as from version number:
G.