Ejemplo n.º 1
0
        public double CalculateRetailTotalOfAllMaterials(lead lead)
        {
            double totalMaterialsCost = 0;

            if (lead.total_cost != null)
            {
                foreach (var item in lead.total_cost)
                {
                    if (item.product_cost != null)
                    {
                        totalMaterialsCost += (double)item.product_cost;
                    }
                }
            }

            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.total_construction_materials_cost != null)
                    {
                        totalMaterialsCost += (double)item.total_construction_materials_cost;
                    }
                }
            }

            return(totalMaterialsCost);
        }
Ejemplo n.º 2
0
        public double CalculateAvgMaterialCost(lead lead)
        {
            double avgMaterialCost = this.CalculateRetailTotalOfAllMaterials(lead);
            double avgCost         = avgMaterialCost * helper.GetApplicableRate(Constants.rate_Name_Avg_Material_Cost);

            return(avgCost);
        }
Ejemplo n.º 3
0
        public double CalculateOperationalAdminExpense(lead lead)
        {
            double operationalAdminExp = this.CalculateAvgMaterialCost(lead);
            double operationalAdExp    = operationalAdminExp * helper.GetApplicableRate(Constants.rate_Name_Operational_Admin);

            return(operationalAdExp);
        }
Ejemplo n.º 4
0
        public ActionResult savetask(FormCollection fo)
        {
            string msg = "The task was updated successfully at " + System.DateTime.Now;;

            int tin = int.Parse(fo["item.tasks_installation_number"]);

            GeneralHelper helper = new GeneralHelper();

            int  iid = db.tasks_installation.Where(c => c.tasks_installation_number == tin).First().installation_number;
            int  lid = db.installations.Where(g => g.installation_number == iid).First().lead_number;
            lead idk = db.leads.Where(b => b.lead_number == lid).First();

            try
            {
                tasks_installation target = db.tasks_installation.Where(f => f.tasks_installation_number == tin).First();
                target.hours                = double.Parse(fo["item.hours"]);
                target.m_cost               = double.Parse(fo["item.m_cost"]);
                target.labor_cost           = helper.GetInstallationLaborRate(idk) * target.hours;
                target.material_retail_cost = helper.GetInstallationMaterialRate(idk) * target.m_cost;
                db.SaveChanges(lid);
            }
            catch (Exception e)
            {
                msg = "Sonething went wrong " + e.Message;
            }



            return(RedirectToAction("lis", new { lid = lid, msg = msg }));
        }
Ejemplo n.º 5
0
        public double CalculateBuildingPermit(lead lead)
        {
            double buildingPermitCost = 0.00;

            if (lead.in_city && lead.delivery_status.delivery_status_name.Equals(Constants.deliver_Status_Installed))
            {
                if (lead.installations != null)
                {
                    foreach (var item in lead.installations)
                    {
                        if (item.installation_labor_only_cost != null)
                        {
                            buildingPermitCost += (double)item.installation_labor_only_cost;
                        }

                        if (item.total_construction_materials_cost != null)
                        {
                            buildingPermitCost += (double)item.total_construction_materials_cost;
                        }
                    }
                }

                buildingPermitCost += new TotalCostHelper().CalculateProductCost(lead);
                return(Math.Round(helper.GetBuildingPermitAmount(buildingPermitCost), 2));
            }

            return(buildingPermitCost);
        }
Ejemplo n.º 6
0
        public double CalculateOperationalExpForCreditCard(lead lead)
        {
            double expForCreditCard = this.CalculateContractTotalWithoutOperationCost(lead);
            double operationalExpCC = expForCreditCard * helper.GetApplicableRate(Constants.rate_Name_Operational_CreditCard);

            return(operationalExpCC);
        }
Ejemplo n.º 7
0
        public ProjectSummary GetProductCategoryList(lead lead, ProjectSummary projectSummary)
        {
            projectSummary.ProductMapList1 = this.GetProductMapList(Constants.catDefList1, lead);
            projectSummary.ProductMapList2 = this.GetProductMapList(Constants.catDefList2, lead);

            return(projectSummary);
        }
Ejemplo n.º 8
0
        public double CalculateContractTotalWithoutOperationCost(lead lead)
        {
            double contractTotal = 0;

            contractTotal += this.CalculateRetailTotalOfAllMaterials(lead);

            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.total_installation_labor_cost != null)
                    {
                        contractTotal += (double)item.total_installation_labor_cost;
                        if (item.total_operational_expenses != null)
                        {
                            contractTotal -= (double)item.total_operational_expenses;
                        }
                    }
                }
            }
            else
            {
                contractTotal += new InstallationCalculationHelper().CalculateBuildingPermit(lead);
            }

            return(contractTotal);
        }
