public List <ReconciliationEgmTotals> GetWorkflowJobs()
        {
            // get workflows
            WorkflowService workflowService = new WorkflowService();
            List <Workflow> workflows       = workflowService.ListWorkflows();

            var HomeRIDs = workflows.AsEnumerable()
                           .Select(w => w.RefObjRID).Distinct().ToList();

            // get sapphire egm totals by HomeRIDs
            var sapphireEgmJobTotals = GetCompanyByJobNumber(GetSapphireEgmJobTotals(HomeRIDs));

            if (!(sapphireEgmJobTotals is null) && sapphireEgmJobTotals.AsEnumerable().Any())
            {
                // Get pervasive egm totals by Job
                PurchaseOrderHeaderRepository purchaseOrderHeaderRepository = new PurchaseOrderHeaderRepository();
                DataTable pervasiveEgmJobTotals = purchaseOrderHeaderRepository.GetPervasiveRecords("JobCstActs_EGM");

                if (!(pervasiveEgmJobTotals is null) && pervasiveEgmJobTotals.AsEnumerable().Any())
                {
                    var egmJobTotalsAudit = AuditEgmJobTotals(sapphireEgmJobTotals, pervasiveEgmJobTotals);
                    return(egmJobTotalsAudit.ToList());
                }
            }
            return(null);
        }
        public ReconciliationEgmTotals GetEgmAmounts(string jobNumber)
        {
            SapphireRepository sapphireRepository   = new SapphireRepository();
            DataTable          sapphireEgmJobTotals = sapphireRepository.GetSapphireRecords("JobCstActs_EGM", jobNumber);

            if (!(sapphireEgmJobTotals is null))
            {
                // Get pervasive egm totals by Job
                PurchaseOrderHeaderRepository purchaseOrderHeaderRepository = new PurchaseOrderHeaderRepository();
                DataTable pervasiveEgmJobTotals = purchaseOrderHeaderRepository.GetPervasiveRecords("JobCstActs_EGM", jobNumber);

                if (!(pervasiveEgmJobTotals is null) && pervasiveEgmJobTotals.AsEnumerable().Any())
                {
                    var egmJobTotalsAudit = AuditEgmJobTotals(sapphireEgmJobTotals, pervasiveEgmJobTotals);

                    ReconciliationEgmTotals egmTotals = new ReconciliationEgmTotals();
                    egmTotals.JobNumber            = jobNumber;
                    egmTotals.SapphireEgmTotal     = Convert.ToDecimal(egmJobTotalsAudit.ToList()[0].SapphireEgmTotal);
                    egmTotals.PervasiveEgmTotal    = Convert.ToDecimal(egmJobTotalsAudit.ToList()[0].PervasiveEgmTotal);
                    egmTotals.EstimateApprovalDate = egmJobTotalsAudit.ToList()[0].EstimateApprovalDate;

                    return(egmTotals);
                }
            }

            return(null);
        }