Correction of monthly captive x free consultation.
This commit is contained in:
parent
d6d41184df
commit
f7716475f2
@ -78,5 +78,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
setlocale(LC_TIME, 'pt_BR');
|
setlocale(LC_TIME, 'pt_BR');
|
||||||
|
Carbon::setlocale(LC_TIME, 'pt_BR');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
return $this->execute($params, $field)
|
return $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-12-01'), 'YYYY-MM-DD') - interval '1' year"))
|
||||||
->groupBy(['ano', 'dad_estimado'])
|
->groupBy(['ano', 'dad_estimado'])
|
||||||
->orderBy(DB::raw("ano, dad_estimado"))
|
->orderBy(DB::raw("ano, dad_estimado"))
|
||||||
->get();
|
->get();
|
||||||
@ -59,16 +59,17 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
$field = [
|
$field = [
|
||||||
DB::raw("TO_DATE(economia.mes, 'YYMM') as mes"),
|
DB::raw("TO_DATE(economia.mes, 'YYMM') as mes"),
|
||||||
DB::raw("SUM(economia.economia_acumulada)/1000 as economia_acumulada"),
|
DB::raw("SUM(economia.economia_acumulada)/1000 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_cativo)) as econ_percentual"),
|
||||||
"economia.dad_estimado"
|
"economia.dad_estimado"
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $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-12-01'), 'YYYY-MM-DD') - interval '1' year"))
|
||||||
->groupBy(['mes', 'dad_estimado'])
|
->groupBy(['mes', 'dad_estimado'])
|
||||||
->orderBy(DB::raw("mes, dad_estimado"))
|
->orderBy(DB::raw("mes, dad_estimado"))
|
||||||
|
->havingRaw("sum(custo_livre) > 0")
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return collect(static::checkDate($result))
|
return collect(static::checkDate($result))
|
||||||
@ -78,7 +79,7 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cativo x livre mensal*/
|
/* cativo x livre mensal*/
|
||||||
public function getCaptiveMonthlyEconomy($params)
|
public function getCaptiveMonthlyEconomy($params): Collection|array
|
||||||
{
|
{
|
||||||
$field = [
|
$field = [
|
||||||
DB::raw("TO_CHAR(TO_DATE(economia.mes, 'YYMM'), 'MM/YYYY') as mes"),
|
DB::raw("TO_CHAR(TO_DATE(economia.mes, 'YYMM'), 'MM/YYYY') as mes"),
|
||||||
@ -90,6 +91,7 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
];
|
];
|
||||||
|
|
||||||
return $this->execute($params, $field)
|
return $this->execute($params, $field)
|
||||||
|
->where('dados_cadastrais.codigo_scde', '!=', '0P')
|
||||||
->whereBetween(
|
->whereBetween(
|
||||||
DB::raw("TO_DATE(economia.mes, 'YYMM')"),
|
DB::raw("TO_DATE(economia.mes, 'YYMM')"),
|
||||||
[
|
[
|
||||||
@ -98,6 +100,7 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
|||||||
])
|
])
|
||||||
->whereRaw("TO_DATE(economia.mes, 'YYMM') >= TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - INTERVAL '0' year")
|
->whereRaw("TO_DATE(economia.mes, 'YYMM') >= TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - INTERVAL '0' year")
|
||||||
->groupBy(['mes', 'dad_estimado'])
|
->groupBy(['mes', 'dad_estimado'])
|
||||||
|
->havingRaw("sum(custo_livre) > 0")
|
||||||
->orderBy(DB::raw("mes, dad_estimado"))
|
->orderBy(DB::raw("mes, dad_estimado"))
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'faker_locale' => 'en_US',
|
'faker_locale' => 'pt_BR',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user