Ejemplo n.º 9
0
        public double CalculateAvgProjectCost(lead lead)
        {
            double avgProjectCost = this.CalculateContractTotalWithoutOperationCost(lead);
            double avgCost        = avgProjectCost * helper.GetApplicableRate(Constants.rate_Name_Avg_Project_Cost);

            return(avgCost);
        }
Ejemplo n.º 10
0
        public ActionResult handler(FormCollection fo)
        {
            int                iid    = int.Parse(fo["installation_number"]);
            string             msg    = "The task was created successfully at " + System.DateTime.Now;;
            int                lid    = db.installations.Where(a => a.installation_number == iid).First().lead_number;
            lead               idk    = db.leads.Where(d => d.lead_number == lid).First();
            GeneralHelper      helper = new GeneralHelper();
            tasks_installation target = new tasks_installation();

            if (int.Parse(fo["mode"]) == 0)
            {
                target.hours                = double.Parse(fo["hours"]);
                target.task_number          = int.Parse(fo["task_number"]);
                target.m_cost               = double.Parse(fo["m_cost"]);
                target.labor_cost           = helper.GetInstallationLaborRate(idk) * target.hours;
                target.material_retail_cost = helper.GetInstallationMaterialRate(idk) * target.m_cost;
                target.installation_number  = iid;
                try
                {
                    db.tasks_installation.Add(target);
                    db.SaveChanges(lid);
                    //db.SaveChanges(lid, "create new");
                }
                catch (Exception e)
                {
                    msg = e.Message;
                }
            }
            else
            {
                task ctask = new task();
                ctask.special_task  = true;
                ctask.task_main_cat = "MISC";
                ctask.task_sub_cat  = "Disclaimers";
                ctask.task_name     = fo["task_name"];
                db.tasks.Add(ctask);


                target.task = ctask;

                target.hours                = double.Parse(fo["hours"]);
                target.m_cost               = double.Parse(fo["m_cost"]);
                target.labor_cost           = helper.GetInstallationLaborRate(idk) * target.hours;
                target.material_retail_cost = helper.GetInstallationMaterialRate(idk) * target.m_cost;
                db.tasks_installation.Add(target);
                target.installation_number = iid;
                try
                {
                    db.SaveChanges(lid);
                }
                catch (Exception e)
                {
                    msg = e.Message;
                }
            }


            return(RedirectToAction("lis", new { lid = lid, msg = msg }));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            lead lead = db.leads.Find(id);

            db.leads.Remove(lead);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 12
0
        //include operationalAdminexpense, operationalexpense for creditcard and operational cost for installation when there is installation job
        public double CalculateTotalOperationalExpense(lead lead)
        {
            if (lead.delivery_status.delivery_status_name.Equals(Constants.deliver_Status_Installed))
            {
                return(Math.Round(this.CalculateOperationalAdminExpense(lead) + this.CalculateOperationalExpForCreditCard(lead) + this.CalculateOperationalExpForInstallation(lead), 2));
            }

            return(0.00);
        }
Ejemplo n.º 13
0
 public TaxCalculationHelper(lead lead)
 {
     if (db.addresses.Where(a => a.deleted == false && a.lead_number == lead.lead_number && a.address_type.Equals(Constants.address_type_jobsite)).Any())
     {
         var address = db.addresses.Where(a => a.deleted == false && a.lead_number == lead.lead_number && a.address_type.Equals(Constants.address_type_jobsite)).First();
         jobsiteAddress = address;
     }
     currLead = lead;
 }
 public ActionResult Edit([Bind(Include = "leadId,code,firstname,lastname,organizationId,rating,email,phone")] lead lead)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lead).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.organizationIdList = new SelectList(db.organizations, "organizationId", "code", lead.organizationId);
     return(View(lead));
 }
Ejemplo n.º 15
0
        public double CalculateApplicableTax(lead lead)
        {
            TaxCalculationHelper taxHelper = new TaxCalculationHelper(lead);

            if (!lead.tax_exempt)
            {
                return(taxHelper.CalculateStateTax() + taxHelper.CalculateCountyTax() + taxHelper.CalculateMunicipalTax() + taxHelper.CalculateBOTax());
            }

            return(0);
        }
        // GET: /CRM/leads/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            lead lead = db.leads.Find(id);

            if (lead == null)
            {
                return(HttpNotFound());
            }
            return(View(lead));
        }
