diff options
| author | Rutger Broekhoff | 2026-03-09 22:40:21 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-03-09 22:40:21 +0100 |
| commit | 6b8cdd36608affc95617c48551c832147aff2e19 (patch) | |
| tree | 422e53f54f38f74a0b409757ef6c440f0130b150 /lib/account/account.ml | |
| parent | c90ff5253efd858a2bf0c20eaa2ee9763a402783 (diff) | |
| download | rdcapsis-ocaml.tar.gz rdcapsis-ocaml.zip | |
asdfocaml
Diffstat (limited to 'lib/account/account.ml')
| -rw-r--r-- | lib/account/account.ml | 12 |
1 files changed, 5 insertions, 7 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 | ||
| 114 | module Balanced_batch_acc_paths = Balanced_batch.Make (Path) | 114 | module Balanced_batch_acc_paths = Balanced_batch.Make (Path) |
| 115 | 115 | ||
| 116 | let apply_balanced_batch (b : Balanced_batch_acc_paths.t) (w : root) = | 116 | let 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) | ||