コード例 #1
0
        public ActionResult mensuelStatTraite(string year, string month)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);

                    int mensuelPoste1Tot = 0;
                    int mensuelPoste2Tot = 0;
                    int mensuelPoste3Tot = 0;
                    int mensuelPoste4Tot = 0;
                    int tot = 0;

                    double mensuelRentaPoste1Tot = 0;
                    double mensuelRentaPoste2Tot = 0;
                    double mensuelRentaPoste3Tot = 0;
                    double mensuelRentaPoste4Tot = 0;
                    double totRenta = 0;
                    List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>();

                    JoinedList = (from f in FormulaireService.GetAll()
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId

                                  select new ClientAffecteViewModel
                    {
                        Formulaire = f,
                        Affectation = a,
                        Lot = l,
                    }).ToList();



                    if (month != "" && year != "" && month != null && year != null)
                    {
                        mensuelPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        tot = mensuelPoste1Tot + mensuelPoste2Tot + mensuelPoste3Tot + mensuelPoste4Tot;

                        mensuelRentaPoste1Tot = rentabiliteAgents(year, month, "POSTE1", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste2Tot = rentabiliteAgents(year, month, "POSTE2", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste3Tot = rentabiliteAgents(year, month, "POSTE3", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste4Tot = rentabiliteAgents(year, month, "POSTE4", LotService, FormulaireService, AffectationService);
                        totRenta = mensuelRentaPoste1Tot + mensuelRentaPoste2Tot + mensuelRentaPoste3Tot + mensuelRentaPoste4Tot;
                    }


                    return(Json(new { tot = tot, mensuelPoste1Tot = mensuelPoste1Tot, mensuelPoste2Tot = mensuelPoste2Tot, mensuelPoste3Tot = mensuelPoste3Tot, mensuelPoste4Tot = mensuelPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), mensuelRentaPoste1Tot = mensuelRentaPoste1Tot, mensuelRentaPoste2Tot = mensuelRentaPoste2Tot, mensuelRentaPoste3Tot = mensuelRentaPoste3Tot, mensuelRentaPoste4Tot = mensuelRentaPoste4Tot }));
                }
            }
        }
コード例 #2
0
        public double rentabiliteAgents(DateTime date, string agent, LotService LotService, FormulaireService FormulaireService, AffectationService AffectationService)
        {
            List <ClientAffecteViewModel> JoinedList     = new List <ClientAffecteViewModel>();
            List <ClientAffecteViewModel> TempJoinedList = new List <ClientAffecteViewModel>();

            double trancheTot = 0;
            double soldeTot   = 0;
            double res        = 0;

            JoinedList = (from f in FormulaireService.GetAll()
                          join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                          join l in LotService.GetAll() on a.LotId equals l.LotId
                          where f.Status == Domain.Entities.Status.VERIFIE
                          select new ClientAffecteViewModel
            {
                Formulaire = f,
                Affectation = a,
                Lot = l,
            }).Where(j => j.Affectation.Employe.Username == agent && j.Formulaire.TraiteLe.Date == date).ToList();



            foreach (ClientAffecteViewModel cvm in JoinedList)
            {
                if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE)
                {
                    trancheTot += (cvm.Formulaire.MontantVerseDeclare);
                }

                if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE)
                {
                    TempJoinedList = getTraitHist(cvm.Affectation.AffectationId, FormulaireService, AffectationService, LotService);
                    if (TempJoinedList.Count() == 0)
                    {
                        soldeTot += (cvm.Formulaire.MontantDebInitial);
                    }
                    else
                    {
                        soldeTot += (TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ);
                    }
                }
            }

            res = soldeTot + trancheTot;

            return(res);
        }
コード例 #3
0
        public List <ClientAffecteViewModel> getTraitHist(int idAff, FormulaireService FormulaireService, AffectationService AffectationService, LotService LotService)
        {
            List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>();

            JoinedList = (from f in FormulaireService.GetAll()
                          join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                          join l in LotService.GetAll() on a.LotId equals l.LotId
                          where f.Status == Domain.Entities.Status.VERIFIE && f.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE && f.AffectationId == idAff

                          select new ClientAffecteViewModel
            {
                Formulaire = f,
                Affectation = a,
                Lot = l,
            }).OrderByDescending(f => f.Formulaire.TraiteLe).ToList();

            return(JoinedList);
        }