Ejemplo n.º 17
0
        public double CalculateProductCost(lead lead)
        {
            double totalProductCost = 0;

            if (lead.products != null)
            {
                foreach (var item in lead.products)
                {
                    totalProductCost += item.price * item.quantity;
                }
            }

            return(totalProductCost);
        }
        // GET: /CRM/leads/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            lead lead = db.leads.Find(id);

            if (lead == null)
            {
                return(HttpNotFound());
            }
            ViewBag.organizationIdList = new SelectList(db.organizations, "organizationId", "code", lead.organizationId);
            return(View(lead));
        }
Ejemplo n.º 19
0
        public ActionResult Add(FormCollection fo, int lid)
        {
            lead    mian   = db.leads.Where(a => a.lead_number == lid).FirstOrDefault();
            product target = new product();

            TryUpdateModel <product>(target, new string[] { "cat_anme", "quantity", "Description", "model", "color", "product_source", "manufacture", "location", "price" }, fo.ToValueProvider());
            //target.cat_anme = fo["Product Category"];
            if (ModelState.IsValid)
            {
                mian.products.Add(target);
                db.products.Add(target);
                db.SaveChanges(lid);
            }

            return(Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri));
        }
Ejemplo n.º 20
0
        public double GetInstallationMaterialRate(lead lead)
        {
            foreach (var item in lead.installations)
            {
                if (item.ov_material_rate == null)
                {
                    return(this.GetApplicableRate(Constants.rate_Name_Installed_Material));
                }
                else
                {
                    return((double)item.ov_material_rate);
                }
            }

            return(0);
        }
Ejemplo n.º 21
0
        public double GetInstallationLaborRate(lead lead)
        {
            foreach (var item in lead.installations)
            {
                if (item.ov_labor_rate == null)
                {
                    return(this.GetApplicableRate(Constants.rate_Name_Hourly_Lead_Installer) + this.GetApplicableRate(Constants.rate_Name_Hourly_Junior_Installer));
                }
                else
                {
                    return((double)item.ov_labor_rate);
                }
            }

            return(0);
        }
Ejemplo n.º 22
0
        // include labor cost, travel cost, mileage expense, hotel expense, building permit cost, operational cost and per diem cost
        public double CalculateTotalLaborExpense(lead lead)
        {
            double totalLaborCost = 0.00;

            if (lead.installations != null)
            {
                foreach (var item in lead.installations)
                {
                    if (item.installation_labor_only_cost != null)
                    {
                        totalLaborCost += (double)item.installation_labor_only_cost;
                    }

                    if (item.mileage_expense != null)
                    {
                        totalLaborCost += (double)item.total_travel_cost;
                    }

                    if (item.mileage_expense != null)
                    {
                        totalLaborCost += (double)item.mileage_expense;
                    }

                    if (item.hotel_expense != null)
                    {
                        totalLaborCost += (double)item.hotel_expense;
                    }

                    if (item.building_permit_cost != null)
                    {
                        totalLaborCost += (double)item.building_permit_cost;
                    }

                    if (item.total_operational_expenses != null)
                    {
                        totalLaborCost += (double)item.total_operational_expenses;
                    }

                    if (item.total_per_diem_cost != null)
                    {
                        totalLaborCost += (double)item.total_per_diem_cost;
                    }
                }
            }
            return(Math.Round(totalLaborCost, 2));
        }
Ejemplo n.º 23
0
        public double CalculateEstimatedHours(lead lead)
        {
            double hours = 0;

            foreach (var item in lead.installations)
            {
                if (item.tasks_installation != null)
                {
                    foreach (var task in item.tasks_installation)
                    {
                        hours += task.hours;
                    }
                }
            }

            return(hours);
        }
Ejemplo n.º 24
0
        public ProjectSummary SetCustomerData(lead lead, ProjectSummary projectSummary)
        {
            customer c = lead.customer;

            if (lead.project_status.project_status_name.Equals(Constants.proj_Status_Closed, StringComparison.OrdinalIgnoreCase))
            {
                var archived_lead = db.archive_leads.Where(a => a.lead_number == lead.lead_number).FirstOrDefault();
                if (archived_lead != null)
                {
                    c.customer_firstname = archived_lead.customer_firstname;
                    c.customer_lastname  = archived_lead.customer_lastname;
                    c.email = archived_lead.customer_email;
                }
            }
            projectSummary.Customer = c;

            return(projectSummary);
        }
