diff --git a/lib/models/command_detail.dart b/lib/models/command_detail.dart index a1c26d8..078ffc0 100644 --- a/lib/models/command_detail.dart +++ b/lib/models/command_detail.dart @@ -17,7 +17,7 @@ class CommandeDetail { final DateTime createdAt; final DateTime updatedAt; final List items; - final String? tablename; + late final String? tablename; CommandeDetail({ required this.id, @@ -56,7 +56,7 @@ class CommandeDetail { totalTtc: double.tryParse(data['total_ttc']?.toString() ?? '0') ?? 0.0, modePaiement: data['mode_paiement'], commentaires: data['commentaires'], - tablename: json['tablename'] ?? 'Inconnue', + tablename: data['tablename'], serveur: data['serveur'] ?? 'Serveur par défaut', dateCommande: data['date_commande'] != null diff --git a/lib/pages/caisse_screen.dart b/lib/pages/caisse_screen.dart index cda86a8..2d42b38 100644 --- a/lib/pages/caisse_screen.dart +++ b/lib/pages/caisse_screen.dart @@ -141,7 +141,7 @@ class _CaisseScreenState extends State { ], ), content: Text( - 'Le paiement de ${commande!.totalTtc.toStringAsFixed(2)} € a été traité avec succès via ${selectedPaymentMethod!.name}.', + 'Le paiement de ${commande!.totalTtc.toStringAsFixed(2)} MGA a été traité avec succès via ${selectedPaymentMethod!.name}.', ), actions: [ TextButton( @@ -226,7 +226,7 @@ class _CaisseScreenState extends State { ), ), Text( - '${commande!.totalTtc.toStringAsFixed(2)} €', + '${commande!.totalTtc.toStringAsFixed(2)} MGA', style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -295,7 +295,7 @@ class _CaisseScreenState extends State { ), const SizedBox(width: 12), Text( - '${item.totalItem.toStringAsFixed(2)} €', + '${item.totalItem.toStringAsFixed(2)} MGA', style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -398,7 +398,7 @@ class _CaisseScreenState extends State { const SizedBox(width: 16), Text( - '${amount.toStringAsFixed(2)} €', + '${amount.toStringAsFixed(2)} MGA', style: const TextStyle( color: Colors.white, fontSize: 18, @@ -460,7 +460,7 @@ class _CaisseScreenState extends State { const SizedBox(width: 8), Text( selectedPaymentMethod != null - ? 'Payer ${commande?.totalTtc.toStringAsFixed(2)} €' + ? 'Payer ${commande?.totalTtc.toStringAsFixed(2)} MGA' : 'Sélectionnez une méthode de paiement', style: const TextStyle( fontSize: 16, diff --git a/lib/pages/cart_page.dart b/lib/pages/cart_page.dart index 368a1f4..6002721 100644 --- a/lib/pages/cart_page.dart +++ b/lib/pages/cart_page.dart @@ -460,16 +460,17 @@ class _CartPageState extends State { ); // Convertir le Map en objet CommandeDetail - final commandeDetail = CommandeDetail.fromJson(commandeData['data']); + var commandeDetail = CommandeDetail.fromJson(commandeData['data']); - // Navigation avec l'objet converti Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => FactureScreen( - commande: - commandeDetail, // Maintenant c'est un objet CommandeDetail + commande: commandeDetail, paymentMethod: selectedPaymentMethod!.id, + tablename: + widget.tablename ?? + 'Table inconnue', // Passer comme paramètre séparé ), ), ); diff --git a/lib/pages/facture_screen.dart b/lib/pages/facture_screen.dart index f4975fb..4953123 100644 --- a/lib/pages/facture_screen.dart +++ b/lib/pages/facture_screen.dart @@ -9,11 +9,13 @@ import '../services/pdf_service.dart'; class FactureScreen extends StatefulWidget { final CommandeDetail commande; final String paymentMethod; + final String? tablename; const FactureScreen({ super.key, required this.commande, required this.paymentMethod, + this.tablename, }); @override @@ -157,7 +159,7 @@ class _FactureScreenState extends State { ), const SizedBox(height: 4), Text( - 'Via: ${widget.commande.tablename}', + 'Via: ${widget.commande?.tablename ?? widget.tablename}', style: const TextStyle(fontSize: 12, color: Colors.black87), ), const SizedBox(height: 4), @@ -236,7 +238,7 @@ class _FactureScreenState extends State { style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), Text( - '${widget.commande.totalTtc.toStringAsFixed(2)} €', + '${widget.commande.totalTtc.toStringAsFixed(2)} MGA', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), ], diff --git a/lib/services/pdf_service.dart b/lib/services/pdf_service.dart index 831c809..5adef41 100644 --- a/lib/services/pdf_service.dart +++ b/lib/services/pdf_service.dart @@ -125,10 +125,10 @@ class PlatformPrintService { fontWeight: pw.FontWeight.bold, ), ), - // pw.Text( - // 'Table: ${commande.tableName}', - // style: pw.TextStyle(fontSize: bodySize), - // ), + pw.Text( + 'Via: ${commande.tablename ?? 'Table inconnue'}', + style: pw.TextStyle(fontSize: bodySize), + ), ], ), @@ -169,7 +169,7 @@ class PlatformPrintService { children: [ // Nom du plat pw.Text( - "NOMPLAT", + '${item.menuNom}', style: pw.TextStyle(fontSize: bodySize), maxLines: 2, ), @@ -180,11 +180,11 @@ class PlatformPrintService { pw.MainAxisAlignment.spaceBetween, children: [ pw.Text( - '${item.quantite}x ${item.prixUnitaire.toStringAsFixed(2)}€', + '${item.quantite}x ${item.prixUnitaire.toStringAsFixed(2)}MGA', style: pw.TextStyle(fontSize: smallSize), ), pw.Text( - '${(item.prixUnitaire * item.quantite).toStringAsFixed(2)}€', + '${(item.prixUnitaire * item.quantite).toStringAsFixed(2)}MGA', style: pw.TextStyle( fontSize: bodySize, fontWeight: pw.FontWeight.bold, @@ -221,7 +221,7 @@ class PlatformPrintService { ), ), pw.Text( - '${commande.totalTtc.toStringAsFixed(2)}€', + '${commande.totalTtc.toStringAsFixed(2)}MGA', style: pw.TextStyle( fontSize: titleSize, fontWeight: pw.FontWeight.bold,