Skip to content

Commit faf5f18

Browse files
committed
feat: billing addition during update
1 parent 8d3c37a commit faf5f18

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
55

6-
<modelVersion>5.1.0</modelVersion>
6+
<modelVersion>4.0.0</modelVersion>
77

88
<groupId>io.github.isa-group</groupId>
99
<artifactId>Pricing4Java</artifactId>
10-
<version>5.0.0</version>
10+
<version>5.1.0</version>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
1313
<description>A pricing driven feature toggling library for java</description>

src/main/java/io/github/isagroup/services/updaters/V11ToV20Updater.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.isagroup.services.updaters;
22

3+
import java.util.LinkedHashMap;
34
import java.util.List;
45
import java.util.Map;
56

@@ -97,6 +98,22 @@ private void updateContainersWithOnlyOnePriceField(Map<String,Object> configFile
9798
System.out.println("[V20 UPDATER WARNING] " + containerName + " " + entry.getKey() + " does not have a monthlyPrice but annualPrice instead, keep in mind that we are copying this value to price");
9899
containerAttributes.put("price", containerAttributes.get("annualPrice"));
99100
}
101+
102+
Map<String, Double> billingMap = new LinkedHashMap<>();
103+
billingMap.put("monthly", 1.0);
104+
105+
if (containerAttributes.get("monthlyPrice") != null && containerAttributes.get("annualPrice") != null) {
106+
Double annualCoef = Double.parseDouble(containerAttributes.get("annualPrice").toString()) / Double.parseDouble(containerAttributes.get("monthlyPrice").toString());
107+
if (annualCoef > 1.0){
108+
billingMap.put("annual", 1.0);
109+
}else if(annualCoef < 0.0){
110+
billingMap.put("annual", 0.0);
111+
}else{
112+
billingMap.put("annual", annualCoef);
113+
}
114+
}
115+
116+
configFile.put("billing", billingMap);
100117
}
101118

102119
containerAttributes.remove("monthlyPrice");

0 commit comments

Comments
 (0)