Skip to content

Commit

Permalink
Changed startingValue field name
Browse files Browse the repository at this point in the history
  • Loading branch information
mikev-cw committed Jun 19, 2023
1 parent 4f07880 commit 86cf80a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/custom_widgets/accounts_sum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AccountsSum extends StatelessWidget with Functions {
children: [
AccountDialog(
accountName: account.name,
amount: account.starting_value,
amount: account.startingValue,
)
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/database/sossoldi_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SossoldiDatabase {
`${BankAccountFields.name}` $textNotNull,
`${BankAccountFields.symbol}` $textNotNull,
`${BankAccountFields.color}` $integerNotNull,
`${BankAccountFields.starting_value}` $realNotNull,
`${BankAccountFields.startingValue}` $realNotNull,
`${BankAccountFields.active}` $integerNotNull CHECK (${BankAccountFields.active} IN (0, 1)),
`${BankAccountFields.mainAccount}` $integerNotNull CHECK (${BankAccountFields.mainAccount} IN (0, 1)),
`${BankAccountFields.createdAt}` $textNotNull,
Expand Down Expand Up @@ -137,7 +137,7 @@ class SossoldiDatabase {
Future fillDemoData() async {
// Add some fake accounts
await _database?.execute('''
INSERT INTO bankAccount(id, name, symbol, color, starting_value, active, mainAccount, createdAt, updatedAt) VALUES
INSERT INTO bankAccount(id, name, symbol, color, startingValue, active, mainAccount, createdAt, updatedAt) VALUES
(70, "Revolut", 'payments', 1, 1235.10, 1, 1, '${DateTime.now()}', '${DateTime.now()}'),
(71, "N26", 'credit_card', 2, 3823.56, 1, 0, '${DateTime.now()}', '${DateTime.now()}'),
(72, "Fineco", 'account_balance', 3, 0.00, 1, 0, '${DateTime.now()}', '${DateTime.now()}');
Expand Down
18 changes: 9 additions & 9 deletions lib/model/bank_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BankAccountFields extends BaseEntityFields {
static String name = 'name';
static String symbol = 'symbol';
static String color = 'color';
static String starting_value = 'starting_value';
static String startingValue = 'startingValue';
static String active = 'active';
static String mainAccount = 'mainAccount';
static String createdAt = BaseEntityFields.getCreatedAt;
Expand All @@ -22,7 +22,7 @@ class BankAccountFields extends BaseEntityFields {
name,
symbol,
color,
starting_value,
startingValue,
active,
mainAccount,
BaseEntityFields.createdAt,
Expand All @@ -34,7 +34,7 @@ class BankAccount extends BaseEntity {
final String name;
final String symbol;
final int color;
final num starting_value;
final num startingValue;
final bool active;
final bool mainAccount;

Expand All @@ -43,7 +43,7 @@ class BankAccount extends BaseEntity {
required this.name,
required this.symbol,
required this.color,
required this.starting_value,
required this.startingValue,
required this.mainAccount,
required this.active,
DateTime? createdAt,
Expand All @@ -55,7 +55,7 @@ class BankAccount extends BaseEntity {
String? name,
String? symbol,
int? color,
num? starting_value,
num? startingValue,
bool? active,
bool? mainAccount,
DateTime? createdAt,
Expand All @@ -65,7 +65,7 @@ class BankAccount extends BaseEntity {
name: name ?? this.name,
symbol: symbol ?? this.symbol,
color: color ?? this.color,
starting_value: starting_value ?? this.starting_value,
startingValue: startingValue ?? this.startingValue,
active: active ?? this.active,
mainAccount: mainAccount ?? this.mainAccount,
createdAt: createdAt ?? this.createdAt,
Expand All @@ -76,7 +76,7 @@ class BankAccount extends BaseEntity {
name: json[BankAccountFields.name] as String,
symbol: json[BankAccountFields.symbol] as String,
color: json[BankAccountFields.color] as int,
starting_value: json[BankAccountFields.starting_value] as num,
startingValue: json[BankAccountFields.startingValue] as num,
active: json[BankAccountFields.active] == 1 ? true : false,
mainAccount: json[BankAccountFields.mainAccount] == 1 ? true : false,
createdAt: DateTime.parse(json[BaseEntityFields.createdAt] as String),
Expand All @@ -87,7 +87,7 @@ class BankAccount extends BaseEntity {
BankAccountFields.name: name,
BankAccountFields.symbol: symbol,
BankAccountFields.color: color,
BankAccountFields.starting_value: starting_value,
BankAccountFields.startingValue: startingValue,
BankAccountFields.active: active ? 1 : 0,
BankAccountFields.mainAccount: mainAccount ? 1 : 0,
BaseEntityFields.createdAt:
Expand Down Expand Up @@ -206,7 +206,7 @@ class BankAccountMethods extends SossoldiDatabase {
final singleObject = result.isNotEmpty ? result[0] : null;

if (singleObject != null) {
num balance = singleObject[BankAccountFields.starting_value] as num;
num balance = singleObject[BankAccountFields.startingValue] as num;

// get all transactions of that account
final transactionsResult = await db.query(transactionTable, where:'${TransactionFields.idBankAccount} = $id OR ${TransactionFields.idBankAccountTransfer} = $id');
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/statistics_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _StatsPageState extends ConsumerState<StatsPage> with Functions {
double max = 0;
for(var i = 0; i < accounts.length; i++)
{
if (max <= accounts[i].starting_value){max = accounts[i].starting_value.toDouble();}
if (max <= accounts[i].startingValue){max = accounts[i].startingValue.toDouble();}
}
return SizedBox(
height: 50.0,
Expand All @@ -170,7 +170,7 @@ class _StatsPageState extends ConsumerState<StatsPage> with Functions {
),
Expanded(
child: Text(
"${account.starting_value}€",
"${account.startingValue}€",
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: blue1),
),
Expand All @@ -184,7 +184,7 @@ class _StatsPageState extends ConsumerState<StatsPage> with Functions {
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.9 * (account.starting_value.toDouble()/max),
width: MediaQuery.of(context).size.width * 0.9 * (account.startingValue.toDouble()/max),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(4.0),
Expand All @@ -194,7 +194,7 @@ class _StatsPageState extends ConsumerState<StatsPage> with Functions {
),
),
Container(
width: MediaQuery.of(context).size.width * 0.9 *(1 - (account.starting_value.toDouble()/max)),
width: MediaQuery.of(context).size.width * 0.9 *(1 - (account.startingValue.toDouble()/max)),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(4.0),
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/accounts_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AsyncAccountsNotifier extends AsyncNotifier<List<BankAccount>> {
name: ref.read(accountNameProvider)!,
symbol: ref.read(accountIconProvider),
color: ref.read(accountColorProvider),
starting_value: 0,
startingValue: 0,
active: true,
mainAccount: ref.read(accountMainSwitchProvider),
);
Expand Down
12 changes: 6 additions & 6 deletions test/model/bank_account_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() {
name: "name",
symbol: 'symbol',
color: 0,
starting_value: 100,
startingValue: 100,
active: true,
mainAccount: true,
createdAt: DateTime.utc(2022),
Expand All @@ -22,7 +22,7 @@ void main() {
assert(bCopy.name == b.name);
assert(bCopy.symbol == b.symbol);
assert(bCopy.color == b.color);
assert(bCopy.starting_value == bCopy.starting_value);
assert(bCopy.startingValue == bCopy.startingValue);
assert(bCopy.active == bCopy.active);
assert(bCopy.mainAccount == bCopy.mainAccount);
assert(bCopy.createdAt == b.createdAt);
Expand All @@ -35,7 +35,7 @@ void main() {
BankAccountFields.name: "name",
BankAccountFields.symbol: "symbol",
BankAccountFields.color: 0,
BankAccountFields.starting_value: 100,
BankAccountFields.startingValue: 100,
BaseEntityFields.createdAt: DateTime.utc(2022).toIso8601String(),
BaseEntityFields.updatedAt: DateTime.utc(2022).toIso8601String(),
};
Expand All @@ -46,7 +46,7 @@ void main() {
assert(b.name == json[BankAccountFields.name]);
assert(b.symbol == json[BankAccountFields.symbol]);
assert(b.color == json[BankAccountFields.color]);
assert(b.starting_value == json[BankAccountFields.starting_value]);
assert(b.startingValue == json[BankAccountFields.startingValue]);
assert(b.createdAt?.toUtc().toIso8601String() ==
json[BaseEntityFields.createdAt]);
assert(b.updatedAt?.toUtc().toIso8601String() ==
Expand All @@ -59,7 +59,7 @@ void main() {
name: "name",
symbol: "symbol",
color: 0,
starting_value: 100,
startingValue: 100,
active: true,
mainAccount: false);

Expand All @@ -69,7 +69,7 @@ void main() {
assert(b.name == json[BankAccountFields.name]);
assert(b.symbol == json[BankAccountFields.symbol]);
assert(b.color == json[BankAccountFields.color]);
assert(b.starting_value == json[BankAccountFields.starting_value]);
assert(b.startingValue == json[BankAccountFields.startingValue]);
assert((b.active ? 1 : 0) == json[BankAccountFields.active]);
assert((b.mainAccount ? 1 : 0) == json[BankAccountFields.mainAccount]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/widget/accounts_sum_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
name: randomAccount,
symbol: "account_balance",
color: 0,
starting_value: randomValue,
startingValue: randomValue,
active: true,
mainAccount: false,
);
Expand Down

0 comments on commit 86cf80a

Please sign in to comment.