From cd269b3540fb5e3a988c1b59d3763db360b1fb34 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Tue, 17 Sep 2024 13:20:04 +0100 Subject: many, many changes --- gui/src/types/currency/gbp.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gui/src/types/currency') 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 }; -- cgit v1.2.3