Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrasset committed Jan 5, 2021
2 parents 0a4892c + f7f6106 commit 695342c
Show file tree
Hide file tree
Showing 16 changed files with 494 additions and 260 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Version 1.1.4

- BUGFIX: Fix bug where you couldn't delete last character when setting budgeted value for a subcategory
- BUGFIX: Changing the name of a subcategory takes effect immediately
- BUGFIX: Fix amount field sliding up when having an error in the Add Transaction tab
- FEATURE: Transaction success or error is now shown using SnackBars
- REFACTOR: [WIP] Refactor addTransactionScreen

## Version 1.1.3

- BUGFIX: To Be budgeted now gets updated directly after transaction
Expand Down
22 changes: 14 additions & 8 deletions lib/appState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class AppState extends ChangeNotifier {
/// extracting the subcategories of each [MainCategory] from
/// scratch
void addSubcategory(SubCategoryModel subcategoryModel) async {
DateTime newDate = startingBudgetDate;
DateTime maxBudgetDate = getMaxBudgetDate();
DateTime previousDate;

int subcatId = await queryContext.addSubcategory(subcategoryModel);
SubCategory subcategory = SubCategory(
subcatId,
Expand All @@ -147,26 +151,28 @@ class AppState extends ChangeNotifier {

/// Insert a budget value for every month from [startingBudgetDate] until [MAX_NB_MONTHS_AHEAD]
/// after [DateTime.now()],
for (int i = 0;
i < Constants.MAX_NB_MONTHS_AHEAD + getMonthDifference(startingBudgetDate, DateTime.now());
i++) {
do {
/// Update BudgetValues
DateTime newDate = Jiffy(startingBudgetDate).add(months: i);
previousDate = newDate;

BudgetValueModel budgetValueModel = BudgetValueModel(
subcategoryId: subcatId,
budgeted: 0,
available: 0,
year: newDate.year,
month: newDate.month,
year: previousDate.year,
month: previousDate.month,
);

int budgetId = await queryContext.addBudgetValue(budgetValueModel);
BudgetValue budgetValue =
BudgetValue(budgetId, subcategory.id, 0, 0, newDate.year, newDate.month);
BudgetValue(budgetId, subcategory.id, 0, 0, previousDate.year, previousDate.month);

_budgetValues.add(budgetValue);
}
newDate = Jiffy(previousDate).add(months: 1);

} while(previousDate.isBefore(maxBudgetDate));

notifyListeners();
}

Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:your_budget/models/constants.dart';
import 'package:your_budget/screens/addAccount/addAccount.dart';

import 'package:your_budget/screens/addTransaction/addTransaction.dart';
import 'package:your_budget/screens/addTransaction/addTransactionState.dart';

import 'package:your_budget/screens/budget/budgetPage.dart';
import 'package:your_budget/models/database_provider.dart';
Expand All @@ -31,6 +32,7 @@ class MyBudget extends StatelessWidget {
ChangeNotifierProvider<AppState>.value(value: GetIt.instance<AppState>()),
// ChangeNotifierProvider<BudgetPageState>(create: (_) => BudgetPageState())
ChangeNotifierProvider<ShowTransactionsState>(create: (_) => ShowTransactionsState()),
ChangeNotifierProvider<AddTransactionState>(create: (_) => AddTransactionState()),
ChangeNotifierProvider<DeleteCategoriesState>(create: (_) => DeleteCategoriesState()),
], child: HomeScreen());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/models/database_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class DatabaseProvider {

int categoryId = await db.rawInsert(CREATE_CATEGORY, ["Essentials"]);

List<String> subcategoryNames = ["Rent", "Eletricity", "Water", "Food", "Internet", "Phone"];
List<String> subcategoryNames = ["Rent", "Electricity", "Water", "Food", "Internet", "Phone"];
List<int> subcategoryIds = [];
for (int i = 0; i < subcategoryNames.length; i++) {
int subcategoryId = await db.rawInsert(CREATE_SUBCATEGORY, [categoryId, subcategoryNames[i]]);
Expand Down
Loading

0 comments on commit 695342c

Please sign in to comment.