feat(transaction): #112 allow negative value without treasurechest for rebalancing #113

Merged
tim merged 2 commits from 112-allow-empty-account-for-rebalancing into prod 2025-05-19 11:23:23 +00:00
3 changed files with 21 additions and 5 deletions

View File

@@ -551,9 +551,7 @@ func updateErrors(transaction *types.Transaction) {
error := "" error := ""
if transaction.Value < 0 { if transaction.Value < 0 {
if transaction.AccountId == nil { if transaction.TreasureChestId == nil {
error = "no account specified"
} else if transaction.TreasureChestId == nil {
error = "no treasure chest specified" error = "no treasure chest specified"
} }
} else if transaction.Value > 0 { } else if transaction.Value > 0 {

View File

@@ -85,6 +85,16 @@ templ AccountItem(account *types.Account) {
} else { } else {
<p class="mr-20 text-green-700">{ displayBalance(account.CurrentBalance) }</p> <p class="mr-20 text-green-700">{ displayBalance(account.CurrentBalance) }</p>
} }
<a
href={ templ.URL("/transaction?account-id=" + account.Id.String()) }
class="button button-neglect px-1 flex items-center gap-2"
title="View transactions"
>
@svg.Eye()
<span>
View
</span>
</a>
<button <button
hx-get={ "/account/" + account.Id.String() + "?edit=true" } hx-get={ "/account/" + account.Id.String() + "?edit=true" }
hx-target="closest #account" hx-target="closest #account"

View File

@@ -1,10 +1,8 @@
package treasurechest package treasurechest
import "fmt" import "fmt"
import "spend-sparrow/template/svg" import "spend-sparrow/template/svg"
import "spend-sparrow/types" import "spend-sparrow/types"
import "github.com/google/uuid" import "github.com/google/uuid"
templ TreasureChest(treasureChests []*types.TreasureChest) { templ TreasureChest(treasureChests []*types.TreasureChest) {
@@ -109,6 +107,16 @@ templ TreasureChestItem(treasureChest *types.TreasureChest) {
} else { } else {
<p class="mr-20 text-green-700">{ displayBalance(treasureChest.CurrentBalance) }</p> <p class="mr-20 text-green-700">{ displayBalance(treasureChest.CurrentBalance) }</p>
} }
<a
href={ templ.URL("/transaction?treasure-chest-id=" + treasureChest.Id.String()) }
class="button button-neglect px-1 flex items-center gap-2"
title="View transactions"
>
@svg.Eye()
<span>
View
</span>
</a>
<button <button
hx-get={ "/treasurechest/" + treasureChest.Id.String() + "?edit=true" } hx-get={ "/treasurechest/" + treasureChest.Id.String() + "?edit=true" }
hx-target="closest #treasurechest" hx-target="closest #treasurechest"