Skip to content
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
26 changes: 23 additions & 3 deletions grails-app/conf/runtime.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,12 @@ openboxes {
order : 5
],
[
widgetId: "discrepancy",
widgetId: "overdueInbound",
order : 6
],
[
widgetId: "discrepancy",
order : 7
]
]
}
Expand Down Expand Up @@ -674,8 +678,12 @@ openboxes {
order : 5
],
[
widgetId: "discrepancy",
widgetId: "overdueInbound",
order : 6
],
[
widgetId: "discrepancy",
order : 7
]
]
}
Expand Down Expand Up @@ -712,8 +720,12 @@ openboxes {
order : 1
],
[
widgetId: "productsInventoried",
widgetId: "overdueInbound",
order : 2
],
[
widgetId: "productsInventoried",
order : 3
]
]
}
Expand Down Expand Up @@ -1020,6 +1032,14 @@ openboxes {
}
}
}
overdueInbound {
enabled = true
title = "react.dashboard.overdueInbound.title.label"
info = "react.dashboard.overdueInbound.info.label"
graphType = "table"
type = 'graph'
endpoint = "/api/dashboard/overdueInbound"
}
sentStockMovements {
enabled = true
title = "react.dashboard.sentStockMovements.title.label"
Expand Down
5 changes: 5 additions & 0 deletions grails-app/controllers/org/pih/warehouse/UrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,11 @@ class UrlMappings {
action = [GET: "getDelayedShipments"]
}

"/api/dashboard/overdueInbound"(parseRequest: true) {
controller = { "dashboardApi" }
action = [GET: "getOverdueInbound"]
}

"/api/dashboard/productWithNegativeInventory"(parseRequest: true) {
controller = { "dashboardApi" }
action = [GET: "getProductWithNegativeInventory"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.pih.warehouse.api

import grails.converters.JSON
import grails.core.GrailsApplication
import grails.validation.ValidationException
import grails.util.Holders
import org.pih.warehouse.auth.AuthService
import org.pih.warehouse.core.Location
Expand Down Expand Up @@ -165,6 +166,16 @@ class DashboardApiController {
render(delayedShipments as JSON)
}

def getOverdueInbound() {
Location location = Location.get(params.locationId)
if (!location) {
ShipmentExceptionCommand command = new ShipmentExceptionCommand()
command.errors.reject("warehouse", "A warehouse must be selected")
throw new ValidationException("A warehouse must be selected", command.errors)
}
render(indicatorDataService.getOverdueInbound(location) as JSON)
}
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved

def getProductWithNegativeInventory() {
Location location = Location.get(params.locationId)
def productsWithNegativeInventory = numberDataService.getProductWithNegativeInventory(location)
Expand Down
2 changes: 2 additions & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4548,6 +4548,8 @@ react.dashboard.discrepancy.title.label=Items received with a discrepancy
react.dashboard.discrepancy.info.label=List of shipments where there was any discrepancy between shipped and received, filterable by month
react.dashboard.delayedShipments.title.label=Delayed Incoming Stock Movements
react.dashboard.delayedShipments.info.label=Air shipments not received 30 days after ship date; Sea shipments not received 60 days after ship date; land shipments not received 7 days after ship date
react.dashboard.overdueInbound.title.label=Overdue inbound
react.dashboard.overdueInbound.info.label=Inbound shipments past their expected delivery date that have not been received
react.dashboard.lossCausedByExpiry.title.label=Value of Stock Lost to Expiry
react.dashboard.percentageAdHoc.title.label=Stock vs ad-hoc requests last month
react.dashboard.percentageAdHoc.info.label=Requests in the previous month broken down by stock vs ad hoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.grails.plugins.web.taglib.ApplicationTagLib
import org.hibernate.SessionFactory
import org.joda.time.LocalDate
import org.pih.warehouse.LocalizationUtil
import org.pih.warehouse.api.ShipmentExceptionCommand
import org.pih.warehouse.api.StockMovementDirection
import org.pih.warehouse.core.ConfigService
import org.pih.warehouse.core.Location
Expand All @@ -25,6 +26,7 @@ import org.pih.warehouse.inventory.OutboundStockMovementListItem
import org.pih.warehouse.inventory.OutgoingStockMovementCounts
import org.pih.warehouse.requisition.RequisitionSourceType
import org.pih.warehouse.shipping.Shipment
import org.pih.warehouse.shipping.ShipmentExceptionService
import util.ConfigHelper

@Transactional
Expand All @@ -38,6 +40,7 @@ class IndicatorDataService {
def messageService
ConfigService configService
SessionFactory sessionFactory
ShipmentExceptionService shipmentExceptionService

ApplicationTagLib getApplicationTagLib() {
return Holders.grailsApplication.mainContext.getBean(ApplicationTagLib)
Expand Down Expand Up @@ -793,6 +796,24 @@ class IndicatorDataService {
return graphData;
}

@Cacheable(value = "dashboardCache", key = { "getOverdueInbound-${location?.id}" })
GraphData getOverdueInbound(Location location) {
ShipmentExceptionCommand command = new ShipmentExceptionCommand(max: 10)
Map overdueInbound = shipmentExceptionService.getOverdueInboundShipments(location, command)
String urlContextPath = ConfigHelper.contextPath
List<TableData> tableBody = overdueInbound.data.collect { row ->
new TableData(
row.shipmentNumber,
row.origin?.name,
row.daysLate == 1 ? "1 day" : "${row.daysLate} days",
"${urlContextPath}/stockMovement/show/${row.id}"
)
}
Table table = new Table("Shipment", "Origin", "Days late", tableBody)
GraphData graphData = new GraphData(table)
return graphData
}

@Cacheable(value = "dashboardCache", key = { "getProductsInventoried-${location?.id}" })
Map getProductsInventoried(Location location) {
List monthsCount = [3, 6, 9, 12, 0]
Expand Down
Loading