Compare commits
No commits in common. "e40f0491fc464ba8eb785428941a447bccfec4e6" and "17a3a1ce200ab0a85bf10d9deb47f0476b8c985a" have entirely different histories.
e40f0491fc
...
17a3a1ce20
3 changed files with 21 additions and 83 deletions
|
@ -6,7 +6,6 @@
|
||||||
- Added pie chart for expense/income data per category
|
- Added pie chart for expense/income data per category
|
||||||
- Added recurring entries
|
- Added recurring entries
|
||||||
- Fixed wrong default sorting
|
- Fixed wrong default sorting
|
||||||
- Differentiate expense and income on home view
|
|
||||||
# 1.0.0-alpha+2
|
# 1.0.0-alpha+2
|
||||||
- Fixed localization issues
|
- Fixed localization issues
|
||||||
- Added graphs for expenses and income per month/year
|
- Added graphs for expenses and income per month/year
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:currency_picker/currency_picker.dart';
|
import 'package:currency_picker/currency_picker.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
import 'package:logger/logger.dart';
|
|
||||||
import 'package:prasule/api/category.dart';
|
import 'package:prasule/api/category.dart';
|
||||||
import 'package:prasule/api/recurring_entry.dart';
|
import 'package:prasule/api/recurring_entry.dart';
|
||||||
import 'package:prasule/api/wallet_entry.dart';
|
import 'package:prasule/api/wallet_entry.dart';
|
||||||
|
@ -57,11 +56,9 @@ class Wallet {
|
||||||
/// Getter for the next unused unique number ID in the wallet's **entry** list
|
/// Getter for the next unused unique number ID in the wallet's **entry** list
|
||||||
int get nextId {
|
int get nextId {
|
||||||
var id = 1;
|
var id = 1;
|
||||||
logger.d("Making ID after ${entries.length} entries");
|
|
||||||
while (entries.where((element) => element.id == id).isNotEmpty) {
|
while (entries.where((element) => element.id == id).isNotEmpty) {
|
||||||
id++; // create unique ID
|
id++; // create unique ID
|
||||||
}
|
}
|
||||||
logger.d("New ID: $id\nLast entry ID: ${entries.lastOrNull?.id}");
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,57 +91,33 @@ class Wallet {
|
||||||
while (n.isAfter(
|
while (n.isAfter(
|
||||||
m,
|
m,
|
||||||
)) {
|
)) {
|
||||||
logger
|
logger.i("Adding recurring entry ${ent.data.name}");
|
||||||
..i("Adding recurring entry ${ent.data.name}")
|
|
||||||
..d("Current entry count: ${entries.length}");
|
|
||||||
recurringEntries[recurringEntries.indexOf(ent)].lastRunDate =
|
recurringEntries[recurringEntries.indexOf(ent)].lastRunDate =
|
||||||
m; // update date on recurring entry
|
m; // update date on recurring entry
|
||||||
logger.i(recurringEntries[recurringEntries.indexOf(ent)].lastRunDate);
|
logger.i(recurringEntries[recurringEntries.indexOf(ent)].lastRunDate);
|
||||||
|
final addedEntry = (recurringEntries[recurringEntries.indexOf(ent)]
|
||||||
var id = 1;
|
as WalletSingleEntry)
|
||||||
logger.d("Making ID after ${entries.length} entries");
|
..date = DateTime.now()
|
||||||
while (entries.where((element) => element.id == id).isNotEmpty) {
|
..id = nextId; // copy entry with today's date and unique ID
|
||||||
id++; // create unique ID
|
entries.add(
|
||||||
}
|
addedEntry,
|
||||||
logger.d("New ID: $id\nLast entry ID: ${entries.lastOrNull?.id}");
|
); // add it to entries
|
||||||
|
|
||||||
final addedEntry = WalletSingleEntry(
|
|
||||||
data: recurringEntries[recurringEntries.indexOf(ent)].data,
|
|
||||||
type: recurringEntries[recurringEntries.indexOf(ent)].type,
|
|
||||||
date: m,
|
|
||||||
category: recurringEntries[recurringEntries.indexOf(ent)].category,
|
|
||||||
id: id,
|
|
||||||
);
|
|
||||||
|
|
||||||
entries.add(addedEntry);
|
|
||||||
|
|
||||||
m = DateTime(
|
m = DateTime(
|
||||||
(ent.recurType == RecurType.year)
|
(ent.recurType == RecurType.year)
|
||||||
? recurringEntries[recurringEntries.indexOf(ent)]
|
? ent.lastRunDate.year + ent.repeatAfter
|
||||||
.lastRunDate
|
: ent.lastRunDate.year,
|
||||||
.year +
|
|
||||||
ent.repeatAfter
|
|
||||||
: recurringEntries[recurringEntries.indexOf(ent)]
|
|
||||||
.lastRunDate
|
|
||||||
.year,
|
|
||||||
(ent.recurType == RecurType.month)
|
(ent.recurType == RecurType.month)
|
||||||
? recurringEntries[recurringEntries.indexOf(ent)]
|
? ent.lastRunDate.month + ent.repeatAfter
|
||||||
.lastRunDate
|
: ent.lastRunDate.month,
|
||||||
.month +
|
|
||||||
ent.repeatAfter
|
|
||||||
: recurringEntries[recurringEntries.indexOf(ent)]
|
|
||||||
.lastRunDate
|
|
||||||
.month,
|
|
||||||
(ent.recurType == RecurType.day)
|
(ent.recurType == RecurType.day)
|
||||||
? recurringEntries[recurringEntries.indexOf(ent)]
|
? ent.lastRunDate.day + ent.repeatAfter
|
||||||
.lastRunDate
|
: ent.lastRunDate.day,
|
||||||
.day +
|
); // add tne variable again to check if we aren't missing any entries
|
||||||
ent.repeatAfter
|
|
||||||
: recurringEntries[recurringEntries.indexOf(ent)].lastRunDate.day,
|
|
||||||
); // add the variable again to check if we aren't missing any entries
|
|
||||||
logger.i(
|
logger.i(
|
||||||
"Last recurred date is now on ${DateFormat.yMMMMd().format(m)} (${n.isAfter(m)})");
|
"Last recurred date is now on ${DateFormat.yMMMMd().format(m)} (${n.isAfter(m)})");
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletManager.saveWallet(this); // save wallet
|
WalletManager.saveWallet(this); // save wallet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
@ -147,8 +146,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.d(
|
logger.d(
|
||||||
"Created ${selectedWallet!.recurringEntries.length} recurring entries",
|
"Created ${selectedWallet!.recurringEntries.length} recurring entries");
|
||||||
);
|
|
||||||
|
|
||||||
// save and reload
|
// save and reload
|
||||||
WalletManager.saveWallet(selectedWallet!).then((value) {
|
WalletManager.saveWallet(selectedWallet!).then((value) {
|
||||||
|
@ -374,7 +372,6 @@ class _HomeViewState extends State<HomeView> {
|
||||||
selectedWallet?.entries.removeWhere(
|
selectedWallet?.entries.removeWhere(
|
||||||
(e) => e.id == element.id,
|
(e) => e.id == element.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
WalletManager.saveWallet(
|
WalletManager.saveWallet(
|
||||||
selectedWallet!,
|
selectedWallet!,
|
||||||
);
|
);
|
||||||
|
@ -411,41 +408,10 @@ class _HomeViewState extends State<HomeView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(element.data.name),
|
title: Text(element.data.name),
|
||||||
subtitle: RichText(
|
subtitle: Text(
|
||||||
text: TextSpan(
|
NumberFormat.currency(
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: NumberFormat.currency(
|
|
||||||
symbol: selectedWallet!.currency.symbol,
|
symbol: selectedWallet!.currency.symbol,
|
||||||
).format(element.data.amount),
|
).format(element.data.amount),
|
||||||
style: TextStyle(
|
|
||||||
color: (element.type == EntryType.income)
|
|
||||||
? (MediaQuery.of(context)
|
|
||||||
.platformBrightness ==
|
|
||||||
Brightness.dark)
|
|
||||||
? Colors.green.shade300
|
|
||||||
: Colors.green.harmonizeWith(
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
)
|
|
||||||
: (MediaQuery.of(context)
|
|
||||||
.platformBrightness ==
|
|
||||||
Brightness.dark)
|
|
||||||
? Colors.red.shade300
|
|
||||||
: Colors.red.harmonizeWith(
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text:
|
|
||||||
" | ${DateFormat.MMMd(locale).format(element.date)}",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue