chore: cleanup code

This commit is contained in:
Matyáš Caras 2024-01-08 23:24:17 +01:00
parent e40f0491fc
commit efc003a719
Signed by untrusted user who does not match committer: hernik
GPG key ID: 2A3175F98820C5C6
2 changed files with 1 additions and 13 deletions

View file

@ -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;
} }
@ -99,21 +96,13 @@ class Wallet {
..d("Current entry count: ${entries.length}"); ..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);
var id = 1;
logger.d("Making ID after ${entries.length} entries");
while (entries.where((element) => element.id == id).isNotEmpty) {
id++; // create unique ID
}
logger.d("New ID: $id\nLast entry ID: ${entries.lastOrNull?.id}");
final addedEntry = WalletSingleEntry( final addedEntry = WalletSingleEntry(
data: recurringEntries[recurringEntries.indexOf(ent)].data, data: recurringEntries[recurringEntries.indexOf(ent)].data,
type: recurringEntries[recurringEntries.indexOf(ent)].type, type: recurringEntries[recurringEntries.indexOf(ent)].type,
date: m, date: m,
category: recurringEntries[recurringEntries.indexOf(ent)].category, category: recurringEntries[recurringEntries.indexOf(ent)].category,
id: id, id: nextId,
); );
entries.add(addedEntry); entries.add(addedEntry);

View file

@ -221,7 +221,6 @@ class _HomeViewState extends State<HomeView> {
), ),
); );
wallets = await WalletManager.listWallets(); wallets = await WalletManager.listWallets();
logger.i(wallets.length);
selectedWallet = wallets.last; selectedWallet = wallets.last;
setState(() {}); setState(() {});
return; return;