2023-07-04 22:07:00 +02:00
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
2023-06-25 14:01:19 +02:00
|
|
|
final DateTime now = DateTime.now();
|
2023-06-23 13:03:17 +02:00
|
|
|
|
|
|
|
enum TransaktionArt { monatlBeitrag, aufladung, einkauf, korrektur }
|
|
|
|
|
|
|
|
enum Unit { stueck, menge }
|
|
|
|
|
2023-06-25 21:11:10 +02:00
|
|
|
class Category {
|
|
|
|
final String name;
|
|
|
|
final String icon;
|
|
|
|
const Category({required this.name, required this.icon});
|
2023-06-23 13:03:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class Transaction {
|
|
|
|
int id = 0;
|
|
|
|
int amount;
|
|
|
|
TransaktionArt type;
|
|
|
|
DateTime date;
|
2023-07-04 22:07:00 +02:00
|
|
|
Basket? basket;
|
2023-06-23 13:03:17 +02:00
|
|
|
String? description;
|
2023-06-25 14:01:19 +02:00
|
|
|
Transaction(
|
|
|
|
{required this.type,
|
|
|
|
required this.amount,
|
|
|
|
required this.date,
|
|
|
|
this.description,
|
|
|
|
this.basket});
|
2023-06-23 13:03:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class Product {
|
|
|
|
final int id = 0;
|
|
|
|
final String name;
|
2023-07-04 22:07:00 +02:00
|
|
|
final Unit unit; //pro Kg oder Stück
|
|
|
|
final double price;
|
2023-06-23 13:03:17 +02:00
|
|
|
final double vat;
|
|
|
|
final Category category;
|
|
|
|
const Product(this.name, this.unit, this.price, this.vat, this.category);
|
|
|
|
}
|
|
|
|
|
|
|
|
class Basket {
|
2023-07-04 22:07:00 +02:00
|
|
|
Map<Product, int> purchases;
|
|
|
|
double price;
|
|
|
|
String guid;
|
|
|
|
Basket(this.purchases, this.price) : guid = const Uuid().v4();
|
|
|
|
|
|
|
|
void addItem(Product product, int quantity) {
|
|
|
|
if (purchases.containsKey(product)) {
|
|
|
|
purchases.update(
|
|
|
|
product, (existingQuantity) => existingQuantity + quantity);
|
|
|
|
} else {
|
|
|
|
purchases[product] = quantity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeItem(Product product) {
|
|
|
|
purchases.remove(product);
|
|
|
|
}
|
2023-06-23 13:03:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class SampleData {
|
2023-06-25 21:11:10 +02:00
|
|
|
static const List<Category> categories = [
|
|
|
|
Category(name: 'Obst und Gemüse', icon: '🍒'),
|
|
|
|
Category(name: 'Kochen und Backen', icon: '🍝'),
|
|
|
|
Category(name: 'Brot, Cerealien & Aufstriche', icon: '🍞'),
|
|
|
|
Category(name: 'Getränke und Pfand', icon: '🫖'),
|
|
|
|
Category(name: 'Drogerie und Haushalt', icon: '🧼'),
|
|
|
|
Category(name: 'Öl, Soßen und Gewürze', icon: '🫚'),
|
|
|
|
Category(name: 'Süßes und Knabbereien', icon: '🍪')
|
|
|
|
];
|
|
|
|
|
|
|
|
static List<Product> products = [
|
|
|
|
Product('Apfel', Unit.stueck, 0.23, 7, categories[0]),
|
|
|
|
Product('Mehl', Unit.menge, 0.003, 19, categories[1]),
|
|
|
|
Product('Brot', Unit.stueck, 1.23, 7, categories[2]),
|
|
|
|
Product('Milch', Unit.stueck, 2.23, 3, categories[3]),
|
|
|
|
Product('Zahnpasta', Unit.stueck, 0.23, 7, categories[4]),
|
|
|
|
Product('Pfeffer', Unit.stueck, 0.23, 7, categories[5]),
|
|
|
|
Product('Schokolade', Unit.menge, 0.23, 7, categories[6]),
|
|
|
|
Product('Flaschenpfand', Unit.stueck, -0.15, 0, categories[3])
|
2023-06-23 13:03:17 +02:00
|
|
|
];
|
|
|
|
|
2023-07-04 22:07:00 +02:00
|
|
|
//such a basket can not exist later. It is for testing purposes
|
|
|
|
// when scrolling through a long basket
|
|
|
|
static Basket basket = Basket({
|
|
|
|
products[0]: 20,
|
|
|
|
products[1]: 2200,
|
|
|
|
products[2]: 2,
|
|
|
|
products[3]: 1,
|
|
|
|
products[4]: 1,
|
|
|
|
products[5]: 2,
|
|
|
|
products[6]: 222,
|
|
|
|
products[0]: 20,
|
|
|
|
products[1]: 2200,
|
|
|
|
products[2]: 2,
|
|
|
|
products[3]: 1,
|
|
|
|
products[4]: 1,
|
|
|
|
products[5]: 2,
|
|
|
|
products[6]: 222
|
|
|
|
}, 27.9);
|
2023-06-25 12:04:17 +02:00
|
|
|
|
2023-07-04 22:07:00 +02:00
|
|
|
static Basket basket2 = Basket({
|
|
|
|
products[0]: 22,
|
|
|
|
products[1]: 2241,
|
|
|
|
products[3]: 2,
|
|
|
|
products[4]: 4,
|
|
|
|
products[6]: 2,
|
|
|
|
products[7]: 5,
|
|
|
|
}, 34);
|
2023-06-25 12:04:17 +02:00
|
|
|
|
2023-07-04 22:07:00 +02:00
|
|
|
static Basket basket3 = Basket({
|
|
|
|
products[0]: 2,
|
|
|
|
products[1]: 21,
|
|
|
|
products[3]: 4,
|
|
|
|
products[4]: 1,
|
|
|
|
products[6]: 5,
|
|
|
|
}, -1);
|
2023-06-25 12:04:17 +02:00
|
|
|
|
|
|
|
List<Transaction> transactions = [
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.monatlBeitrag,
|
|
|
|
amount: 0,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.aufladung,
|
|
|
|
amount: 2042,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.einkauf,
|
|
|
|
amount: -2442,
|
|
|
|
date: now.subtract(const Duration(days: 2)),
|
|
|
|
basket: basket),
|
2023-06-25 12:04:17 +02:00
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.korrektur,
|
|
|
|
amount: 2332,
|
|
|
|
date: now.subtract(const Duration(hours: 5)),
|
2023-06-25 12:04:17 +02:00
|
|
|
description: 'Korrektur des Warenkorbs',
|
|
|
|
basket: basket3,
|
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.monatlBeitrag,
|
|
|
|
amount: 0,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.aufladung,
|
|
|
|
amount: 2042,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.einkauf,
|
|
|
|
amount: -2442,
|
|
|
|
date: now.subtract(const Duration(days: 2)),
|
2023-06-25 12:04:17 +02:00
|
|
|
basket: basket2),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.korrektur,
|
|
|
|
amount: 2332,
|
|
|
|
date: now.subtract(const Duration(hours: 5)),
|
|
|
|
description: 'Korrektur des FinanzAK'),
|
2023-06-25 12:04:17 +02:00
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.monatlBeitrag,
|
|
|
|
amount: 0,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.aufladung,
|
|
|
|
amount: 2042,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.einkauf,
|
|
|
|
amount: -2442,
|
|
|
|
date: now.subtract(const Duration(days: 2)),
|
2023-06-25 12:04:17 +02:00
|
|
|
basket: basket,
|
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.korrektur,
|
|
|
|
amount: 2332,
|
|
|
|
date: now.subtract(const Duration(hours: 5)),
|
2023-06-25 12:04:17 +02:00
|
|
|
description: 'Korrektur des Warenkorbs'),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.monatlBeitrag,
|
|
|
|
amount: 0,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.aufladung,
|
|
|
|
amount: 2042,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.einkauf,
|
|
|
|
amount: -2442,
|
|
|
|
date: now.subtract(const Duration(days: 2)),
|
|
|
|
basket: basket),
|
2023-06-25 12:04:17 +02:00
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.korrektur,
|
|
|
|
amount: 2332,
|
|
|
|
date: now.subtract(const Duration(hours: 5)),
|
2023-06-25 12:04:17 +02:00
|
|
|
description: 'Korrektur des Warenkorbs'),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.monatlBeitrag,
|
|
|
|
amount: 0,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.aufladung,
|
|
|
|
amount: 2042,
|
|
|
|
date: now,
|
2023-06-25 12:04:17 +02:00
|
|
|
),
|
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.einkauf,
|
|
|
|
amount: -2442,
|
|
|
|
date: now.subtract(const Duration(days: 2)),
|
|
|
|
basket: basket2),
|
2023-06-25 12:04:17 +02:00
|
|
|
Transaction(
|
2023-06-25 14:01:19 +02:00
|
|
|
type: TransaktionArt.korrektur,
|
|
|
|
amount: 2332,
|
|
|
|
date: now.subtract(const Duration(hours: 5)),
|
2023-06-25 12:04:17 +02:00
|
|
|
description: 'Korrektur des Warenkorbs'),
|
|
|
|
];
|
2023-06-23 13:03:17 +02:00
|
|
|
}
|