Merge branch 'develop' into feature/cierres
This commit is contained in:
@ -45,6 +45,8 @@ abstract class Repository implements Define\Repository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Define\Model
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function fetchById(int $id): Define\Model
|
||||
|
||||
@ -88,8 +88,8 @@ class Movimientos extends Ideal\Controller
|
||||
$sociedades_ruts = $input['sociedades_ruts'];
|
||||
foreach ($sociedades_ruts as $sociedadRut) {
|
||||
try {
|
||||
$movimientos = $movimientoService->getAmountBySociedadAndMes($sociedadRut, new DateTimeImmutable($input['mes']), $input['amount'] ?? null);
|
||||
$output['movimientos'] = array_merge($output['movimientos'], $this->movimientosToArray($movimientos));
|
||||
$movimientos = $movimientoService->getAmountBySociedadAndMes($sociedadRut, new DateTimeImmutable($input['mes']), $input['amount'] ?? null);
|
||||
$output['movimientos'] = array_merge($output['movimientos'], $this->movimientosToArray($movimientos));
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
|
||||
@ -54,6 +54,11 @@ class Movimiento extends Ideal\Repository
|
||||
return $this->update($model, ['cuenta_id', 'fecha', 'glosa', 'documento', 'cargo', 'abono', 'saldo'], $new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cuenta_id
|
||||
* @return array
|
||||
* @throws Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByCuenta(int $cuenta_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -97,6 +102,13 @@ class Movimiento extends Ideal\Repository
|
||||
->where("cuenta_id = ? AND fecha = ? AND SUBSTRING(LOWER(LTRIM(glosa)), 0, {$len}) = SUBSTRING(LOWER(LTRIM(?)), 0, {$len}) AND cargo = ? AND abono = ? AND saldo = ?");
|
||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d'), $glosa, $cargo, $abono, $saldo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $start
|
||||
* @param int $amount
|
||||
* @return array
|
||||
* @throws Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchAmountStartingFrom(int $start, int $amount): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -105,6 +117,14 @@ class Movimiento extends Ideal\Repository
|
||||
->limit($amount, $start);
|
||||
return $this->fetchMany($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sociedad_rut
|
||||
* @param DateTimeInterface $mes
|
||||
* @param int|null $amount
|
||||
* @return array
|
||||
* @throws Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchAmountBySociedadAndMes(int $sociedad_rut, DateTimeInterface $mes, ?int $amount): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
|
||||
@ -19,10 +19,13 @@ class Proveedor extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Model\Inmobiliaria\Proveedor
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['rut', 'digito', 'nombre', 'razon']))
|
||||
$map = new Implement\Repository\MapperParser(['rut', 'digito', 'nombre', 'razon'])
|
||||
->register('contacto_rut', (new Implement\Repository\Mapper())
|
||||
->setProperty('contacto')
|
||||
->setFunction(function($data) {
|
||||
if ($data['contacto_rut'] === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->personaService->getById($data['contacto_rut']);
|
||||
})
|
||||
->setDefault(null));
|
||||
|
||||
Reference in New Issue
Block a user