commande
This commit is contained in:
parent
d9998e1a79
commit
5434679d77
@ -17,7 +17,7 @@ class CommandeDetail {
|
|||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
final DateTime updatedAt;
|
final DateTime updatedAt;
|
||||||
final List<CommandeItem> items;
|
final List<CommandeItem> items;
|
||||||
final String? tablename;
|
late final String? tablename;
|
||||||
|
|
||||||
CommandeDetail({
|
CommandeDetail({
|
||||||
required this.id,
|
required this.id,
|
||||||
@ -56,7 +56,7 @@ class CommandeDetail {
|
|||||||
totalTtc: double.tryParse(data['total_ttc']?.toString() ?? '0') ?? 0.0,
|
totalTtc: double.tryParse(data['total_ttc']?.toString() ?? '0') ?? 0.0,
|
||||||
modePaiement: data['mode_paiement'],
|
modePaiement: data['mode_paiement'],
|
||||||
commentaires: data['commentaires'],
|
commentaires: data['commentaires'],
|
||||||
tablename: json['tablename'] ?? 'Inconnue',
|
tablename: data['tablename'],
|
||||||
serveur: data['serveur'] ?? 'Serveur par défaut',
|
serveur: data['serveur'] ?? 'Serveur par défaut',
|
||||||
dateCommande:
|
dateCommande:
|
||||||
data['date_commande'] != null
|
data['date_commande'] != null
|
||||||
|
|||||||
@ -141,7 +141,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
content: Text(
|
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: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
@ -226,7 +226,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${commande!.totalTtc.toStringAsFixed(2)} €',
|
'${commande!.totalTtc.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -295,7 +295,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Text(
|
Text(
|
||||||
'${item.totalItem.toStringAsFixed(2)} €',
|
'${item.totalItem.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
@ -398,7 +398,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
|||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
'${amount.toStringAsFixed(2)} €',
|
'${amount.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@ -460,7 +460,7 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
selectedPaymentMethod != null
|
selectedPaymentMethod != null
|
||||||
? 'Payer ${commande?.totalTtc.toStringAsFixed(2)} €'
|
? 'Payer ${commande?.totalTtc.toStringAsFixed(2)} MGA'
|
||||||
: 'Sélectionnez une méthode de paiement',
|
: 'Sélectionnez une méthode de paiement',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
|||||||
@ -460,16 +460,17 @@ class _CartPageState extends State<CartPage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Convertir le Map en objet CommandeDetail
|
// 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(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder:
|
builder:
|
||||||
(context) => FactureScreen(
|
(context) => FactureScreen(
|
||||||
commande:
|
commande: commandeDetail,
|
||||||
commandeDetail, // Maintenant c'est un objet CommandeDetail
|
|
||||||
paymentMethod: selectedPaymentMethod!.id,
|
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 {
|
class FactureScreen extends StatefulWidget {
|
||||||
final CommandeDetail commande;
|
final CommandeDetail commande;
|
||||||
final String paymentMethod;
|
final String paymentMethod;
|
||||||
|
final String? tablename;
|
||||||
|
|
||||||
const FactureScreen({
|
const FactureScreen({
|
||||||
super.key,
|
super.key,
|
||||||
required this.commande,
|
required this.commande,
|
||||||
required this.paymentMethod,
|
required this.paymentMethod,
|
||||||
|
this.tablename,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -157,7 +159,7 @@ class _FactureScreenState extends State<FactureScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'Via: ${widget.commande.tablename}',
|
'Via: ${widget.commande?.tablename ?? widget.tablename}',
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.black87),
|
style: const TextStyle(fontSize: 12, color: Colors.black87),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
@ -236,7 +238,7 @@ class _FactureScreenState extends State<FactureScreen> {
|
|||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${widget.commande.totalTtc.toStringAsFixed(2)} €',
|
'${widget.commande.totalTtc.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -125,10 +125,10 @@ class PlatformPrintService {
|
|||||||
fontWeight: pw.FontWeight.bold,
|
fontWeight: pw.FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// pw.Text(
|
pw.Text(
|
||||||
// 'Table: ${commande.tableName}',
|
'Via: ${commande.tablename ?? 'Table inconnue'}',
|
||||||
// style: pw.TextStyle(fontSize: bodySize),
|
style: pw.TextStyle(fontSize: bodySize),
|
||||||
// ),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ class PlatformPrintService {
|
|||||||
children: [
|
children: [
|
||||||
// Nom du plat
|
// Nom du plat
|
||||||
pw.Text(
|
pw.Text(
|
||||||
"NOMPLAT",
|
'${item.menuNom}',
|
||||||
style: pw.TextStyle(fontSize: bodySize),
|
style: pw.TextStyle(fontSize: bodySize),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
),
|
),
|
||||||
@ -180,11 +180,11 @@ class PlatformPrintService {
|
|||||||
pw.MainAxisAlignment.spaceBetween,
|
pw.MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
pw.Text(
|
pw.Text(
|
||||||
'${item.quantite}x ${item.prixUnitaire.toStringAsFixed(2)}€',
|
'${item.quantite}x ${item.prixUnitaire.toStringAsFixed(2)}MGA',
|
||||||
style: pw.TextStyle(fontSize: smallSize),
|
style: pw.TextStyle(fontSize: smallSize),
|
||||||
),
|
),
|
||||||
pw.Text(
|
pw.Text(
|
||||||
'${(item.prixUnitaire * item.quantite).toStringAsFixed(2)}€',
|
'${(item.prixUnitaire * item.quantite).toStringAsFixed(2)}MGA',
|
||||||
style: pw.TextStyle(
|
style: pw.TextStyle(
|
||||||
fontSize: bodySize,
|
fontSize: bodySize,
|
||||||
fontWeight: pw.FontWeight.bold,
|
fontWeight: pw.FontWeight.bold,
|
||||||
@ -221,7 +221,7 @@ class PlatformPrintService {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
pw.Text(
|
pw.Text(
|
||||||
'${commande.totalTtc.toStringAsFixed(2)}€',
|
'${commande.totalTtc.toStringAsFixed(2)}MGA',
|
||||||
style: pw.TextStyle(
|
style: pw.TextStyle(
|
||||||
fontSize: titleSize,
|
fontSize: titleSize,
|
||||||
fontWeight: pw.FontWeight.bold,
|
fontWeight: pw.FontWeight.bold,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user