Implement account editing and autocomplete
This commit is contained in:
parent
75a1839456
commit
d22816dfd1
@ -9,6 +9,28 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (h *Handler) autocompleteAccounts(c *gin.Context) {
|
||||||
|
budgetID := c.Param("budgetid")
|
||||||
|
budgetUUID, err := uuid.Parse(budgetID)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"budgetid missing from URL"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
query := c.Request.URL.Query().Get("s")
|
||||||
|
searchParams := postgres.SearchAccountsParams{
|
||||||
|
BudgetID: budgetUUID,
|
||||||
|
Search: "%" + query + "%",
|
||||||
|
}
|
||||||
|
categories, err := h.Service.SearchAccounts(c.Request.Context(), searchParams)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, categories)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handler) autocompleteCategories(c *gin.Context) {
|
func (h *Handler) autocompleteCategories(c *gin.Context) {
|
||||||
budgetID := c.Param("budgetid")
|
budgetID := c.Param("budgetid")
|
||||||
budgetUUID, err := uuid.Parse(budgetID)
|
budgetUUID, err := uuid.Parse(budgetID)
|
||||||
|
@ -65,6 +65,7 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
|
|||||||
budget.GET("/:budgetid/:year/:month", h.budgetingForMonth)
|
budget.GET("/:budgetid/:year/:month", h.budgetingForMonth)
|
||||||
budget.POST("/:budgetid/category/:categoryid/:year/:month", h.setCategoryAssignment)
|
budget.POST("/:budgetid/category/:categoryid/:year/:month", h.setCategoryAssignment)
|
||||||
budget.GET("/:budgetid/autocomplete/payees", h.autocompletePayee)
|
budget.GET("/:budgetid/autocomplete/payees", h.autocompletePayee)
|
||||||
|
budget.GET("/:budgetid/autocomplete/accounts", h.autocompleteAccounts)
|
||||||
budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
||||||
budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
|
budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
|
||||||
budget.DELETE("/:budgetid", h.deleteBudget)
|
budget.DELETE("/:budgetid", h.deleteBudget)
|
||||||
|
@ -9,6 +9,7 @@ import Button from "./SimpleButton.vue";
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
transactionid: string
|
transactionid: string
|
||||||
|
withAccount: bool
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits(["save"]);
|
const emit = defineEmits(["save"]);
|
||||||
@ -45,6 +46,13 @@ function saveTransaction(e: MouseEvent) {
|
|||||||
class="border-b-2 border-black"
|
class="border-b-2 border-black"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
<td v-if="withAccount">
|
||||||
|
<Autocomplete
|
||||||
|
v-model:text="TX.Account"
|
||||||
|
v-model:id="TX.AccountID"
|
||||||
|
model="accounts"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
v-model:text="TX.Payee"
|
v-model:text="TX.Payee"
|
||||||
|
@ -75,6 +75,7 @@ function getStatusSymbol() {
|
|||||||
<TransactionEditRow
|
<TransactionEditRow
|
||||||
v-if="edit"
|
v-if="edit"
|
||||||
:transactionid="TX.ID"
|
:transactionid="TX.ID"
|
||||||
|
:withAccount="withAccount"
|
||||||
@save="edit = false"
|
@save="edit = false"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user