Add row to create new transaction #2

Merged
jacob1123 merged 2 commits from new-transaction-row into master 2022-01-18 11:43:23 +01:00
2 changed files with 43 additions and 0 deletions

View File

@ -13,6 +13,7 @@ type AccountData struct {
Account *postgres.Account
Categories []postgres.GetCategoriesRow
Transactions []postgres.GetTransactionsForAccountRow
Payees []postgres.Payee
}
func (h *Handler) account(c *gin.Context) {
@ -43,11 +44,18 @@ func (h *Handler) account(c *gin.Context) {
return
}
payees, err := h.Service.GetPayees(c.Request.Context(), data.Budget.ID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
return
}
d := AccountData{
data,
&account,
categories,
transactions,
payees,
}
c.HTML(http.StatusOK, "account.html", d)

View File

@ -12,6 +12,41 @@
<span class="time"></span>
</div>
<table class="container col-lg-12" id="content">
<form id="newtransactionform" action="/api/v1/transaction/new" method="POST">
<td>
<input type="hidden" name="account_id" value="{{.Account.ID}}" />
<input type="date" name="date" class="form-control" value="{{now.Format "2006-01-02"}}" />
</td>
<td>
{{.Account.Name}}
</td>
<td>
<input list="payees" name="payee_id" class="form-control">
<datalist id="payees">
<option value="">-- none --</option>
{{range .Payees}}
<option data-value="{{.ID}}">{{.Name}}</option>
{{- end}}
</datalist>
</td>
<td>
<input list="categories" name="category_id" class="form-control">
<datalist id="categories">
<option value="">-- none --</option>
{{range .Categories}}
<option data-value="{{.ID}}">{{.Group}} : {{.Name}}</option>
{{- end}}
</select>
</td>
<td></td>
<td>
<input type="text" name="memo" class="form-control" />
</td>
<td>
<input type="number" name="amount" class="form-control" placeholder="0.00" />
<input type="submit" class="btn btn-primary" name="create" value="Create" class="form-control" />
</td>
</form>
{{range .Transactions}}
<tr class="{{if .Date.After now}}future{{end}}">
<td>{{.Date.Format "02.01.2006"}}</td>