Exemplo n.º 1
0
        public DisabilityCoverage?GetDisabilityCoverage(int employeeID)
        {
            Logger.Instance.LogCurrentMethod(LogLevel.Info);

            try
            {
                var detail = PA20Service.GetHrDetail(employeeID, "Contingents d'absences  (2006)", "15");

                var valueText = detail.FindByName <GuiTextField>("P2006-ANZHL").Text.Trim();

                Logger.Instance.Info("-> {0} < 99999", valueText);
                var result = double.Parse(valueText) < 99999 ? DisabilityCoverage.Weeks52 : DisabilityCoverage.Weeks26;

                Logger.Instance.Info("=> " + result);
                return(result);
            }
            catch (Exception e)
            {
                const string NoRecordStatusMessage = "Aucune donnée existe pour Contingents d'absences  (2006) (dans période sélectionnée)";
                if (e.Data["StatusMessage"] as string == NoRecordStatusMessage)
                {
                    Logger.Instance.Warn("-> " + NoRecordStatusMessage);
                    Logger.Instance.Info("=> null");
                    return(null);
                }

                throw;
            }
        }
Exemplo n.º 2
0
        public KeyValuePair <EmploymentType, DateTime>?GetModificationEvent(int employeeID)
        {
            Logger.Instance.LogCurrentMethod(LogLevel.Info);

            var entries = PA20Service.GetHrEntries(employeeID, "Mesures  (0000)");

            /*  Index Type          Title             Tooltip
             *  0     GuiTextField  Début             Date de début
             *  1     GuiTextField  Fin               Date de fin
             *  2     GuiCTextField Mes.              Catégorie de mesure
             *  3     GuiTextField  Dés. cat. mesure  Dés. cat. mesure
             *  4     GuiCTextField MotMe             Motif mesure
             *  5     GuiTextField  Dés. motif mesure Dés. motif mesure
             *  6     GuiCTextField Client            Statut propre client
             *  7     GuiCTextField Activité          Statut d'activité
             *  8     GuiCTextField Paiement          Statut paiement part */
            var actionToEmploymentType = new Dictionary <string, EmploymentType>
            {
                { "A5", EmploymentType.Temporary }, // Cess. réemb. sans bris /CCE
                { "A6", EmploymentType.Permanent }, // Mouvement de personnel /CCE
            };

            Logger.Instance.Info("Searching for a record with action of [A5 or A6] and reason of [90]");
            var match = entries
                        .Select(x => new
            {
                StartDate  = x[0],
                EndDate    = x[1],
                Action     = x[2, true],
                ActionText = x[3],
                Reason     = x[4, true],
                ReasonText = x[5],
            })
                        .FirstOrDefault(x => actionToEmploymentType.Keys.Contains(x.Action));

            if (match == null)
            {
                Logger.Instance.Warn("-> There is no record matching the criteria.");
                Logger.Instance.Info("=> null");
                return(null);
            }

            Logger.Instance.Info("-> " + match);
            var result = KVPair.Create(
                actionToEmploymentType[match.Action],
                DateTime.ParseExact(match.StartDate, "yyyy/MM/dd", CultureInfo.InvariantCulture));

            Logger.Instance.Info("=> " + result);
            return(result);
        }
Exemplo n.º 3
0
        public bool?HasDentalInsurance(int employeeID)
        {
            Logger.Instance.LogCurrentMethod(LogLevel.Info);

            try
            {
                var detail = PA20Service.GetHrDetail(employeeID, "Régimes de santé  (0167)", "DENT");

                // only '[DEN0]Dentaire Bureau/Métier/Techn.' is taken into consideration
                if (detail.FindByName <GuiCTextField>("P0167-BPLAN").Text != "DEN0")
                {
                    // TODO: ask for the reason why this is invalid
                    const string Message = "The dental plan type is invalid.";
                    var          context = new Dictionary <string, string>
                    {
                        { "Type", detail.FindByName <GuiTextField>("Q0167-BPLAN").Text },
                        { "Description", detail.FindByName <GuiTextField>("T5UCA-LTEXT").Text },
                    };

                    Logger.Instance.Error("The dental plan type is invalid: " + context.Prettify());
                    throw new ArgumentOutOfRangeException(Message + Environment.NewLine + context.Prettify())
                          .BindContext(context);
                }

                var options = new Dictionary <string, bool>
                {
                    { "EXEM", false }, // Exempté de participation
                    { "BASE", true },  // Option de base
                    { "MOD1", true },  // Module de base
                    { "MOD2", true },  // Module bonifié
                    { "MOD3", true },  // Module enrichi
                    { "NONP", false }, // Non participant
                };
                var option     = detail.FindByName <GuiCTextField>("P0167-BOPTI").Text;
                var optionText = detail.FindByName <GuiTextField>("T5UCE-LTEXT").Text;

                bool result;
                if (!options.TryGetValue(option, out result))
                {
                    const string Message = "The dental plan option could not be processed.";
                    var          context = new Dictionary <string, string>
                    {
                        { "Option", option },
                        { "Description", optionText },
                    };

                    Logger.Instance.Error("Invalid dental plan option:" + context.Prettify());
                    throw new ArgumentOutOfRangeException(Message + Environment.NewLine + context.Prettify())
                          .BindContext(context);
                }

                Logger.Instance.Info("-> [{0}]{1}", option, optionText);
                Logger.Instance.Info("=> " + result);
                return(result);
            }
            catch (Exception e)
            {
                const string NoRecordStatusMessage = "Aucune donnée existe pour Régimes de santé  (0167) (dans période sélectionnée)";
                if (e.Data["StatusMessage"] as string == NoRecordStatusMessage)
                {
                    Logger.Instance.Warn("-> " + NoRecordStatusMessage);
                    Logger.Instance.Info("=> false");
                    return(false);
                }

                throw;
            }
        }
Exemplo n.º 4
0
        public bool?HasHealthInsurance(int employeeID)
        {
            Logger.Instance.LogCurrentMethod(LogLevel.Info);

            try
            {
                var detail = PA20Service.GetHrDetail(employeeID, "Régimes de santé  (0167)", "MEDI");

                // retirement health plan is not considered valid
                if (detail.FindByName <GuiTextField>("Q0167-BPLAN").Text == "MALH")
                {
                    Logger.Instance.Warn("-> The employee doesn't have a valid health plan: [{0}]{1}",
                                         detail.FindByName <GuiTextField>("Q0167-BPLAN").Text,
                                         detail.FindByName <GuiTextField>("T5UCA-LTEXT").Text);

                    Logger.Instance.Info("=> null");
                    return(null);
                }

                // an expired plan will have an end date other than 9999-12-31
                if (!detail.FindByName <GuiCTextField>("P0167-ENDDA").Text.StartsWith("9999"))
                {
                    Logger.Instance.Info("-> Employee's last health plan has expired on " +
                                         detail.FindByName <GuiCTextField>("P0167-ENDDA").Text);

                    Logger.Instance.Warn("=> false");
                    return(false);
                }

                var options = new Dictionary <string, bool>
                {
                    { "EXEM", false }, // Exempté de participation
                    { "BASE", true },  // Option de base
                    { "MOD1", true },  // Module de base
                    { "MOD2", true },  // Module bonifié
                    { "MOD3", true },  // Module enrichi
                    { "NONP", false }, // Non participant
                };
                var option     = detail.FindByName <GuiCTextField>("P0167-BOPTI").Text;
                var optionText = detail.FindByName <GuiTextField>("T5UCE-LTEXT").Text;

                bool result;
                if (!options.TryGetValue(option, out result))
                {
                    const string Message = "The application doesn't know to how to process this information.";
                    var          context = new Dictionary <string, string>
                    {
                        { "Option", option },
                        { "Description", optionText },
                    };

                    Logger.Instance.Error("Invalid health plan option:" + context.Prettify());
                    throw new ArgumentOutOfRangeException(Message + Environment.NewLine + context.Prettify())
                          .BindContext(context);
                }

                Logger.Instance.Info("-> [{0}]{1}", option, optionText);
                Logger.Instance.Info("=> " + result);
                return(result);
            }
            catch (InvalidOperationException e)
            {
                const string NoRecordStatusMessage = "Aucune donnée existe pour Régimes de santé  (0167) (dans période sélectionnée)";
                if (e.Data["StatusMessage"] as string == NoRecordStatusMessage)
                {
                    Logger.Instance.Warn("-> " + NoRecordStatusMessage);
                    Logger.Instance.Info("=> false");
                    return(false);
                }

                throw;
            }
        }