Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.64 KB | None | 0 0
  1.         public decimal? ModifPartYeur(int OptionValue, decimal Pourcentage, bool ViePACPaid, int healthcareProtectionId, int dentalProtectionId, int vieProtectionId, int mamProtectionId, int pacProtectionId)
  2.         {
  3.             // 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)
  4.            
  5.             // Backup employee data
  6.             var tmp = new ActualEmployee();
  7.             tmp.HealthcareProtectionId = _aggregate.Employee.HealthcareProtectionId;
  8.             tmp.DentalProtectionId = _aggregate.Employee.DentalProtectionId;
  9.             tmp.VieProtectionId = _aggregate.Employee.VieProtectionId;
  10.             tmp.MAMProtectionId = _aggregate.Employee.MAMProtectionId;
  11.             tmp.PACProtectionId = _aggregate.Employee.PACProtectionId;
  12.             tmp.Options = _aggregate.Employee.Options;
  13.             tmp.PartYeurGlobale = _aggregate.Employee.PartYeurGlobale;
  14.  
  15.  
  16.             var _engine = ((Container)_this).GetInstance<ActualEngine>();
  17.             if (_premium == null)
  18.             {
  19.                 return null;
  20.             }
  21.             var montantInitialYe = _premium.Coverages.Where(o => o.Key.CoverageTypeId < 15).Sum(o => o.Value.PremiumInclTax);
  22.            
  23.             // Modification des paramètres pour convenir à la nouvelle façon de calculer
  24.             _aggregate.Employee.HealthcareProtectionId = (tmp.HealthcareProtectionId == 5 || tmp.HealthcareProtectionId == 6 ? 6 : healthcareProtectionId);
  25.             _aggregate.Employee.DentalProtectionId = (tmp.DentalProtectionId == 5 || tmp.DentalProtectionId == 6 ? 6 : dentalProtectionId);
  26.             _aggregate.Employee.VieProtectionId = vieProtectionId;
  27.             _aggregate.Employee.MAMProtectionId = mamProtectionId;
  28.             _aggregate.Employee.PACProtectionId = pacProtectionId;
  29.             _aggregate.Employee.Options.Remove("Option");
  30.             _aggregate.Employee.Options.Add("Option", OptionValue); // Option désirée
  31.             _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.
  32.  
  33.             var premium = new ActualPremium(_aggregate.Employee, _premium.CalculationDate);
  34.             premium.OptimizationTypeId = _premium.OptimizationTypeId;
  35.             var task = Task.Run(async () =>
  36.             {
  37.                 await _engine._chain.Apply(_aggregate, premium);
  38.                 return premium;
  39.             });
  40.             premium = task.Result;
  41.            
  42.             var sommeGarantiesPayeParYeur = premium.Coverages.Where(o => o.Key.CoverageTypeId < 15 && (ViePACPaid ? true : o.Key.CoverageId != 10)).Sum(o => o.Value.PremiumInclTax);
  43.  
  44.             var montantPayeParYeur = sommeGarantiesPayeParYeur * Pourcentage;
  45.  
  46.             decimal res = 0;
  47.             if (montantInitialYe != 0)
  48.             {
  49.                 res = montantPayeParYeur / montantInitialYe;
  50.             }
  51.  
  52.             // ATTENTION À CONFIRMER AVEC CAS EXEMPTÉ
  53.             if (res > 1)
  54.             {
  55.                 res = 1;
  56.             }
  57.  
  58.             _premium.Employee.HealthcareProtectionId = tmp.HealthcareProtectionId;
  59.             _premium.Employee.DentalProtectionId = tmp.DentalProtectionId;
  60.             _premium.Employee.VieProtectionId = tmp.VieProtectionId;
  61.             _premium.Employee.MAMProtectionId = tmp.MAMProtectionId;
  62.             _premium.Employee.PACProtectionId = tmp.PACProtectionId;
  63.  
  64.  
  65.             _premium.Employee.Options = tmp.Options;
  66.             _premium.Employee.PartYeurGlobale = tmp.PartYeurGlobale;
  67.  
  68.  
  69.             return res;
  70.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement