Skip to content

OBPIH-7195 refactor inventory import to use baseline + adjustment transactions#5263

Merged
awalkowiak merged 4 commits intodevelopfrom
maintenance/OBPIH-7195-inventory-import-transaction-type
May 27, 2025
Merged

OBPIH-7195 refactor inventory import to use baseline + adjustment transactions#5263
awalkowiak merged 4 commits intodevelopfrom
maintenance/OBPIH-7195-inventory-import-transaction-type

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented May 20, 2025

✨ 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:
Screenshot from 2025-05-21 10-39-59

@ewaterman ewaterman requested a review from alannadolny May 20, 2025 23:26
@ewaterman ewaterman self-assigned this May 20, 2025
@ewaterman ewaterman added the status: work in progress For issues or pull requests that are in progress but not yet completed label May 20, 2025
@github-actions github-actions bot added type: maintenance Code improvements, optimizations and refactors, dependency upgrades... domain: backend Changes or discussions relating to the backend server labels May 20, 2025
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: investigate if we still need to flush. I changed it to not but I'm not sure why it was originally required

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the flush added unnecessarily a lot of time, so this one can also be added in this manner

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ewaterman ewaterman requested a review from awalkowiak May 21, 2025 18:58
@ewaterman ewaterman removed the status: work in progress For issues or pull requests that are in progress but not yet completed label May 21, 2025
@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

❌ Patch coverage is 3.00752% with 129 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.32%. Comparing base (97c81e8) to head (d1e2ab3).
⚠️ Report is 135 commits behind head on develop.

Files with missing lines Patch % Lines
...rehouse/importer/InventoryImportDataService.groovy 1.28% 77 Missing ⚠️
...rg/pih/warehouse/inventory/InventoryService.groovy 0.00% 30 Missing ⚠️
...ehouse/inventory/ProductAvailabilityService.groovy 0.00% 18 Missing ⚠️
...oryImportProductInventoryTransactionService.groovy 0.00% 2 Missing ⚠️
...nventory/ProductInventoryTransactionService.groovy 50.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@awalkowiak awalkowiak merged commit 77c5d04 into develop May 27, 2025
8 checks passed
@awalkowiak awalkowiak deleted the maintenance/OBPIH-7195-inventory-import-transaction-type branch May 27, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server type: maintenance Code improvements, optimizations and refactors, dependency upgrades...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants