You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
64 lines
1.3 KiB
import 'package:youmazgestion/Components/paymentType.dart';
|
|
import 'package:youmazgestion/Models/produit.dart';
|
|
|
|
class Remise {
|
|
final RemiseType type;
|
|
final double valeur;
|
|
final String description;
|
|
|
|
Remise({
|
|
required this.type,
|
|
required this.valeur,
|
|
this.description = '',
|
|
});
|
|
|
|
double calculerRemise(double montantOriginal) {
|
|
switch (type) {
|
|
case RemiseType.pourcentage:
|
|
return montantOriginal * (valeur / 100);
|
|
case RemiseType.fixe:
|
|
return valeur;
|
|
}
|
|
}
|
|
|
|
String get libelle {
|
|
switch (type) {
|
|
case RemiseType.pourcentage:
|
|
return '$valeur%';
|
|
case RemiseType.fixe:
|
|
return '${valeur.toStringAsFixed(0)} MGA';
|
|
}
|
|
}
|
|
}
|
|
|
|
enum RemiseType { pourcentage, fixe }
|
|
|
|
class ProduitCadeau {
|
|
final Product produit;
|
|
final String motif;
|
|
|
|
ProduitCadeau({
|
|
required this.produit,
|
|
this.motif = 'Cadeau client',
|
|
});
|
|
}
|
|
|
|
// Modifiez votre classe PaymentMethod pour inclure la remise
|
|
class PaymentMethodEnhanced {
|
|
final PaymentType type;
|
|
final double amountGiven;
|
|
final Remise? remise;
|
|
|
|
PaymentMethodEnhanced({
|
|
required this.type,
|
|
this.amountGiven = 0,
|
|
this.remise,
|
|
});
|
|
|
|
double calculerMontantFinal(double montantOriginal) {
|
|
if (remise != null) {
|
|
return montantOriginal - remise!.calculerRemise(montantOriginal);
|
|
}
|
|
return montantOriginal;
|
|
}
|
|
}
|