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