Skip to content

Commit

Permalink
add transaction - expenses details assets
Browse files Browse the repository at this point in the history
  • Loading branch information
gwalus committed Jun 8, 2024
1 parent f72ead8 commit 9b1c504
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ It's like having a digital wallet for all financial needs! 💲💲💲
<img src="assets/expenses_dark.jpg" alt="logo" width="300"/>
</div>

### Transactions (Expenses - Details)
<div align="left">
<img src="assets/expenses_details_light.jpg" alt="logo" width="300"/>
<img src="assets/expenses_details_dark.jpg" alt="logo" width="300"/>
</div>

### Transactions (New Expense)
<div align="left">
<img src="assets/new_expense_light.jpg" alt="logo" width="300"/>
Expand Down
Binary file added assets/expenses_details_dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/expenses_details_light.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public partial class EditExpensePageViewModel(IUnitOfWork unitOfWork) : Observab
private int id;

[ObservableProperty]
decimal _amount;
[NotifyCanExecuteChangedFor(nameof(EditExpenseCommand))]
decimal? _amount;

[ObservableProperty]
Account _selectedAccount;
Expand Down Expand Up @@ -68,12 +69,12 @@ async Task Appearing()
SelectedCategory = Categories[categoryIndex];
}

[RelayCommand]
[RelayCommand(CanExecute = nameof(CanEditExpense))]
async Task EditExpense()
{
var selectedAccount = Accounts.FirstOrDefault(x => x.Id == SelectedAccount.Id);

var difference = Amount - initialAmount;
var difference = (Amount ?? 0) - initialAmount;

if (difference > 0)
selectedAccount.Amount -= difference;
Expand All @@ -82,8 +83,8 @@ async Task EditExpense()

var expense = await _unitOfWork.ExpensesRepository.GetAsync(id);

expense.Amount = Amount;
//expense.Account = selectedAccount;
expense.Amount = Amount.Value;
expense.Account = selectedAccount;
expense.Category = SelectedCategory;
expense.Date = Date;
expense.Comment = Comment;
Expand All @@ -105,5 +106,7 @@ await Toast

await Shell.Current.GoToAsync("..", true, navigationParameter);
}

bool CanEditExpense() => Amount.HasValue;
}
}

0 comments on commit 9b1c504

Please sign in to comment.