diff options
Diffstat (limited to 'lib/ledger.ml')
-rw-r--r-- | lib/ledger.ml | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/ledger.ml b/lib/ledger.ml index ba21e49..84a0146 100644 --- a/lib/ledger.ml +++ b/lib/ledger.ml | |||
@@ -1,4 +1,4 @@ | |||
1 | open Core | 1 | open Prelude |
2 | 2 | ||
3 | type account_type = Asset | Equity | Liability | Expense | Income | 3 | type account_type = Asset | Equity | Liability | Expense | Income |
4 | 4 | ||
@@ -87,12 +87,6 @@ module Labels = struct | |||
87 | Sexp.List [ Sexp.Atom "Unit_label"; [%sexp_of: unit_tag] tag ])) | 87 | Sexp.List [ Sexp.Atom "Unit_label"; [%sexp_of: unit_tag] tag ])) |
88 | end | 88 | end |
89 | 89 | ||
90 | module Z = struct | ||
91 | include Z | ||
92 | |||
93 | let sexp_of_t x = Sexp.Atom (Z.to_string x) | ||
94 | end | ||
95 | |||
96 | module Money : sig | 90 | module Money : sig |
97 | type t | 91 | type t |
98 | 92 | ||
@@ -142,7 +136,15 @@ type bal_assert = { | |||
142 | module Account_id_map = Map.Make (Account_id) | 136 | module Account_id_map = Map.Make (Account_id) |
143 | 137 | ||
144 | module Tx : sig | 138 | module Tx : sig |
145 | type t | 139 | (* Private because we only want to allow constructing balanced transactions. *) |
140 | type t = private { | ||
141 | cleared : Date.t option; | ||
142 | commodity_id : commodity_id; | ||
143 | debit : scalar Account_id_map.t; | ||
144 | credit : scalar Account_id_map.t; | ||
145 | labels : Labels.t; | ||
146 | } | ||
147 | |||
146 | type error = Unbalanced | 148 | type error = Unbalanced |
147 | 149 | ||
148 | val make : | 150 | val make : |
@@ -153,14 +155,8 @@ module Tx : sig | |||
153 | labels:Labels.t -> | 155 | labels:Labels.t -> |
154 | (t, error) result | 156 | (t, error) result |
155 | 157 | ||
156 | val cleared : t -> Date.t option | ||
157 | val commodity_id : t -> commodity_id | ||
158 | val debit : t -> scalar Account_id_map.t | ||
159 | val credit : t -> scalar Account_id_map.t | ||
160 | val labels : t -> Labels.t | ||
161 | val sexp_of_t : t -> Sexp.t | 158 | val sexp_of_t : t -> Sexp.t |
162 | end = struct | 159 | end = struct |
163 | (* We hide this because we only want to allow constructing balanced transactions *) | ||
164 | type t = { | 160 | type t = { |
165 | cleared : Date.t option; | 161 | cleared : Date.t option; |
166 | commodity_id : commodity_id; | 162 | commodity_id : commodity_id; |
@@ -168,7 +164,7 @@ end = struct | |||
168 | credit : scalar Account_id_map.t; | 164 | credit : scalar Account_id_map.t; |
169 | labels : Labels.t; | 165 | labels : Labels.t; |
170 | } | 166 | } |
171 | [@@deriving fields, sexp_of] | 167 | [@@deriving sexp_of] |
172 | 168 | ||
173 | type error = Unbalanced | 169 | type error = Unbalanced |
174 | 170 | ||