commande
This commit is contained in:
parent
d9998e1a79
commit
5434679d77
@ -17,7 +17,7 @@ class CommandeDetail {
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final List<CommandeItem> 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
|
||||
|
||||
@ -141,7 +141,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
||||
],
|
||||
),
|
||||
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<CaisseScreen> {
|
||||
),
|
||||
),
|
||||
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<CaisseScreen> {
|
||||
),
|
||||
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<CaisseScreen> {
|
||||
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<CaisseScreen> {
|
||||
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,
|
||||
|
||||
@ -460,16 +460,17 @@ class _CartPageState extends State<CartPage> {
|
||||
);
|
||||
|
||||
// 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é
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -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<FactureScreen> {
|
||||
),
|
||||
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<FactureScreen> {
|
||||
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),
|
||||
),
|
||||
],
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user