A local-first personal finance app
feat: show full decimals while editing (#5808)
Çağdaş Şenele1c2f0a181bd
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.tsxindex ca2ec88163..7ba6fe9f55 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx@@ -57,6 +57,7 @@ import {} from 'loot-core/shared/transactions';import {amountToCurrency,+ currencyToAmount,type IntegerAmount,integerToCurrency,titleFirst,@@ -1591,6 +1592,10 @@ const Transaction = memo(function Transaction({exposed={focusedField === 'debit'}focused={focusedField === 'debit'}value={debit === '' && credit === '' ? amountToCurrency(0) : debit}+ formatter={value =>+ // reformat value so since we might have kept decimals+ value ? amountToCurrency(currencyToAmount(value) || 0) : ''+ }valueStyle={valueStyle}textAlign="right"title={debit}@@ -1618,6 +1623,10 @@ const Transaction = memo(function Transaction({exposed={focusedField === 'credit'}focused={focusedField === 'credit'}value={credit}+ formatter={value =>+ // reformat value so since we might have kept decimals+ value ? amountToCurrency(currencyToAmount(value) || 0) : ''+ }valueStyle={valueStyle}textAlign="right"title={credit}diff --git a/packages/desktop-client/src/components/transactions/table/utils.ts b/packages/desktop-client/src/components/transactions/table/utils.tsindex 1e0e34dd5c..4a29e01edb 100644--- a/packages/desktop-client/src/components/transactions/table/utils.ts+++ b/packages/desktop-client/src/components/transactions/table/utils.ts@@ -5,7 +5,7 @@ import { currentDay } from 'loot-core/shared/months';import {amountToInteger,type CurrencyAmount,- integerToCurrency,+ integerToCurrencyWithDecimal,} from 'loot-core/shared/util';import {type AccountEntity,@@ -58,11 +58,12 @@ export function serializeTransaction(date = null as unknown as string;}+ // Convert with decimals here so the value doesn't lose decimals and formatter will show or hide them.return {...transaction,date,- debit: debit != null ? integerToCurrency(debit) : '',- credit: credit != null ? integerToCurrency(credit) : '',+ debit: debit != null ? integerToCurrencyWithDecimal(debit) : '',+ credit: credit != null ? integerToCurrencyWithDecimal(credit) : '',};}diff --git a/packages/loot-core/src/shared/util.ts b/packages/loot-core/src/shared/util.tsindex 415303d8f6..7683a17da8 100644--- a/packages/loot-core/src/shared/util.ts+++ b/packages/loot-core/src/shared/util.ts@@ -430,6 +430,21 @@ export function integerToCurrency(return formatter.format(amount);}+export function integerToCurrencyWithDecimal(integerAmount: IntegerAmount) {+ // If decimal digits exist, keep them. Otherwise format them as usual.+ if (integerAmount % 100 !== 0) {+ return integerToCurrency(+ integerAmount,+ getNumberFormat({+ ...numberFormatConfig,+ hideFraction: false,+ }).formatter,+ );+ }++ return integerToCurrency(integerAmount);+}+export function amountToCurrency(amount: Amount): CurrencyAmount {return getNumberFormat().formatter.format(amount);}diff --git a/upcoming-release-notes/5808.md b/upcoming-release-notes/5808.mdnew file mode 100644index 0000000000..de2e8e5a38--- /dev/null+++ b/upcoming-release-notes/5808.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [csenel]+---++show full decimals while editing regardless of hide decimals setting