diff --git a/lib/pages/operation/reception/reception_details_page.dart b/lib/pages/operation/reception/reception_details_page.dart index 6e975af..3c36b7a 100644 --- a/lib/pages/operation/reception/reception_details_page.dart +++ b/lib/pages/operation/reception/reception_details_page.dart @@ -39,101 +39,103 @@ class _ReceptionDetailsPageState extends ConsumerState { ), body: state.loading ? Center(child: LoadingProgressComponent()) - : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: ListView( - children: [ - const SizedBox(height: 16), - if (reception?.isDone == false) ...[ - QuickActionComponent( - onTapScan: () { - final id = reception?.id; - if (id == null) return; - ReceptionScanRoute(receptionId: id).push(context); - }, - ), + : 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: [ const SizedBox(height: 16), - ], - Text( - 'Détails réception', - style: AppTheme.of( - context, - ).bodyMedium.copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: 10), - StockPickingCard( - isDone: reception?.isDone == true, - margin: EdgeInsets.symmetric(horizontal: 5), - reference: reception?.name ?? '', - from: reception?.locationId.target?.completeName, - to: reception?.locationDestId.target?.completeName, - contact: reception?.partnerId.target?.displayName, - origin: reception?.origin, - status: reception?.state, - ), - SizedBox(height: 20), - ListView( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - primary: true, - children: [ - Text( - 'Produits', - style: AppTheme.of( - context, - ).bodyMedium.copyWith(fontWeight: FontWeight.bold), + if (reception?.isDone == false) ...[ + QuickActionComponent( + onTapScan: () { + final id = reception?.id; + if (id == null) return; + ReceptionScanRoute(receptionId: id).push(context); + }, ), - SizedBox(height: 10), - ...reception?.moveIdsWithoutPackage - .map( - (move) => Card( - color: AppTheme.of(context).primaryBackground, - child: ListTile( - title: Text( - move.productId.target?.displayName ?? '', - style: TextStyle(color: Colors.black), - ), - subtitle: Wrap( - spacing: 5, - children: [ - Chip( - backgroundColor: AppTheme.of( - context, - ).secondaryBackground, - label: Text( - "Qté demandée: ${move.productUomQty}", + const SizedBox(height: 16), + ], + Text( + 'Détails réception', + style: AppTheme.of( + context, + ).bodyMedium.copyWith(fontWeight: FontWeight.bold), + ), + SizedBox(height: 10), + StockPickingCard( + isDone: reception?.isDone == true, + margin: EdgeInsets.symmetric(horizontal: 5), + reference: reception?.name ?? '', + from: reception?.locationId.target?.completeName, + to: reception?.locationDestId.target?.completeName, + contact: reception?.partnerId.target?.displayName, + origin: reception?.origin, + status: reception?.state, + ), + SizedBox(height: 20), + Text( + 'Produits', + style: AppTheme.of( + context, + ).bodyMedium.copyWith(fontWeight: FontWeight.bold), + ), + SizedBox(height: 10), + ...reception?.moveIdsWithoutPackage + .map( + (move) => Card( + color: AppTheme.of(context).primaryBackground, + child: ListTile( + title: Text( + move.productId.target?.displayName ?? '', + style: TextStyle(color: Colors.black), + ), + subtitle: Wrap( + spacing: 5, + children: [ + Chip( + backgroundColor: AppTheme.of( + context, + ).secondaryBackground, + label: Text( + "Qté demandée: ${move.productUomQty}", + ), + ), + Chip( + backgroundColor: AppTheme.of( + context, + ).secondaryBackground, + label: Text( + "Qté reçue: ${move.quantity}", + ), + ), + Chip( + backgroundColor: AppTheme.of( + context, + ).secondaryBackground, + label: Text( + "Ecart: ${move.ecart}", + style: TextStyle( + color: Colors.green, + fontWeight: FontWeight.bold, ), ), - Chip( - backgroundColor: AppTheme.of( - context, - ).secondaryBackground, - label: Text( - "Qté reçue: ${move.quantity}", - ), - ), - Chip( - backgroundColor: AppTheme.of( - context, - ).secondaryBackground, - label: Text( - "Ecart: ${move.ecart}", - style: TextStyle( - color: Colors.green, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), + ), + ], ), ), - ) - .toList() ?? - [], - ], - ), - ], + ), + ) + .toList() ?? + [], + ], + ), ), ), floatingActionButton: reception?.isDone == false diff --git a/lib/pages/operation/reception/reception_scan_page_model.dart b/lib/pages/operation/reception/reception_scan_page_model.dart index 3ac4734..17a863d 100644 --- a/lib/pages/operation/reception/reception_scan_page_model.dart +++ b/lib/pages/operation/reception/reception_scan_page_model.dart @@ -52,6 +52,7 @@ class ReceptionScanPageModel void incrementMoveLineQuantity({required String barcode}) { final moveLineBox = objectboxManager.store .box(); + final moveBox = objectboxManager.store.box(); final productBox = objectboxManager.store.box(); 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); } } }