Daily commit

This commit is contained in:
Dennis Nemec
2026-02-05 10:46:13 +01:00
parent 4e808e234d
commit e0007dcf33
51 changed files with 2131 additions and 139 deletions

View File

@ -1,10 +1,129 @@
import 'supplier.dart';
import 'delivery.dart';
import 'package:json_annotation/json_annotation.dart';
import 'car.dart';
part 'tour.g.dart';
@JsonSerializable(fieldRename: FieldRename.snake)
class Article {
final int id;
final String title;
final int quantity;
final double pricePerQuantity;
final double depositPricePerQuantity;
final int quantityDelivered;
final int quantityReturned;
final int quantityToDeposit;
final int? referenceTo;
Article({
required this.id,
required this.title,
required this.quantity,
required this.pricePerQuantity,
required this.depositPricePerQuantity,
required this.quantityDelivered,
required this.quantityReturned,
required this.quantityToDeposit,
this.referenceTo,
});
factory Article.fromJson(Map<String, dynamic> json) => _$ArticleFromJson(json);
Map<String, dynamic> toJson() => _$ArticleToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Address {
final String street;
final String housingNumber;
final String postalCode;
final String city;
final String? country;
Address({
required this.street,
required this.housingNumber,
required this.postalCode,
required this.city,
this.country,
});
factory Address.fromJson(Map<String, dynamic> json) => _$AddressFromJson(json);
Map<String, dynamic> toJson() => _$AddressToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Customer {
final String name;
final int id;
final Address address;
Customer({
required this.name,
required this.id,
required this.address,
});
String get displayAddress => "${address.street} ${address.housingNumber}, ${address.postalCode} ${address.city}";
factory Customer.fromJson(Map<String, dynamic> json) => _$CustomerFromJson(json);
Map<String, dynamic> toJson() => _$CustomerToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Receipt {
final List<Article> articles;
final Customer customer;
final double totalGrossPrice;
final double totalNetPrice;
Receipt({
required this.articles,
required this.customer,
required this.totalGrossPrice,
required this.totalNetPrice,
});
factory Receipt.fromJson(Map<String, dynamic> json) => _$ReceiptFromJson(json);
Map<String, dynamic> toJson() => _$ReceiptToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Delivery {
final Receipt receipt;
final String informationForDriver;
final DateTime desiredDeliveryTime;
final DateTime? timeDelivered;
Delivery({
required this.receipt,
required this.informationForDriver,
required this.desiredDeliveryTime,
required this.timeDelivered,
});
factory Delivery.fromJson(Map<String, dynamic> json) => _$DeliveryFromJson(json);
Map<String, dynamic> toJson() => _$DeliveryToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Tour {
DateTime date;
Supplier supplier;
List<Delivery> deliveries;
final Car car;
final String date;
final List<Delivery> deliveries;
Tour({required this.date, required this.deliveries, required this.supplier});
Tour({
required this.car,
required this.date,
required this.deliveries,
});
int get amountDeliveries => deliveries.length;
int get amountFinishedDeliveries => deliveries.where((delivery) => delivery.timeDelivered != null).length;
int get amountDeliveriesLeft => amountDeliveries - amountFinishedDeliveries;
double get progress => amountFinishedDeliveries / amountDeliveries;
int get progressPercentage => (progress * 100).toInt();
factory Tour.fromJson(Map<String, dynamic> json) => _$TourFromJson(json);
Map<String, dynamic> toJson() => _$TourToJson(this);
}