Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void updateKpis(TreeNode treeTable, Map<String, ScenarioRow> tableElements){
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().startsWith(CategoryEnum.UNITS.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1 &&
- (entry.getKey().endsWith(CategoryEnum.EMEA_ROADMAP.getCodice()) || entry.getKey().endsWith(CategoryEnum.EMEA_CORRECTION.getCodice()))) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- Double unitsScenarioPw = tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double unitsScenarioPwAdj = tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecastTotalAdjustments() != null
- && tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecastTotalAdjustments().getAmount() != null ?
- tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix).getPreviousWeekForecastTotalAdjustments().getAmount() : 0;
- Integer count = 0;
- if (codeSuffix.contains(CategoryEnum.EMEA_ROADMAP.getCodice()) || codeSuffix.contains(CategoryEnum.EMEA_CORRECTION.getCodice())) {
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getKpi().equals(CategoryEnum.CAS.getCodice())) {
- updateCasPreviousWeekForecastValue(child, CategoryEnum.CAS.getCodice(), codeSuffix, count, unitsScenarioPw);
- updateCasPreviousWeekForecastTotalAdjValue(child, CategoryEnum.CAS.getCodice(), codeSuffix, count, unitsScenarioPwAdj);
- }
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().startsWith(CategoryEnum.NBMC_P.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- Double netRevenueScenarioMx = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getMx() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double nbmcScenarioMx = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getMx() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double netRevenueScenarioCw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double nbmcScenarioCw = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double netRevenueScenarioCampaign = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double nbmcScenarioCampaign = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double netRevenueScenarioBudget = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getBudget() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double nbmcScenarioBudget = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getBudget() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double netRevenueScenarioPw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcScenarioPw = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcPercScenarioMx = netRevenueScenarioMx != 0 ? (nbmcScenarioMx / netRevenueScenarioMx) * 100 : 0;
- Double nbmcPercScenarioCw = netRevenueScenarioCw != 0 ? (nbmcScenarioCw / netRevenueScenarioCw) * 100 : 0;
- Double nbmcPercScenarioCampaign = netRevenueScenarioCampaign != 0 ? (nbmcScenarioCampaign / netRevenueScenarioCampaign) * 100 : 0;
- Double nbmcPercScenarioBudget = netRevenueScenarioBudget != 0 ? (nbmcScenarioBudget / netRevenueScenarioBudget) * 100 : 0;
- Double nbmcPercScenarioPw = netRevenueScenarioPw != 0 ? (nbmcScenarioPw / netRevenueScenarioPw) * 100 : 0;
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateMxValue(child, CategoryEnum.NBMC_P.getCodice(), codeSuffix, count, nbmcPercScenarioMx);
- updateBudgetValue(child, CategoryEnum.NBMC_P.getCodice(), codeSuffix, count, nbmcPercScenarioBudget);
- updateCampaignValue(child, CategoryEnum.NBMC_P.getCodice(), codeSuffix, count, nbmcPercScenarioCampaign);
- updateCurrentWeekForecastValue(child, CategoryEnum.NBMC_P.getCodice(), codeSuffix, count, nbmcPercScenarioCw);
- updatePreviousWeekForecastValue(child, CategoryEnum.NBMC_P.getCodice(), codeSuffix, count, nbmcPercScenarioPw);
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.NBMC_P.getCodice())) {
- Double netRevenueScenarioMx = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() : 0;
- Double nbmcScenarioMx = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx().getAmount() : 0;
- Double netRevenueScenarioCw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double nbmcScenarioCw = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double netRevenueScenarioCampaign = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() : 0;
- Double nbmcScenarioCampaign = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan().getAmount() : 0;
- Double netRevenueScenarioBudget = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() : 0;
- Double nbmcScenarioBudget = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget().getAmount() : 0;
- Double netRevenueScenarioPw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcScenarioPw = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcPercScenarioMx = netRevenueScenarioMx != 0 ? (nbmcScenarioMx / netRevenueScenarioMx) * 100 : 0;
- Double nbmcPercScenarioCw = netRevenueScenarioCw != 0 ? (nbmcScenarioCw / netRevenueScenarioCw) * 100 : 0;
- Double nbmcPercScenarioCampaign = netRevenueScenarioCampaign != 0 ? (nbmcScenarioCampaign / netRevenueScenarioCampaign) * 100 : 0;
- Double nbmcPercScenarioBudget = netRevenueScenarioBudget != 0 ? (nbmcScenarioBudget / netRevenueScenarioBudget) * 100 : 0;
- Double nbmcPercScenarioPw = netRevenueScenarioPw != 0 ? (nbmcScenarioPw / netRevenueScenarioPw) * 100 : 0;
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.NBMC_P.getCodice())) {
- ScenarioRow scenarioUpdate = (ScenarioRow) child.getData();
- Double oldValueCw = scenarioUpdate.getCurrentWeekForecast() != null
- && scenarioUpdate.getCurrentWeekForecast().getAmount() != null ?
- scenarioUpdate.getCurrentWeekForecast().getAmount() : 0;
- scenarioUpdate.getCurrentWeekForecast().setAmount(nbmcPercScenarioCw);
- Double oldValueMx = scenarioUpdate.getMx() != null
- && scenarioUpdate.getMx().getAmount() != null ?
- scenarioUpdate.getMx().getAmount() : 0;
- scenarioUpdate.getMx().setAmount(nbmcPercScenarioMx);
- Double oldValueBudget = scenarioUpdate.getBudget() != null
- && scenarioUpdate.getBudget().getAmount() != null ?
- scenarioUpdate.getBudget().getAmount() : 0;
- scenarioUpdate.getBudget().setAmount(nbmcPercScenarioBudget);
- Double oldValueCampaign = scenarioUpdate.getCampaignPlan() != null
- && scenarioUpdate.getCampaignPlan().getAmount() != null ?
- scenarioUpdate.getCampaignPlan().getAmount() : 0;
- scenarioUpdate.getCampaignPlan().setAmount(nbmcPercScenarioCampaign);
- Double oldValuePw = scenarioUpdate.getPreviousWeekForecast() != null
- && scenarioUpdate.getPreviousWeekForecast().getAmount() != null ?
- scenarioUpdate.getPreviousWeekForecast().getAmount() : 0;
- scenarioUpdate.getPreviousWeekForecast().setAmount(nbmcPercScenarioPw);
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.BMC_MARGIN_P.getCodice())) {
- ScenarioRow scenarioBmc = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice());
- ScenarioRow scenarionetRevenue = tableElements.get(CategoryEnum.NET_REVENUE.getCodice());
- ScenarioRow scenarioUpdate = new ScenarioRow();
- scenarioUpdate.setCategoryCode(CategoryEnum.BMC_MARGIN_P.getCodice());
- if (scenarioBmc != null && scenarionetRevenue != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioBmc, scenarionetRevenue);
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.BMC_MARGIN_P.getCodice())) {
- ScenarioRow selectedScenario = (ScenarioRow) child.getData();
- ScenarioRow oldScenario = selectedScenario;
- child = Utils.updateNodeValues(child, scenarioUpdate, oldScenario);
- }
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.AUR.getCodice())) {
- ScenarioRow scenarioCas = tableElements.get(CategoryEnum.UNITS.getCodice());
- ScenarioRow scenarioNetRevenue = tableElements.get(CategoryEnum.NET_REVENUE.getCodice());
- ScenarioRow scenarioUpdate = new ScenarioRow();
- if (scenarioCas != null && scenarioNetRevenue != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioNetRevenue, scenarioCas);
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.AUR.getCodice())) {
- ScenarioRow selectedScenario = (ScenarioRow) child.getData();
- ScenarioRow oldScenario = selectedScenario;
- child = Utils.updateNodeValues(child, scenarioUpdate, oldScenario);
- }
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.AUC.getCodice())) {
- ScenarioRow scenarioBmc = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice());
- ScenarioRow scenarioNetRevenue = tableElements.get(CategoryEnum.NET_REVENUE.getCodice());
- ScenarioRow scenarioDifference = new ScenarioRow();
- scenarioDifference = Utils.differenceScenarioRow(scenarioDifference, scenarioNetRevenue, scenarioBmc);
- ScenarioRow scenarioCas = tableElements.get(CategoryEnum.UNITS.getCodice());
- ScenarioRow scenarioUpdate = new ScenarioRow();
- if (scenarioCas != null && scenarioBmc != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioDifference, scenarioCas);
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.AUC.getCodice())) {
- ScenarioRow selectedScenario = (ScenarioRow) child.getData();
- ScenarioRow oldScenario = selectedScenario;
- child = Utils.updateNodeValues(child, scenarioUpdate, oldScenario);
- }
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().startsWith(CategoryEnum.BMC_MARGIN_P.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- ScenarioRow scenarioBmc = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarionetRevenue = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarioUpdate = new ScenarioRow();
- scenarioUpdate.setCategoryCode(CategoryEnum.BMC_MARGIN_P.getCodice() + "_" + codeSuffix);
- if (scenarioBmc != null && scenarionetRevenue != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioBmc, scenarionetRevenue);
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateScenarioRow(child, CategoryEnum.BMC_MARGIN_P.getCodice(), codeSuffix, count, scenarioUpdate);
- }
- }
- }
- if (entry.getKey().startsWith(CategoryEnum.AUR.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- ScenarioRow scenarioCas = tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarioNetRevenue = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarioUpdate = new ScenarioRow();
- if (scenarioCas != null && scenarioNetRevenue != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioNetRevenue, scenarioCas);
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateScenarioRow(child, CategoryEnum.AUR.getCodice(), codeSuffix, count, scenarioUpdate);
- }
- }
- }
- if (entry.getKey().startsWith(CategoryEnum.AUC.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- ScenarioRow scenarioBmc = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarioCas = tableElements.get(CategoryEnum.UNITS.getCodice() + "_" + codeSuffix);
- ScenarioRow scenarioUpdate = new ScenarioRow(new CurrentWeek());
- if (scenarioCas != null && scenarioBmc != null) {
- scenarioUpdate = Utils.updateScenarioRow(scenarioUpdate, scenarioBmc, scenarioCas);
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateScenarioRow(child, CategoryEnum.AUC.getCodice(), codeSuffix, count, scenarioUpdate);
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().startsWith(CategoryEnum.PTI_K.getCodice()) && entry.getKey().indexOf("_") > 0) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- Double bmcMarginScenario = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double nbmcScenario = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double controllExpScenario = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double allocExpScenario = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double bmcMarginScenarioBudget = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getBudget() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double nbmcScenarioBudget = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getBudget() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double controllExpScenarioBudget = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getBudget() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double allocExpScenarioBudget = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getBudget() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getBudget().getAmount() : 0;
- Double bmcMarginScenarioMx = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getMx() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double nbmcScenarioMx = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getMx() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double controllExpScenarioMx = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getMx() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double allocExpScenarioMx = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getMx() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getMx().getAmount() : 0;
- Double bmcMarginScenarioCampaign = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getCampaignPlan() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double nbmcScenarioCampaign = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCampaignPlan() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double controllExpScenarioCampaign = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getCampaignPlan() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double allocExpScenarioCampaign = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getCampaignPlan() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getCampaignPlan().getAmount() : 0;
- Double bmcMarginScenarioPw = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcScenarioPw = tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double controllExpScenarioPw = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double allocExpScenarioPw = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double ptiScenario = bmcMarginScenario - nbmcScenario - controllExpScenario - allocExpScenario;
- Double ptiScenarioBudget = bmcMarginScenarioBudget - nbmcScenarioBudget - controllExpScenarioBudget - allocExpScenarioBudget;
- Double ptiScenarioMx = bmcMarginScenarioMx - nbmcScenarioMx - controllExpScenarioMx - allocExpScenarioMx;
- Double ptiScenarioCampaign = bmcMarginScenarioCampaign - nbmcScenarioCampaign - controllExpScenarioCampaign - allocExpScenarioCampaign;
- Double ptiScenarioPw = bmcMarginScenarioPw - nbmcScenarioPw - controllExpScenarioPw - allocExpScenarioPw;
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateCurrentWeekForecastValue(child, CategoryEnum.PTI_K.getCodice(), codeSuffix, count, ptiScenario);
- updateBudgetValue(child, CategoryEnum.PTI_K.getCodice(), codeSuffix, count, ptiScenarioBudget);
- updateMxValue(child, CategoryEnum.PTI_K.getCodice(), codeSuffix, count, ptiScenarioMx);
- updateCampaignValue(child, CategoryEnum.PTI_K.getCodice(), codeSuffix, count, ptiScenarioCampaign);
- updatePreviousWeekForecastValue(child, CategoryEnum.PTI_K.getCodice(), codeSuffix, count, ptiScenarioPw);
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.PTI_K.getCodice())) {
- Double bmcMarginScenario = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double nbmcScenario = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double controllExpScenario = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double allocExpScenario = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double bmcMarginScenarioBudget = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getBudget().getAmount() : 0;
- Double nbmcScenarioBudget = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getBudget().getAmount() : 0;
- Double controllExpScenarioBudget = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getBudget().getAmount() : 0;
- Double allocExpScenarioBudget = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getBudget().getAmount() : 0;
- Double bmcMarginScenarioMx = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getMx().getAmount() : 0;
- Double nbmcScenarioMx = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getMx().getAmount() : 0;
- Double controllExpScenarioMx = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getMx().getAmount() : 0;
- Double allocExpScenarioMx = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getMx().getAmount() : 0;
- Double bmcMarginScenarioCampaign = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getCampaignPlan().getAmount() : 0;
- Double nbmcScenarioCampaign = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getCampaignPlan().getAmount() : 0;
- Double controllExpScenarioCampaign = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getCampaignPlan().getAmount() : 0;
- Double allocExpScenarioCampaign = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getCampaignPlan().getAmount() : 0;
- Double bmcMarginScenarioPw = tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()) != null
- && tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.BMC_MARGIN.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double nbmcScenarioPw = tableElements.get(CategoryEnum.NBMC_K.getCodice()) != null
- && tableElements.get(CategoryEnum.NBMC_K.getCodice()).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.NBMC_K.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double controllExpScenarioPw = tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.CONTROLLABLE_EXPENSES.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double allocExpScenarioPw = tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()) != null
- && tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getPreviousWeekForecast() != null ?
- tableElements.get(CategoryEnum.ALLOCATED_EXPENSES.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double ptiScenario = bmcMarginScenario - nbmcScenario - controllExpScenario - allocExpScenario;
- Double ptiScenarioBudget = bmcMarginScenarioBudget - nbmcScenarioBudget - controllExpScenarioBudget - allocExpScenarioBudget;
- Double ptiScenarioMx = bmcMarginScenarioMx - nbmcScenarioMx - controllExpScenarioMx - allocExpScenarioMx;
- Double ptiScenarioCampaign = bmcMarginScenarioCampaign - nbmcScenarioCampaign - controllExpScenarioCampaign - allocExpScenarioCampaign;
- Double ptiScenarioPw = bmcMarginScenarioPw - nbmcScenarioPw - controllExpScenarioPw - allocExpScenarioPw;
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.PTI_K.getCodice())) {
- ScenarioRow scenarioUpdate = (ScenarioRow) child.getData();
- Double oldValueCw = scenarioUpdate.getCurrentWeekForecast() != null
- && scenarioUpdate.getCurrentWeekForecast().getAmount() != null ?
- scenarioUpdate.getCurrentWeekForecast().getAmount() : 0;
- scenarioUpdate.getCurrentWeekForecast().setAmount(ptiScenario);
- Double oldValueMx = scenarioUpdate.getMx() != null
- && scenarioUpdate.getMx().getAmount() != null ?
- scenarioUpdate.getMx().getAmount() : 0;
- scenarioUpdate.getMx().setAmount(ptiScenarioMx);
- Double oldValueBudget = scenarioUpdate.getBudget() != null
- && scenarioUpdate.getBudget().getAmount() != null ?
- scenarioUpdate.getBudget().getAmount() : 0;
- scenarioUpdate.getBudget().setAmount(ptiScenarioBudget);
- Double oldValueCampaign = scenarioUpdate.getCampaignPlan() != null
- && scenarioUpdate.getCampaignPlan().getAmount() != null ?
- scenarioUpdate.getCampaignPlan().getAmount() : 0;
- scenarioUpdate.getCampaignPlan().setAmount(ptiScenarioCampaign);
- Double oldValuePw = scenarioUpdate.getPreviousWeekForecast() != null
- && scenarioUpdate.getPreviousWeekForecast().getAmount() != null ?
- scenarioUpdate.getPreviousWeekForecast().getAmount() : 0;
- scenarioUpdate.getPreviousWeekForecast().setAmount(ptiScenarioPw);
- }
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().startsWith(CategoryEnum.PTI_P.getCodice()) && entry.getKey().indexOf("_") > 1) {
- String codeSuffix = "";
- if (entry.getKey().indexOf("_") > -1) {
- codeSuffix = entry.getKey().substring(entry.getKey().indexOf("_") + 1);
- }
- Double ptiScenario = tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double netRevenueScenario = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getCurrentWeekForecast().getAmount() : 0;
- Double ptiScenarioMx = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx().getAmount() : 0;
- Double netRevenueScenarioMx = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() : 0;
- Double ptiScenarioBudget = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget().getAmount() : 0;
- Double netRevenueScenarioBudget = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() : 0;
- Double ptiScenarioCampaign = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan().getAmount() : 0;
- Double netRevenueScenarioCampaign = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() : 0;
- Double ptiScenarioPw = tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double netRevenueScenarioPw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice() + "_" + codeSuffix).getPreviousWeekForecast().getAmount() : 0;
- Double ptiPercScenario = netRevenueScenario != 0 ? (ptiScenario / netRevenueScenario) * 100 : 0;
- Double ptiPercScenarioMx = netRevenueScenarioMx != 0 ? (ptiScenarioMx / netRevenueScenarioMx) * 100 : 0;
- Double ptiPercScenarioBudget = netRevenueScenarioBudget != 0 ? (ptiScenarioBudget / netRevenueScenarioBudget) * 100 : 0;
- Double ptiPercScenarioCampaign = netRevenueScenarioCampaign != 0 ? (ptiScenarioCampaign / netRevenueScenarioCampaign) * 100 : 0;
- Double ptiPercScenarioPw = netRevenueScenarioPw != 0 ? (ptiScenarioPw / netRevenueScenarioPw) * 100 : 0;
- Integer count = 0;
- for (TreeNode child : treeTable.getChildren()) {
- updateCurrentWeekForecastValue(child, CategoryEnum.PTI_P.getCodice(), codeSuffix, count, ptiPercScenario);
- updateBudgetValue(child, CategoryEnum.PTI_P.getCodice(), codeSuffix, count, ptiPercScenarioBudget);
- updateMxValue(child, CategoryEnum.PTI_P.getCodice(), codeSuffix, count, ptiPercScenarioMx);
- updateCampaignValue(child, CategoryEnum.PTI_P.getCodice(), codeSuffix, count, ptiPercScenarioCampaign);
- updatePreviousWeekForecastValue(child, CategoryEnum.PTI_P.getCodice(), codeSuffix, count, ptiPercScenarioPw);
- }
- }
- }
- for (Map.Entry<String, ScenarioRow> entry : tableElements.entrySet()) {
- if (entry.getKey().equals(CategoryEnum.PTI_P.getCodice())) {
- Double ptiScenario = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double netRevenueScenario = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCurrentWeekForecast().getAmount() : 0;
- Double ptiScenarioMx = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getMx().getAmount() : 0;
- Double netRevenueScenarioMx = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getMx().getAmount() : 0;
- Double ptiScenarioBudget = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getBudget().getAmount() : 0;
- Double netRevenueScenarioBudget = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getBudget().getAmount() : 0;
- Double ptiScenarioCampaign = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getCampaignPlan().getAmount() : 0;
- Double netRevenueScenarioCampaign = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getCampaignPlan().getAmount() : 0;
- Double ptiScenarioPw = tableElements.get(CategoryEnum.PTI_K.getCodice()) != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.PTI_K.getCodice()).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.PTI_K.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double netRevenueScenarioPw = tableElements.get(CategoryEnum.NET_REVENUE.getCodice()) != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast() != null
- && tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast().getAmount() != null ?
- tableElements.get(CategoryEnum.NET_REVENUE.getCodice()).getPreviousWeekForecast().getAmount() : 0;
- Double ptiPercScenario = netRevenueScenario != 0 ? (ptiScenario / netRevenueScenario) * 100 : 0;
- Double ptiPercScenarioMx = netRevenueScenarioMx != 0 ? (ptiScenarioMx / netRevenueScenarioMx) * 100 : 0;
- Double ptiPercScenarioBudget = netRevenueScenarioBudget != 0 ? (ptiScenarioBudget / netRevenueScenarioBudget) * 100 : 0;
- Double ptiPercScenarioCampaign = netRevenueScenarioCampaign != 0 ? (ptiScenarioCampaign / netRevenueScenarioCampaign) * 100 : 0;
- Double ptiPercScenarioPw = netRevenueScenarioPw != 0 ? (ptiScenarioPw / netRevenueScenarioPw) * 100 : 0;
- for (TreeNode child : treeTable.getChildren()) {
- if (((ScenarioRow) child.getData()).getCategoryCode().equals(CategoryEnum.PTI_P.getCodice())) {
- ScenarioRow scenarioUpdate = (ScenarioRow) child.getData();
- Double oldValueCw = scenarioUpdate.getCurrentWeekForecast() != null
- && scenarioUpdate.getCurrentWeekForecast().getAmount() != null ?
- scenarioUpdate.getCurrentWeekForecast().getAmount() : 0;
- scenarioUpdate.getCurrentWeekForecast().setAmount(ptiPercScenario);
- Double oldValueMx = scenarioUpdate.getMx() != null
- && scenarioUpdate.getMx().getAmount() != null ?
- scenarioUpdate.getMx().getAmount() : 0;
- scenarioUpdate.getMx().setAmount(ptiPercScenarioMx);
- Double oldValueBudget = scenarioUpdate.getBudget() != null
- && scenarioUpdate.getBudget().getAmount() != null ?
- scenarioUpdate.getBudget().getAmount() : 0;
- scenarioUpdate.getBudget().setAmount(ptiPercScenarioBudget);
- Double oldValueCampaign = scenarioUpdate.getCampaignPlan() != null
- && scenarioUpdate.getCampaignPlan().getAmount() != null ?
- scenarioUpdate.getCampaignPlan().getAmount() : 0;
- scenarioUpdate.getCampaignPlan().setAmount(ptiPercScenarioCampaign);
- Double oldValuePw = scenarioUpdate.getPreviousWeekForecast() != null
- && scenarioUpdate.getPreviousWeekForecast().getAmount() != null ?
- scenarioUpdate.getPreviousWeekForecast().getAmount() : 0;
- scenarioUpdate.getPreviousWeekForecast().setAmount(ptiPercScenarioPw);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement