mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-29 02:54:09 -05:00
feat: show full decimals while editing (#5808)
* show full decimals while editing * add changes * handle null
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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) : '',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
6
upcoming-release-notes/5808.md
Normal file
6
upcoming-release-notes/5808.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [csenel]
|
||||
---
|
||||
|
||||
show full decimals while editing regardless of hide decimals setting
|
||||
Reference in New Issue
Block a user