Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public decimal? ModifPartYeur(int OptionValue, decimal Pourcentage, bool ViePACPaid, int healthcareProtectionId, int dentalProtectionId, int vieProtectionId, int mamProtectionId, int pacProtectionId)
- {
- // Prime en protection protectionId (ind, fam, mono, exempt ou NA) de l'option (A, B, C, EX) de l'employée payée à Pourcentage selon si ViePACPaid (Vrai Ou Faux)
- // Backup employee data
- var tmp = new ActualEmployee();
- tmp.HealthcareProtectionId = _aggregate.Employee.HealthcareProtectionId;
- tmp.DentalProtectionId = _aggregate.Employee.DentalProtectionId;
- tmp.VieProtectionId = _aggregate.Employee.VieProtectionId;
- tmp.MAMProtectionId = _aggregate.Employee.MAMProtectionId;
- tmp.PACProtectionId = _aggregate.Employee.PACProtectionId;
- tmp.Options = _aggregate.Employee.Options;
- tmp.PartYeurGlobale = _aggregate.Employee.PartYeurGlobale;
- var _engine = ((Container)_this).GetInstance<ActualEngine>();
- if (_premium == null)
- {
- return null;
- }
- var montantInitialYe = _premium.Coverages.Where(o => o.Key.CoverageTypeId < 15).Sum(o => o.Value.PremiumInclTax);
- // Modification des paramètres pour convenir à la nouvelle façon de calculer
- _aggregate.Employee.HealthcareProtectionId = (tmp.HealthcareProtectionId == 5 || tmp.HealthcareProtectionId == 6 ? 6 : healthcareProtectionId);
- _aggregate.Employee.DentalProtectionId = (tmp.DentalProtectionId == 5 || tmp.DentalProtectionId == 6 ? 6 : dentalProtectionId);
- _aggregate.Employee.VieProtectionId = vieProtectionId;
- _aggregate.Employee.MAMProtectionId = mamProtectionId;
- _aggregate.Employee.PACProtectionId = pacProtectionId;
- _aggregate.Employee.Options.Remove("Option");
- _aggregate.Employee.Options.Add("Option", OptionValue); // Option désirée
- _aggregate.Employee.PartYeurGlobale = "1"; // Afin de ne pas créer une boucle infini. Ne pas en tenir compte car nous voulons seulement la prime totale.
- var premium = new ActualPremium(_aggregate.Employee, _premium.CalculationDate);
- premium.OptimizationTypeId = _premium.OptimizationTypeId;
- var task = Task.Run(async () =>
- {
- await _engine._chain.Apply(_aggregate, premium);
- return premium;
- });
- premium = task.Result;
- var sommeGarantiesPayeParYeur = premium.Coverages.Where(o => o.Key.CoverageTypeId < 15 && (ViePACPaid ? true : o.Key.CoverageId != 10)).Sum(o => o.Value.PremiumInclTax);
- var montantPayeParYeur = sommeGarantiesPayeParYeur * Pourcentage;
- decimal res = 0;
- if (montantInitialYe != 0)
- {
- res = montantPayeParYeur / montantInitialYe;
- }
- // ATTENTION À CONFIRMER AVEC CAS EXEMPTÉ
- if (res > 1)
- {
- res = 1;
- }
- _premium.Employee.HealthcareProtectionId = tmp.HealthcareProtectionId;
- _premium.Employee.DentalProtectionId = tmp.DentalProtectionId;
- _premium.Employee.VieProtectionId = tmp.VieProtectionId;
- _premium.Employee.MAMProtectionId = tmp.MAMProtectionId;
- _premium.Employee.PACProtectionId = tmp.PACProtectionId;
- _premium.Employee.Options = tmp.Options;
- _premium.Employee.PartYeurGlobale = tmp.PartYeurGlobale;
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement