diff --git a/package.json b/package.json index 63d4d35..e194d81 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,14 @@ "build": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "prepare": "svelte-kit sync" }, "devDependencies": { "@sveltejs/adapter-static": "^3.0.1", "@sveltejs/kit": "^2.0.6", "bulma": "^0.9.4", - "sass": "^1.69.5", + "sass": "^1.69.6", "svelte": "^4.2.8", "svelte-check": "^3.6.2", "tslib": "^2.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 95d7df0..54f5f5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,14 +18,14 @@ devDependencies: specifier: ^0.9.4 version: 0.9.4 sass: - specifier: ^1.69.5 - version: 1.69.5 + specifier: ^1.69.6 + version: 1.69.6 svelte: specifier: ^4.2.8 version: 4.2.8 svelte-check: specifier: ^3.6.2 - version: 3.6.2(sass@1.69.5)(svelte@4.2.8) + version: 3.6.2(sass@1.69.6)(svelte@4.2.8) tslib: specifier: ^2.6.2 version: 2.6.2 @@ -34,7 +34,7 @@ devDependencies: version: 5.3.3 vite: specifier: ^5.0.10 - version: 5.0.10(sass@1.69.5) + version: 5.0.10(sass@1.69.6) packages: @@ -443,7 +443,7 @@ packages: sirv: 2.0.4 svelte: 4.2.8 tiny-glob: 0.2.9 - vite: 5.0.10(sass@1.69.5) + vite: 5.0.10(sass@1.69.6) dev: true /@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.8)(vite@5.0.10): @@ -457,7 +457,7 @@ packages: '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.2.8)(vite@5.0.10) debug: 4.3.4 svelte: 4.2.8 - vite: 5.0.10(sass@1.69.5) + vite: 5.0.10(sass@1.69.6) transitivePeerDependencies: - supports-color dev: true @@ -476,7 +476,7 @@ packages: magic-string: 0.30.5 svelte: 4.2.8 svelte-hmr: 0.15.3(svelte@4.2.8) - vite: 5.0.10(sass@1.69.5) + vite: 5.0.10(sass@1.69.6) vitefu: 0.2.5(vite@5.0.10) transitivePeerDependencies: - supports-color @@ -988,8 +988,8 @@ packages: rimraf: 2.7.1 dev: true - /sass@1.69.5: - resolution: {integrity: sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==} + /sass@1.69.6: + resolution: {integrity: sha512-qbRr3k9JGHWXCvZU77SD2OTwUlC+gNT+61JOLcmLm+XqH4h/5D+p4IIsxvpkB89S9AwJOyb5+rWNpIucaFxSFQ==} engines: {node: '>=14.0.0'} hasBin: true dependencies: @@ -1033,7 +1033,7 @@ packages: min-indent: 1.0.1 dev: true - /svelte-check@3.6.2(sass@1.69.5)(svelte@4.2.8): + /svelte-check@3.6.2(sass@1.69.6)(svelte@4.2.8): resolution: {integrity: sha512-E6iFh4aUCGJLRz6QZXH3gcN/VFfkzwtruWSRmlKrLWQTiO6VzLsivR6q02WYLGNAGecV3EocqZuCDrC2uttZ0g==} hasBin: true peerDependencies: @@ -1046,7 +1046,7 @@ packages: picocolors: 1.0.0 sade: 1.8.1 svelte: 4.2.8 - svelte-preprocess: 5.1.3(sass@1.69.5)(svelte@4.2.8)(typescript@5.3.3) + svelte-preprocess: 5.1.3(sass@1.69.6)(svelte@4.2.8)(typescript@5.3.3) typescript: 5.3.3 transitivePeerDependencies: - '@babel/core' @@ -1069,7 +1069,7 @@ packages: svelte: 4.2.8 dev: true - /svelte-preprocess@5.1.3(sass@1.69.5)(svelte@4.2.8)(typescript@5.3.3): + /svelte-preprocess@5.1.3(sass@1.69.6)(svelte@4.2.8)(typescript@5.3.3): resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} requiresBuild: true @@ -1110,7 +1110,7 @@ packages: '@types/pug': 2.0.10 detect-indent: 6.1.0 magic-string: 0.30.5 - sass: 1.69.5 + sass: 1.69.6 sorcery: 0.11.0 strip-indent: 3.0.0 svelte: 4.2.8 @@ -1165,7 +1165,7 @@ packages: hasBin: true dev: true - /vite@5.0.10(sass@1.69.5): + /vite@5.0.10(sass@1.69.6): resolution: {integrity: sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -1196,7 +1196,7 @@ packages: esbuild: 0.19.10 postcss: 8.4.32 rollup: 4.9.1 - sass: 1.69.5 + sass: 1.69.6 optionalDependencies: fsevents: 2.3.3 dev: true @@ -1209,7 +1209,7 @@ packages: vite: optional: true dependencies: - vite: 5.0.10(sass@1.69.5) + vite: 5.0.10(sass@1.69.6) dev: true /wrappy@1.0.2: diff --git a/src/lib/InvoiceForm.svelte b/src/lib/InvoiceForm.svelte index 5517581..9f60851 100644 --- a/src/lib/InvoiceForm.svelte +++ b/src/lib/InvoiceForm.svelte @@ -2,7 +2,7 @@ import { browser } from "$app/environment"; import { goto } from "$app/navigation"; import { invoice } from "../store"; - import { DecimalFixed } from "./decimal"; + import { DecimalFixed, DecimalFixedNum } from "./decimal"; const currencies = ["£", "$", "€"]; const fromPlaceholder = `From Goldenhand Software @@ -26,12 +26,13 @@ willy@wonka.com for (const row of $invoice.rows) { if (row.rate == undefined || row.quantity == undefined) { row.amount = ""; - } else { - row.rate = Math.floor(row.rate * 100) / 100; - row.quantity = Math.floor(row.quantity * 100) / 100; - row.amount = DecimalFixed(row.rate * row.quantity); - $invoice.totalAmount += parseFloat(row.amount); - } + continue + } + + row.rate = DecimalFixedNum(row.rate); + row.quantity = DecimalFixedNum(row.quantity); + row.amount = DecimalFixed(row.rate * row.quantity); + $invoice.totalAmount += parseFloat(row.amount); } } @@ -78,8 +79,8 @@ willy@wonka.com function setAutoDueDate(event: Event) { const target = event.target as HTMLInputElement; - const futureDate = new Date(Date.parse(target.value) + 15 * dayInMs); - $invoice.dueDate = futureDate.toISOString().split('T')[0]; + const futureDate = new Date(Date.parse(target.value) + 15 * dayInMs); + $invoice.dueDate = futureDate.toISOString().split("T")[0]; } function addRow() { @@ -269,7 +270,7 @@ willy@wonka.com
Total: {$invoice.currencySymbol}{DecimalFixed( - $invoice.totalAmount + $invoice.totalAmount, )}