OBPIH-7195 refactor inventory import to use baseline + adjustment transactions#5263
Conversation
grails-app/services/org/pih/warehouse/inventory/ProductAvailabilityService.groovy
Outdated
Show resolved
Hide resolved
| InventoryImportDataRow row = entry.value | ||
|
|
||
| // If we have no product availability record for the item, we assume that means we have no quantity. | ||
| int quantityOnHand = availableItems.get(key)?.quantityOnHand ?: 0 |
There was a problem hiding this comment.
@alannadolny this is what I was mentioning in your PR. Because we have a map that is keyed on product + bin + lot we can just do a lookup on that key to fetch the QoH instead of looping all the AvailableItems.
| } | ||
| // Force refresh of inventory snapshot table | ||
| transaction.forceRefresh = Boolean.TRUE | ||
| transaction.save(flush: true, failOnError: true) |
There was a problem hiding this comment.
TODO: investigate if we still need to flush. I changed it to not but I'm not sure why it was originally required
There was a problem hiding this comment.
I saw the flush added unnecessarily a lot of time, so this one can also be added in this manner
There was a problem hiding this comment.
It seems to be functioning fine without the forced flush so I'm leaving it out
| // Now that we know there is at least one discrepancy, create the transaction itself and map it to the entries. | ||
| TransactionType transactionType = TransactionType.read(Constants.ADJUSTMENT_CREDIT_TRANSACTION_TYPE_ID) | ||
| Transaction transaction = new Transaction( | ||
| source: cycleCount.facility, |
There was a problem hiding this comment.
I removed this because it's actually redundant information. Cycle count doesn't have a source -> destination transfer like we'd have for stock movements.
grails-app/services/org/pih/warehouse/importer/InventoryImportDataService.groovy
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5263 +/- ##
============================================
+ Coverage 8.28% 8.32% +0.04%
- Complexity 968 979 +11
============================================
Files 642 646 +4
Lines 43311 43437 +126
Branches 10523 10535 +12
============================================
+ Hits 3587 3615 +28
- Misses 39175 39270 +95
- Partials 549 552 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✨ Description of Change
Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7195
Description: Switch inventory import to do baseline + adjustment transactions (instead of the old product inventory).
📷 Screenshots & Recordings (optional)
Demo of backdated inventory import working:
Screenshot of a transaction after doing an import:
