diff --git a/pom.xml b/pom.xml
index 5b2ebce2..a7f2a440 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.iemr.inventory
inventory-api
- 3.9.0
+ 3.12.0
war
Inventory-API
Inventory Page
diff --git a/src/main/java/com/iemr/inventory/controller/report/CRMReportController.java b/src/main/java/com/iemr/inventory/controller/report/CRMReportController.java
index 3627768d..3ed55557 100644
--- a/src/main/java/com/iemr/inventory/controller/report/CRMReportController.java
+++ b/src/main/java/com/iemr/inventory/controller/report/CRMReportController.java
@@ -86,6 +86,25 @@ public String getExpiryReport(@RequestBody String request) {
return response.toString();
}
+ @ApiOperation(value = "Get low stock and out of stock report for a store", consumes = "application/json", produces = "application/json")
+ @RequestMapping(value = "/getLowStockReport", headers = "Authorization", method = {
+ RequestMethod.POST }, produces = { "application/json" })
+ public String getLowStockReport(@RequestBody String request) {
+ logger.info("getLowStockReport request " + request.toString());
+ OutputResponse response = new OutputResponse();
+ try {
+
+ ItemStockEntryReport report = InputMapper.gson().fromJson(request, ItemStockEntryReport.class);
+ String res = crmReportService.getLowStockReport(report);
+ response.setResponse(res);
+ logger.info("getLowStockReport response " + response.toString());
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ response.setError(e);
+ }
+ return response.toString();
+ }
+
@ApiOperation(value = "Get consumption report", consumes = "application/json", produces = "application/json")
@RequestMapping(value = "/getConsumptionReport", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
diff --git a/src/main/java/com/iemr/inventory/model/report/LowStockReport.java b/src/main/java/com/iemr/inventory/model/report/LowStockReport.java
new file mode 100644
index 00000000..7b8e95b5
--- /dev/null
+++ b/src/main/java/com/iemr/inventory/model/report/LowStockReport.java
@@ -0,0 +1,76 @@
+/*
+* AMRIT – Accessible Medical Records via Integrated Technology
+* Integrated EHR (Electronic Health Records) Solution
+*
+* Copyright (C) "Piramal Swasthya Management and Research Institute"
+*
+* This file is part of AMRIT.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see https://www.gnu.org/licenses/.
+*/
+package com.iemr.inventory.model.report;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.LongSerializationPolicy;
+
+import lombok.Data;
+
+@Data
+public class LowStockReport {
+
+ private Long slNo;
+
+ private String facilityName;
+
+ private Integer itemID;
+
+ private String itemName;
+
+ private String itemCategory;
+
+ private String strength;
+
+ private Integer minStock;
+
+ private Integer quantityInHand;
+
+ // "Out of stock" (nothing usable left) or "Low stock" (at or below the item's minimum stock)
+ private String stockStatus;
+
+ public LowStockReport() {
+
+ }
+
+ public LowStockReport(String facilityName, Integer itemID, String itemName, String itemCategory, String strength,
+ Integer minStock, Integer quantityInHand) {
+
+ this.facilityName = facilityName;
+ this.itemID = itemID;
+ this.itemName = itemName;
+ this.itemCategory = itemCategory;
+ this.strength = strength;
+ this.minStock = minStock;
+ this.quantityInHand = quantityInHand;
+ this.stockStatus = (quantityInHand == null || quantityInHand <= 0) ? "Out of stock" : "Low stock";
+ }
+
+ @Override
+ public String toString() {
+
+ return new GsonBuilder().setLongSerializationPolicy(LongSerializationPolicy.STRING).serializeNulls().create()
+ .toJson(this);
+
+ }
+
+}
diff --git a/src/main/java/com/iemr/inventory/repo/report/ItemStockReportRepo.java b/src/main/java/com/iemr/inventory/repo/report/ItemStockReportRepo.java
index 99a9ca67..efcdaef8 100644
--- a/src/main/java/com/iemr/inventory/repo/report/ItemStockReportRepo.java
+++ b/src/main/java/com/iemr/inventory/repo/report/ItemStockReportRepo.java
@@ -57,6 +57,21 @@ List getItemStockEntryReportByFacilityID(@Param("startDate
List