コード例 #4
0
        public ActionResult quotidienStatTraite(string date)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);

                    DateTime d = new DateTime();

                    int quotidienPoste1Tot = 0;
                    int quotidienPoste2Tot = 0;
                    int quotidienPoste3Tot = 0;
                    int quotidienPoste4Tot = 0;
                    int tot = 0;

                    double quotidienRentaPoste1Tot = 0;
                    double quotidienRentaPoste2Tot = 0;
                    double quotidienRentaPoste3Tot = 0;
                    double quotidienRentaPoste4Tot = 0;
                    double totRenta = 0;
                    List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>();

                    JoinedList = (from f in FormulaireService.GetAll()
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId

                                  select new ClientAffecteViewModel
                    {
                        Formulaire = f,
                        Affectation = a,
                        Lot = l,
                    }).ToList();

                    if (date != "" && date != null)
                    {
                        if (DateTime.TryParse(date, out d))
                        {
                            quotidienPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date == d.Date).Count();
                            quotidienPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date == d.Date).Count();
                            quotidienPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date == d.Date).Count();
                            quotidienPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date == d.Date).Count();
                            tot = quotidienPoste1Tot + quotidienPoste2Tot + quotidienPoste3Tot + quotidienPoste4Tot;


                            quotidienRentaPoste1Tot = rentabiliteAgents(d, "POSTE1", LotService, FormulaireService, AffectationService);
                            quotidienRentaPoste2Tot = rentabiliteAgents(d, "POSTE2", LotService, FormulaireService, AffectationService);
                            quotidienRentaPoste3Tot = rentabiliteAgents(d, "POSTE3", LotService, FormulaireService, AffectationService);
                            quotidienRentaPoste4Tot = rentabiliteAgents(d, "POSTE4", LotService, FormulaireService, AffectationService);
                            totRenta = quotidienRentaPoste1Tot + quotidienRentaPoste2Tot + quotidienRentaPoste3Tot + quotidienRentaPoste4Tot;
                        }
                    }



                    return(Json(new { tot = tot, quotidienPoste1Tot = quotidienPoste1Tot, quotidienPoste2Tot = quotidienPoste2Tot, quotidienPoste3Tot = quotidienPoste3Tot, quotidienPoste4Tot = quotidienPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), quotidienRentaPoste1Tot = quotidienRentaPoste1Tot, quotidienRentaPoste2Tot = quotidienRentaPoste2Tot, quotidienRentaPoste3Tot = quotidienRentaPoste3Tot, quotidienRentaPoste4Tot = quotidienRentaPoste4Tot }));
                }
            }
        }
コード例 #5
0
        public ActionResult StatLot(int numLot, string typeStat, string dateStat, string agent)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);

                    ViewData["list"]      = new SelectList(NumLotListForDropDown(), "Value", "Text");
                    ViewData["sortOrder"] = new SelectList(TypeStatForDropDown(), "Value", "Text");
                    ViewBag.AgentList     = new SelectList(AgentListForDropDown(), "Value", "Text");

                    int nb        = 0;
                    int rdv       = 0;
                    int fn        = 0;
                    int versement = 0;
                    int encours   = 0;

                    string avgRdv     = 0 + "";
                    string avgVers    = 0 + "";
                    string avgFn      = 0 + "";
                    string avgencours = 0 + "";


                    ViewData["years"] = new SelectList(YearListForDropDown(), "Value", "Text");
                    ViewData["month"] = new SelectList(MonthListForDropDown(), "Value", "Text");

                    List <Affectation>            affectations = new List <Affectation>();
                    List <Lot>                    lots         = new List <Lot>();
                    List <ClientAffecteViewModel> rdvCAVm      = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> fnCAVm       = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> versCAVm     = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> encoursCAVm  = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> tot          = new List <ClientAffecteViewModel>();

                    if (numLot == 0)
                    {
                        tot = (from a in AffectationService.GetAll()
                               join l in LotService.GetAll() on a.LotId equals l.LotId
                               select new ClientAffecteViewModel
                        {
                            Affectation = a,
                            Lot = l,
                        }).ToList();


                        rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                   join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                   join l in LotService.GetAll() on a.LotId equals l.LotId

                                   select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList();


                        fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId

                                  select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList();


                        versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                    join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                    join l in LotService.GetAll() on a.LotId equals l.LotId

                                    select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList();


                        encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                       join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                       join l in LotService.GetAll() on a.LotId equals l.LotId

                                       select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList();
                    }
                    else
                    {
                        tot = (from a in AffectationService.GetAll()
                               join l in LotService.GetAll() on a.LotId equals l.LotId
                               where l.NumLot == numLot.ToString()
                               select new ClientAffecteViewModel
                        {
                            Affectation = a,
                            Lot = l,
                        }).ToList();


                        rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                   join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                   join l in LotService.GetAll() on a.LotId equals l.LotId
                                   where l.NumLot == numLot + ""

                                   select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList();


                        fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId
                                  where l.NumLot == numLot + ""

                                  select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList();


                        versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                    join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                    join l in LotService.GetAll() on a.LotId equals l.LotId
                                    where l.NumLot == numLot + ""

                                    select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList();


                        encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                       join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                       join l in LotService.GetAll() on a.LotId equals l.LotId
                                       where l.NumLot == numLot + ""

                                       select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList();
                    }

                    if (typeStat == "1")
                    {
                        nb        = tot.Count();
                        rdv       = rdvCAVm.Count();
                        fn        = fnCAVm.Count();
                        versement = versCAVm.Count();
                        encours   = encoursCAVm.Count();

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "2")
                    {
                        rdv       = rdvCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        fn        = fnCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        versement = versCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        encours   = encoursCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "3")
                    {
                        rdv       = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        fn        = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        encours   = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "4")
                    {
                        rdv       = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        fn        = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        encours   = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }

                    StatLot statLot = new StatLot()
                    {
                        nb         = nb,
                        rdv        = rdv,
                        fn         = fn,
                        versement  = versement,
                        encours    = encours,
                        avgRdv     = avgRdv.Replace(",", "."),
                        avgFn      = avgFn.Replace(",", "."),
                        avgVers    = avgVers.Replace(",", "."),
                        avgencours = avgencours.Replace(",", ".")
                    };

                    return(View("Index", statLot));
                }
            }
        }
コード例 #6
0
        public ActionResult ExtraireLettreAction(string numLot, string debutDate, string finDate, string agent)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    LotService         LotService         = new LotService(UOW);
                    LettreService      lettreService      = new LettreService(UOW);
                    EmployeService     EmployeService     = new EmployeService(UOW);

                    ViewData["list"]  = new SelectList(NumLotListForDropDown(LotService), "Value", "Text");
                    ViewBag.AgentList = new SelectList(AgentListForDropDown(EmployeService), "Value", "Text");

                    string   lettreDir = GetFolderNameForLettre();
                    DateTime startDate = DateTime.Parse(debutDate);
                    DateTime endDate   = DateTime.Parse(finDate);

                    if (!Directory.Exists(lettreDir))
                    {
                        Directory.CreateDirectory(lettreDir);
                    }

                    string lettreDirList = Directory.GetDirectories(lettreDir).Length + 1 + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + "";

                    string dirLettre = "";

                    if (!Directory.Exists(lettreDir + "/" + lettreDirList))
                    {
                        Directory.CreateDirectory(lettreDir + "/" + lettreDirList);
                        dirLettre = lettreDir + "/" + lettreDirList;
                    }

                    List <LettreContent> lettreJoinedList = new List <LettreContent>();

                    if (numLot == "0")
                    {
                        lettreJoinedList = (from f in FormulaireService.GetAll()
                                            join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                            join l in LotService.GetAll() on a.LotId equals l.LotId
                                            where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId)
                                            select new LettreContent
                        {
                            NumLot = l.NumLot,
                            Adresse = l.Adresse,
                            NomClient = l.NomClient,
                            Agence = l.DescIndustry,
                            Compte = l.Compte
                        }).ToList();

                        if (int.Parse(agent) != 0)
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && a.EmployeId == int.Parse(agent)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte
                            }).ToList();
                        }
                        else
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte
                            }).ToList();
                        }
                    }
                    else
                    {
                        if (int.Parse(agent) != 0)
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot)) && a.EmployeId == int.Parse(agent)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte,
                                IdAgent = a.EmployeId + ""
                            }).ToList();
                        }
                        else
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot))
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte,
                                IdAgent = a.EmployeId + ""
                            }).ToList();
                        }
                    }



                    int x = 0;
                    ViewBag.total = lettreJoinedList.Count();
                    foreach (LettreContent lc in lettreJoinedList)
                    {
                        string path = dirLettre + "/" + x + "_" + "lettre" + "_" + lc.Compte + ".docx";

                        if (Directory.Exists(dirLettre))
                        {
                            GenerateWordForLettre(path, lc);
                        }
                        ViewData["currClient"] = x;
                        x++;
                    }

                    string zipPath = zipFolderResult(dirLettre);

                    string adressExcelPath = Server.MapPath("~/Uploads/Lettre/0_Result/") + DateTime.Now.ToString("dd.MM.yyyy") + "_" + Path.GetFileName(dirLettre) + ".xlsx";

                    GenerateExcelForLettre(GenerateDatatableFromJoinedListForLettre(lettreJoinedList), adressExcelPath);
                    Lettre lettre = new Lettre
                    {
                        DateDeb              = startDate.Date,
                        DateFin              = endDate.Date,
                        DateExtrait          = DateTime.Now,
                        LettrePathName       = zipPath,
                        LettreAdressPathName = Path.GetFileName(adressExcelPath)
                    };

                    lettreService.Add(lettre);
                    lettreService.Commit();

                    return(RedirectToAction("Renseigner", new { page = 1 }));
                }
            }
        }
