Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIGENG-72 RHVOrderForm #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class RHVOrderFormModel
{
// RHVOrderForm
private Double year1RhvOrderSku;
private String year1RhvOrderSku;
private Double year1RhvOrder;
private Double year1RhvOrderConsult;
private Double year1RhvOrderTAndE;
Expand All @@ -21,13 +21,13 @@ public class RHVOrderFormModel
private Double year1RhvOrderTAndETotalValue;
private Double year1RhvOrderLearningSubsTotalValue;
private Double year1RhvOrderGrandTotal;
private Double year2RhvOrderSku;
private String year2RhvOrderSku;
private Double year2RhvOrder;
private Double year2RhvOrderListValue;
private Double year2RhvOrderDiscountValue;
private Double year2RhvOrderTotalValue;
private Double year2RhvOrderGrandTotal;
private Double year3RhvOrderSku;
private String year3RhvOrderSku;
private Double year3RhvOrder;
private Double year3RhvOrderListValue;
private Double year3RhvOrderDiscountValue;
Expand All @@ -36,11 +36,11 @@ public class RHVOrderFormModel

public RHVOrderFormModel() {}

public Double getYear1RhvOrderSku() {
public String getYear1RhvOrderSku() {
return year1RhvOrderSku;
}

public void setYear1RhvOrderSku(Double year1RhvOrderSku) {
public void setYear1RhvOrderSku(String year1RhvOrderSku) {
this.year1RhvOrderSku = year1RhvOrderSku;
}

Expand Down Expand Up @@ -180,11 +180,11 @@ public void setYear1RhvOrderGrandTotal(Double year1RhvOrderGrandTotal) {
this.year1RhvOrderGrandTotal = year1RhvOrderGrandTotal;
}

public Double getYear2RhvOrderSku() {
public String getYear2RhvOrderSku() {
return year2RhvOrderSku;
}

public void setYear2RhvOrderSku(Double year2RhvOrderSku) {
public void setYear2RhvOrderSku(String year2RhvOrderSku) {
this.year2RhvOrderSku = year2RhvOrderSku;
}

Expand Down Expand Up @@ -228,11 +228,11 @@ public void setYear2RhvOrderGrandTotal(Double year2RhvOrderGrandTotal) {
this.year2RhvOrderGrandTotal = year2RhvOrderGrandTotal;
}

public Double getYear3RhvOrderSku() {
public String getYear3RhvOrderSku() {
return year3RhvOrderSku;
}

public void setYear3RhvOrderSku(Double year3RhvOrderSku) {
public void setYear3RhvOrderSku(String year3RhvOrderSku) {
this.year3RhvOrderSku = year3RhvOrderSku;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package org.jboss.xavier.analytics.rules.initialcostsaving;


import org.jboss.xavier.analytics.pojo.support.initialcostsaving.PricingDataModel;
import org.jboss.xavier.analytics.pojo.output.RHVOrderFormModel
import org.jboss.xavier.analytics.pojo.output.EnvironmentModel
import org.jboss.xavier.analytics.pojo.output.InitialSavingsEstimationReportModel
import org.jboss.xavier.analytics.pojo.output.RHVYearByYearCostsModel
import org.jboss.xavier.analytics.pojo.output.RHVRampUpCostsModel



import function org.jboss.xavier.analytics.functions.HelperFunctions.round;


dialect "java"
agenda-group "RHVOrderForm"
lock-on-active true

rule "RHVOrderFormRules"
when
pricing : PricingDataModel(
rhvListValue != null,
rhvValue != null,
rhVirtListValue != null,
rhVirtValue != null,
rhvConsultValue != null,
rhvTAndEValue != null,
rhLearningSubsValue != null)
report : InitialSavingsEstimationReportModel(
environmentModel != null,
environmentModel.sourceProductIndicator != null,
rhvRampUpCostsModel != null,
rhvRampUpCostsModel.year1RhvPaidSubs != null,
rhvRampUpCostsModel.year1RhvPaidSubsGrowth != null,
rhvRampUpCostsModel.year2RhvPaidSubs != null,
rhvRampUpCostsModel.year2RhvPaidSubsGrowth != null,
rhvRampUpCostsModel.year3RhvPaidSubs != null,
rhvRampUpCostsModel.year3RhvPaidSubsGrowth != null)
then
RHVOrderFormModel rhvOrderFormModel = new RHVOrderFormModel();
RHVRampUpCostsModel rhvRampUpCostsModel = report.getRhvRampUpCostsModel();
boolean isVSphere = report.getEnvironmentModel().getSourceProductIndicator()==1;
//Year1
boolean year1SubsNotPaid = rhvRampUpCostsModel.getYear1RhvPaidSubs()==0;
boolean noYear1PaidSubsGrowth = rhvRampUpCostsModel.getYear1RhvPaidSubsGrowth()==0;
if(year1SubsNotPaid && noYear1PaidSubsGrowth)
{
rhvOrderFormModel.setYear1RhvOrderSku("");
rhvOrderFormModel.setYear1RhvOrder(0d);
rhvOrderFormModel.setYear1RhvOrderListValue(0d);
rhvOrderFormModel.setYear1RhvOrderDiscountValue(0d);
rhvOrderFormModel.setYear1RhvOrderTotalValue(0d);
}
else if( isVSphere)
{
rhvOrderFormModel.setYear1RhvOrderSku("RV0213787");
rhvOrderFormModel.setYear1RhvOrder((double)round(rhvRampUpCostsModel.getYear1RhvPaidSubs() + rhvRampUpCostsModel.getYear1RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear1RhvOrderListValue(pricing.getRhvListValue());
rhvOrderFormModel.setYear1RhvOrderDiscountValue((1-pricing.getRhvValue())*pricing.getRhvListValue());
rhvOrderFormModel.setYear1RhvOrderTotalValue(rhvOrderFormModel.getYear1RhvOrder()*rhvOrderFormModel.getYear1RhvOrderDiscountValue());
}
else
{
rhvOrderFormModel.setYear1RhvOrderSku("RV00012");
rhvOrderFormModel.setYear1RhvOrder((double)round(rhvRampUpCostsModel.getYear1RhvPaidSubs() + rhvRampUpCostsModel.getYear1RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear1RhvOrderListValue(pricing.getRhVirtListValue());
rhvOrderFormModel.setYear1RhvOrderDiscountValue((1-pricing.getRhVirtValue())*pricing.getRhVirtListValue());
rhvOrderFormModel.setYear1RhvOrderTotalValue(rhvOrderFormModel.getYear1RhvOrder()*rhvOrderFormModel.getYear1RhvOrderDiscountValue());
}
rhvOrderFormModel.setYear1RhvOrderConsult(pricing.getRhvConsultValue()/100);
rhvOrderFormModel.setYear1RhvOrderConsultListValue(100.0);
rhvOrderFormModel.setYear1RhvOrderConsultDiscountValue(100.0);
rhvOrderFormModel.setYear1RhvOrderConsultTotalValue(rhvOrderFormModel.getYear1RhvOrderConsult()*rhvOrderFormModel.getYear1RhvOrderConsultDiscountValue());
rhvOrderFormModel.setYear1RhvOrderTAndE(1d);
rhvOrderFormModel.setYear1RhvOrderTAndEValue(pricing.getRhvTAndEValue());
rhvOrderFormModel.setYear1RhvOrderTAndEDiscountValue(pricing.getRhvTAndEValue());
rhvOrderFormModel.setYear1RhvOrderTAndETotalValue(rhvOrderFormModel.getYear1RhvOrderTAndE()*rhvOrderFormModel.getYear1RhvOrderTAndEDiscountValue());
rhvOrderFormModel.setYear1RhvOrderLearningSubsListValue(7000d);
rhvOrderFormModel.setYear1RhvOrderLearningSubs(pricing.getRhLearningSubsValue()/rhvOrderFormModel.getYear1RhvOrderLearningSubsListValue());
rhvOrderFormModel.setYear1RhvOrderLearningSubsDiscountValue(7000d);
rhvOrderFormModel.setYear1RhvOrderLearningSubsTotalValue(rhvOrderFormModel.getYear1RhvOrderLearningSubs()*rhvOrderFormModel.getYear1RhvOrderLearningSubsListValue());
rhvOrderFormModel.setYear1RhvOrderGrandTotal(rhvOrderFormModel.getYear1RhvOrderTotalValue() +
rhvOrderFormModel.getYear1RhvOrderConsultTotalValue() +
rhvOrderFormModel.getYear1RhvOrderTAndETotalValue() +
rhvOrderFormModel.getYear1RhvOrderLearningSubsTotalValue());
//Year2
boolean year2SubsNotPaid = rhvRampUpCostsModel.getYear2RhvPaidSubs()==0;
boolean noYear2PaidSubsGrowth = rhvRampUpCostsModel.getYear2RhvPaidSubsGrowth()==0;
if(year2SubsNotPaid && noYear2PaidSubsGrowth)
{
rhvOrderFormModel.setYear2RhvOrderSku("");
rhvOrderFormModel.setYear2RhvOrder(0d);
rhvOrderFormModel.setYear2RhvOrderListValue(0d);
rhvOrderFormModel.setYear2RhvOrderDiscountValue(0d);
rhvOrderFormModel.setYear2RhvOrderTotalValue(0d);
}
else if( isVSphere)
{
rhvOrderFormModel.setYear2RhvOrderSku("RV0213787");
rhvOrderFormModel.setYear2RhvOrder((double)round(rhvRampUpCostsModel.getYear2RhvPaidSubs() + rhvRampUpCostsModel.getYear2RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear2RhvOrderListValue(pricing.getRhvListValue());
rhvOrderFormModel.setYear2RhvOrderDiscountValue((1-pricing.getRhvValue())*pricing.getRhvListValue());
rhvOrderFormModel.setYear2RhvOrderTotalValue(rhvOrderFormModel.getYear2RhvOrder()*rhvOrderFormModel.getYear2RhvOrderDiscountValue());
}
else
{
rhvOrderFormModel.setYear2RhvOrderSku("RV00012");
rhvOrderFormModel.setYear2RhvOrder((double)round(rhvRampUpCostsModel.getYear2RhvPaidSubs() + rhvRampUpCostsModel.getYear2RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear2RhvOrderListValue(pricing.getRhVirtListValue());
rhvOrderFormModel.setYear2RhvOrderDiscountValue((1-pricing.getRhVirtValue())*pricing.getRhVirtListValue());
rhvOrderFormModel.setYear2RhvOrderTotalValue(rhvOrderFormModel.getYear2RhvOrder()*rhvOrderFormModel.getYear2RhvOrderDiscountValue());
}
rhvOrderFormModel.setYear2RhvOrderGrandTotal(rhvOrderFormModel.getYear2RhvOrderTotalValue());
//Year3
boolean year3SubsNotPaid = rhvRampUpCostsModel.getYear3RhvPaidSubs()==0;
boolean noYear3PaidSubsGrowth = rhvRampUpCostsModel.getYear3RhvPaidSubsGrowth()==0;
if(year3SubsNotPaid && noYear3PaidSubsGrowth)
{
rhvOrderFormModel.setYear3RhvOrderSku("");
rhvOrderFormModel.setYear3RhvOrder(0d);
rhvOrderFormModel.setYear3RhvOrderListValue(0d);
rhvOrderFormModel.setYear3RhvOrderDiscountValue(0d);
rhvOrderFormModel.setYear3RhvOrderTotalValue(0d);
}
else if( isVSphere)
{
rhvOrderFormModel.setYear3RhvOrderSku("RV0213787");
rhvOrderFormModel.setYear3RhvOrder((double)round(rhvRampUpCostsModel.getYear3RhvPaidSubs() + rhvRampUpCostsModel.getYear3RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear3RhvOrderListValue(pricing.getRhvListValue());
rhvOrderFormModel.setYear3RhvOrderDiscountValue((1-pricing.getRhvValue())*pricing.getRhvListValue());
rhvOrderFormModel.setYear3RhvOrderTotalValue(rhvOrderFormModel.getYear3RhvOrder()*rhvOrderFormModel.getYear3RhvOrderDiscountValue());
}
else
{
rhvOrderFormModel.setYear3RhvOrderSku("RV00012");
rhvOrderFormModel.setYear3RhvOrder((double)round(rhvRampUpCostsModel.getYear3RhvPaidSubs() + rhvRampUpCostsModel.getYear3RhvPaidSubsGrowth()));
rhvOrderFormModel.setYear3RhvOrderListValue(pricing.getRhVirtListValue());
rhvOrderFormModel.setYear3RhvOrderDiscountValue((1-pricing.getRhVirtValue())*pricing.getRhVirtListValue());
rhvOrderFormModel.setYear3RhvOrderTotalValue(rhvOrderFormModel.getYear3RhvOrder()*rhvOrderFormModel.getYear3RhvOrderDiscountValue());
}
rhvOrderFormModel.setYear3RhvOrderGrandTotal(rhvOrderFormModel.getYear3RhvOrderTotalValue());

modify(report)
{
setRhvOrderFormModel(rhvOrderFormModel)
}
end
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package org.jboss.xavier.analytics.rules.initialcostsaving;

import org.jboss.xavier.analytics.pojo.input.UploadFormInputDataModel;
import org.jboss.xavier.analytics.pojo.output.EnvironmentModel;
import org.jboss.xavier.analytics.pojo.output.InitialSavingsEstimationReportModel;
import org.jboss.xavier.analytics.pojo.output.RHVAdditionalContainerCapacityModel;
import org.jboss.xavier.analytics.pojo.output.RHVRampUpCostsModel;
import org.jboss.xavier.analytics.pojo.output.RHVSavingsModel;
import org.jboss.xavier.analytics.pojo.output.RHVYearByYearCostsModel;
import org.jboss.xavier.analytics.pojo.output.SourceCostsModel;
import org.jboss.xavier.analytics.pojo.output.SourceRampDownCostsModel;
import org.jboss.xavier.analytics.pojo.output.*;
import org.jboss.xavier.analytics.pojo.support.initialcostsaving.PricingDataModel;
import org.jboss.xavier.analytics.rules.BaseIntegrationTest;
import org.jboss.xavier.analytics.test.Utils;
Expand Down Expand Up @@ -39,7 +32,7 @@ public InitialSavingsEstimationReportTest()
public void test_SourceNewELAIndicator_0()
{
// check that the numbers of rule from the DRL file is the number of rules loaded
Utils.checkLoadedRulesNumber(kieSession, "org.jboss.xavier.analytics.rules.initialcostsaving", 26);
Utils.checkLoadedRulesNumber(kieSession, "org.jboss.xavier.analytics.rules.initialcostsaving", 27);

// create a Map with the facts (i.e. Objects) you want to put in the working memory
Map<String, Object> facts = new HashMap<>();
Expand Down Expand Up @@ -71,7 +64,7 @@ public void test_SourceNewELAIndicator_0()
Map<String, Object> results = Utils.executeCommandsAndGetResults(kieSession, commands);

// check that the number of rules fired is what you expect
Assert.assertEquals(21, results.get(NUMBER_OF_FIRED_RULE_KEY));
Assert.assertEquals(22, results.get(NUMBER_OF_FIRED_RULE_KEY));
// check the names of the rules fired are what you expect
Utils.verifyRulesFiredNames(this.agendaEventListener,
// Environment
Expand All @@ -89,8 +82,9 @@ public void test_SourceNewELAIndicator_0()
// RHVSavings
"RHVSavingsRules",
// RHVAdditionalContainerCapacity
"RHVAdditionalContainerCapacity"
"RHVAdditionalContainerCapacity",
// RHVOrderForm
"RHVOrderFormRules"
);

// retrieve the QueryResults that was available in the working memory from the results
Expand Down Expand Up @@ -281,6 +275,43 @@ public void test_SourceNewELAIndicator_0()
Assert.assertEquals(345210, model.getRhvContainerLikely(), 0);
Assert.assertEquals(243960, model.getRhvContainerLow(), 0);
// RHVOrderForm
RHVOrderFormModel rhvOrderFormModel = report.getRhvOrderFormModel();
Assert.assertEquals("", rhvOrderFormModel.getYear1RhvOrderSku());
Assert.assertEquals(0, rhvOrderFormModel.getYear1RhvOrder().doubleValue(),0.1);
Assert.assertEquals(0, rhvOrderFormModel.getYear1RhvOrderListValue().doubleValue(),0.1);
Assert.assertEquals(0, rhvOrderFormModel.getYear1RhvOrderDiscountValue().doubleValue(),0.1);
Assert.assertEquals(0, rhvOrderFormModel.getYear1RhvOrderTotalValue().doubleValue(),0.1);


Assert.assertEquals(1000, rhvOrderFormModel.getYear1RhvOrderConsult().doubleValue(),0.1);
Assert.assertEquals(100, rhvOrderFormModel.getYear1RhvOrderConsultListValue().doubleValue(),0.1);
Assert.assertEquals(100, rhvOrderFormModel.getYear1RhvOrderConsultDiscountValue().doubleValue(),0.1);
Assert.assertEquals(100000, rhvOrderFormModel.getYear1RhvOrderConsultTotalValue().doubleValue(),0.1);
Assert.assertEquals(1, rhvOrderFormModel.getYear1RhvOrderTAndE().doubleValue(),0.1);
Assert.assertEquals(30000, rhvOrderFormModel.getYear1RhvOrderTAndEValue().doubleValue(),0.1);
Assert.assertEquals(30000, rhvOrderFormModel.getYear1RhvOrderTAndEDiscountValue().doubleValue(),0.1);
Assert.assertEquals(30000, rhvOrderFormModel.getYear1RhvOrderTAndETotalValue().doubleValue(),0.1);
Assert.assertEquals(7000, rhvOrderFormModel.getYear1RhvOrderLearningSubsListValue().doubleValue(),0.1);
Assert.assertEquals(4.28, rhvOrderFormModel.getYear1RhvOrderLearningSubs().doubleValue(),0.1);
Assert.assertEquals(7000, rhvOrderFormModel.getYear1RhvOrderLearningSubsDiscountValue().doubleValue(),0.1);
Assert.assertEquals(30000, rhvOrderFormModel.getYear1RhvOrderLearningSubsTotalValue().doubleValue(),0.1);
Assert.assertEquals(160000, rhvOrderFormModel.getYear1RhvOrderGrandTotal().doubleValue(),0.1);


Assert.assertEquals("RV0213787", rhvOrderFormModel.getYear2RhvOrderSku());
Assert.assertEquals(620, rhvOrderFormModel.getYear2RhvOrder().doubleValue(),0.1);
Assert.assertEquals(1500, rhvOrderFormModel.getYear2RhvOrderListValue().doubleValue(),0.1);
Assert.assertEquals(375, rhvOrderFormModel.getYear2RhvOrderDiscountValue().doubleValue(),0.1);
Assert.assertEquals(232500, rhvOrderFormModel.getYear2RhvOrderTotalValue().doubleValue(),0.1);
Assert.assertEquals(232500, rhvOrderFormModel.getYear2RhvOrderGrandTotal().doubleValue(),0.1);


Assert.assertEquals("RV0213787", rhvOrderFormModel.getYear3RhvOrderSku());
Assert.assertEquals(864, rhvOrderFormModel.getYear3RhvOrder().doubleValue(),0.1);
Assert.assertEquals(1500, rhvOrderFormModel.getYear3RhvOrderListValue().doubleValue(),0.1);
Assert.assertEquals(375, rhvOrderFormModel.getYear3RhvOrderDiscountValue().doubleValue(),0.1);
Assert.assertEquals(324000, rhvOrderFormModel.getYear3RhvOrderTotalValue().doubleValue(),0.1);
Assert.assertEquals(324000, rhvOrderFormModel.getYear3RhvOrderGrandTotal().doubleValue(),0.1);
}

@Test @Ignore
Expand Down
Loading