summaryrefslogtreecommitdiffstats
path: root/lib/account
diff options
context:
space:
mode:
Diffstat (limited to 'lib/account')
-rw-r--r--lib/account/account.ml12
-rw-r--r--lib/account/type_hierarchy.ml6
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/account/account.ml b/lib/account/account.ml
index 0ef3d28..56734c3 100644
--- a/lib/account/account.ml
+++ b/lib/account/account.ml
@@ -76,7 +76,7 @@ let rec unsafe_update_bal_aux (aid : Path.t) (dc : Money.Debit_credit.t)
76 | None -> Error Not_found 76 | None -> Error Not_found
77 | Some subacc -> 77 | Some subacc ->
78 let open Result.Let_syntax in 78 let open Result.Let_syntax in
79 let%bind subacc' = 79 let%map subacc' =
80 (* TODO: when reporting at which level Not_found fails, 80 (* TODO: when reporting at which level Not_found fails,
81 we want to make sure that we extend the information 81 we want to make sure that we extend the information
82 in the error with the current aid0 (so we recover a 82 in the error with the current aid0 (so we recover a
@@ -86,7 +86,7 @@ let rec unsafe_update_bal_aux (aid : Path.t) (dc : Money.Debit_credit.t)
86 let core' = 86 let core' =
87 Kernel.Subtree (Map.set subaccs ~key:aid0 ~data:subacc') 87 Kernel.Subtree (Map.set subaccs ~key:aid0 ~data:subacc')
88 in 88 in
89 Ok (Option.value_exn (Kernel.make w.type_ w.extra core'))) 89 Option.value_exn (Kernel.make w.type_ w.extra core'))
90 90
91(* Unfortunate but true, there has to be some kind of a root account 91(* Unfortunate but true, there has to be some kind of a root account
92 with no type :) *) 92 with no type :) *)
@@ -106,16 +106,14 @@ let unsafe_update_bal (aid : Path.t) (dc : Money.Debit_credit.t)
106 we want to make sure that we extend the information 106 we want to make sure that we extend the information
107 in the error with the current aid0 (so we recover a 107 in the error with the current aid0 (so we recover a
108 full path to where the account is missing *) 108 full path to where the account is missing *)
109 let%bind subacc' = 109 let%map subacc' =
110 unsafe_update_bal_aux aid' dc by_amount in_comm subacc 110 unsafe_update_bal_aux aid' dc by_amount in_comm subacc
111 in 111 in
112 Ok (Map.set w ~key:aid0 ~data:subacc')) 112 Map.set w ~key:aid0 ~data:subacc')
113 113
114module Balanced_batch_acc_paths = Balanced_batch.Make (Path) 114module Balanced_batch_acc_paths = Balanced_batch.Make (Path)
115 115
116let apply_balanced_batch (b : Balanced_batch_acc_paths.t) (w : root) = 116let apply_balanced_batch (b : Balanced_batch_acc_paths.t) (w : root) =
117 Map.fold_result (Balanced_batch_acc_paths.entries b) ~init:w 117 Map.fold_result (Balanced_batch_acc_paths.entries b) ~init:w
118 ~f:(fun ~key:aid ~(data : Balanced_batch_acc_paths.entry) w -> 118 ~f:(fun ~key:aid ~(data : Balanced_batch_acc_paths.entry) w ->
119 let open Result.Let_syntax in 119 unsafe_update_bal aid data.dc data.amount data.commodity w)
120 let%bind w = unsafe_update_bal aid data.dc data.amount data.commodity w in
121 Ok w)
diff --git a/lib/account/type_hierarchy.ml b/lib/account/type_hierarchy.ml
index 7f27830..8c20f07 100644
--- a/lib/account/type_hierarchy.ml
+++ b/lib/account/type_hierarchy.ml
@@ -31,9 +31,9 @@ let canonical : trunk =
31 make [ ("Accounts_payable", make []); ("Credit", make []) ] ) ); 31 make [ ("Accounts_payable", make []); ("Credit", make []) ] ) );
32 ] 32 ]
33 33
34(* In this module, only the following two function entertains the 34(* In this module, only the following function entertains the option
35 option that the given path may not be valid (i.e., it does not 35 that the given path may not be valid (i.e., it does not throw an
36 throw an exception for invalid paths). *) 36 exception for invalid paths). *)
37let rec get_node : path -> tree option = 37let rec get_node : path -> tree option =
38 let open Option.Let_syntax in 38 let open Option.Let_syntax in
39 function 39 function