enhance: Enhances reception details with refresh and syncs scan quantities
Adds pull-to-refresh functionality to the reception details page, allowing users to manually update the displayed information. Ensures that when a product is scanned, both the move line and the main move entities have their quantities correctly incremented, improving data consistency.
This commit is contained in:
parent
da2c3ac4f0
commit
46b93d7fa4
@ -39,7 +39,15 @@ class _ReceptionDetailsPageState extends ConsumerState<ReceptionDetailsPage> {
|
||||
),
|
||||
body: state.loading
|
||||
? Center(child: LoadingProgressComponent())
|
||||
: Padding(
|
||||
: RefreshIndicator(
|
||||
color: AppTheme.of(context).white,
|
||||
backgroundColor: AppTheme.of(context).primary,
|
||||
onRefresh: () async {
|
||||
await ref
|
||||
.read(receptionDetailsPageModelProvider.notifier)
|
||||
.getReceptionById(id: widget.receptionId);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ListView(
|
||||
children: [
|
||||
@ -72,11 +80,6 @@ class _ReceptionDetailsPageState extends ConsumerState<ReceptionDetailsPage> {
|
||||
status: reception?.state,
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ListView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
primary: true,
|
||||
children: [
|
||||
Text(
|
||||
'Produits',
|
||||
style: AppTheme.of(
|
||||
@ -133,7 +136,6 @@ class _ReceptionDetailsPageState extends ConsumerState<ReceptionDetailsPage> {
|
||||
[],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: reception?.isDone == false
|
||||
|
@ -52,6 +52,7 @@ class ReceptionScanPageModel
|
||||
void incrementMoveLineQuantity({required String barcode}) {
|
||||
final moveLineBox = objectboxManager.store
|
||||
.box<MoveLineWithoutPackageEntity>();
|
||||
final moveBox = objectboxManager.store.box<MoveWithoutPackageEntity>();
|
||||
final productBox = objectboxManager.store.box<ProductEntity>();
|
||||
final productEntity = productBox
|
||||
.query(ProductEntity_.barcode.equals(barcode))
|
||||
@ -63,9 +64,15 @@ class ReceptionScanPageModel
|
||||
.query(MoveLineWithoutPackageEntity_.productId.equals(productId))
|
||||
.build()
|
||||
.findFirst();
|
||||
if (moveLineEntity != null) {
|
||||
final moveEntity = moveBox
|
||||
.query(MoveWithoutPackageEntity_.productId.equals(productId))
|
||||
.build()
|
||||
.findFirst();
|
||||
if (moveLineEntity != null && moveEntity != null) {
|
||||
moveLineEntity.quantity = (moveLineEntity.quantity ?? 0) + 1;
|
||||
moveEntity.quantity = (moveEntity.quantity ?? 0) + 1;
|
||||
moveLineBox.put(moveLineEntity);
|
||||
moveBox.put(moveEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user