migration #51
@@ -35,23 +35,23 @@ SELECT lot.ProductionLotHumanReadableId
|
|||||||
,MaterialHumanReadableId
|
,MaterialHumanReadableId
|
||||||
,MaterialDescription
|
,MaterialDescription
|
||||||
--IsMainMaterial,
|
--IsMainMaterial,
|
||||||
--case when SourcingState in (1, 2) then 1
|
,case when SourcingState in (1, 2) then 1
|
||||||
--when x.ProvidedAmount > 0 then 1
|
when x.ProvidedAmount > 0 then 1
|
||||||
--when x.EffectiveConsumption > 0 then 1
|
when x.EffectiveConsumption > 0 then 1
|
||||||
--else 0 end as Staged,
|
else 0 end as Staged
|
||||||
,x.ProvidedAmount as Provided
|
,x.ProvidedAmount as Provided
|
||||||
,x.EffectiveConsumption as consumption
|
,x.EffectiveConsumption as consumption
|
||||||
,x.TotalDemand as totalDemand ,
|
,x.TotalDemand as totalDemand ,
|
||||||
case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
|
case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
|
||||||
(a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
(a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
||||||
,l.qty as invForAutoConsume
|
,l.qty as invForAutoConsume
|
||||||
/* remaining needed to complete the lot */
|
/* remaining needed to complete the lot */
|
||||||
--,x.TotalDemand - x.EffectiveConsumption as remainingNeeded
|
--,x.TotalDemand - x.EffectiveConsumption as remainingNeeded
|
||||||
/* do we have enough staged or scanned to the lot? */
|
/* do we have enough staged or scanned to the lot? */
|
||||||
,case when (case when x.ProvidedAmount <> 0
|
,case when (case when x.ProvidedAmount <> 0
|
||||||
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
||||||
case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
|
(case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
|
||||||
(a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end
|
(a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end)
|
||||||
then 'good'
|
then 'good'
|
||||||
else 'no' end as noMaterialShortage
|
else 'no' end as noMaterialShortage
|
||||||
-- pkg check
|
-- pkg check
|
||||||
@@ -60,14 +60,14 @@ SELECT lot.ProductionLotHumanReadableId
|
|||||||
|
|
||||||
,case when cp.Percentage is null then
|
,case when cp.Percentage is null then
|
||||||
case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else
|
case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else
|
||||||
(case when l.qty > (a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0
|
(case when l.qty > (a.Weight *((case when cp.Percentage is null then 80.25 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 and IsManualProcess = 0
|
||||||
then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck
|
then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck
|
||||||
,x.IsManualProcess as isManual
|
,x.IsManualProcess as isManual
|
||||||
,IsMainMaterial
|
,IsMainMaterial
|
||||||
,lot.TotalPlannedLoadingUnits
|
,lot.TotalPlannedLoadingUnits
|
||||||
,lot.TotalProducedLoadingUnits
|
,lot.TotalProducedLoadingUnits
|
||||||
,lot.TotalPlannedLoadingUnits - lot.TotalProducedLoadingUnits as remainingPallets
|
,lot.TotalPlannedLoadingUnits - lot.TotalProducedLoadingUnits as remainingPallets
|
||||||
,cp.Percentage
|
,case when cp.Percentage is null then 80.25 else cp.Percentage end as Percentage -- this is to over come the alternate mm put in planning
|
||||||
,case when cp.Pieces is not null then cp.Pieces else pkg.QuantityPosition end as peices
|
,case when cp.Pieces is not null then cp.Pieces else pkg.QuantityPosition end as peices
|
||||||
FROM [issueMaterial].[MaterialDemand] x (nolock)
|
FROM [issueMaterial].[MaterialDemand] x (nolock)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user