Operation summary filter correction.

This commit is contained in:
Djonathan 2022-07-08 15:01:00 -03:00
parent 471c4fb3ed
commit 9ae172db78
3 changed files with 5 additions and 3 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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')