Initial commit

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-19 20:29:22 +01:00
commit f050d10a1d
137 changed files with 5877 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
class AppSettings {
AppSettings({
required this.rentUsd,
required this.occupied,
this.notOccupiedFromYearMonth,
this.localFallbackHour = 9,
this.localQuietHourStart = 23,
});
final double rentUsd;
final bool occupied;
final String? notOccupiedFromYearMonth;
final int localFallbackHour;
final int localQuietHourStart;
factory AppSettings.defaults() {
return AppSettings(rentUsd: 0, occupied: true);
}
AppSettings copyWith({
double? rentUsd,
bool? occupied,
String? notOccupiedFromYearMonth,
bool clearNotOccupiedFromYearMonth = false,
int? localFallbackHour,
int? localQuietHourStart,
}) {
return AppSettings(
rentUsd: rentUsd ?? this.rentUsd,
occupied: occupied ?? this.occupied,
notOccupiedFromYearMonth: clearNotOccupiedFromYearMonth
? null
: (notOccupiedFromYearMonth ?? this.notOccupiedFromYearMonth),
localFallbackHour: localFallbackHour ?? this.localFallbackHour,
localQuietHourStart: localQuietHourStart ?? this.localQuietHourStart,
);
}
Map<String, dynamic> toJson() {
return {
'rentUsd': rentUsd,
'occupied': occupied,
'notOccupiedFromYearMonth': notOccupiedFromYearMonth,
'localFallbackHour': localFallbackHour,
'localQuietHourStart': localQuietHourStart,
};
}
factory AppSettings.fromJson(Map<String, dynamic> json) {
return AppSettings(
rentUsd: (json['rentUsd'] ?? 0).toDouble(),
occupied: json['occupied'] ?? true,
notOccupiedFromYearMonth: json['notOccupiedFromYearMonth'] as String?,
localFallbackHour: json['localFallbackHour'] ?? 9,
localQuietHourStart: json['localQuietHourStart'] ?? 23,
);
}
}
+51
View File
@@ -0,0 +1,51 @@
enum PaymentStatus { onTime, late, notPaid, notOccupied, pending }
class MonthlyRentRecord {
MonthlyRentRecord({
required this.year,
required this.month,
required this.usdAmount,
required this.sekAmount,
required this.usdToSekRate,
required this.paidAtUtc,
required this.onTime,
required this.source,
});
final int year;
final int month;
final double usdAmount;
final double sekAmount;
final double usdToSekRate;
final DateTime paidAtUtc;
final bool onTime;
final String source;
String get key => '$year-${month.toString().padLeft(2, '0')}';
Map<String, dynamic> toJson() {
return {
'year': year,
'month': month,
'usdAmount': usdAmount,
'sekAmount': sekAmount,
'usdToSekRate': usdToSekRate,
'paidAtUtc': paidAtUtc.toIso8601String(),
'onTime': onTime,
'source': source,
};
}
factory MonthlyRentRecord.fromJson(Map<String, dynamic> json) {
return MonthlyRentRecord(
year: json['year'] as int,
month: json['month'] as int,
usdAmount: (json['usdAmount'] as num).toDouble(),
sekAmount: (json['sekAmount'] as num).toDouble(),
usdToSekRate: (json['usdToSekRate'] as num).toDouble(),
paidAtUtc: DateTime.parse(json['paidAtUtc'] as String).toUtc(),
onTime: json['onTime'] as bool,
source: (json['source'] as String?) ?? 'manual',
);
}
}