Skip to content
Merged
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
17 changes: 17 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,23 @@ openboxes:
enabled: true
pageSize: 10

transactions:
inventoryBaseline:
# OBPIH-7194
recordStock:
enabled: true
# OBPIH-7195
inventoryImport:
enabled: true
# OBPIH-7254
loadDemoData:
enabled: true
# OBPIH-7198
migration:
enabled: true
# this one is for testing and should be always set to true on production
cleanupAdjustment: true

mail:
error:
enabled: false
Expand Down
7 changes: 0 additions & 7 deletions grails-app/conf/runtime.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ openboxes.products.merge.enabled = false
// Cycle Count configuration (OBPIH-7033)
openboxes.cycleCount.products.maxAmount = 50

// Inventory baseline transaction configuration (OBPIH-7194, OBPIH-7195)
openboxes.transactions.inventoryBaseline.recordStock.enabled = true
openboxes.transactions.inventoryBaseline.inventoryImport.enabled = true

// Inventory snapshot configuration (OBPIH-7254)
openboxes.transactions.inventoryBaseline.loadDemoData.enabled = true

openboxes.security.rbac.rules = [
[controller: '*', actions: ['delete'], accessRules: [ minimumRequiredRole: RoleType.ROLE_SUPERUSER ]],
[controller: '*', actions: ['remove'], accessRules: [ minimumRequiredRole: RoleType.ROLE_SUPERUSER ]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class MigrationController {

def dataService
def migrationService
def inventoryService
def locationService
def productAvailabilityService

Expand All @@ -55,11 +54,19 @@ class MigrationController {
def organizations = migrationService.getSuppliersForMigration()
def productSuppliers = migrationService.getProductsForMigration()
TransactionType inventoryTransactionType = TransactionType.load(Constants.INVENTORY_TRANSACTION_TYPE_ID)
def inventoryTransactionCount = Transaction.countByTransactionType(inventoryTransactionType)
TransactionType productInventoryTransactionType = TransactionType.load(Constants.PRODUCT_INVENTORY_TRANSACTION_TYPE_ID)
Integer inventoryTransactionCount = Transaction.countByTransactionType(inventoryTransactionType)
Integer productInventoryTransactionCount = Transaction.countByTransactionType(productInventoryTransactionType)
Location currentLocation = Location.get(session.warehouse.id)
Integer productInventoryTransactionInCurrentLocationCount = Transaction.countByTransactionTypeAndInventory(productInventoryTransactionType, currentLocation.inventory)
List<Product> productsWithProductInventoryTransactionInCurrentLocation = migrationService.getProductsWithTransactions(currentLocation, productInventoryTransactionType)

[
organizationCount : organizations.size(),
inventoryTransactionCount: inventoryTransactionCount,
productInventoryTransactionCount: productInventoryTransactionCount,
productInventoryTransactionInCurrentLocationCount: productInventoryTransactionInCurrentLocationCount,
productsWithProductInventoryTransactionInCurrentLocation: productsWithProductInventoryTransactionInCurrentLocation?.productCode,
productSupplierCount : productSuppliers.size(),

]
Expand Down Expand Up @@ -296,6 +303,11 @@ class MigrationController {
render([count: locations.size(), locations: locations] as JSON)
}

def locationsWithProductInventoryTransactions() {
TransactionType transactionType = TransactionType.get(Constants.PRODUCT_INVENTORY_TRANSACTION_TYPE_ID)
def locations = migrationService.getLocationsWithTransaction(transactionType)
render([count: locations.size(), locations: locations] as JSON)
}

def productsWithInventoryTransactions() {
def location = Location.get(session.warehouse.id)
Expand Down Expand Up @@ -359,6 +371,21 @@ class MigrationController {

}

def migrateProductInventoryTransactions() {
long startTime = System.currentTimeMillis()
Location location = Location.get(session.warehouse.id)

boolean performMigration = params.boolean("performMigration", false)
Map results = migrationService.migrateProductInventoryTransactions(location, performMigration)

long responseTime = System.currentTimeMillis() - startTime
String responseTimeMessage = "${performMigration ? 'Migration' : 'Generating preview'} of product inventory " +
"transactions at location ${location.name} took ${(responseTime)} ms"
log.info "$responseTimeMessage"
Comment thread
awalkowiak marked this conversation as resolved.

render([responseTime: "$responseTimeMessage", results: results] as JSON)
}


def migrateProductSuppliers(MigrationCommand command) {
def startTime = System.currentTimeMillis()
Expand Down
Loading