Skip to content

Commit 6a0b300

Browse files
committed
#149|Disable Zero Current quantity and support fractional value for receivedQuantity and dispatchedQuantity
1 parent ae49307 commit 6a0b300

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

goonj/src/main/java/org/avni_integration_service/goonj/dto/DispatchReceivedStatusLineItem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class DispatchReceivedStatusLineItem {
3030
@JsonProperty("ReceivingStatus")
3131
private String receivingStatus;
3232
@JsonProperty("DispatchedQuantity")
33-
private int dispatchedQuantity;
33+
private double dispatchedQuantity;
3434
@JsonProperty("ReceivedQuantity")
35-
private int receivedQuantity;
35+
private double receivedQuantity;
3636

3737
/**
3838
* No args constructor for use in serialization
@@ -51,7 +51,7 @@ public DispatchReceivedStatusLineItem() {
5151
* @param dispatchedQuantity
5252
* @param receivedQuantity
5353
*/
54-
public DispatchReceivedStatusLineItem(String sourceId, String typeOfMaterial, String itemName, String dispatchStatusLineItem, String unit, String receivingStatus, int dispatchedQuantity, int receivedQuantity) {
54+
public DispatchReceivedStatusLineItem(String sourceId, String typeOfMaterial, String itemName, String dispatchStatusLineItem, String unit, String receivingStatus, double dispatchedQuantity, double receivedQuantity) {
5555
super();
5656
this.sourceId = sourceId;
5757
this.typeOfMaterial = typeOfMaterial;
@@ -124,7 +124,7 @@ public void setReceivingStatus(String receivingStatus) {
124124
}
125125

126126
@JsonProperty("DispatchedQuantity")
127-
public int getDispatchedQuantity() {
127+
public double getDispatchedQuantity() {
128128
return dispatchedQuantity;
129129
}
130130

@@ -134,7 +134,7 @@ public void setDispatchedQuantity(int dispatchedQuantity) {
134134
}
135135

136136
@JsonProperty("ReceivedQuantity")
137-
public int getReceivedQuantity() {
137+
public double getReceivedQuantity() {
138138
return receivedQuantity;
139139
}
140140

goonj/src/main/java/org/avni_integration_service/goonj/repository/DispatchReceiptRepository.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ private List<DispatchReceivedStatusLineItem> fetchDrsLineItemsFromEncounter(Gene
103103
}
104104

105105
public DispatchReceivedStatusLineItem createDispatchReceivedStatusLineItem(HashMap<String, Object> entry) {
106-
int receivedQuantity;
106+
double receivedQuantity;
107107
String dispatchStatusLineItemId = (String) entry.get(DISPATCH_STATUS_LINE_ITEM_ID);
108108
String typeOfMaterial = (String) entry.get(TYPE_OF_MATERIAL);
109109
String itemName = typeOfMaterial.equals(CONTRIBUTED_ITEM) ?
110110
(String) entry.get(CONTRIBUTED_ITEM_NAME) :
111111
(typeOfMaterial.equals(KIT) ? (String) entry.get(KIT_NAME) : (String) entry.get(MATERIAL_NAME));
112-
int dispatchedQuantity = entry.get(QUANTITY_DISPATCHED) != null ?
113-
(int) entry.get(QUANTITY_DISPATCHED) : 0;
112+
double dispatchedQuantity = entry.get(QUANTITY_DISPATCHED) != null ?
113+
(double) entry.get(QUANTITY_DISPATCHED) : 0d;
114114
boolean quantityMatching = entry.get(QUANTITY_MATCHING).equals("Yes");
115115
if (quantityMatching) {
116116
receivedQuantity = dispatchedQuantity;
117117
} else {
118-
receivedQuantity = entry.get(QUANTITY) != null ? (int) entry.get(QUANTITY) : 0;
118+
receivedQuantity = entry.get(QUANTITY) != null ? (double) entry.get(QUANTITY) : 0d;
119119
}
120120
return new DispatchReceivedStatusLineItem(dispatchStatusLineItemId, mapTypeOfMaterial(entry), itemName,
121121
dispatchStatusLineItemId, EMPTY_STRING, EMPTY_STRING, dispatchedQuantity, receivedQuantity);

goonj/src/main/java/org/avni_integration_service/goonj/worker/goonj/InventoryEventWorker.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ private void processImplementationInventory(Map<String, Object> inventoryRespons
5656
Inventory inventoryItems = Inventory.from(inventoryResponse);
5757
Subject subject = inventoryItems.subjectWithoutObservations();
5858
inventoryService.populateObservations(subject, inventoryItems);
59+
if (subject.getVoided() == Boolean.FALSE){
60+
Object currentQuantity = subject.getObservation("Current Quantity");
61+
if (currentQuantity != null && (Double) currentQuantity == 0d){
62+
subject.setVoided(Boolean.TRUE);
63+
logger.info(String.format("0 currentQuantity, Voiding implementation inventory: name %s || uuid %s", inventoryResponse.get("ImplementationInventoryName"), inventoryResponse.get("ImplementationInventoryId")));
64+
}
65+
}
5966
avniSubjectRepository.create(subject);
6067
}
6168

0 commit comments

Comments
 (0)