Skip to content

Commit

Permalink
Fix categories sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Bishop committed Apr 23, 2022
1 parent 25f8fb0 commit 7c8378f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ability_cash/sql_schema/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ import (
)

const (
AccountsSql = "SELECT Id, Name, StartingBalance, Currency FROM Accounts WHERE NOT Deleted"
CurrenciesSql = "SELECT Id, Code, Precision FROM Currencies WHERE NOT Deleted"
CategoriesSql = "SELECT Id, Name, Parent FROM Categories WHERE NOT Deleted ORDER BY Parent"
AccountsSql = "SELECT Id, Name, StartingBalance, Currency FROM Accounts WHERE NOT Deleted"
CurrenciesSql = "SELECT Id, Code, Precision FROM Currencies WHERE NOT Deleted"
CategoriesSql = `
WITH RECURSIVE parents AS (
SELECT Id, Name, Parent FROM Categories WHERE Parent IS NULL AND NOT Deleted
UNION ALL
SELECT Categories.Id, Categories.Name, Categories.Parent FROM Categories
JOIN parents ON parents.Id == Categories.Parent
WHERE NOT Categories.Deleted
)
SELECT * FROM parents
`
RatesSql = "SELECT RateDate, Currency1, Currency2, Value1, Value2 FROM CurrencyRates WHERE NOT Deleted ORDER BY RateDate"
TxCategoriesSql = "SELECT Category, \"Transaction\" FROM TransactionCategories WHERE NOT Deleted"
TxsSql = `
Expand Down

0 comments on commit 7c8378f

Please sign in to comment.