Exemple #1
0
        public async Task <IActionResult> UpdateEndorsement(LeadEndorsementVM leadEndorsementVM, IFormCollection formCollection)
        {
            var             userId          = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            LeadEndorsement leadEndorsement = new LeadEndorsement();

            leadEndorsement = leadEndorsementVM.leadEndorsement;

            leadEndorsement.EndDate = Convert.ToDateTime(formCollection["EndDate"].ToString());

            leadEndorsement.IsDeleted    = false;
            leadEndorsement.ModifiedBy   = Guid.Parse(userId);
            leadEndorsement.DateModified = DateTime.Now;
            leadEndorsement.StartDate    = Convert.ToDateTime(formCollection["StartDate"].ToString());

            leadEndorsement.Agents = Util.getAgents(formCollection);

            _context.Update(leadEndorsement);
            await _context.SaveChangesAsync();

            StatusMessage             = StaticContent.LEAD_ENDORSEMENT_UPDATE_MESSAGE;
            ViewData["StatusMessage"] = StatusMessage;

            var routeValues = new RouteValueDictionary {
                { "id", leadEndorsement.ClientId },
                { "IsOpen", "policies" }
            };

            return(RedirectToAction("Details", "Client", routeValues));
        }
Exemple #2
0
        public ActionResult GenerateLeadEndorsementPayment(string leid, string isnew)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var orgId  = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId;

            var leadEndorsementPaymentVM = new LeadEndorsementPaymentVM();

            LeadEndorsement leadEndorsement = _context.LeadEndorsements.Where(l => l.Id == Guid.Parse(leid)).FirstOrDefault();

            Client client = _context.Clients.Where(c => c.Id == leadEndorsement.ClientId).FirstOrDefault();

            Branch branch = _context.Branches.Where(b => b.OrganisationId == orgId).FirstOrDefault();

            Organisation organisation = _context.Organisations.Where(o => o.Id == orgId).FirstOrDefault();

            var leadEndorsementPaymentDetail = _context.LeadEndorsementPaymentDetails.Where(d => d.DebitNoteId == leadEndorsement.DebitNoteId).FirstOrDefault();
            var insurerId     = _context.InsurerMasters.Where(i => i.Id == leadEndorsement.InsurerMasterId).FirstOrDefault().GlobalInsurerId;
            var policyMasters = _context.PolicyClassMaster.ToList();

            leadEndorsementPaymentVM.clientId                     = client.Id.ToString();;
            leadEndorsementPaymentVM.leadEndorsement              = leadEndorsement;
            leadEndorsementPaymentVM.addresss                     = organisation.Address;
            leadEndorsementPaymentVM.organisationName             = organisation.OrganisationName;
            leadEndorsementPaymentVM.amountReceived               = "";
            leadEndorsementPaymentVM.city                         = organisation.City;
            leadEndorsementPaymentVM.currency                     = "";
            leadEndorsementPaymentVM.customerAddress              = client.Address;
            leadEndorsementPaymentVM.email                        = organisation.Email;
            leadEndorsementPaymentVM.endorsementNo                = "";
            leadEndorsementPaymentVM.leadEndorsementPaymentDetail = leadEndorsementPaymentDetail;

            leadEndorsementPaymentVM.paymentMode = "";
            leadEndorsementPaymentVM.phone       = organisation.PhoneNumber;
            leadEndorsementPaymentVM.policyName  = Util.GetPolicyName(policyMasters, leadEndorsement.PolicyClassId);
            leadEndorsementPaymentVM.policyNo    = "TBA";
            if (string.IsNullOrEmpty(leadEndorsementPaymentVM.leadEndorsement.PolicyNo))
            {
                leadEndorsementPaymentVM.policyNo = "TBA";
            }
            else
            {
                leadEndorsementPaymentVM.policyNo = leadEndorsementPaymentVM.leadEndorsement.PolicyNo;
            }

            leadEndorsementPaymentVM.riskType        = "";
            leadEndorsementPaymentVM.transcationType = "";
            leadEndorsementPaymentVM.branchName      = branch.BranchName;
            leadEndorsementPaymentVM.customerNo      = client.ClientCode.ToString();
            leadEndorsementPaymentVM.customerName    = client.Name.ToString();
            leadEndorsementPaymentVM.preparedBy      = _context.Users.Where(x => x.Id == leadEndorsementPaymentDetail.CreatedBy.ToString()).FirstOrDefault().FirstName;

            leadEndorsementPaymentVM.insurerName = Util.GetInsurerName(_context, insurerId);
            leadEndorsementPaymentVM.imageUrl    = Util.GetImageUrl(organisation.ImageUrl);
            leadEndorsementPaymentVM.isNew       = isnew;

            if (isnew == "true")
            {
                StatusMessage             = StaticContent.PAYMENT_GENERATE_SUCCESS_MSG;
                ViewData["StatusMessage"] = StatusMessage;
            }
            return(PartialView("EndorsementPaymentPartialView", leadEndorsementPaymentVM));
        }
Exemple #3
0
        public async Task <ActionResult> GenerateEndorseDebitNote(Guid?leid)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var orgId  = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId;

            var endorsementDebitVM = new EndorsementDebitNoteVM();

            LeadEndorsement leadEndorsement = _context.LeadEndorsements.Where(l => l.Id == leid).FirstOrDefault();

            Client client = _context.Clients.Where(c => c.Id == leadEndorsement.ClientId).FirstOrDefault();

            Branch branch = _context.Branches.Where(b => b.OrganisationId == orgId).FirstOrDefault();

            Organisation organisation = _context.Organisations.Where(o => o.Id == orgId).FirstOrDefault();

            var insurerId     = _context.InsurerMasters.Where(i => i.Id == leadEndorsement.InsurerMasterId).FirstOrDefault().GlobalInsurerId;
            var policyMasters = _context.PolicyClassMaster.ToList();

            endorsementDebitVM.leadEndorsement  = leadEndorsement;
            endorsementDebitVM.addresss         = organisation.Address;
            endorsementDebitVM.organisationName = organisation.OrganisationName;
            endorsementDebitVM.amountReceived   = "";
            endorsementDebitVM.city             = organisation.City;
            endorsementDebitVM.currency         = "";
            endorsementDebitVM.customerAddress  = client.Address;
            endorsementDebitVM.clientId         = client.Id.ToString();
            endorsementDebitVM.email            = organisation.Email;
            endorsementDebitVM.endorsementNo    = "";

            endorsementDebitVM.paymentMode = "";
            endorsementDebitVM.phone       = organisation.PhoneNumber;
            endorsementDebitVM.policyName  = Util.GetPolicyName(policyMasters, leadEndorsement.PolicyClassId);
            if (string.IsNullOrEmpty(leadEndorsement.PolicyNo))
            {
                endorsementDebitVM.leadEndorsement.PolicyNo = "TBA";
            }

            endorsementDebitVM.riskType = "";

            endorsementDebitVM.branchName  = branch.BranchName;
            endorsementDebitVM.customerNo  = client.ClientCode.ToString();
            endorsementDebitVM.insurerName = Util.GetInsurerName(_context, insurerId);
            endorsementDebitVM.imageUrl    = Util.GetImageUrl(organisation.ImageUrl);
            endorsementDebitVM.Client      = client;

            var endorsementDebitNote = new EndorsementDebitNote();

            endorsementDebitVM.isNew = false;
            if (leadEndorsement.DebitNoteId == null || leadEndorsement.DebitNoteId == Guid.Empty)
            {
                endorsementDebitNote.PolicyNo          = leadEndorsement.PolicyNo;
                endorsementDebitNote.ID                = Guid.NewGuid();
                endorsementDebitNote.CreatedBy         = Guid.Parse(userId);
                endorsementDebitNote.ModifiedBy        = Guid.Parse(userId);
                endorsementDebitNote.LeadEndorsementId = leadEndorsement.Id;
                endorsementDebitNote.OrganisationId    = orgId;
                _context.Add(endorsementDebitNote);

                leadEndorsement.DebitNoteId = endorsementDebitNote.ID;

                _context.Update(leadEndorsement);
                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                }
                endorsementDebitVM.isNew = true;

                StatusMessage             = StaticContent.DEBITNOTE_GENERATE_SUCCESS_MSG;
                ViewData["StatusMessage"] = StatusMessage;
            }

            endorsementDebitVM.endorsementDebitNote = _context.EndorsementDebitNotes.Where(l => l.ID == leadEndorsement.DebitNoteId).OrderByDescending(a => a.DateCreated).SingleOrDefault();
            endorsementDebitVM.preparedBy           = _context.Users.Where(x => x.Id == endorsementDebitVM.endorsementDebitNote.CreatedBy.ToString()).FirstOrDefault().FirstName;


            return(PartialView("DebitNotePartial", endorsementDebitVM));
        }
Exemple #4
0
        public async Task <IActionResult> AddEndorsement(LeadEndorsementVM leadEndorsementVM, IFormCollection formCollection)
        {
            Guid ClientId = Guid.Parse(formCollection["policy.ClientId"].ToString());
            var  userId   = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var  pid      = formCollection["policy.Id"].ToString();
            var  policy   = _context.Policies.Where(p => p.Id == Guid.Parse(pid)).FirstOrDefault();
            var  lpolicy  = _context.LeadPolicies.Where(l => l.Id == policy.LeadId).FirstOrDefault();

            LeadEndorsement leadEndorsement = new LeadEndorsement();

            leadEndorsement.Id          = Guid.NewGuid();
            leadEndorsement.ClientId    = ClientId;
            leadEndorsement.Commission  = leadEndorsementVM.leadEndorsement.Commission;
            leadEndorsement.Description = leadEndorsementVM.leadEndorsement.Description;

            leadEndorsement.CreatedBy    = Guid.Parse(userId);
            leadEndorsement.DateCreated  = DateTime.Now;
            leadEndorsement.DateModified = DateTime.Now;
            leadEndorsement.DateUpdated  = DateTime.Now;
            leadEndorsement.EndDate      = Convert.ToDateTime(formCollection["EndDate"].ToString());
            leadEndorsement.GrossPremium = leadEndorsementVM.leadEndorsement.GrossPremium;
            leadEndorsement.IsDeleted    = false;

            leadEndorsement.ModifiedBy     = Guid.Parse(userId);
            leadEndorsement.NetPremium     = leadEndorsementVM.leadEndorsement.NetPremium;
            leadEndorsement.OrganisationId = Guid.Parse(formCollection["policy.OrganisationId"].ToString());
            leadEndorsement.PolicyClassId  = policy.PolicyClassId;

            leadEndorsement.StartDate = Convert.ToDateTime(formCollection["StartDate"].ToString());
            leadEndorsement.Status    = "New";

            leadEndorsement.InsurerMasterId = policy.InsurerMasterId;
            leadEndorsement.Currency        = policy.Currency;
            leadEndorsement.TranscationType = leadEndorsementVM.leadEndorsement.TranscationType;
            ///get Agents
            leadEndorsement.Agents   = Util.getAgents(formCollection);
            leadEndorsement.LeadId   = policy.LeadId;
            leadEndorsement.PolicyId = policy.Id;


            _context.Add(leadEndorsement);

            policy.LeadEndorsementId  = leadEndorsement.Id;
            lpolicy.LeadEndorsementId = leadEndorsement.Id;

            int cnt = Convert.ToInt32(policy.EndorsementCount);

            cnt++;
            policy.EndorsementCount = cnt;

            _context.Update(policy);
            _context.Update(lpolicy);
            await _context.SaveChangesAsync();


            StatusMessage             = StaticContent.LEAD_ENDORSEMENT_CREATE_MESSAGE;
            ViewData["StatusMessage"] = StatusMessage;

            var routeValues = new RouteValueDictionary {
                { "id", ClientId },
                { "IsOpen", "leads" }
            };

            return(RedirectToAction("Details", "Client", routeValues));
        }