migration #51

Merged
cowch merged 166 commits from migration into main 2025-09-19 22:18:47 -05:00
Showing only changes of commit f4f3de49ca - Show all commits

View File

@@ -35,23 +35,23 @@ SELECT lot.ProductionLotHumanReadableId
,MaterialHumanReadableId
,MaterialDescription
--IsMainMaterial,
--case when SourcingState in (1, 2) then 1
--when x.ProvidedAmount > 0 then 1
--when x.EffectiveConsumption > 0 then 1
--else 0 end as Staged,
,case when SourcingState in (1, 2) then 1
when x.ProvidedAmount > 0 then 1
when x.EffectiveConsumption > 0 then 1
else 0 end as Staged
,x.ProvidedAmount as Provided
,x.EffectiveConsumption as consumption
,x.TotalDemand as totalDemand ,
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
/* remaining needed to complete the lot */
--,x.TotalDemand - x.EffectiveConsumption as remainingNeeded
/* do we have enough staged or scanned to the lot? */
,case when (case when x.ProvidedAmount <> 0
then x.ProvidedAmount else x.EffectiveConsumption end) >
case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
(a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end
(case when cp.Pieces = 1 then (lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces else
(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'
else 'no' end as noMaterialShortage
-- pkg check
@@ -60,14 +60,14 @@ SELECT lot.ProductionLotHumanReadableId
,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 > (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
,x.IsManualProcess as isManual
,IsMainMaterial
,lot.TotalPlannedLoadingUnits
,lot.TotalProducedLoadingUnits
,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
FROM [issueMaterial].[MaterialDemand] x (nolock)