@gpayne This is the code I used. It’s very similar to yours, but I am having one more issue. There was one issue I noticed last night while testing this further. If the operation is asking for 34 and I try to clock 34 it will not Let me. If I clocked 17 it works fine. If I try another 17 it does not work but if I try 10 it won’t either, but if I try 7 it will. It allows me to do random quantities to get to 32, but that’s it.
@josecgomez If you have any insight, I am all ears. Tried doing this myself and nothing seems to be working.
/* Stopping Over Reporting of Production Quantities */
string Customer = string.Empty;
int oldLaborQty = 0;
Erp.Tables.JobHead JobHead;
Erp.Tables.LaborDtl LaborDtl;
Ice.Diagnostics.Log.WriteEntry("DD Labor Update stop over reporting start");
var orgLaborDtl = (from Old_Row in ttLaborDtl
where Old_Row.Unchanged()
select Old_Row).FirstOrDefault();
if (orgLaborDtl != null)
{
oldLaborQty = System.Convert.ToInt32(orgLaborDtl.LaborQty);
}
foreach(var ttLaborDtlRow in(from ttLaborDtl_Row in ttLaborDtl
where ttLaborDtl_Row.Updated() && (ttLaborDtl_Row.LaborType == "P")
select ttLaborDtl_Row))
{
// Ice.Diagnostics.Log.WriteEntry($"Type {ttLaborDtlRow.LaborType}");
if(ttLaborDtlRow.LaborType == "P")
{
// Ice.Diagnostics.Log.WriteEntry($"before joboper job {ttLaborDtlRow.JobNum} asm {ttLaborDtlRow.AssemblySeq} opr {ttLaborDtlRow.OprSeq}");
var jo = Db.JobOper.Where(j => j.Company == CompanyID && j.JobNum == ttLaborDtlRow.JobNum && j.AssemblySeq == ttLaborDtlRow.AssemblySeq && j.OprSeq == ttLaborDtlRow.OprSeq).Select(j=> new {j.QtyCompleted,j.RunQty}).FirstOrDefault();
// Ice.Diagnostics.Log.WriteEntry("after read");
if (jo != null)
{
// Ice.Diagnostics.Log.WriteEntry($" End Act in JobOper Complete:{jo.QtyCompleted} LaborQ:{ttLaborDtlRow.LaborQty} Total {jo.RunQty} ");
// Ice.Diagnostics.Log.WriteEntry($" oldlabor {oldLaborQty}");
if((jo.QtyCompleted - oldLaborQty) + ttLaborDtlRow.LaborQty > jo.RunQty && ttLaborDtlRow.LaborQty != 0)
{
throw new Ice.BLException("There are already " + jo.QtyCompleted.ToString("N2") + " complete. The operation required quantity is " +
jo.RunQty.ToString("N2") + ". You entered a quantity of " + ttLaborDtlRow.LaborQty.ToString("N2") + " this will result in over reported quantities.");
ttLaborDtlRow.LaborQty = 0;
}
}
}
}
Ice.Diagnostics.Log.WriteEntry("DD Labor Update stop over reporting exit");