From f4f3de49cae277ffa158116d1802495b27fa8e75 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 25 Aug 2025 18:34:09 -0500 Subject: [PATCH] fix(material check): alt mm causing issues and utilizing an 80% to just be ok --- .../sqlServer/querys/ocp/mainMaterial.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index fc6e3e1..42c31e1 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -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 + 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 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)