2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 18:55:34 +00:00

Stock location scan (#169)

* Add action for scanning a stock location into another location

* Adds barcode scan handler for new functionality

* Handle scanning of stock location

* Cleanup

* Refactor existing barcode scanning functions

- Will require extensive testing and validation

* Add entry to release notes

* Delete dead code

* Improved ordering based on stock quantity

* Bug fix for 'adjustStock' function

* Improve error responses for barcode scanning

* Improve error responses for barcode scanning

* Remove old debug statements

* Add some extra explanatory texts

* Icon change

* Fixes for unit tests

* Adds extra functionality for user profile manager

* Refactor barcode code - do not rely on BuildContext

* Adds initial unit testing for barcode scanning

- Work on mocking barcode data
- Add hooks for testing snackBar and audio files

* Linting fixes

* More barcode unit tests

* Cleanup unit tests for barcode

* Remove unused import

* Handle HTTPException in API

* Improvements for API unit testing

* Unit testing for scanning item into location

* Add unit test for scanning in items from a location context

* Unit test for scanning location into parent location

* Improve feedback for barcode scanning events
This commit is contained in:
Oliver
2022-07-18 22:10:00 +10:00
committed by GitHub
parent c6678e201f
commit aa274b2e45
21 changed files with 711 additions and 255 deletions

View File

@ -57,6 +57,9 @@ class UserProfile {
}
}
/*
* Class for storing and managing user (server) profiles
*/
class UserProfileDBManager {
final store = StoreRef("profiles");
@ -96,6 +99,8 @@ class UserProfileDBManager {
if (exists) {
debug("addProfile() : UserProfile '${profile.name}' already exists");
return false;
} else {
debug("Adding new profile: '${profile.name}'");
}
int key = await store.add(await _db, profile.toJson()) as int;
@ -149,8 +154,6 @@ class UserProfileDBManager {
for (int idx = 0; idx < profiles.length; idx++) {
debug("- Checking ${idx} - key = ${profiles[idx].key} - ${profiles[idx].value.toString()}");
if (profiles[idx].key is int && profiles[idx].key == selected) {
return UserProfile.fromJson(
profiles[idx].key as int,
@ -190,6 +193,24 @@ class UserProfileDBManager {
return profileList;
}
/*
* Retrieve a profile by name (or null if no match exists)
*/
Future<UserProfile?> getProfileByName(String name) async {
final profiles = await getAllProfiles();
UserProfile? prf;
for (UserProfile profile in profiles) {
if (profile.name == name) {
prf = profile;
break;
}
}
return prf;
}
/*
* Mark the particular profile as selected
*/