summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md7
-rw-r--r--Hledger/Web/Handler/MiscR.hs2
-rw-r--r--Hledger/Web/Json.hs14
-rw-r--r--hledger-web.cabal12
4 files changed, 25 insertions, 10 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 528ed6b..90f8bfa 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,13 @@
User-visible changes in hledger-web.
See also the hledger changelog.
+# 1.14.1 2019-03-20
+
+- /accounts JSON: return all accounts, not just top-level ones (#985)
+ Accounts are returned as a flat list, in tree order, with asubs fields empty.
+
+- use hledger 1.14.2
+
# 1.14 2019-03-01
- serve the same JSON-providing routes as in hledger-api:
diff --git a/Hledger/Web/Handler/MiscR.hs b/Hledger/Web/Handler/MiscR.hs
index da26eb3..3ffecdd 100644
--- a/Hledger/Web/Handler/MiscR.hs
+++ b/Hledger/Web/Handler/MiscR.hs
@@ -83,7 +83,7 @@ getAccountsR = do
VD{caps, j} <- getViewData
when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability")
selectRep $ do
- provideJson $ ledgerTopAccounts $ ledgerFromJournal Any j
+ provideJson $ laccounts $ ledgerFromJournal Any j
getAccounttransactionsR :: Text -> Handler TypedContent
getAccounttransactionsR a = do
diff --git a/Hledger/Web/Json.hs b/Hledger/Web/Json.hs
index 97d7250..ab9572d 100644
--- a/Hledger/Web/Json.hs
+++ b/Hledger/Web/Json.hs
@@ -54,6 +54,7 @@ instance ToJSON BalanceAssertion
instance ToJSON Price
instance ToJSON MarketPrice
instance ToJSON PostingType
+
instance ToJSON Posting where
toJSON Posting{..} = object
["pdate" .= toJSON pdate
@@ -71,7 +72,9 @@ instance ToJSON Posting where
-- This is probably not wanted in json, we discard it.
,"poriginal" .= toJSON (Nothing :: Maybe Posting)
]
+
instance ToJSON Transaction
+
instance ToJSON Account where
toJSON a = object
["aname" .= toJSON (aname a)
@@ -82,10 +85,12 @@ instance ToJSON Account where
-- To avoid a cycle, show just the parent account's name
-- in a dummy field. When re-parsed, there will be no parent.
,"aparent_" .= toJSON (maybe "" aname $ aparent a)
- -- To avoid a cycle, drop the subaccounts, showing just their names
- -- in a dummy field. When re-parsed, there will be no subaccounts.
- ,"asubs" .= toJSON ([]::[Account])
+ -- Just the names of subaccounts, as a dummy field, ignored when parsed.
,"asubs_" .= toJSON (map aname $ asubs a)
+ -- The actual subaccounts (and their subs..), making a (probably highly redundant) tree
+ -- ,"asubs" .= toJSON (asubs a)
+ -- Omit the actual subaccounts
+ ,"asubs" .= toJSON ([]::[Account])
]
-- From JSON
@@ -104,6 +109,9 @@ instance FromJSON PostingType
instance FromJSON Posting
instance FromJSON Transaction
instance FromJSON AccountDeclarationInfo
+-- XXX The ToJSON instance replaces subaccounts with just names.
+-- Here we should try to make use of those to reconstruct the
+-- parent-child relationships.
instance FromJSON Account
-- Decimal, various attempts
diff --git a/hledger-web.cabal b/hledger-web.cabal
index 5a23812..5e332c4 100644
--- a/hledger-web.cabal
+++ b/hledger-web.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
--- hash: da546060d989bf42b59988f7db214e93c1ac3e3d166272cbcdbf1c8cbd283187
+-- hash: 8eb80f6aa7e34e0b036d490c3c0f5994e3959f33045102d18cac6367c369c352
name: hledger-web
-version: 1.14
+version: 1.14.1
synopsis: Web interface for the hledger accounting tool
description: This is hledger's web interface.
It provides a more user-friendly and collaborative UI than the
@@ -151,7 +151,7 @@ library
hs-source-dirs:
./.
ghc-options: -Wall -fwarn-tabs
- cpp-options: -DVERSION="1.14"
+ cpp-options: -DVERSION="1.14.1"
build-depends:
Decimal
, aeson
@@ -169,8 +169,8 @@ library
, directory
, filepath
, hjsmin
- , hledger >=1.14 && <1.15
- , hledger-lib >=1.14 && <1.15
+ , hledger >=1.14.2 && <1.15
+ , hledger-lib >=1.14.1 && <1.15
, http-client
, http-conduit
, http-types
@@ -211,7 +211,7 @@ executable hledger-web
hs-source-dirs:
app
ghc-options: -Wall -fwarn-tabs
- cpp-options: -DVERSION="1.14"
+ cpp-options: -DVERSION="1.14.1"
build-depends:
base
, hledger-web