Support spaces in quoted metadata values

This commit is contained in:
Ben Sturmfels 2024-02-20 14:37:54 +11:00
parent 783d98c4da
commit 5421ae8adc
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
2 changed files with 4 additions and 11 deletions

View file

@ -166,6 +166,7 @@
name name
"rt:19462/674660" "rt:19462/674660"
(let [r-super-lines (filter #(str/starts-with? (:category %) "403b") records) (let [r-super-lines (filter #(str/starts-with? (:category %) "403b") records)
;; TODO: Have I got the liability/witholding right? Which is used in which report.
r-witholding-lines (filter #(= (:type %) "Withholding") records) r-witholding-lines (filter #(= (:type %) "Withholding") records)
r-insurance-lines (filter #(and (= (:type %) "Withholding") r-insurance-lines (filter #(and (= (:type %) "Withholding")
(str/includes? (:category %) "NY Disability")) records) (str/includes? (:category %) "NY Disability")) records)

View file

@ -16,9 +16,7 @@
:key ::token :key ::token
:_ #{\:} :_ #{\:}
:_ ::whitespace :_ ::whitespace
:_ #{\"} :value ::quoted-token
:value ::token
:_ #{\"}
:_ #{\newline})) :_ #{\newline}))
(s/def ::posting (s/def ::posting
@ -62,11 +60,9 @@
;; posting amount to bigdec ;; posting amount to bigdec
(and (= (type %) clojure.lang.PersistentArrayMap) (and (= (type %) clojure.lang.PersistentArrayMap)
(contains? % :amount)) (dissoc (update % :amount bigdec) :_) (contains? % :amount)) (dissoc (update % :amount bigdec) :_)
;; flatten description ;; flatten quoted-tokens
(and (= (type %) clojure.lang.PersistentArrayMap) (and (= (type %) clojure.lang.PersistentArrayMap)
(contains? % :desc)) (-> % (contains? % :token)) (:token %)
(update :desc :token)
(dissoc :_))
;; drop :_ keys ;; drop :_ keys
(= (type %) clojure.lang.PersistentArrayMap) (dissoc % :_) (= (type %) clojure.lang.PersistentArrayMap) (dissoc % :_)
;; convert {:key a :value b} to {:a b} ;; convert {:key a :value b} to {:a b}
@ -83,7 +79,3 @@
[text] [text]
(let [tree (s/conform ::transactions (conj (vec text) \newline))] (let [tree (s/conform ::transactions (conj (vec text) \newline))]
(convert-parse-tree tree))) (convert-parse-tree tree)))
(convert-parse-tree
[{:desc {:token "foo"}}])