/// <summary>
        /// Calculates Total Allowances
        /// </summary>
        /// <param name="role">Subject's role within the calculation</param>
        /// <param name="maritalStatus">Marital status</param>
        /// <param name="stateOfResidency">State of residency</param>
        /// <param name="numInCollege">Number in college</param>
        /// <param name="numInHousehold">Number in household</param>
        /// <param name="employablePersons">People capable of employment. Exact definition varies depending on
        /// role. If the role is "Parent", for example, <see cref="employablePersons"/> refers to the parents.
        /// If the role is "IndependentStudent", <see cref="employablePersons"/> refers to the student and
        /// spouse</param>
        /// <param name="totalIncome">Total income</param>
        /// <param name="incomeTaxPaid">U.S. income tax paid</param>
        /// <returns>"Total Allowances"</returns>
        public double CalculateTotalAllowances(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            UnitedStatesStateOrTerritory stateOfResidency,
            int numInCollege,
            int numInHousehold,
            List<HouseholdMember> employablePersons,
            double totalIncome,
            double incomeTaxPaid)
        {
            double totalAllowances = 0;

            // Income Tax Paid
            totalAllowances += CalculateIncomeTaxAllowance(incomeTaxPaid);

            // State Tax
            totalAllowances += CalculateStateTaxAllowance(role, stateOfResidency, totalIncome);

            // Social Security Tax
            totalAllowances += employablePersons
                                    .Where(person => person.IsWorking)
                                    .Sum(person => CalculateSocialSecurityTaxAllowance(person.WorkIncome));

            // Employment Expense Allowance
            if (role != EfcCalculationRole.DependentStudent)
            {
                totalAllowances += CalculateEmploymentExpenseAllowance(role, maritalStatus, employablePersons);
            }

            // Income Protection Allowance
            totalAllowances += CalculateIncomeProtectionAllowance(role, maritalStatus, numInCollege, numInHousehold);

            return Math.Round(totalAllowances < 0 ? 0 : totalAllowances, MidpointRounding.AwayFromZero);
        }
Example #2
0
        public override void LoadFromStore(VMStore modelStore)
        {
            try
            {
                Profile               = JsonConvert.DeserializeObject <ClientProfileDTO>(modelStore.Store);
                Downloaded            = Profile.Downloaded;
                ClientId              = Profile.ClientId;
                SelectedMaritalStatus = MaritalStatus.FirstOrDefault(x => x.Id == Profile.MaritalStatus);
                SelectedKeyPop        = KeyPops.FirstOrDefault(x => x.Id == Profile.KeyPop);
                OtherKeyPop           = Profile.OtherKeyPop;
                SelectedEducation     = Educations.FirstOrDefault(x => x.ItemId == Profile.Education);
                SelectedCompletion    = Completions.FirstOrDefault(x => x.ItemId == Profile.Completion);
                SelectedOccupation    = Occupations.FirstOrDefault(x => x.ItemId == Profile.Occupation);

                if (null != Profile.RelTypeId && !string.IsNullOrWhiteSpace(Profile.RelTypeId))
                {
                    SelectedRelationshipType =
                        RelationshipTypes.FirstOrDefault(x => x.Description.ToLower() == Profile.RelTypeId.ToLower());
                }
            }
            catch (Exception e)
            {
                Mvx.Error(e.Message);
            }
        }
Example #3
0
 public Person(String pName, Gender pGender, MaritalStatus pMaritalStatus, int pEdad)
 {
     this.Name = pName;
     this.Gender = pGender;
     this.MaritalStatus = pMaritalStatus;
     this.Age = pEdad;
 }
Example #4
0
        /// <summary>
        /// Valida que un registro cumpla con los filtros actuales
        /// </summary>
        /// <param name="maritalStatus">objeto a valida</param>
        /// <returns>True. Si cumple | False. No cumple</returns>
        /// <history>
        /// [emoguel] created 01/040/2016
        /// </history>
        private bool ValidateFilter(MaritalStatus maritalStatus)
        {
            if (_nStatus != -1)//Filtro por Estatus
            {
                if (maritalStatus.msA != Convert.ToBoolean(_nStatus))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_MaritaStaFilter.msID))//Filtro por ID
            {
                if (_MaritaStaFilter.msID != maritalStatus.msID)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_MaritaStaFilter.msN))//Filtro por descripcion
            {
                if (!_MaritaStaFilter.msN.Contains(maritalStatus.msN, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(true);
        }
Example #5
0
        /// <summary>
        /// Muestra la ventana detalle en modo ReadOnly|edicion
        /// </summary>
        /// <history>
        /// [emoguel] 01/04/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            MaritalStatus          maritalStatus = (MaritalStatus)dgrMaritalStatus.SelectedItem;
            frmMaritalStatusDetail frmMarStatus  = new frmMaritalStatusDetail();

            frmMarStatus.Owner            = this;
            frmMarStatus.oldMaritalStatus = maritalStatus;
            frmMarStatus.enumMode         = (_blnEdit == true)?EnumMode.Edit:EnumMode.ReadOnly;
            if (frmMarStatus.ShowDialog() == true)
            {
                int nIndex = 0;
                List <MaritalStatus> lstMaritalStatus = (List <MaritalStatus>)dgrMaritalStatus.ItemsSource;
                if (!ValidateFilter(frmMarStatus.maritalStatus))
                {
                    lstMaritalStatus.Remove(maritalStatus);//Quitamos el registro de la lista
                    StatusBarReg.Content = lstMaritalStatus.Count + " Marital Status.";
                }
                else
                {
                    ObjectHelper.CopyProperties(maritalStatus, frmMarStatus.maritalStatus); //Le asignamos los nuevos valores
                    lstMaritalStatus.Sort((x, y) => string.Compare(x.msN, y.msN));          //ordenamos la lista
                    nIndex = lstMaritalStatus.IndexOf(maritalStatus);                       //obtenemos la posicion del registro
                }
                dgrMaritalStatus.Items.Refresh();
                GridHelper.SelectRow(dgrMaritalStatus, nIndex);
            }
        }
        /// <summary>
        /// Calculates Contribution From Assets
        /// </summary>
        /// <param name="role">Role of the subject within the calculation</param>
        /// <param name="maritalStatus">Marital Status</param>
        /// <param name="age">Age</param>
        /// <param name="cashSavingsCheckings">Cash, savings, and checkings value</param>
        /// <param name="investmentNetWorth">Net worth of investments</param>
        /// <param name="businessFarmNetWorth">Net worth of business and/or investment farm</param>
        /// <returns>"Contribution From Assets"</returns>
        public double CalculateContributionFromAssets(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            int age,
            double cashSavingsCheckings,
            double investmentNetWorth,
            double businessFarmNetWorth)
        {
            double contributionFromAssets = 0;

            if (role == EfcCalculationRole.DependentStudent)
            {
                contributionFromAssets
                    += CalculateNetWorth(role, cashSavingsCheckings, investmentNetWorth, businessFarmNetWorth);
            }
            else
            {
                contributionFromAssets
                    += CalculateDiscretionaryNetWorth(role, maritalStatus, age, cashSavingsCheckings,
                                                        investmentNetWorth, businessFarmNetWorth);
            }

            double assetRate = 1;

            switch (role)
            {
                case EfcCalculationRole.Parent:
                    assetRate = _constants.DependentParentAssetRate;
                    break;

                case EfcCalculationRole.DependentStudent:
                    assetRate = _constants.DependentStudentAssetRate;
                    break;

                case EfcCalculationRole.IndependentStudentWithDependents:
                    assetRate = _constants.IndependentWithDependentsAssetRate;
                    break;

                case EfcCalculationRole.IndependentStudentWithoutDependents:
                    assetRate = _constants.IndependentWithoutDependentsAssetRate;
                    break;
            }

            contributionFromAssets *= assetRate;

            return Math.Round(contributionFromAssets < 0 ? 0 : contributionFromAssets, MidpointRounding.AwayFromZero);
        }
        /// <summary>
        /// Calculates Income Protection Allowance
        /// </summary>
        /// <param name="role">Subject's role within the calculation</param>
        /// <param name="maritalStatus">Marital status</param>
        /// <param name="numInCollege">Number in college</param>
        /// <param name="numInHousehold">Number in household</param>
        /// <returns>"Income Protection Allowance"</returns>
        public double CalculateIncomeProtectionAllowance(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            int numInCollege,
            int numInHousehold)
        {
            if (numInCollege > numInHousehold || numInCollege <= 0 || numInHousehold <= 0)
            {
                return 0;
            }

            double incomeProtectionAllowance = 0;

            switch (role)
            {
                case EfcCalculationRole.IndependentStudentWithDependents:
                case EfcCalculationRole.Parent:

                    // Determine the appropriate charts to use for Income Protection Allowance values
                    int[,] incomeProtectionAllowances = (role == EfcCalculationRole.Parent)
                        ? _constants.DependentParentIncomeProtectionAllowances
                        : _constants.IndependentWithDependentsIncomeProtectionAllowances;

                    int additionalStudentAllowance = (role == EfcCalculationRole.Parent)
                        ? _constants.DependentAdditionalStudentAllowance
                        : _constants.IndependentAdditionalStudentAllowance;

                    int additionalFamilyAllowance = (role == EfcCalculationRole.Parent)
                        ? _constants.DependentAdditionalFamilyAllowance
                        : _constants.IndependentAdditionalFamilyAllowance;

                    // If number of children in the household exceeds table range, add additionalFamilyAllowance
                    // for each additional child
                    int maxHouseholdCount = incomeProtectionAllowances.GetLength(0) - 1;
                    int householdCount = numInHousehold;

                    if (numInHousehold > maxHouseholdCount)
                    {
                        // Set number in household to maximum table range
                        householdCount = maxHouseholdCount;
                        incomeProtectionAllowance += (numInHousehold - maxHouseholdCount) * additionalFamilyAllowance;
                    }

                    // If number of children in college exceeds table range, add additionalStudentAllowance
                    // for each additional child
                    int maxCollegeCount = incomeProtectionAllowances.GetLength(1) - 1;
                    int collegeCount = numInCollege;

                    if (numInCollege > maxCollegeCount)
                    {
                        // Set number in college to maximum table range
                        collegeCount = maxCollegeCount;
                        incomeProtectionAllowance -= (numInCollege - maxCollegeCount) * additionalStudentAllowance;
                    }

                    // Add standard incomeProtectionAllowance value
                    incomeProtectionAllowance += incomeProtectionAllowances[householdCount, collegeCount];

                    break;

                case EfcCalculationRole.IndependentStudentWithoutDependents:

                    if (maritalStatus == MaritalStatus.SingleSeparatedDivorced)
                    {
                        incomeProtectionAllowance
                            = _constants.SingleIndependentWithoutDependentsIncomeProtectionAllowance;
                    }
                    else
                    {
                        // If spouse is enrolled at least 1/2 time, then use the Income Protection Allowance value
                        // for Single/Separated/Divorced
                        incomeProtectionAllowance = (numInCollege > 1) ?
                            _constants.SingleIndependentWithoutDependentsIncomeProtectionAllowance
                                : _constants.MarriedIndependentWithoutDependentsIncomeProtectionAllowance;
                    }

                    break;

                case EfcCalculationRole.DependentStudent:

                    incomeProtectionAllowance = _constants.DependentStudentIncomeProtectionAllowance;

                    break;
            }

            return Math.Round(incomeProtectionAllowance < 0 ? 0 : incomeProtectionAllowance,
                MidpointRounding.AwayFromZero);
        }
        /// <summary>
        /// Calculates "Employmement Expense Allowance"
        /// </summary>
        /// <param name="role">Subject's role within the calculation</param>
        /// <param name="maritalStatus">Marital status</param>
        /// <param name="employablePersons">People capable of employment. Exact definition varies depending on
        /// role. If the role is "Parent", for example, <see cref="employablePersons"/> refers to the parents.
        /// If the role is "IndependentStudent", <see cref="employablePersons"/> refers to the student and
        /// spouse</param>
        /// <returns>"Employment Expense Allowance"</returns>
        public double CalculateEmploymentExpenseAllowance(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            List<HouseholdMember> employablePersons)
        {
            if (employablePersons == null
                || !employablePersons.Any()
                || (role == EfcCalculationRole.DependentStudent)
                || (role == EfcCalculationRole.IndependentStudentWithoutDependents
                        && maritalStatus == MaritalStatus.SingleSeparatedDivorced))
            {
                return 0;
            }

            IEnumerable<HouseholdMember> incomeEarners
                = employablePersons
                    .Where(ep => ep.IsWorking)
                    .OrderBy(ie => ie.WorkIncome);

            // Not all of the employable persons are working
            if (incomeEarners.Count() != employablePersons.Count())
            {
                return 0;
            }

            // Use the lesser of the incomes for the calculation
            double lowestIncome = incomeEarners.First().WorkIncome;
            double adjustedLowestIncome = (lowestIncome * _constants.EmploymentExpensePercent);

            double employmentExpenseAllowance = adjustedLowestIncome > _constants.EmploymentExpenseMaximum
                ? _constants.EmploymentExpenseMaximum : adjustedLowestIncome;

            return Math.Round(employmentExpenseAllowance < 0 ? 0 : employmentExpenseAllowance,
                MidpointRounding.AwayFromZero);
        }
Example #9
0
 /// <summary>
 /// Sets the value of the <c>&lt;MaritalStatus&gt;</c> element.
 /// </summary>
 /// <param name="val">A MaritalStatus object</param>
 /// <remarks>
 /// <para>The SIF specification defines the meaning of this element as: "The person's marital status."</para>
 /// <para>Version: 2.5</para>
 /// <para>Since: 1.1</para>
 /// </remarks>
 public void SetMaritalStatus( MaritalStatus val )
 {
     SetField( CommonDTD.DEMOGRAPHICS_MARITALSTATUS, val );
 }
Example #10
0
 public Person(String pName, Gender pGender, MaritalStatus pMaritalStatus)
     : this(pName, pGender, pMaritalStatus, 0)
 {
 }
        /// <summary>
        /// Calculates Discretionary Net Worth contribution
        /// </summary>
        /// <param name="role">Role of the subject within the calculation</param>
        /// <param name="maritalStatus">Marital Status</param>
        /// <param name="age">Age</param>
        /// <param name="cashSavingsCheckings">Cash, savings, and checkings value</param>
        /// <param name="investmentNetWorth">Net worth of investments</param>
        /// <param name="businessFarmNetWorth">Net worth of business and/or investment farm</param>
        /// <returns>"Discretionary Net Worth" contribution</returns>
        public double CalculateDiscretionaryNetWorth(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            int age,
            double cashSavingsCheckings,
            double investmentNetWorth,
            double businessFarmNetWorth)
        {
            double discretionaryNetWorth = 0;

            discretionaryNetWorth +=
                CalculateNetWorth(role, cashSavingsCheckings, investmentNetWorth, businessFarmNetWorth);

            discretionaryNetWorth -=
                CalculateAssetProtectionAllowance(maritalStatus, age);

            return Math.Round(discretionaryNetWorth, MidpointRounding.AwayFromZero);
        }
        /// <summary>
        /// Calculates Asset Protection Allowance
        /// </summary>
        /// <param name="maritalStatus">Marital status</param>
        /// <param name="age">Age of subject</param>
        /// <returns>"Asset Protection Allowance"</returns>
        public int CalculateAssetProtectionAllowance(MaritalStatus maritalStatus, int age)
        {
            if (age < _constants.AssetProtectionAllowanceLowestAge)
            {
                return 0;
            }

            int[] assetProtectionAllowances =
                (maritalStatus == MaritalStatus.MarriedRemarried)
                    ? _constants.MarriedAssetProtectionAllowances
                    : _constants.SingleAssetProtectionAllowances;

            int maxIndex = (assetProtectionAllowances.Length - 1);

            if (age > (_constants.AssetProtectionAllowanceLowestAge + maxIndex))
            {
                return assetProtectionAllowances[maxIndex];
            }

            return assetProtectionAllowances[age - _constants.AssetProtectionAllowanceLowestAge];
        }
Example #13
0
 private int GetDataIndex(int age, Sex sex, MaritalStatus status, int deltaYear)
 {
     if (age >= MaxAgeCategory) age = MaxAgeCategory;
     int statusAsInt;
     switch (status)
     {
         case MaritalStatus.Single:
             statusAsInt = 0;
             break;
         case MaritalStatus.Married:
         case MaritalStatus.MarriedSpouseOutOfSimulation:
             statusAsInt = 1;
             break;
         case MaritalStatus.Divorced:
             statusAsInt = 2;
             break;
         default:
             statusAsInt = 3;
             break;
     }
     int sexOffset = sex == Sex.Male ? 0 : 1920;
     return deltaYear * 24 + (age / 5) + statusAsInt * 480 + sexOffset;
 }
        /// <summary>
        /// Calculates "Employmement Expense Allowance"
        /// </summary>
        /// <param name="role">Subject's role within the calculation</param>
        /// <param name="maritalStatus">Marital status</param>
        /// <param name="employablePersons">People capable of employment. Exact definition varies depending on
        /// role. If the role is "Parent", for example, <see cref="employablePersons"/> refers to the parents.
        /// If the role is "IndependentStudent", <see cref="employablePersons"/> refers to the student and
        /// spouse</param>
        /// <returns>"Employment Expense Allowance"</returns>
        public double CalculateEmploymentExpenseAllowance(
            EfcCalculationRole role,
            MaritalStatus maritalStatus,
            List<HouseholdMember> employablePersons)
        {
            if (employablePersons == null
                || employablePersons.Count == 0
                || (role == EfcCalculationRole.DependentStudent)
                || (role == EfcCalculationRole.IndependentStudentWithoutDependents
                        && maritalStatus == MaritalStatus.SingleSeparatedDivorced))
            {
                return 0;
            }

            // Create a list of working Household Members
            List<HouseholdMember> incomeEarners = new List<HouseholdMember>();

            foreach (HouseholdMember person in employablePersons)
            {
                if (person.IsWorking)
                {
                    incomeEarners.Add(person);
                }
            }

            // Not all of the employable persons are working
            if (incomeEarners.Count != employablePersons.Count)
            {
                return 0;
            }

            HouseholdMember lowestIncomeEarner = incomeEarners[0];
            foreach (HouseholdMember person in incomeEarners)
            {
                if (person.WorkIncome < lowestIncomeEarner.WorkIncome)
                {
                    lowestIncomeEarner = person;
                }
            }

            // Use the lesser of the incomes for the calculation
            double lowestIncome = lowestIncomeEarner.WorkIncome;
            double adjustedLowestIncome = (lowestIncome * _constants.EmploymentExpensePercent);

            double employmentExpenseAllowance = adjustedLowestIncome > _constants.EmploymentExpenseMaximum
                ? _constants.EmploymentExpenseMaximum : adjustedLowestIncome;

            return Math.Round(employmentExpenseAllowance < 0 ? 0 : employmentExpenseAllowance,
                MidpointRounding.AwayFromZero);
        }
Example #15
0
 /// <summary>
 /// Convert the demographic data into an index into the data.
 /// </summary>
 /// <param name="age"></param>
 /// <param name="status"></param>
 /// <param name="deltaYear"></param>
 /// <returns>The rate to use</returns>
 private static int GetDataIndex(int age, MaritalStatus status, int deltaYear)
 {
     // shockingly converting from an enum to an integer in .Net is slower than doing this
     age = Math.Min(age, MaximumAgeCategoryForBirth);
     int statusAsInt;
     switch(status)
     {
         case MaritalStatus.Single:
             statusAsInt = 0;
             break;
         case MaritalStatus.Married:
         case MaritalStatus.MarriedSpouseOutOfSimulation:
             statusAsInt = 1;
             break;
         case MaritalStatus.Divorced:
             statusAsInt = 2;
             break;
         default:
             statusAsInt = 3;
             break;
     }
     return deltaYear * 8 + (age / 5) - 2 + (statusAsInt) * 160;
 }
 private int ConvertToInt(MaritalStatus status)
 {
     switch (status)
     {
         case MaritalStatus.Single:
             return 0;
         case MaritalStatus.Married:
             return 1;
         case MaritalStatus.Divorced:
             return 2;
         case MaritalStatus.Widowed:
             return 3;
         case MaritalStatus.MarriedSpouseOutOfSimulation:
             return 4;
         default:
             return 0;    
     }
 }
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			
			switch( version )
			{
/*				case 2:
					{
						Hallucinating = ( bool )reader.ReadBool();
						goto case 1;
					}*/
				case 1:
					{
						IsMarried = ( bool )reader.ReadBool();
						m_AllowGayMarriages = ( bool )reader.ReadBool();
						m_AllowCelestialMarriages = ( bool )reader.ReadBool();
						m_MarriageTime = reader.ReadDateTime();
						m_WifeLoc = reader.ReadPoint3D();
						m_HusbandLoc = reader.ReadPoint3D();
						m_MaritalStatus = ( MaritalStatus )reader.ReadInt();
						m_TypeOfMarriage = ( TypeOfMarriage )reader.ReadInt();
						m_FirstName = ( string )reader.ReadString();
						m_LastName = ( string )reader.ReadString();
						m_MaidenName = ( string )reader.ReadString();
						m_RankPoints = reader.ReadInt();
						
						/*GD13_HS_Start_5*/
						m_HuntMode = ( HuntMode )reader.ReadInt();
						m_HuntRank = ( HuntRank )reader.ReadInt();
						m_HuntReward = ( HuntReward )reader.ReadInt();
						m_Hunting = ( bool )reader.ReadBool();
						m_EasyKills = reader.ReadInt();
						m_HardKills = reader.ReadInt();
						m_ExtremeKills = reader.ReadInt();
						m_GodKills = reader.ReadInt();
						/*GD13_HS_End_5*/
						goto case 0;
					}
					
				case 0:
					{
						m_Class = ( PlayerClasses )reader.ReadInt();
						m_Race = ( PlayerRaces )reader.ReadInt();
						m_Tribe = ( PlayerTribes )reader.ReadInt();
						m_Rank = ( PlayerRanks )reader.ReadInt();
						m_RewardsClaimed = reader.ReadInt();
						m_Level = reader.ReadInt();
						m_SkillPts = reader.ReadInt();
						m_Experience = reader.ReadInt();
						m_Age = reader.ReadInt();
						m_NextLevelUp = reader.ReadInt();
						m_Updated = reader.ReadBool();
						m_Bioenginer = reader.ReadBool();
						NextSmithBulkOrder = reader.ReadTimeSpan();
						NextTailorBulkOrder = reader.ReadTimeSpan();
						//NextFletcherBulkOrder = reader.ReadTimeSpan();
						//NextCarpenterBulkOrder = reader.ReadTimeSpan();
						//NextTinkerBulkOrder = reader.ReadTimeSpan();
						//NextTamingBulkOrder = reader.ReadTimeSpan();
						m_BOBFilter = new Engines.BulkOrders.BOBFilter( reader );
						//m_TinkBOBFilter = new Engines.BulkOrders.TinkBOBFilter( reader );
						//m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter( reader );
						m_Flags = (MyPlayerFlag)reader.ReadInt();
						break;
					}
			}
			
			if ( m_BOBFilter == null )
				m_BOBFilter = new Engines.BulkOrders.BOBFilter();
			
/*			if ( m_TinkBOBFilter == null )
				m_TinkBOBFilter = new Engines.BulkOrders.TinkBOBFilter();
			
			if ( m_TamingBOBFilter == null )
				m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter();*/
		}