Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public lead SetAllInstallationCosts(lead lead)
        {
            InstallationCalculationHelper installHelper = new InstallationCalculationHelper();

            if (lead.installations != null)
            {
                foreach (var item in lead.installations)
                {
                    item.recommendation                    = installHelper.GetRecommendation(item.oneway_mileages_to_destination);
                    item.estimated_hours                   = installHelper.CalculateEstimatedHours(lead);
                    item.billable_hours                    = installHelper.CalculateBillableHours((double)item.estimated_hours);
                    item.installation_days                 = installHelper.CalculateInstallationDays((double)item.billable_hours);
                    item.tile_installation_days            = Math.Round(installHelper.CalculateTileInstallationDays(item.total_tile_cost));
                    item.required_hotel_nights             = installHelper.CalculateNumberOfHotelNights((double)item.installation_days, item.recommendation);
                    item.travel_time_one_way               = installHelper.CalculateTravelTimeOneWay(item.oneway_mileages_to_destination);
                    item.hotel_round_trip                  = Math.Round(installHelper.CalculateHotelRoundTrip((double)item.installation_days));
                    item.total_per_diem_cost               = Math.Round(installHelper.CalculatePerDiem((double)item.installation_days, item.recommendation), 2);
                    item.total_miles                       = installHelper.CalculateTotalMiles((double)item.installation_days, item.recommendation, item.oneway_mileages_to_destination);
                    item.installation_labor_only_cost      = installHelper.CalculateLaborOnlyExpense((double)item.billable_hours, this.GetInstallationLaborRate(item.ov_labor_rate));
                    item.mileage_expense                   = installHelper.CalculateMileageExpense((double)item.total_miles, item.recommendation);
                    item.total_travel_cost                 = installHelper.CalculateTravelExpense((double)item.installation_days, (double)item.travel_time_one_way, item.recommendation);
                    item.hotel_expense                     = installHelper.CalculateHotelExpense((double)item.required_hotel_nights, item.recommendation);
                    item.total_construction_materials_cost = installHelper.CalculateMaterialRetailPrice(lead);
                    item.building_permit_cost              = installHelper.CalculateBuildingPermit(lead);
                    item.total_operational_expenses        = new FeeCalculationHelper().CalculateTotalOperationalExpense(lead);
                    item.total_installation_labor_cost     = installHelper.CalculateTotalLaborExpense(lead);

                    // round the data before saving in the DB
                    item.estimated_hours       = Math.Round((double)item.estimated_hours, 2);
                    item.billable_hours        = Math.Round((double)item.billable_hours, 2);
                    item.installation_days     = Math.Round((double)item.installation_days);
                    item.required_hotel_nights = Math.Round((double)item.required_hotel_nights);
                    item.travel_time_one_way   = Math.Round((double)item.travel_time_one_way, 2);
                    item.total_miles           = Math.Round((double)item.total_miles);
                }
            }
            return(lead);
        }
Esempio n. 5
0
        public double CalculateInstallationCost(lead lead)
        {
            double totalInstallCost = 0;

            if (lead.installations.Count != 0)
            {
                foreach (var item in lead.installations)
                {
                    if (item.total_installation_labor_cost != null)
                    {
                        totalInstallCost += (double)item.total_installation_labor_cost;
                    }
                }
            }
            else
            {
                // this is when there is no installation data
                double buildingPermit = new InstallationCalculationHelper().CalculateBuildingPermit(lead);
                double operationalExp = new FeeCalculationHelper().CalculateTotalOperationalExpense(lead);
                totalInstallCost = buildingPermit + operationalExp;
            }

            return(totalInstallCost);
        }
Esempio n. 6
0
        public void SaveProjectTotal(int leadNbr)
        {
            var lead = db.leads.Where(l => l.lead_number == leadNbr).First();

            if ((lead.products != null && lead.products.Count != 0) || (lead.installations != null && lead.installations.Count != 0))
            {
                // set calculated installation data
                lead = this.SetAllInstallationCosts(lead);

                //set totalcost data
                TotalCostHelper cHelper = new TotalCostHelper();
                InstallationCalculationHelper installHelper = new InstallationCalculationHelper();
                double buildingPermit   = 0;
                double installationCost = 0;
                double materialCost     = 0;
                foreach (var item in lead.installations)
                {
                    buildingPermit   = (double)item.building_permit_cost;
                    installationCost = (double)item.total_installation_labor_cost;
                    materialCost     = (double)item.total_construction_materials_cost;
                }

                if (lead.total_cost.Count == 0)
                {
                    total_cost total = new total_cost
                    {
                        lead_number          = (int)lead.lead_number,
                        product_cost         = cHelper.CalculateProductCost(lead),
                        building_permit_cost = buildingPermit,
                        tax_cost             = cHelper.CalculateApplicableTax(lead)
                    };

                    // this is when there is no installation data
                    if (installationCost == 0)
                    {
                        buildingPermit   = installHelper.CalculateBuildingPermit(lead);
                        installationCost = cHelper.CalculateInstallationCost(lead);
                    }

                    total.total_cost1 = total.product_cost + materialCost + total.installation_cost + total.tax_cost;
                    List <total_cost> costList = new List <total_cost>
                    {
                        total
                    };

                    lead.total_cost = costList;
                }
                else
                {
                    foreach (var item2 in lead.total_cost)
                    {
                        item2.product_cost         = cHelper.CalculateProductCost(lead);
                        item2.installation_cost    = cHelper.CalculateInstallationCost(lead);
                        item2.building_permit_cost = installHelper.CalculateBuildingPermit(lead);
                        item2.tax_cost             = cHelper.CalculateApplicableTax(lead);
                        item2.total_cost1          = item2.product_cost + materialCost + item2.installation_cost + item2.tax_cost;
                    }
                }

                db.SaveChanges();
            }
        }