|
1 | 1 | (ns easy.common |
2 | 2 | "This namespace covers the common requirements for all events." |
3 | | - (:require [cljs.spec.alpha :as s] |
| 3 | + (:require [clojure.spec.alpha :as s] |
4 | 4 | [easy.util :as util :refer [assoc*]] |
5 | | - [cljs-time.core :as cljs-time] |
6 | | - [cljs-time.format :as time])) |
7 | | - |
8 | | - |
9 | | -;; spec |
| 5 | + [clj-time.core :as time] |
| 6 | + [clj-time.coerce :as coerce] |
| 7 | + [clj-time.format :as format])) |
10 | 8 |
|
| 9 | +;;; spec |
11 | 10 |
|
12 | 11 | (def match-iso-date (partial re-matches #"^\d{4}-\d\d-\d\d$")) |
13 | 12 | (def match-template (partial re-matches #".*\.hbs")) |
|
26 | 25 | "salary" ;; Gehalt |
27 | 26 | "outlay" ;; Spesenabrechnung |
28 | 27 | "redistribution" ;; "200ok Sozialfaktor" |
29 | | - "dctd"}) ;; Diner's Club Transaction Details |
| 28 | + "dctd" ;; Diner's Club Transaction Details |
| 29 | + "pfcc"}) ;; Postfinance Credit Cards |
30 | 30 |
|
31 | 31 | (s/def ::date (s/or :date util/date? |
32 | 32 | :iso-string (s/and string? match-iso-date))) |
|
39 | 39 | ::file])) |
40 | 40 | (s/def ::events (s/coll-of ::event)) |
41 | 41 |
|
42 | | - |
43 | | -;; helpers |
44 | | - |
| 42 | +;;; helpers |
45 | 43 |
|
46 | 44 | (defn ignore-warning? |
47 | 45 | "Checks if `evt` has `:ignore-warnings` set for `key`." |
48 | 46 | [evt key] |
49 | 47 | (->> (get evt :ignore-warnings []) |
50 | 48 | (util/include? (name key)))) |
51 | 49 |
|
52 | | - |
53 | 50 | (defn harmonize [evt] |
54 | 51 | (->> evt |
55 | 52 | (util/harmonize-date-field :date) |
56 | 53 | ;; TODO: remove, we don' use `:settled` anymore |
57 | 54 | (util/harmonize-date-field :settled))) |
58 | 55 |
|
59 | | - |
60 | 56 | (defn validate! |
61 | 57 | "Same as `util/validate!`, but with arguments swapped." |
62 | 58 | [x spec] |
63 | 59 | (util/validate! spec x)) |
64 | 60 |
|
65 | | - |
66 | 61 | (defn make-iso-date [date] |
67 | | - (->> date |
68 | | - cljs-time/date-time |
69 | | - (time/unparse util/iso-formatter))) |
70 | | - |
| 62 | + (format/unparse util/iso-formatter date)) |
71 | 63 |
|
72 | | -;; transformers |
| 64 | +;;; transformers |
73 | 65 |
|
74 | 66 | (defn add-iso-date |
75 | 67 | "Transformer that takes the value of `:date`, builds an iso-date |
|
0 commit comments