Table with totalizer error - date group by month
rodrigodeniel opened this issue · comments
Package
filament/filament
Package Version
v3.2.91
Laravel Version
v10.48.11
Livewire Version
v3.5.0
PHP Version
PHP 8.2.16
Problem description
The table presents a calculation error in the totalizer, when the date field is grouped by month/year.
The example below shows the summary for the month of May adding only the last record.
In this case I am using: ->configure([Table::$defaultDateDisplayFormat = 'F Y'])
Expected behavior
When not grouping, the sum is obtained correctly, but the grouping is by day/month/year
//->configure([Table::$defaultDateDisplayFormat = 'F Y'])
Steps to reproduce
This is the code used:
` public function table(Table $table): Table
{
return $table
->defaultGroup('DataVencimento')
->groupsOnly(false)
->groupingSettingsHidden()
->groupingDirectionSettingHidden(false)
->groups([
Group::make('DataVencimento')
->label('Vencimento')
->date()
->collapsible(true)
->titlePrefixedWithLabel(true)
,
])
->configure([
Table::$defaultDateDisplayFormat = 'F Y'
])
->defaultSort('DataVencimento', 'asc')
->columns([
Tables\Columns\TextColumn::make('CodigoVendaID')
->label('Venda'),
Tables\Columns\TextColumn::make('loja.NomeLoja')
->label('Farmácia'),
Tables\Columns\TextColumn::make('DataLancamento')
->label('Lançamento')
->searchable()
->datetime('d/m/Y')
->sortable(),
Tables\Columns\TextColumn::make('Parcela'),
Tables\Columns\TextColumn::make('DataVencimento')
->label('Vencimento')
->searchable()
->datetime('d/m/Y')
->sortable(),
Tables\Columns\TextColumn::make('Saldo')
->label('Saldo')
->formatStateUsing(fn ($state): string => 'R$ ' . number_format((float) $state, 2, ',', '.'))
->summarize(
Sum::make()
->label('Total:')
->extraAttributes(['class' => 'font-bold'])
->formatStateUsing(fn ($state): string => 'R$ ' . number_format((float) $state, 2, ',', '.')),
)
,
])
->filters([
//
])
->actions([
//
]);
}`
Reproduction repository (issue will be closed if this is not valid)
https://github.com/rodrigodeniel/filament-table-error
Relevant log output
No response
Donate 💰 to fund this issue
- You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
- 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
- Thank you in advance for helping us make maintenance sustainable!
Please create a complete reproduction repository that we can run locally, not just a single resource's files. 🙂