Skip to content

Commit

Permalink
Refine Txn edit to make payee & category as mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
guanlisheng committed Sep 27, 2024
1 parent 3928caf commit 73cf641
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MMEX/Views/Transactions/TransactionAddView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ struct TransactionAddView: View {
isPresentingTransactionAddView = false
onSave(&newTxn)
}
.disabled(!isTransactionValid())
}
}
}
}
func isTransactionValid() -> Bool {
return newTxn.payeeId > 0 && newTxn.categId > 0
}
}

#Preview {
Expand Down
5 changes: 5 additions & 0 deletions MMEX/Views/Transactions/TransactionAddView2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct TransactionAddView2: View {
selectedTab = 0
newTxn = TransactionData()
}
.disabled(!isTransactionValid())
}
}
}
Expand All @@ -57,6 +58,10 @@ struct TransactionAddView2: View {
}
}

func isTransactionValid() -> Bool {
return newTxn.payeeId > 0 && newTxn.categId > 0
}

func addTransaction(txn: inout TransactionData) {
let repository = dataManager.getTransactionRepository()
if repository.insert(&txn) {
Expand Down

0 comments on commit 73cf641

Please sign in to comment.