LaborDtl validation

When an Operator ends an activity through MES I would like to:

  1. validate that the ttLaborDtl.LaborQty + ttLaborDtl.ScrapQty + ttLaborDtl.DiscrepQty is not greater than the JobOper.RunQty - (all other LaborDtl records for the same job, same oprseq) - return an exception detailing the expected balance

  2. validate that the (ttLaborDtl.LaborHrs + JobOper.ActHours) <= (JobOper.EstSetHours + JobOper.EstProdHours) + 1 and ttLaborDtl.LaborNote <> “” - return an exception detailing that a labor note must be added to explain why the operation has run over by an hour

  3. validate the the ttLaborDtl.LaborQty, ttLaborDtl.ScrapQty, ttLaborDtl.DiscrepQty are non decimal and are positive numbers

What approach would be suggested and has anyone coded / created these types of validations?

Roberto

For suggestions 1 and 2, I would run a dynamicqueryadapter to run a query to check for the things that you are looking for. Then based on the results, you can take the appropriate actions.

For number 3, you can create on leave events in a customization and do the checks that you want in code. You also could probably change the extended properties to only allow for the types of values that you want.

All of these are customizations, and how hard they are really depends on your level of Epicor experience and C# abilities. Search DynaminQueryAdapter to find some examples of how to run a query using code for number 1 and 3. Number 3 is going to be pretty simple if statements. Use the wizard to create the framework for the event to trigger all of these actions.

object MESSAGE_WARN = null;
string msg = string.Empty;

Erp.Tables.JobOper JobOper;

var ttLaborDtl_xRow = (from ttLaborDtl_Row in ttLaborDtl
                       where ttLaborDtl_Row.Company == Session.CompanyID && !String.IsNullOrEmpty(ttLaborDtl_Row.RowMod)
                       select ttLaborDtl_Row).FirstOrDefault();
if (ttLaborDtl_xRow.OpComplete)
{
  JobOper = (from JobOper_Row in Db.JobOper
                   where string.Compare(JobOper_Row.Company, ttLaborDtl_xRow.Company, true) == 0 && string.Compare(JobOper_Row.JobNum, ttLaborDtl_xRow.JobNum, true) == 0 && JobOper_Row.AssemblySeq == ttLaborDtl_xRow.AssemblySeq && JobOper_Row.OprSeq == ttLaborDtl_xRow.OprSeq
                   select JobOper_Row).FirstOrDefault();
  if (JobOper != null)
  {
    if ((JobOper.ActProdHours + ttLaborDtl_xRow.LaborHrs) - (JobOper.EstProdHours + JobOper.EstSetHours) >= 1.0 && String.IsNullOrEmpty(ttLaborDtl_xRow.LaborNote))
      {
        msg = "'This Operation is overbooked by more than 1 hour - please detail Reason'";
        CallContext.Current.ExceptionManager.AddBLException(msg); 
      }
  }
}

So far I have written everything using a combination of condition widgets and execute custom code widgets - I am receiving a compilation error on this though which is stopping me in my tracks.

Can you suggest correct syntax?

Roberto.

CS0019 Operator ‘>=’ cannot be applied to operands of type ‘decimal’ and ‘double’

you are comparing two different types. You have to convert one of them.

object MESSAGE_WARN = null;
string msg = string.Empty;

Erp.Tables.JobOper JobOper;

var ttLaborDtl_xRow = (from ttLaborDtl_Row in ttLaborDtl
                       where ttLaborDtl_Row.Company == Session.CompanyID && !String.IsNullOrEmpty(ttLaborDtl_Row.RowMod)
                       select ttLaborDtl_Row).FirstOrDefault();
if (ttLaborDtl_xRow.OpComplete)
{
  JobOper = (from JobOper_Row in Db.JobOper
                   where string.Compare(JobOper_Row.Company, ttLaborDtl_xRow.Company, true) == 0 && string.Compare(JobOper_Row.JobNum, ttLaborDtl_xRow.JobNum, true) == 0 && JobOper_Row.AssemblySeq == ttLaborDtl_xRow.AssemblySeq && JobOper_Row.OprSeq == ttLaborDtl_xRow.OprSeq
                   select JobOper_Row).FirstOrDefault();
  if (JobOper != null)
  {
    if ((JobOper.ActProdHours + ttLaborDtl_xRow.LaborHrs) - (JobOper.EstProdHours + JobOper.EstSetHours) >= System.Convert.ToDecimal(1.0) && String.IsNullOrEmpty(ttLaborDtl_xRow.LaborNote))
      {
        msg = "'This Operation is overbooked by more than 1 hour - please detail Reason'";
        CallContext.Current.ExceptionManager.AddBLException(msg); 
      }
  }
}
'''

Seems odd to convert 1.0 to decimal

They are just different, and since you didn’t declare what it was, it assumed a double. If you declared it first, and then used the variable instead, you wouldn’t have to convert it.