Use view everywhere
This commit is contained in:
parent
81aacf339e
commit
2cf6b815bf
@ -1,5 +1,5 @@
|
|||||||
-- name: GetTransaction :one
|
-- name: GetTransaction :one
|
||||||
SELECT * FROM transactions
|
SELECT * FROM display_transactions
|
||||||
WHERE id = $1;
|
WHERE id = $1;
|
||||||
|
|
||||||
-- name: CreateTransaction :one
|
-- name: CreateTransaction :one
|
||||||
|
@ -127,23 +127,29 @@ func (q *Queries) GetAllTransactionsForBudget(ctx context.Context, budgetID uuid
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getTransaction = `-- name: GetTransaction :one
|
const getTransaction = `-- name: GetTransaction :one
|
||||||
SELECT id, date, memo, amount, account_id, category_id, payee_id, group_id, status FROM transactions
|
SELECT id, date, memo, amount, group_id, status, account, payee_id, category_id, payee, category_group, category, transfer_account, budget_id, account_id FROM display_transactions
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) GetTransaction(ctx context.Context, id uuid.UUID) (Transaction, error) {
|
func (q *Queries) GetTransaction(ctx context.Context, id uuid.UUID) (DisplayTransaction, error) {
|
||||||
row := q.db.QueryRowContext(ctx, getTransaction, id)
|
row := q.db.QueryRowContext(ctx, getTransaction, id)
|
||||||
var i Transaction
|
var i DisplayTransaction
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Date,
|
&i.Date,
|
||||||
&i.Memo,
|
&i.Memo,
|
||||||
&i.Amount,
|
&i.Amount,
|
||||||
&i.AccountID,
|
|
||||||
&i.CategoryID,
|
|
||||||
&i.PayeeID,
|
|
||||||
&i.GroupID,
|
&i.GroupID,
|
||||||
&i.Status,
|
&i.Status,
|
||||||
|
&i.Account,
|
||||||
|
&i.PayeeID,
|
||||||
|
&i.CategoryID,
|
||||||
|
&i.Payee,
|
||||||
|
&i.CategoryGroup,
|
||||||
|
&i.Category,
|
||||||
|
&i.TransferAccount,
|
||||||
|
&i.BudgetID,
|
||||||
|
&i.AccountID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func (ynab *YNABExport) ExportTransactions(context context.Context, w io.Writer)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTransactionRow(transaction GetAllTransactionsForBudgetRow) []string {
|
func GetTransactionRow(transaction DisplayTransaction) []string {
|
||||||
row := []string{
|
row := []string{
|
||||||
transaction.Account,
|
transaction.Account,
|
||||||
"", // Flag
|
"", // Flag
|
||||||
|
@ -33,7 +33,7 @@ func (h *Handler) transactionsForAccount(c *gin.Context) {
|
|||||||
|
|
||||||
type TransactionsResponse struct {
|
type TransactionsResponse struct {
|
||||||
Account postgres.Account
|
Account postgres.Account
|
||||||
Transactions []postgres.GetTransactionsForAccountRow
|
Transactions []postgres.DisplayTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditAccountRequest struct {
|
type EditAccountRequest struct {
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||||
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
"git.javil.eu/jacob1123/budgeteer/postgres/numeric"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@ -15,6 +16,11 @@ type ReconcileTransactionsRequest struct {
|
|||||||
ReconcilationTransactionAmount numeric.Numeric `json:"reconcilationTransactionAmount"`
|
ReconcilationTransactionAmount numeric.Numeric `json:"reconcilationTransactionAmount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReconcileTransactionsResponse struct {
|
||||||
|
Message string
|
||||||
|
ReconcilationTransaction []postgres.GetTransactionsForAccountRow
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handler) reconcileTransactions(c *gin.Context) {
|
func (h *Handler) reconcileTransactions(c *gin.Context) {
|
||||||
var request ReconcileTransactionsRequest
|
var request ReconcileTransactionsRequest
|
||||||
err := c.BindJSON(&request)
|
err := c.BindJSON(&request)
|
||||||
@ -42,5 +48,8 @@ func (h *Handler) reconcileTransactions(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, SuccessResponse{fmt.Sprintf("Set status for %d transactions", len(request.TransactionIDs))})
|
c.JSON(http.StatusOK, ReconcileTransactionsResponse{
|
||||||
|
Message: fmt.Sprintf("Set status for %d transactions", len(request.TransactionIDs)),
|
||||||
|
ReconcilationTransaction: nil,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,14 @@ function cancelReconcilation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitReconcilation() {
|
function submitReconcilation() {
|
||||||
accounts.SubmitReconcilation();
|
accounts.SubmitReconcilation(0);
|
||||||
accounts.Reconciling = false;
|
accounts.Reconciling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReconcilationTransaction() {
|
function createReconcilationTransaction() {
|
||||||
|
const diff = accounts.ReconcilingBalance - TargetReconcilingBalance.value;
|
||||||
|
accounts.SubmitReconcilation(diff);
|
||||||
|
accounts.Reconciling = false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user