Daily commit
This commit is contained in:
@ -1,7 +1,19 @@
|
||||
class Car {
|
||||
String id;
|
||||
String carName;
|
||||
String? driverName;
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
Car({required this.id, required this.carName, this.driverName});
|
||||
}
|
||||
part 'car.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Car {
|
||||
final int id;
|
||||
final String carName;
|
||||
final String? driverName;
|
||||
|
||||
Car({
|
||||
required this.id,
|
||||
required this.carName,
|
||||
this.driverName,
|
||||
});
|
||||
|
||||
factory Car.fromJson(Map<String, dynamic> json) => _$CarFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CarToJson(this);
|
||||
}
|
||||
|
||||
19
lib/model/car.g.dart
Normal file
19
lib/model/car.g.dart
Normal file
@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'car.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Car _$CarFromJson(Map<String, dynamic> json) => Car(
|
||||
id: (json['id'] as num).toInt(),
|
||||
carName: json['car_name'] as String,
|
||||
driverName: json['driver_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CarToJson(Car instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'car_name': instance.carName,
|
||||
'driver_name': instance.driverName,
|
||||
};
|
||||
@ -7,13 +7,14 @@ class Delivery {
|
||||
|
||||
DateTime? deliveredAt;
|
||||
DateTime? desiredDeliveryTime;
|
||||
String? driverInformation;
|
||||
|
||||
String? informationForDriver;
|
||||
|
||||
Delivery({
|
||||
required this.receipt,
|
||||
|
||||
this.desiredDeliveryTime,
|
||||
this.driverInformation,
|
||||
this.informationForDriver,
|
||||
this.deliveredAt
|
||||
});
|
||||
}
|
||||
@ -16,3 +16,21 @@ class Supplier {
|
||||
required this.address,
|
||||
});
|
||||
}
|
||||
|
||||
/// Contains information about the cars the supplier has and how many
|
||||
/// deliveries they have per car.
|
||||
class SupplierTourMetadata {
|
||||
String date;
|
||||
|
||||
/// The list of cars the supplier has and how many deliveries they have per car.
|
||||
List<TourMetadata> tours;
|
||||
|
||||
SupplierTourMetadata({required this.date, required this.tours});
|
||||
}
|
||||
|
||||
class TourMetadata {
|
||||
Car car;
|
||||
int amountDeliveries;
|
||||
|
||||
TourMetadata({required this.car, required this.amountDeliveries});
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
106
lib/model/tour.g.dart
Normal file
106
lib/model/tour.g.dart
Normal file
@ -0,0 +1,106 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'tour.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Article _$ArticleFromJson(Map<String, dynamic> json) => Article(
|
||||
id: (json['id'] as num).toInt(),
|
||||
title: json['title'] as String,
|
||||
quantity: (json['quantity'] as num).toInt(),
|
||||
pricePerQuantity: (json['price_per_quantity'] as num).toDouble(),
|
||||
depositPricePerQuantity: (json['deposit_price_per_quantity'] as num)
|
||||
.toDouble(),
|
||||
quantityDelivered: (json['quantity_delivered'] as num).toInt(),
|
||||
quantityReturned: (json['quantity_returned'] as num).toInt(),
|
||||
quantityToDeposit: (json['quantity_to_deposit'] as num).toInt(),
|
||||
referenceTo: (json['reference_to'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ArticleToJson(Article instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'quantity': instance.quantity,
|
||||
'price_per_quantity': instance.pricePerQuantity,
|
||||
'deposit_price_per_quantity': instance.depositPricePerQuantity,
|
||||
'quantity_delivered': instance.quantityDelivered,
|
||||
'quantity_returned': instance.quantityReturned,
|
||||
'quantity_to_deposit': instance.quantityToDeposit,
|
||||
'reference_to': instance.referenceTo,
|
||||
};
|
||||
|
||||
Address _$AddressFromJson(Map<String, dynamic> json) => Address(
|
||||
street: json['street'] as String,
|
||||
housingNumber: json['housing_number'] as String,
|
||||
postalCode: json['postal_code'] as String,
|
||||
city: json['city'] as String,
|
||||
country: json['country'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AddressToJson(Address instance) => <String, dynamic>{
|
||||
'street': instance.street,
|
||||
'housing_number': instance.housingNumber,
|
||||
'postal_code': instance.postalCode,
|
||||
'city': instance.city,
|
||||
'country': instance.country,
|
||||
};
|
||||
|
||||
Customer _$CustomerFromJson(Map<String, dynamic> json) => Customer(
|
||||
name: json['name'] as String,
|
||||
id: (json['id'] as num).toInt(),
|
||||
address: Address.fromJson(json['address'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CustomerToJson(Customer instance) => <String, dynamic>{
|
||||
'name': instance.name,
|
||||
'id': instance.id,
|
||||
'address': instance.address,
|
||||
};
|
||||
|
||||
Receipt _$ReceiptFromJson(Map<String, dynamic> json) => Receipt(
|
||||
articles: (json['articles'] as List<dynamic>)
|
||||
.map((e) => Article.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
customer: Customer.fromJson(json['customer'] as Map<String, dynamic>),
|
||||
totalGrossPrice: (json['total_gross_price'] as num).toDouble(),
|
||||
totalNetPrice: (json['total_net_price'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ReceiptToJson(Receipt instance) => <String, dynamic>{
|
||||
'articles': instance.articles,
|
||||
'customer': instance.customer,
|
||||
'total_gross_price': instance.totalGrossPrice,
|
||||
'total_net_price': instance.totalNetPrice,
|
||||
};
|
||||
|
||||
Delivery _$DeliveryFromJson(Map<String, dynamic> json) => Delivery(
|
||||
receipt: Receipt.fromJson(json['receipt'] as Map<String, dynamic>),
|
||||
informationForDriver: json['information_for_driver'] as String,
|
||||
desiredDeliveryTime: DateTime.parse(json['desired_delivery_time'] as String),
|
||||
timeDelivered: json['time_delivered'] == null
|
||||
? null
|
||||
: DateTime.parse(json['time_delivered'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$DeliveryToJson(Delivery instance) => <String, dynamic>{
|
||||
'receipt': instance.receipt,
|
||||
'information_for_driver': instance.informationForDriver,
|
||||
'desired_delivery_time': instance.desiredDeliveryTime.toIso8601String(),
|
||||
'time_delivered': instance.timeDelivered?.toIso8601String(),
|
||||
};
|
||||
|
||||
Tour _$TourFromJson(Map<String, dynamic> json) => Tour(
|
||||
car: Car.fromJson(json['car'] as Map<String, dynamic>),
|
||||
date: json['date'] as String,
|
||||
deliveries: (json['deliveries'] as List<dynamic>)
|
||||
.map((e) => Delivery.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TourToJson(Tour instance) => <String, dynamic>{
|
||||
'car': instance.car,
|
||||
'date': instance.date,
|
||||
'deliveries': instance.deliveries,
|
||||
};
|
||||
Reference in New Issue
Block a user