Operation summary filter correction.
This commit is contained in:
parent
471c4fb3ed
commit
9ae172db78
@ -21,14 +21,14 @@ class Helpers
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function orderByDate($result, $field = 'mes'): array
|
||||
public static function orderByDate($result, $format ='M/Y', $field = 'mes'): array
|
||||
{
|
||||
return collect($result)
|
||||
->transform(fn($value) => Arr::set(
|
||||
$value,
|
||||
$field,
|
||||
Carbon::createFromFormat('ym', $value['mes'])->locale('pt-BR')
|
||||
->translatedFormat('M/Y')))
|
||||
->translatedFormat($format)))
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class OperationSummaryController extends Controller
|
||||
{
|
||||
try {
|
||||
$response = $this->dadosTeContract->search($request->all(), true);
|
||||
$response = Helpers::orderByDate($response);
|
||||
$response = Helpers::orderByDate($response, 'm/Y');
|
||||
return (new OperationSummaryResource($response))
|
||||
->response()
|
||||
->setStatusCode(Response::HTTP_OK);
|
||||
|
||||
@ -45,6 +45,8 @@ class DadosTeRepository extends AbstractRepository implements DadosTeContractInt
|
||||
'dados_te.nf_c_icms'
|
||||
];
|
||||
|
||||
$params = static::filterRow($params);
|
||||
|
||||
$result = $this->execute($fields, $params)
|
||||
->whereRaw("TO_DATE(dados_te.mes, 'YYMM') >= TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - INTERVAL '1' year")
|
||||
->orderBy('mes', 'DESC')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user