Update ConfeccionResource.php
This commit is contained in:
@@ -176,7 +176,17 @@ class ConfeccionResource extends Resource
|
||||
|
||||
TextColumn::make('cantidad_enviada'),
|
||||
|
||||
TextColumn::make('cantidad_recibida'),
|
||||
TextColumn::make('recibidas_neto')
|
||||
->label('Cantidad recibida')
|
||||
->getStateUsing(function ($record) {
|
||||
$recepciones = (int) $record->recepciones()->sum(\DB::raw('cantidad - COALESCE(prendas_defectuosas, 0)'));
|
||||
$arreglos = (int) $record->ajustes()->where('tipo', 'arreglo')->sum('cantidad');
|
||||
return $recepciones - $arreglos;
|
||||
})
|
||||
->sortable(query: function ($query, $direction) {
|
||||
return $query->withSum('recepciones as recepciones_sum', \DB::raw('cantidad - COALESCE(prendas_defectuosas, 0)'))
|
||||
->orderBy('recepciones_sum', $direction);
|
||||
}),
|
||||
|
||||
TextColumn::make('faltantes')
|
||||
->label('Faltan')
|
||||
|
||||
Reference in New Issue
Block a user