Skip to content

Commit

Permalink
v1.0.21 - Horizontal scroll for Accounts (#21)
Browse files Browse the repository at this point in the history
* v1.0.21 - Version

* v1.0.21 - Horizontal scroll

* v1.0.21 - Refactor

* v1.0.21 - Make unselected accounts invisible

* v1.0.21 - UI fixes

* v1.0.21 - Add Asset/Liability Pie chart

* v1.0.21 - Ask both amounts in multi currency transaction

* v1.0.21 - Show hidden accounts
  • Loading branch information
Donnie authored Jan 22, 2024
1 parent 5fc3de4 commit 7609769
Show file tree
Hide file tree
Showing 16 changed files with 469 additions and 396 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ app.*.map.json
/android/app/profile
/android/app/release
main.db
fx-*.xml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<a href="https://flutter.dev/" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Platform-Flutter%203.16.5-blue">
</a>
<a href="https://github.com/Donnie/Finease/releases/tag/v1.0.20" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Version-1.0.20-orange">
<a href="https://github.com/Donnie/Finease/releases/tag/v1.0.21" style="text-decoration:none" area-label="flutter">
<img src="https://img.shields.io/badge/Version-1.0.21-orange">
</a>
<a href="https://github.com/Donnie/Finease/actions/workflows/android_release.yml" style="text-decoration:none" area-label="flutter">
<img src="https://github.com/Donnie/Finease/actions/workflows/android_release.yml/badge.svg">
Expand Down
26 changes: 26 additions & 0 deletions lib/db/entries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ class EntryService {
return entry;
}

Future<void> createMultiCurrencyEntry(Entry entry, double debitAmount) async {
final creditAccount =
await AccountService().getAccount(entry.creditAccountId);
final debitAccount =
await AccountService().getAccount(entry.debitAccountId);

final forexAccountDebit = await AccountService()
.createForexAccountIfNotExist(debitAccount!.currency);
final forexAccountCredit = await AccountService()
.createForexAccountIfNotExist(creditAccount!.currency);

await createEntry(Entry(
debitAccountId: entry.debitAccountId,
creditAccountId: forexAccountDebit.id!,
amount: debitAmount,
notes: "Forex transaction by App",
));

await createEntry(Entry(
debitAccountId: forexAccountCredit.id!,
creditAccountId: entry.creditAccountId,
amount: entry.amount,
notes: entry.notes,
));
}

Future<void> createForexEntry(Entry entry) async {
final creditAccount =
await AccountService().getAccount(entry.creditAccountId);
Expand Down
25 changes: 15 additions & 10 deletions lib/pages/add_account/account_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:finease/core/extensions/color_extension.dart';
import 'package:finease/db/accounts.dart';
import 'package:finease/db/currency.dart';
import 'package:finease/parts/account_item.dart';
import 'package:finease/parts/export.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down Expand Up @@ -67,11 +66,13 @@ class AddAccountBodyState extends State<AddAccountBody> {
),
),
const SizedBox(height: 16),
AppTextFormField(
TextFormField(
key: const Key('account_name'),
controller: widget.accountName,
hintText: 'Enter account name',
label: 'Enter account name',
decoration: const InputDecoration(
hintText: 'Enter account name',
label: Text('Enter account name'),
),
keyboardType: TextInputType.name,
validator: (val) {
if (val!.isNotEmpty) {
Expand All @@ -95,14 +96,16 @@ class AddAccountBodyState extends State<AddAccountBody> {
),
),
),
AppTextFormField(
TextFormField(
key: const Key('account_balance'),
controller: widget.accountBalance,
hintText: 'Enter current balance',
decoration: const InputDecoration(
hintText: 'Enter current balance',
label: Text('Enter current balance'),
),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp("[0-9.-]")),
],
label: 'Enter current balance',
keyboardType: TextInputType.number,
validator: (val) {
if (val!.isNotEmpty) {
Expand All @@ -125,11 +128,13 @@ class AddAccountBodyState extends State<AddAccountBody> {
widget.accountCurrency.text = currency.code,
),
child: AbsorbPointer(
child: AppTextFormField(
child: TextFormField(
key: const Key('account_currency'),
controller: widget.accountCurrency,
hintText: 'Select currency',
label: 'Currency',
decoration: const InputDecoration(
hintText: 'Select currency',
label: Text('Currency'),
),
keyboardType: TextInputType.name,
validator: (val) {
if (val!.isNotEmpty) {
Expand Down
166 changes: 118 additions & 48 deletions lib/pages/add_entry/entry_body.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:finease/db/accounts.dart';
import 'package:finease/db/currency.dart';
import 'package:finease/pages/export.dart';
import 'package:finease/parts/export.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
Expand All @@ -13,7 +13,9 @@ class AddEntryBody extends StatefulWidget {
this.dateTime,
this.creditAccount,
this.debitAccount,
required this.entryAmount,
this.defaultCurrency,
required this.creditAmount,
required this.debitAmount,
required this.entryNotes,
required this.formState,
required this.onCreditAccountSelected,
Expand All @@ -29,8 +31,10 @@ class AddEntryBody extends StatefulWidget {
final List<Account> accounts;
final Function routeArg;
final String addNewRoute;
final TextEditingController entryAmount;
final TextEditingController creditAmount;
final TextEditingController debitAmount;
final TextEditingController entryNotes;
final String? defaultCurrency;
final ValueChanged<DateTime> onDateTimeChanged;
final ValueChanged<Account?> onCreditAccountSelected;
final ValueChanged<Account?> onDebitAccountSelected;
Expand All @@ -52,56 +56,19 @@ class AddEntryBodyState extends State<AddEntryBody> {

@override
Widget build(BuildContext context) {
String? creditCurrencyISO =
widget.creditAccount?.currency ?? widget.defaultCurrency;
String? creditCurrency = SupportedCurrency[creditCurrencyISO];
String? debitCurrencyISO =
widget.debitAccount?.currency ?? widget.defaultCurrency;
String? debitCurrency = SupportedCurrency[debitCurrencyISO];
bool showDebitAmount = creditCurrency != debitCurrency;
return Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: widget.formState,
child: ListView(
children: [
AppTextFormField(
key: const Key('entry_notes'),
controller: widget.entryNotes,
hintText: 'Enter entry notes',
label: 'Enter entry notes',
keyboardType: TextInputType.text,
),
const SizedBox(height: 16),
AppTextFormField(
key: const Key('entry_amount'),
controller: widget.entryAmount,
hintText: 'Enter amount',
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
TextInputFormatter.withFunction((oldValue, newValue) {
try {
final text = newValue.text;
if (text.isNotEmpty) double.parse(text);
return newValue;
} catch (_) {}
return oldValue;
}),
],
label: 'Enter amount',
keyboardType: TextInputType.number,
validator: (val) {
if (val == null) {
return 'Enter an amount';
}
if (val.isEmpty) {
return 'Enter an amount';
}
if (double.tryParse(val) == 0) {
return 'Enter an amount';
}
return null;
},
),
const SizedBox(height: 16),
DateTimePicker(
dateTime: widget.dateTime,
onDateTimeChanged: widget.onDateTimeChanged,
),
const SizedBox(height: 16),
AccountChoiceFormField(
key: UniqueKey(),
title: "From Account",
Expand All @@ -119,7 +86,6 @@ class AddEntryBodyState extends State<AddEntryBody> {
return null;
},
),
const SizedBox(height: 16),
AccountChoiceFormField(
key: UniqueKey(),
title: "To Account",
Expand All @@ -137,6 +103,110 @@ class AddEntryBodyState extends State<AddEntryBody> {
return null;
},
),
const SizedBox(height: 32),
TextFormField(
key: const Key('entry_notes'),
controller: widget.entryNotes,
decoration: const InputDecoration(
hintText: 'Enter entry notes',
label: Text('Enter entry notes'),
),
keyboardType: TextInputType.text,
),
Visibility(
visible: showDebitAmount,
child: Column(
children: [
const SizedBox(height: 16),
TextFormField(
key: const Key('entry_amount_debit'),
controller: widget.debitAmount,
decoration: InputDecoration(
hintText: 'Enter $debitCurrencyISO amount',
label: Text('Enter $debitCurrencyISO amount'),
prefixIcon: Padding(
padding: const EdgeInsets.only(left: 12, right: 4),
child: Text("$debitCurrency"),
),
prefixIconConstraints:
const BoxConstraints(minWidth: 0, minHeight: 0),
),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
TextInputFormatter.withFunction((oldValue, newValue) {
try {
final text = newValue.text;
if (text.isNotEmpty) double.parse(text);
return newValue;
} catch (_) {}
return oldValue;
}),
],
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
validator: (val) {
if (val == null) {
return 'Enter an amount';
}
if (val.isEmpty) {
return 'Enter an amount';
}
if (double.tryParse(val) == 0) {
return 'Enter an amount';
}
return null;
},
),
],
),
),
const SizedBox(height: 16),
TextFormField(
key: const Key('entry_amount_credit'),
controller: widget.creditAmount,
decoration: InputDecoration(
hintText: 'Enter $creditCurrencyISO amount',
label: Text('Enter $creditCurrencyISO amount'),
prefixIcon: Padding(
padding: const EdgeInsets.only(left: 12, right: 4),
child: Text("$creditCurrency"),
),
prefixIconConstraints:
const BoxConstraints(minWidth: 0, minHeight: 0),
),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
TextInputFormatter.withFunction((oldValue, newValue) {
try {
final text = newValue.text;
if (text.isNotEmpty) double.parse(text);
return newValue;
} catch (_) {}
return oldValue;
}),
],
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
validator: (val) {
if (val == null) {
return 'Enter an amount';
}
if (val.isEmpty) {
return 'Enter an amount';
}
if (double.tryParse(val) == 0) {
return 'Enter an amount';
}
return null;
},
),
const SizedBox(height: 16),
DateTimePicker(
dateTime: widget.dateTime,
onDateTimeChanged: widget.onDateTimeChanged,
),
],
),
),
Expand Down
Loading

0 comments on commit 7609769

Please sign in to comment.