コード例 #7
0
        public ActionResult extraireFacture(string numLot, string factureNum, string pourcentage, string debutDate, string finDate)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    LotService         LotService         = new LotService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    FactureService     factureService     = new FactureService(UOW);

                    ViewData["list"] = new SelectList(NumLotListForDropDown(LotService), "Value", "Text");

                    DateTime startDate   = DateTime.Parse(debutDate);
                    DateTime endDate     = DateTime.Parse(finDate);
                    double   trancheTot  = 0;
                    double   soldeTot    = 0;
                    double   tot         = 0;
                    float    revenuParOp = float.Parse(pourcentage.Replace(".", ","));
                    List <ClientAffecteViewModel> JoinedList       = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> TempJoinedList   = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> AnnexeJoinedList = new List <ClientAffecteViewModel>();

                    if (numLot == "0")
                    {
                        JoinedList = (from f in FormulaireService.GetAll()
                                      join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                      join l in LotService.GetAll() on a.LotId equals l.LotId
                                      where f.Status == Domain.Entities.Status.VERIFIE
                                      select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).Where(j => j.Formulaire.TraiteLe.Date >= startDate.Date && j.Formulaire.TraiteLe.Date <= endDate.Date).ToList();
                    }
                    else
                    {
                        JoinedList = (from f in FormulaireService.GetAll()
                                      join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                      join l in LotService.GetAll() on a.LotId equals l.LotId
                                      where f.Status == Domain.Entities.Status.VERIFIE && l.NumLot.Equals(numLot)
                                      select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).Where(j => j.Formulaire.TraiteLe.Date >= startDate.Date && j.Formulaire.TraiteLe.Date <= endDate.Date).ToList();
                    }

                    foreach (ClientAffecteViewModel cvm in JoinedList)
                    {
                        if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE_TRANCHE)
                        {
                            trancheTot  += (cvm.Formulaire.MontantVerseDeclare * revenuParOp) / 100;
                            cvm.vers     = cvm.Formulaire.MontantVerseDeclare;
                            cvm.recouvre = cvm.Formulaire.MontantVerseDeclare;
                            AnnexeJoinedList.Add(cvm);
                        }

                        if (cvm.Formulaire.EtatClient == Domain.Entities.Note.SOLDE)
                        {
                            TempJoinedList = getTraitHist(cvm.Affectation.AffectationId, FormulaireService, AffectationService, LotService);
                            if (TempJoinedList.Count() == 0)
                            {
                                soldeTot    += (cvm.Formulaire.MontantDebInitial * revenuParOp) / 100;
                                cvm.recouvre = cvm.Formulaire.MontantDebInitial;
                                cvm.vers     = cvm.Formulaire.MontantVerseDeclare;

                                AnnexeJoinedList.Add(cvm);
                            }
                            else
                            {
                                soldeTot    += (TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ *revenuParOp) / 100;
                                cvm.vers     = cvm.Formulaire.MontantVerseDeclare;
                                cvm.recouvre = TempJoinedList.FirstOrDefault().Formulaire.MontantDebMAJ;
                                AnnexeJoinedList.Add(cvm);
                            }
                        }
                    }

                    string        lotsNames   = "";
                    List <string> listNameLot = JoinedList.DistinctBy(j => j.Lot.NumLot).Select(l => l.Lot.NumLot).ToList();

                    if (listNameLot.Count() == 1)
                    {
                        lotsNames = listNameLot.FirstOrDefault();
                    }
                    else if (listNameLot.Count() > 1)
                    {
                        string lastlots = JoinedList.DistinctBy(j => j.Lot.NumLot).Select(l => l.Lot.NumLot).LastOrDefault();
                        listNameLot.RemoveAt(listNameLot.Count - 1);
                        string lots = String.Join(", ", listNameLot);
                        lotsNames = lots + " et " + lastlots;
                    }


                    tot = soldeTot + trancheTot;
                    FactureContent factureContent = new FactureContent();
                    factureContent.FacNum       = factureNum;
                    factureContent.Date         = DateTime.Today;
                    factureContent.Beneficiere  = "Zitouna Bank";
                    factureContent.PrixHT       = tot;
                    factureContent.PrixTVA      = (tot * 19) / 100;
                    factureContent.TimbreFiscal = 0.600;

                    factureContent.PrixTTC = tot + factureContent.PrixTVA;

                    string  annexeFileName  = "Annexe_" + DateTime.Now.ToString("dd.MM.yyyy") + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + ".xlsx";
                    string  factureFileName = "Facture_" + DateTime.Now.ToString("dd.MM.yyyy") + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + ".pdf";
                    string  pathAnnexe      = GetFolderName() + "/" + annexeFileName;
                    string  pathFacture     = GetFolderName() + "/" + factureFileName;
                    Facture facture         = new Facture()
                    {
                        AnnexePathName  = annexeFileName,
                        FacturePathName = factureFileName,
                        DateDeb         = startDate,
                        DateFin         = endDate,
                        DateExtrait     = DateTime.Now
                    };
                    factureService.Add(facture);
                    factureService.Commit();
                    GenerateExcel(GenerateDatatableFromJoinedList(AnnexeJoinedList), pathAnnexe, String.Format("{0:0.000}", AnnexeJoinedList.Sum(j => j.recouvre)));
                    GeneratePDF(pathFacture, lotsNames, factureContent);

                    return(RedirectToAction("genererFacture", new { page = 1 }));
                }
            }
        }