Ejemplo n.º 25
0
        public ProjectSummary CalculateInstallationsData(lead lead, ProjectSummary projectSummary)
        {
            double operationExp = 0.0;
            InstallationCalculationHelper calHelper = new InstallationCalculationHelper();

            foreach (var item in lead.installations)
            {
                projectSummary.TwoWayMilesToJob           = Math.Round(calHelper.CalculateBothWayMilesToJob(item.oneway_mileages_to_destination), 2);
                projectSummary.TotalInstallationDays      = Math.Round(calHelper.CalculateTotalInstallationDays(item.installation_days, item.tile_installation_days), 2);
                projectSummary.PaidTravelTimeOneWay       = Math.Round(calHelper.CalculatePaidTravelTimeOneWay(item.travel_time_one_way), 2);
                projectSummary.TotalApplicableTravelHours = Math.Round(calHelper.CalculateTotalApplicableTravelHours(item.installation_days, item.travel_time_one_way, item.recommendation), 2);
                operationExp = item.total_operational_expenses != null ? (double)item.total_operational_expenses : 0;
            }

            projectSummary.OperationalExp = operationExp == 0 ? new FeeCalculationHelper().CalculateTotalOperationalExpense(lead) : operationExp;

            return(projectSummary);
        }
 public ActionResult Delete(int id)
 {
     try
     {
         List <lead> Lead_list = db.leads.Where(d => d.lead_number == id).ToList();
         ViewBag.Customerslist = Lead_list;
         lead target = Lead_list[0];
         target.deleted = true;
         db.SaveChanges(id, "delete");
         ViewBag.m = "The lead was successfully deleted.";
         return(RedirectToAction("ListLead", new { search = "", msg = ViewBag.m }));
     }
     catch (Exception e)
     {
         ViewBag.m = "The lead was not deleted ... " + e.Message;
         return(RedirectToAction("ListLead", new { search = "", msg = ViewBag.m }));
     }
 }
Ejemplo n.º 27
0
        public double CalculateOperationalExpForInstallation(lead lead)
        {
            double expForInstallation = this.CalculateAvgInstallLaborCost(lead);

            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.total_travel_cost != null)
                    {
                        expForInstallation += (double)item.total_travel_cost;
                    }

                    if (item.hotel_expense != null)
                    {
                        expForInstallation += (double)item.hotel_expense;
                    }

                    if (item.mileage_expense != null)
                    {
                        expForInstallation += (double)item.mileage_expense;
                    }

                    if (item.total_per_diem_cost != null)
                    {
                        expForInstallation += (double)item.total_per_diem_cost;
                    }

                    if (item.building_permit_cost != null)
                    {
                        expForInstallation += (double)item.building_permit_cost;
                    }
                }
            }
            else
            {
                expForInstallation += new InstallationCalculationHelper().CalculateBuildingPermit(lead);
            }

            double operationalExpenseForInstall = expForInstallation * helper.GetApplicableRate(Constants.rate_Name_Operational_Installation);

            return(operationalExpenseForInstall);
        }
Ejemplo n.º 28
0
        public ProjectSummary SetAddresses(lead lead, ProjectSummary projectSummary)
        {
            if (db.addresses.Where(a => a.deleted == false && a.lead_number == lead.lead_number).Any())
            {
                var addressList = db.addresses.Where(a => a.deleted == false && a.lead_number == lead.lead_number).ToList();
                foreach (var address in addressList)
                {
                    if (address.address_type.Equals(Constants.address_type_jobsite))
                    {
                        projectSummary.JobsiteAddress = address;
                    }
                    else
                    {
                        projectSummary.AlternativeAddress = address;
                    }
                }
            }

            return(projectSummary);
        }
Ejemplo n.º 29
0
        public lead CalculateLaborAndMaterialsCostForAllTasks(lead lead)
        {
            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.tasks_installation.Count != 0)
                    {
                        double laborRate    = helper.GetInstallationLaborRate(lead);
                        double materialRate = helper.GetInstallationMaterialRate(lead);
                        foreach (var tasks in item.tasks_installation)
                        {
                            tasks.labor_cost           = tasks.hours * laborRate;
                            tasks.material_retail_cost = tasks.m_cost * materialRate;
                        }
                    }
                }
            }

            return(lead);
        }
Ejemplo n.º 30
0
        public double CalculateAvgInstallLaborCost(lead lead)
        {
            double avgInstallLaborCost = 0.00;

            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.installation_labor_only_cost != null)
                    {
                        avgInstallLaborCost += (double)item.installation_labor_only_cost;
                    }
                }
            }

            if (avgInstallLaborCost != 0)
            {
                return(avgInstallLaborCost * helper.GetApplicableRate(Constants.rate_Name_Avg_Install_Cost));
            }

            return(avgInstallLaborCost);
        }