Exemplo n.º 1
0
        private void processClaimServices(int claimID, CarrierInvoiceProfile invoiceProfile, int invoiceID)
        {
            CarrierInvoiceProfileFeeItemized profileTEFee = null;
            List<ClaimService> claimServices = null;
            decimal lineTotal = 0;
            decimal quantity = 0;
            decimal rateAmount = 0;
            string serviceDescription = null;
            string serviceComments = null;
            string activity = null;
            string activityDescription = null;
            bool isBillable = true;
            bool billed = true;
            InvoiceServiceType invoiceServiceType = null;

            // get TE services for claim entered by adjuster
            using (ClaimServiceManager repositiory = new ClaimServiceManager())
            {
                claimServices = repositiory.GetAllForInvoice(claimID);
            }

            if (claimServices != null && claimServices.Count > 0)
            {

                foreach (ClaimService claimService in claimServices)
                {

                    profileTEFee = (from x in invoiceProfile.CarrierInvoiceProfileFeeItemized
                                 where x.ServiceTypeID == claimService.ServiceTypeID
                                 select x
                                 ).FirstOrDefault();
                    int claimServiceID = claimService.ClaimServiceID;
                    quantity = (claimService.ServiceQty ?? 0);
                    serviceDescription = claimService.InvoiceServiceType == null ? string.Empty : claimService.InvoiceServiceType.ServiceDescription;
                    invoiceServiceType = claimService.InvoiceServiceType;
                    activity = claimService.Activity == null ? string.Empty : claimService.Activity;
                    activityDescription = claimService.ServiceDescription;
                    isBillable = claimService.IsBillable.Value;
                    billed = claimService.Billed.Value;
                    if (profileTEFee != null)
                    {
                        // use override from invoice profile
                        if (profileTEFee.ItemRate > 0)
                        {
                            serviceComments = profileTEFee.ItemDescription;
                            rateAmount = profileTEFee.ItemRate;

                            lineTotal = rateAmount * quantity;
                            if (isBillable == true)
                            {
                                insertDetailLine(invoiceID, serviceDescription, activity, activityDescription, lineTotal, quantity, rateAmount, claimService.ServiceDate, serviceComments);
                                using (ClaimServiceManager myRepository = new ClaimServiceManager())
                                {
                                    ClaimService myClaimService = myRepository.Get(claimServiceID);
                                    myClaimService.Billed = true;
                                    myRepository.Save(myClaimService);
                                }

                            }
                        }
                        else if (profileTEFee.ItemPercentage > 0)
                        {
                        }
                    }
                    else
                    {
                        if ((invoiceServiceType.ServiceRate ?? 0) > 0)
                        {
                            rateAmount = invoiceServiceType.ServiceRate ?? 0;
                            quantity = claimService.ServiceQty ?? 0;
                            lineTotal = rateAmount * quantity;
                        }
                        else if ((invoiceServiceType.ServicePercentage ?? 0) > 0)
                        {
                        }
                        if (isBillable == true )
                        {
                            insertDetailLine(invoiceID, serviceDescription, activity, activityDescription, lineTotal, quantity, rateAmount, claimService.ServiceDate, serviceComments);
                            using (ClaimServiceManager myRepository = new ClaimServiceManager())
                            {
                                ClaimService myClaimService = myRepository.Get(claimServiceID);
                                myClaimService.Billed = true;
                                myRepository.Save(myClaimService);
                            }
                        }

                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSaveClaimService_Click(object sender, EventArgs e)
        {
            ClaimService claimService = null;
            ClaimComment diary = null;
            AdjusterMaster adjuster = null;
            Claim myClaim = null;
            CarrierInvoiceProfile CarrierInvoice = null;

            int userID = SessionHelper.getUserId();
            int claimID = SessionHelper.getClaimID();
            int id = 0;
            int myAdjusterID = 0;
            int profileID = 0;

            Page.Validate("service");
            if (!Page.IsValid)
                return;

            id = Convert.ToInt32(ViewState["ClaimServiceID"]);

            //Get current claim info to pass through to emails
            ClaimManager cm = new ClaimManager();
            myClaim =  cm.Get(claimID);

            //AdjusterManager

            try {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimServiceManager repository = new ClaimServiceManager())
                    {
                        if (id == 0)
                        {
                            claimService = new ClaimService();
                            claimService.ClaimID = claimID;
                        }
                        else
                        {
                            claimService = repository.Get(id);
                        }

                        claimService.ServiceQty = this.txtServiceQty.Value == null ? 0 : Convert.ToDecimal(txtServiceQty.Value);
                        claimService.ServiceDate = txtServiceDate.Date;
                        claimService.ServiceDescription = txtServiceDescription.Text.Trim();
                        claimService.ServiceTypeID = Convert.ToInt32(this.ddlInvoiceServiceType.SelectedValue);
                        claimService.UserID = userID;
                        claimService.AdjusterID = Convert.ToInt32(hf_serviceAdjusterID.Value);
                        claimService.Activity = ddlActivity.SelectedItem.Text;
                        claimService.InternalComments = txtMyComments.Text.Trim();
                        claimService.IsBillable = cbIsBillable.Checked;
                        claimService.Billed = false;
                        //save to db
                        claimService = repository.Save(claimService);

                        //string EmailService = ddlInvoiceServiceType.SelectedItem.Text;
                        //string EmailActivity = ddlActivity.SelectedItem.Text;
                        //string EmailDescription = txtServiceDescription.Text;
                        //string EmailInternal = txtMyComments.Text;
                        //string EmailQuantity = txtServiceQty.Text;
                        //string EmailDate = txtServiceDate.Text;

                    }

                    // diary
                    diary = new ClaimComment();
                    diary.ClaimID = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId = userID;
                    diary.ActivityType = ddlActivity.SelectedItem.Text;
                    diary.InternalComments = txtMyComments.Text.Trim();
                    diary.CommentText = string.Format("Service: {0}, Description: {1}, Date {2:MM/dd/yyyy}, Qty: {3:N2}, Adjuster: {4}",
                                                ddlInvoiceServiceType.SelectedItem.Text,
                                                claimService.ServiceDescription,
                                                claimService.ServiceDate,
                                                claimService.ServiceQty,
                                                txtServiceAdjuster.Text
                                                );
                    ClaimCommentManager.Save(diary);

                    myAdjusterID = Convert.ToInt32(claimService.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID);

                    //EMAIL ADJUSTER OC 10/21/2014
                    if (myAdjusterID != 0 || myAdjusterID != null)
                    {
                        adjuster = AdjusterManager.GetAdjusterId(myAdjusterID);
                    }
                    if (cbEmailAdjuster.Checked == true)
                    {
                        try
                        {
                            notifyAdjuster(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL CLIENT CONTACT OC 10/22/2014
                    if (cbEmailClient.Checked == true) //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already
                    {
                        if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen
                        {
                            profileID = Convert.ToInt32(Session["CarrierInvoiceID"]);
                        }
                        else//coming from claim detail page
                        {
                            profileID = Convert.ToInt32(Session["InvoiceProfileID"]);
                        }
                        CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID);
                        try
                        {
                            notifyClientContact(CarrierInvoice, claimService, myClaim, adjuster);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to client contact";
                            lblMessage.CssClass = "error";
                        }

                    }
                    //EMAIL TO WHOMEVER
                    if(txtEmailTo.Text != "")
                    {

                        try
                        {
                            notifySpecifiedUser(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }

                    scope.Complete();

                }

                lblMessage.Text = "Service was saved successfully.";
                lblMessage.CssClass = "ok";

                // keep edit form active
                lbtnNewClaimService_Click(null, null);

                // refresh grid
                gvClaimService.DataSource = loadClaimServices(claimID);
                gvClaimService.DataBind();

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);

                lblMessage.Text = "Unable to save claim service.";
                lblMessage.CssClass = "error";
            }
            //send email to adjuster
        }
        private void bindTimeExpenseForInvoice(int claimID)
        {
            List<InvoiceDetail> invoiceDetails = new List<InvoiceDetail>();
            InvoiceDetail invoiceDetail = null;
            decimal serviceRate = 0;
            decimal servicePercentage = 0;
            decimal rate = 0;

            List<ClaimService> claimServices = null;
            List<ClaimExpense> claimExpenses = null;

            using (ClaimServiceManager repository = new ClaimServiceManager()) {
                claimServices = repository.GetAll(claimID);
            }
            using (ClaimExpenseManager repository = new ClaimExpenseManager()) {
                claimExpenses = repository.GetAll(claimID);
            }

            // add claim services to invoice
            if (claimServices != null) {
                foreach (ClaimService service in claimServices) {
                    invoiceDetail = new InvoiceDetail();
                    invoiceDetail.LineDate = service.ServiceDate;
                    invoiceDetail.ServiceTypeID = service.ServiceTypeID;
                    invoiceDetail.LineDescription = service.InvoiceServiceType.ServiceDescription;
                    invoiceDetail.Qty = service.ServiceQty;
                    invoiceDetail.Comments = service.ServiceDescription;

                    serviceRate = service.InvoiceServiceType.ServiceRate ?? 0;
                    servicePercentage = service.InvoiceServiceType.ServicePercentage ?? 0;

                    if (serviceRate > 0) {
                        rate = serviceRate;
                    }
                    else {
                        rate = servicePercentage / 100;
                    }

                    invoiceDetail.LineAmount = invoiceDetail.Qty * rate;
                    invoiceDetail.Rate = rate;

                    // add service to invoicedetail list
                    invoiceDetails.Add(invoiceDetail);
                }
            }
            // add claim expenses to invoice
            if (claimExpenses != null) {
                foreach (ClaimExpense expense in claimExpenses) {

                    invoiceDetail = new InvoiceDetail();
                    invoiceDetail.ExpenseTypeID = expense.ExpenseTypeID;
                    invoiceDetail.LineDate = expense.ExpenseDate;
                    invoiceDetail.LineDescription = expense.ExpenseDescription;
                    invoiceDetail.Comments = expense.ExpenseDescription;
                    invoiceDetail.LineAmount = expense.ExpenseAmount;
                    invoiceDetail.Qty = 1;
                    invoiceDetail.Rate = expense.ExpenseAmount;
                    // add expense to invoicedetail list
                    invoiceDetails.Add(invoiceDetail);

                }
            }

            // bind invoice detail lines
            gvTimeExpense.DataSource = invoiceDetails;
            gvTimeExpense.DataBind();
        }
Exemplo n.º 4
0
        protected void gvClaimService_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int id = 0;
            ClaimService claimService = null;

            if (e.CommandName == "DoEdit") {
                id = Convert.ToInt32(e.CommandArgument);

                using (ClaimServiceManager repository = new ClaimServiceManager()) {
                    claimService = repository.Get(id);

                    if (claimService != null) {
                        bindServiceTypes();

                        if (claimService.AdjusterMaster != null) {
                            txtServiceAdjuster.Text = claimService.AdjusterMaster.adjusterName;
                            hf_serviceAdjusterID.Value = claimService.AdjusterID.ToString();
                        }

                        txtServiceDate.Value = claimService.ServiceDate;
                        txtServiceDescription.Text = claimService.ServiceDescription;
                        txtServiceQty.Value = claimService.ServiceQty;
                        txtMyComments.Text = claimService.InternalComments;
                        cbIsBillable.Checked = claimService.IsBillable.Value;

                        try
                        {
                            Activity myActivity = ActivityManager.GetByAcctivity(claimService.Activity);
                            ddlActivity.SelectedValue =  myActivity.ActivityID.ToString();
                            RequiredFieldValidator4.Enabled = false;

                        }
                        catch (Exception ex)
                        {
                            ddlActivity.SelectedIndex = 0;
                            RequiredFieldValidator4.Enabled = true;
                            Core.EmailHelper.emailError(ex);
                        }
                        try
                        {
                            ddlInvoiceServiceType.SelectedValue = claimService.ServiceTypeID.ToString();

                        }
                        catch (Exception ex) {
                            ddlInvoiceServiceType.SelectedIndex = -1;
                            Core.EmailHelper.emailError(ex);
                        }

                        ViewState["ClaimServiceID"] = claimService.ClaimServiceID.ToString();

                        showServiceEditPanel();
                    }
                }
            }
            else if (e.CommandName == "DoDelete") {
                id = Convert.ToInt32(e.CommandArgument);
                lblMessage.Text = string.Empty;

                using (ClaimServiceManager repository = new Repository.ClaimServiceManager()) {
                    try {
                        claimService = repository.Get(id);
                        if (claimService != null) {
                            repository.Delete(id);

                            bindData(SessionHelper.getClaimID());
                        }
                    }
                    catch (Exception ex) {
                        lblMessage.Text = "Unable to delete service.";
                        lblMessage.CssClass = "error";

                        Core.EmailHelper.emailError(ex);
                    }

                }
            }
        }
        public static string SaveNotes(int claimID, string serviceQty, string serviceDate, string descp, string invoiceServiceType, int invoiceServiceTypeId, string serviceAdjuster, string serviceAdjustId, int leadID, string emailTo)
        {
            string json = "";
            ClaimService claimService = null;
            ClaimComment diary = null;
            Leads objLeads = null;
            Claim objClaim = null;
            int userID = SessionHelper.getUserId();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimServiceManager repository = new ClaimServiceManager())
                    {
                        claimService = new ClaimService();
                        claimService.ClaimID = claimID;

                        claimService.ServiceQty = serviceQty == null ? 0 : Convert.ToDecimal(serviceQty);
                        claimService.ServiceDate = Convert.ToDateTime(serviceDate);
                        claimService.ServiceDescription = descp.Trim();
                        claimService.ServiceTypeID = Convert.ToInt32(invoiceServiceTypeId);
                        claimService.UserID = userID;
                        claimService.AdjusterID = Convert.ToInt32(serviceAdjustId);

                        claimService = repository.Save(claimService);
                    }

                    // diary
                    diary = new ClaimComment();
                    diary.ClaimID = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId = userID;
                    diary.ActivityType = "Service: " + invoiceServiceType;
                    diary.CommentText = string.Format("Description: {0}, Date {1:MM/dd/yyyy h:mm}, Qty: {2:N2}, Adjuster: {3}",
                                                claimService.ServiceDescription,
                                                claimService.ServiceDate,
                                                claimService.ServiceQty,
                                                serviceAdjuster
                                                );
                    ClaimCommentManager.Save(diary);

                    scope.Complete();
                    //  SendNoteEmail();
                }
                objLeads = LeadsManager.GetByLeadId(leadID);
                ClaimManager objClaimManager = new ClaimManager();
                objClaim = objClaimManager.Get(claimID);
                string insuerFileId = objClaim.InsurerClaimNumber;
                string insurerName = objLeads.InsuredName;
                string claimNumber = objClaim.AdjusterClaimNumber;
                string userName = SessionHelper.getUserName();
                SendNoteEmail(insuerFileId, insurerName, claimNumber, serviceAdjuster, descp.Trim(), userName, emailTo, serviceDate, serviceQty);

                json = "Service save successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }