Fix ordering Gross Monthly Savings.
This commit is contained in:
parent
16c65f8471
commit
57bafadc4d
@ -10,6 +10,7 @@ use DateInterval;
|
|||||||
use DatePeriod;
|
use DatePeriod;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@ -54,13 +55,13 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
public function getGrossMonthlyEconomy($params)
|
public function getGrossMonthlyEconomy($params)
|
||||||
{
|
{
|
||||||
$field = [
|
$field = [
|
||||||
DB::raw("TO_CHAR(TO_DATE(economia.mes, 'YYMM'), 'MM/YYYY') as mes"),
|
DB::raw("TO_DATE(economia.mes, 'YYMM') as mes"),
|
||||||
DB::raw("SUM(economia.economia_acumulada) as economia_acumulada"),
|
DB::raw("SUM(economia.economia_acumulada) as economia_acumulada"),
|
||||||
DB::raw("(SUM(economia.economia_mensal)/SUM(economia.custo_livre)) as econ_percentual"),
|
DB::raw("(SUM(economia.economia_mensal)/SUM(economia.custo_livre)) as econ_percentual"),
|
||||||
"economia.dad_estimado"
|
"economia.dad_estimado"
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->execute($params, $field)
|
$result = $this->execute($params, $field)
|
||||||
->where(DB::raw("TO_DATE(economia.mes, 'YYMM')"),
|
->where(DB::raw("TO_DATE(economia.mes, 'YYMM')"),
|
||||||
">=",
|
">=",
|
||||||
DB::raw("TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - interval '1' year"))
|
DB::raw("TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - interval '1' year"))
|
||||||
@ -68,6 +69,9 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
->orderBy('mes')
|
->orderBy('mes')
|
||||||
->orderBy('dad_estimado')
|
->orderBy('dad_estimado')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
return collect($result)->transform(fn($value) => Arr::set($value, 'mes', date_format(date_create($value['mes']), "m/Y")))->all();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCaptiveMonthlyEconomy($params)
|
public function getCaptiveMonthlyEconomy($params)
|
||||||
|
|||||||
@ -13,13 +13,4 @@ class FaqRepository extends AbstractRepository implements FaqContractInterface
|
|||||||
parent::__construct($faq);
|
parent::__construct($faq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function intdex()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user