コード例 #8
0
        public ActionResult Index()
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService     EmpService         = new EmployeService(UOW);
                    RoleService        RoleService        = new RoleService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);

                    List <ClientAffecteViewModel> traiteList = new List <ClientAffecteViewModel>();

                    List <HomeViewModel> result = new List <HomeViewModel>();
                    List <Lot>           lots   = new List <Lot>();


                    string[] lotsLst = { };

                    lots    = LotService.GetAll().ToList();
                    lotsLst = lots.DistinctBy(l => l.NumLot).Select(l => l.NumLot).ToArray();

                    List <Affectation> Affectations = new List <Affectation>();
                    List <Formulaire>  Formulaires  = new List <Formulaire>();
                    string[]           agents       = { };

                    Affectations = AffectationService.GetAll().ToList();
                    Formulaires  = FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe).ToList();

                    foreach (string numlot in lotsLst)
                    {
                        lots = LotService.GetAll().Where(l => l.NumLot.Equals(numlot)).ToList();

                        traiteList = (from f in Formulaires
                                      join a in Affectations on f.AffectationId equals a.AffectationId
                                      join l in lots on a.LotId equals l.LotId
                                      select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).ToList();

                        var agentLinq = (from a in Affectations
                                         join l in lots on a.LotId equals l.LotId
                                         select new ClientAffecteViewModel
                        {
                            Affectation = a
                        });


                        agents = agentLinq.DistinctBy(a => a.Affectation.Employe.Username).Select(a => a.Affectation.Employe.Username).ToArray();

                        string agentsStr = string.Join(", ", agents);

                        float  nbAffTotal = agentLinq.Count();
                        float  nbTraite   = traiteList.Count();
                        string avgLot     = String.Format("{0:0.00}", (nbTraite / nbAffTotal) * 100);


                        HomeViewModel homeViewModel = new HomeViewModel
                        {
                            agents     = agentsStr,
                            nbAffTotal = nbAffTotal + "",
                            nbTraite   = nbTraite + "",
                            numLot     = numlot,
                            avancement = avgLot.Replace(",", ".")
                        };
                        result.Add(homeViewModel);
                    }

                    return(View(result));
                }
            }
        }