Initial draft
This commit is contained in:
71
lib/model/tour.dart
Normal file
71
lib/model/tour.dart
Normal file
@ -0,0 +1,71 @@
|
||||
import 'package:hl_lieferservice/dto/payment.dart';
|
||||
|
||||
import 'car.dart';
|
||||
import 'delivery.dart';
|
||||
|
||||
class Payment {
|
||||
const Payment({
|
||||
required this.description,
|
||||
required this.shortcode,
|
||||
required this.id,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String description;
|
||||
final String shortcode;
|
||||
|
||||
factory Payment.fromDTO(PaymentMethodDTO dto) {
|
||||
return Payment(
|
||||
description: dto.description,
|
||||
shortcode: dto.shortCode,
|
||||
id: dto.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Tour {
|
||||
Tour({
|
||||
required this.date,
|
||||
required this.deliveries,
|
||||
required this.driver,
|
||||
required this.discountArticleNumber,
|
||||
required this.paymentMethods,
|
||||
});
|
||||
|
||||
final DateTime date;
|
||||
final String discountArticleNumber;
|
||||
Driver driver;
|
||||
final List<Delivery> deliveries;
|
||||
List<Payment> paymentMethods;
|
||||
|
||||
int getFinishedDeliveries(int carId) {
|
||||
return deliveries
|
||||
.where((delivery) => delivery.carId == carId)
|
||||
.where((delivery) => delivery.state == DeliveryState.finished)
|
||||
.toList()
|
||||
.length;
|
||||
}
|
||||
}
|
||||
|
||||
class Driver {
|
||||
Driver({
|
||||
required this.teamNumber,
|
||||
required this.name,
|
||||
required this.salutation,
|
||||
required this.cars,
|
||||
});
|
||||
|
||||
final int teamNumber;
|
||||
final String name;
|
||||
final String salutation;
|
||||
List<Car> cars;
|
||||
|
||||
/// If the driver is representing a company, then the company name is returned.
|
||||
String getSalutatedLastName() {
|
||||
if (salutation != "Firma") {
|
||||
return "$salutation, ${name.split(" ").first}";
|
||||
}
|
||||
|
||||
return "$salutation, $name";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user