Revisiones
This commit is contained in:
@ -6,6 +6,13 @@ use Phinx\Seed\AbstractSeed;
|
|||||||
|
|
||||||
class Comuna extends AbstractSeed
|
class Comuna extends AbstractSeed
|
||||||
{
|
{
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Provincia',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Method.
|
* Run Method.
|
||||||
*
|
*
|
||||||
@ -29,6 +36,9 @@ class Comuna extends AbstractSeed
|
|||||||
if (str_contains($column, 'id')) {
|
if (str_contains($column, 'id')) {
|
||||||
return 'id';
|
return 'id';
|
||||||
}
|
}
|
||||||
|
if (str_contains($column, 'provincia')) {
|
||||||
|
return 'provincia';
|
||||||
|
}
|
||||||
return $column;
|
return $column;
|
||||||
}, $columns);
|
}, $columns);
|
||||||
$data = array_map(function ($row) use ($columns) {
|
$data = array_map(function ($row) use ($columns) {
|
||||||
|
@ -6,6 +6,13 @@ use Phinx\Seed\AbstractSeed;
|
|||||||
|
|
||||||
class Provincia extends AbstractSeed
|
class Provincia extends AbstractSeed
|
||||||
{
|
{
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Region',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Method.
|
* Run Method.
|
||||||
*
|
*
|
||||||
@ -29,6 +36,9 @@ class Provincia extends AbstractSeed
|
|||||||
if (str_contains($column, 'id')) {
|
if (str_contains($column, 'id')) {
|
||||||
return 'id';
|
return 'id';
|
||||||
}
|
}
|
||||||
|
if (str_contains($column, 'region')) {
|
||||||
|
return 'region';
|
||||||
|
}
|
||||||
return $column;
|
return $column;
|
||||||
}, $columns);
|
}, $columns);
|
||||||
$data = array_map(function ($row) use ($columns) {
|
$data = array_map(function ($row) use ($columns) {
|
||||||
|
@ -29,6 +29,9 @@ class Region extends AbstractSeed
|
|||||||
if (str_contains($column, 'id')) {
|
if (str_contains($column, 'id')) {
|
||||||
return 'id';
|
return 'id';
|
||||||
}
|
}
|
||||||
|
if (str_contains($column, 'numeracion')) {
|
||||||
|
return 'numeracion';
|
||||||
|
}
|
||||||
return $column;
|
return $column;
|
||||||
}, $columns);
|
}, $columns);
|
||||||
$data = array_map(function ($row) use ($columns) {
|
$data = array_map(function ($row) use ($columns) {
|
||||||
|
52
app/resources/database/seeds/TipoPago.php
Normal file
52
app/resources/database/seeds/TipoPago.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Seed\AbstractSeed;
|
||||||
|
|
||||||
|
class TipoPago extends AbstractSeed
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$table = $this->table('tipo_pago');
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'descripcion' => 'cheque',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'carta de resguardo',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'vale vista'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'deposito',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'efectivo',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'tarjeta de credito',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'transferencia electronica',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'virtual',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$table->truncate();
|
||||||
|
$table
|
||||||
|
->insert($data)
|
||||||
|
->saveData();
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,6 @@ class Unidad extends Ideal\Repository
|
|||||||
->register('pt', (new Implement\Repository\Mapper())
|
->register('pt', (new Implement\Repository\Mapper())
|
||||||
->setProperty('proyectoTipoUnidad')
|
->setProperty('proyectoTipoUnidad')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
var_dump($data['pt']);
|
|
||||||
return $this->proyectoTipoUnidadService->getById($data['pt']);
|
return $this->proyectoTipoUnidadService->getById($data['pt']);
|
||||||
}));
|
}));
|
||||||
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
||||||
|
@ -9,6 +9,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
use Incoviba\Exception\ServiceAction\Create;
|
use Incoviba\Exception\ServiceAction\Create;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
|
|
||||||
@ -23,6 +24,20 @@ class Cuota extends Ideal\Service
|
|||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $cuota_id
|
||||||
|
* @return Model\Venta\Cuota
|
||||||
|
* @throws Read
|
||||||
|
*/
|
||||||
|
public function getById(int $cuota_id): Model\Venta\Cuota
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->process($this->cuotaRepository->fetchById($cuota_id));
|
||||||
|
} catch (EmptyResult $exception) {
|
||||||
|
throw new Read(__CLASS__, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function pendientes(): array
|
public function pendientes(): array
|
||||||
{
|
{
|
||||||
$cuotas = $this->cuotaRepository->fetchPendientes();
|
$cuotas = $this->cuotaRepository->fetchPendientes();
|
||||||
@ -130,4 +145,9 @@ class Cuota extends Ideal\Service
|
|||||||
throw new Create(__CLASS__, $exception);
|
throw new Create(__CLASS__, $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function process(Model\Venta\Cuota $cuota): Model\Venta\Cuota
|
||||||
|
{
|
||||||
|
return $cuota;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,8 @@ spl_autoload_register(function($className) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$bootstrap = new TestBootstrap($_ENV);
|
$bootstrap = new TestBootstrap($_ENV);
|
||||||
$resetDatabase = ($_ENV['RESET_DATABASE'] === 'true') ?? false;
|
$resetDatabase = (array_key_exists('RESET_DATABASE', $_ENV) and $_ENV['RESET_DATABASE'] === 'true') ?? false;
|
||||||
$debug = ($_ENV['DEBUG'] === 'true') ?? false;
|
$debug = (array_key_exists('DEBUG', $_ENV) and $_ENV['DEBUG'] === 'true') ?? false;
|
||||||
|
|
||||||
Benchmark::execute([$bootstrap, 'run'], ['debug' => $debug]);
|
Benchmark::execute([$bootstrap, 'run'], ['debug' => $debug]);
|
||||||
Benchmark::print();
|
Benchmark::print();
|
||||||
|
@ -96,27 +96,42 @@ class QueueTest extends TestCase
|
|||||||
$propiedad = $propiedadRepository->create($propiedadData);
|
$propiedad = $propiedadRepository->create($propiedadData);
|
||||||
$propiedad = $propiedadRepository->save($propiedad);
|
$propiedad = $propiedadRepository->save($propiedad);
|
||||||
$fecha = $faker->date;
|
$fecha = $faker->date;
|
||||||
|
$pieData = [
|
||||||
|
'valor' => 10000,
|
||||||
|
'cuotas' => 12,
|
||||||
|
'fecha' => $fecha,
|
||||||
|
];
|
||||||
|
$pieRepository = $this->container->get(Repository\Venta\Pie::class);
|
||||||
|
$pie = $pieRepository->create($pieData);
|
||||||
|
$pie = $pieRepository->save($pie);
|
||||||
$ventaData = [
|
$ventaData = [
|
||||||
'fecha' => $fecha,
|
'fecha' => $fecha,
|
||||||
'propietario' => $propietario->rut,
|
'propietario' => $propietario->rut,
|
||||||
'propiedad' => $propiedad->id,
|
'propiedad' => $propiedad->id,
|
||||||
'fecha_ingreso' => new DateTimeImmutable($fecha)->add(new DateInterval('P3D'))->format('Y-m-d'),
|
'fecha_ingreso' => new DateTimeImmutable($fecha)->add(new DateInterval('P3D'))->format('Y-m-d'),
|
||||||
|
'pie' => $pie->id,
|
||||||
];
|
];
|
||||||
$ventaRepository = $this->container->get(Repository\Venta::class);
|
$ventaRepository = $this->container->get(Repository\Venta::class);
|
||||||
$venta = $ventaRepository->create($ventaData);
|
$venta = $ventaRepository->create($ventaData);
|
||||||
$venta = $ventaRepository->save($venta);
|
$venta = $ventaRepository->save($venta);
|
||||||
|
$bancoData = [
|
||||||
|
'nombre' => $faker->word,
|
||||||
|
];
|
||||||
|
$bancoRepository = $this->container->get(Repository\Contabilidad\Banco::class);
|
||||||
|
$banco = $bancoRepository->create($bancoData);
|
||||||
|
$banco = $bancoRepository->save($banco);
|
||||||
|
|
||||||
$cuotaData = [
|
$cuotaData = [
|
||||||
'venta' => $venta->id,
|
'pie' => $pie->id,
|
||||||
'fecha' => '2022-01-01',
|
'fecha' => '2022-01-01',
|
||||||
'valor' => 10000,
|
'valor' => 10000,
|
||||||
|
'banco' => $banco->id,
|
||||||
];
|
];
|
||||||
$cuotaService = $this->container->get(Service\Venta\Cuota::class);
|
$cuotaService = $this->container->get(Service\Venta\Cuota::class);
|
||||||
$cuota = $cuotaService->add($cuotaData);
|
$cuota = $cuotaService->add($cuotaData);
|
||||||
|
|
||||||
$this->assertEquals(0.0, $cuota->pago->uf);
|
$this->assertEquals(0.0, $cuota->pago->uf);
|
||||||
|
|
||||||
$queueService = $this->container->get(Service\Queue::class);
|
|
||||||
$queueService->run();
|
$queueService->run();
|
||||||
|
|
||||||
$cuota = $cuotaService->getById($cuota->id);
|
$cuota = $cuotaService->getById($cuota->id);
|
||||||
|
Reference in New Issue
Block a user