mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-06-30 19:48:38 -04:00
testing: Add transaction-creation test
This commit is contained in:
@ -410,15 +410,6 @@ func TransactionHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
transaction.TransactionId = -1
|
||||
transaction.UserId = user.UserId
|
||||
|
||||
balanced, err := transaction.Balanced(tx)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return NewError(999 /*Internal Error*/)
|
||||
}
|
||||
if !transaction.Valid() || !balanced {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
for i := range transaction.Splits {
|
||||
transaction.Splits[i].SplitId = -1
|
||||
_, err := GetAccount(tx, transaction.Splits[i].AccountId, user.UserId)
|
||||
@ -427,6 +418,14 @@ func TransactionHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
}
|
||||
}
|
||||
|
||||
balanced, err := transaction.Balanced(tx)
|
||||
if err != nil {
|
||||
return NewError(999 /*Internal Error*/)
|
||||
}
|
||||
if !transaction.Valid() || !balanced {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
err = InsertTransaction(tx, &transaction, user)
|
||||
if err != nil {
|
||||
if _, ok := err.(AccountMissingError); ok {
|
||||
|
Reference in New Issue
Block a user