summaryrefslogtreecommitdiff
path: root/gui/src/types/currency
diff options
context:
space:
mode:
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 };