This commit is contained in:
swrup 2025-12-07 01:51:07 +01:00
parent e9b7142412
commit bb1431251c

View file

@ -12,11 +12,14 @@ module Caqti_type = struct
let amount : Amount.t t =
let open Amount in
custom
~encode:(fun amount -> Ok (amount.value, amount.fraction))
~decode:(fun (value, fraction) ->
Amount.make ~sign:None ~currency:Config.currency ~value ~fraction)
(t2 int64 int32)
let intro value fraction =
match make ~sign:None ~currency:Config.currency ~value ~fraction with
| Error e -> raise (Caqti_type.Reject e)
| Ok v -> v
in
let p1 t = t.value in
let p2 t = t.fraction in
product intro @@ proj int64 p1 @@ proj int32 p2 @@ proj_end
let age_mask : int t = Caqti_type.int