Summerise when using cents?

As I am now storing values as intergers, what's the recommend approach for Summerising? Wondering if we should just cast at * 100 by default?
Solution:
Answer:
->money('EUR', 100)
->money('EUR', 100)
...
Jump to solution
2 Replies
toeknee
toeknee6mo ago
i.e.
TextColumn::make('total')
->label('Total')
->alignCenter()
->toggleable()
->formatStateUsing(
fn ($state): string => (number_format((float) $state, 2))
)
->summarize([
Tables\Columns\Summarizers\Sum::make()

->numeric(
decimalPlaces: 0,
decimalSeparator: '.',
thousandsSeparator: ',',
)
->label('Total'),
])
->default(0),
TextColumn::make('total')
->label('Total')
->alignCenter()
->toggleable()
->formatStateUsing(
fn ($state): string => (number_format((float) $state, 2))
)
->summarize([
Tables\Columns\Summarizers\Sum::make()

->numeric(
decimalPlaces: 0,
decimalSeparator: '.',
thousandsSeparator: ',',
)
->label('Total'),
])
->default(0),
How do we cast the value to dollars since formatStateUsing doesn't work on Sum
Solution
toeknee
toeknee6mo ago
Answer:
->money('EUR', 100)
->money('EUR', 100)