Compare commits
No commits in common. "5ad019d35e08f7df3b75a7741d28b8ccc90de166" and "3e6a81c2c3b43e2a4ddf400b63dab722e4eedab8" have entirely different histories.
5ad019d35e
...
3e6a81c2c3
@ -8,8 +8,7 @@ plugins {
|
|||||||
android {
|
android {
|
||||||
namespace = "com.example.my_app"
|
namespace = "com.example.my_app"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = "26.3.11579264"
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
|||||||
@ -1447,61 +1447,58 @@ class AppDatabase {
|
|||||||
// --- TRANSACTIONS COMPLEXES ---
|
// --- TRANSACTIONS COMPLEXES ---
|
||||||
|
|
||||||
// Méthode pour créer une commande complète avec remises
|
// Méthode pour créer une commande complète avec remises
|
||||||
Future<int> createCommandeComplete(
|
Future<int> createCommandeComplete(
|
||||||
Client client, Commande commande, List<DetailCommande> details) async {
|
Client client, Commande commande, List<DetailCommande> details) async {
|
||||||
final db = await database;
|
final db = await database;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await db.query('START TRANSACTION');
|
await db.query('START TRANSACTION');
|
||||||
|
|
||||||
// 1. Créer ou récupérer le client
|
// 1. Créer ou récupérer le client
|
||||||
final existingOrNewClient = await createOrGetClient(client);
|
final existingOrNewClient = await createOrGetClient(client);
|
||||||
final clientId = existingOrNewClient.id!;
|
final clientId = existingOrNewClient.id!;
|
||||||
|
|
||||||
// 2. Créer la commande
|
// 2. Créer la commande
|
||||||
final commandeMap = commande.toMap();
|
final commandeMap = commande.toMap();
|
||||||
commandeMap.remove('id');
|
commandeMap.remove('id');
|
||||||
commandeMap['clientId'] = clientId;
|
commandeMap['clientId'] = clientId;
|
||||||
|
|
||||||
final commandeFields = commandeMap.keys.join(', ');
|
final commandeFields = commandeMap.keys.join(', ');
|
||||||
final commandePlaceholders = List.filled(commandeMap.length, '?').join(', ');
|
final commandePlaceholders =
|
||||||
|
List.filled(commandeMap.length, '?').join(', ');
|
||||||
|
|
||||||
final commandeResult = await db.query(
|
final commandeResult = await db.query(
|
||||||
'INSERT INTO commandes ($commandeFields) VALUES ($commandePlaceholders)',
|
'INSERT INTO commandes ($commandeFields) VALUES ($commandePlaceholders)',
|
||||||
commandeMap.values.toList(),
|
commandeMap.values.toList());
|
||||||
);
|
final commandeId = commandeResult.insertId!;
|
||||||
final commandeId = commandeResult.insertId!;
|
|
||||||
|
|
||||||
// 3. Créer les détails de commande avec remises
|
// 3. Créer les détails de commande avec remises
|
||||||
for (final detail in details) {
|
for (final detail in details) {
|
||||||
final detailMap = detail.toMap();
|
final detailMap = detail.toMap();
|
||||||
detailMap.remove('id');
|
detailMap.remove('id');
|
||||||
detailMap['commandeId'] = commandeId;
|
detailMap['commandeId'] = commandeId;
|
||||||
|
|
||||||
final detailFields = detailMap.keys.join(', ');
|
final detailFields = detailMap.keys.join(', ');
|
||||||
final detailPlaceholders = List.filled(detailMap.length, '?').join(', ');
|
final detailPlaceholders =
|
||||||
|
List.filled(detailMap.length, '?').join(', ');
|
||||||
|
|
||||||
await db.query(
|
await db.query(
|
||||||
'INSERT INTO details_commandes ($detailFields) VALUES ($detailPlaceholders)',
|
'INSERT INTO details_commandes ($detailFields) VALUES ($detailPlaceholders)',
|
||||||
detailMap.values.toList(),
|
detailMap.values.toList());
|
||||||
);
|
|
||||||
|
|
||||||
// 4. Mettre à jour le stock
|
// 4. Mettre à jour le stock
|
||||||
await db.query(
|
await db.query('UPDATE products SET stock = stock - ? WHERE id = ?',
|
||||||
'UPDATE products SET stock = stock - ? WHERE id = ?',
|
[detail.quantite, detail.produitId]);
|
||||||
[detail.quantite, detail.produitId],
|
}
|
||||||
);
|
|
||||||
|
await db.query('COMMIT');
|
||||||
|
return commandeId;
|
||||||
|
} catch (e) {
|
||||||
|
await db.query('ROLLBACK');
|
||||||
|
print("Erreur lors de la création de la commande complète: $e");
|
||||||
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.query('COMMIT');
|
|
||||||
return commandeId;
|
|
||||||
} catch (e) {
|
|
||||||
await db.query('ROLLBACK');
|
|
||||||
print("Erreur lors de la création de la commande complète: $e");
|
|
||||||
rethrow;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Méthode pour mettre à jour un détail de commande (utile pour modifier les remises)
|
// Méthode pour mettre à jour un détail de commande (utile pour modifier les remises)
|
||||||
Future<int> updateDetailCommande(DetailCommande detail) async {
|
Future<int> updateDetailCommande(DetailCommande detail) async {
|
||||||
|
|||||||
@ -52,7 +52,6 @@ class _ApprobationSortiesPageState extends State<ApprobationSortiesPage> {
|
|||||||
Text('Quantité: ${sortie['quantite']}'),
|
Text('Quantité: ${sortie['quantite']}'),
|
||||||
Text('Demandeur: ${sortie['admin_nom']}'),
|
Text('Demandeur: ${sortie['admin_nom']}'),
|
||||||
Text('Motif: ${sortie['motif']}'),
|
Text('Motif: ${sortie['motif']}'),
|
||||||
Text('Note: ${sortie['notes']}'),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
const Text(
|
const Text(
|
||||||
'Confirmer l\'approbation de cette demande de sortie personnelle ?',
|
'Confirmer l\'approbation de cette demande de sortie personnelle ?',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -177,7 +177,7 @@ void _login() async {
|
|||||||
|
|
||||||
// 6. Navigation immédiate
|
// 6. Navigation immédiate
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
if (userCredentials['role'] == 'commercial' || userCredentials['role'] == 'caisse') {
|
if (userCredentials['role'] == 'commercial') {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => const MainLayout()),
|
MaterialPageRoute(builder: (context) => const MainLayout()),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
16
pubspec.lock
16
pubspec.lock
@ -37,10 +37,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
|
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.12.0"
|
version: "2.13.0"
|
||||||
barcode:
|
barcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -181,10 +181,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
|
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.3.3"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -516,10 +516,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
|
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.8"
|
version: "10.0.9"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1193,10 +1193,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
|
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.3.1"
|
version: "15.0.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user