summaryrefslogtreecommitdiff
path: root/gui/src/types/currency
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2024-09-17 13:20:04 +0100
committerJoe Carstairs <me@joeac.net>2024-09-17 13:20:04 +0100
commitcd269b3540fb5e3a988c1b59d3763db360b1fb34 (patch)
treea728403d8d5708ad29eeed2b391706b09a93fe4c /gui/src/types/currency
parentf0e3e0cfb183253e03b1a61ddecb7b9330d47fdb (diff)
many, many changes
Diffstat (limited to 'gui/src/types/currency')
-rw-r--r--gui/src/types/currency/gbp.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/gui/src/types/currency/gbp.ts b/gui/src/types/currency/gbp.ts
index ce24e48..b88aae3 100644
--- a/gui/src/types/currency/gbp.ts
+++ b/gui/src/types/currency/gbp.ts
@@ -43,4 +43,12 @@ class Gbp implements Currency {
}
}
-export default Gbp;
+function newGbpFromDto(dto: unknown): Gbp {
+ const signedPence = dto as number;
+ const pounds = Math.floor(Math.abs(signedPence) / 100);
+ const pence = Math.abs(signedPence) % 100;
+ const sign = signedPence < 0 ? -1 : 1;
+ return new Gbp(pounds, pence, sign);
+}
+
+export { Gbp, newGbpFromDto };