Commit 415fe263 authored by phil's avatar phil

introduce event type plain

parent 4a3278c1
......@@ -15,7 +15,8 @@
(def match-template (partial re-matches #".*\.hbs"))
(s/def ::type #{"opening" ;; Eröffnungsbilanz
(s/def ::type #{"plain" ;; Allgemeine Buchung
"opening" ;; Eröffnungsbilanz
"invoice" ;; Rechnung wurde gestellt
"settlement" ;; Rechnung wurde beglichen
"expense" ;; Ausgabe
......
......@@ -7,6 +7,7 @@
[easy.transform :refer [transform]]
[easy.overview :as overview]
[easy.invoice :as invoice]
easy.plain
easy.expense
easy.refund
easy.opening
......
(ns easy.plain
(:require [cljs.spec.alpha :as s]
[easy.util :as util :refer [assoc*]]
[easy.common :as common]
[easy.config :refer [config]]
[easy.transform :refer [transform]]))
;; spec
;; required
(s/def ::type #{"plain"})
(s/def ::date util/date?)
(s/def ::amount float?)
(s/def ::source string?)
(s/def ::target string?)
;; optional
(s/def ::description string?)
(s/def ::iso-date (s/and string? common/match-iso-date))
(s/def ::ledger-template (s/and string? common/match-template))
(s/def ::event (s/keys :req-un [::type
::date
::amount
::source
::target
::description]
:opt-un [::iso-date
::ledger-template]))
;; defaults
(def defaults
{})
(def merge-defaults
(partial merge defaults))
;; transformer
(defmethod transform :plain [_ event]
(-> event
(common/validate! ::event)
common/add-iso-date
(assoc* :ledger-template
(get-in @config [:templates :ledger :plain]))
(common/validate! ::event)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment