export const mmQuery = `
SELECT lot.ProductionLotHumanReadableId,
  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 totalNeeded,
	/* 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) > x.TotalDemand then 'good' else 'bad' end as noShortage ,
	x.IsManualProcess as isManual,
	MaterialHumanReadableId
FROM [test1_AlplaPROD2.0_Read].[issueMaterial].[MaterialDemand] x (nolock)
left join
	[test1_AlplaPROD2.0_Read].[issueMaterial].[ProductionLot]  as lot on
	x.ProductionLotId = lot.Id
where lot.ProductionLotHumanReadableId = [lotNumber]
	and IsMainMaterial = 1
`;
