Revisiones
This commit is contained in:
@ -6,6 +6,13 @@ use Phinx\Seed\AbstractSeed;
|
||||
|
||||
class Comuna extends AbstractSeed
|
||||
{
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
'Provincia',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
@ -29,6 +36,9 @@ class Comuna extends AbstractSeed
|
||||
if (str_contains($column, 'id')) {
|
||||
return 'id';
|
||||
}
|
||||
if (str_contains($column, 'provincia')) {
|
||||
return 'provincia';
|
||||
}
|
||||
return $column;
|
||||
}, $columns);
|
||||
$data = array_map(function ($row) use ($columns) {
|
||||
|
@ -6,6 +6,13 @@ use Phinx\Seed\AbstractSeed;
|
||||
|
||||
class Provincia extends AbstractSeed
|
||||
{
|
||||
public function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
'Region',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
@ -29,6 +36,9 @@ class Provincia extends AbstractSeed
|
||||
if (str_contains($column, 'id')) {
|
||||
return 'id';
|
||||
}
|
||||
if (str_contains($column, 'region')) {
|
||||
return 'region';
|
||||
}
|
||||
return $column;
|
||||
}, $columns);
|
||||
$data = array_map(function ($row) use ($columns) {
|
||||
|
@ -29,6 +29,9 @@ class Region extends AbstractSeed
|
||||
if (str_contains($column, 'id')) {
|
||||
return 'id';
|
||||
}
|
||||
if (str_contains($column, 'numeracion')) {
|
||||
return 'numeracion';
|
||||
}
|
||||
return $column;
|
||||
}, $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())
|
||||
->setProperty('proyectoTipoUnidad')
|
||||
->setFunction(function($data) {
|
||||
var_dump($data['pt']);
|
||||
return $this->proyectoTipoUnidadService->getById($data['pt']);
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
||||
|
@ -9,6 +9,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Exception\ServiceAction\Create;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
@ -23,6 +24,20 @@ class Cuota extends Ideal\Service
|
||||
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
|
||||
{
|
||||
$cuotas = $this->cuotaRepository->fetchPendientes();
|
||||
@ -130,4 +145,9 @@ class Cuota extends Ideal\Service
|
||||
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);
|
||||
$resetDatabase = ($_ENV['RESET_DATABASE'] === 'true') ?? false;
|
||||
$debug = ($_ENV['DEBUG'] === 'true') ?? false;
|
||||
$resetDatabase = (array_key_exists('RESET_DATABASE', $_ENV) and $_ENV['RESET_DATABASE'] === 'true') ?? false;
|
||||
$debug = (array_key_exists('DEBUG', $_ENV) and $_ENV['DEBUG'] === 'true') ?? false;
|
||||
|
||||
Benchmark::execute([$bootstrap, 'run'], ['debug' => $debug]);
|
||||
Benchmark::print();
|
||||
|
@ -96,27 +96,42 @@ class QueueTest extends TestCase
|
||||
$propiedad = $propiedadRepository->create($propiedadData);
|
||||
$propiedad = $propiedadRepository->save($propiedad);
|
||||
$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 = [
|
||||
'fecha' => $fecha,
|
||||
'propietario' => $propietario->rut,
|
||||
'propiedad' => $propiedad->id,
|
||||
'fecha_ingreso' => new DateTimeImmutable($fecha)->add(new DateInterval('P3D'))->format('Y-m-d'),
|
||||
'pie' => $pie->id,
|
||||
];
|
||||
$ventaRepository = $this->container->get(Repository\Venta::class);
|
||||
$venta = $ventaRepository->create($ventaData);
|
||||
$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 = [
|
||||
'venta' => $venta->id,
|
||||
'pie' => $pie->id,
|
||||
'fecha' => '2022-01-01',
|
||||
'valor' => 10000,
|
||||
'banco' => $banco->id,
|
||||
];
|
||||
$cuotaService = $this->container->get(Service\Venta\Cuota::class);
|
||||
$cuota = $cuotaService->add($cuotaData);
|
||||
|
||||
$this->assertEquals(0.0, $cuota->pago->uf);
|
||||
|
||||
$queueService = $this->container->get(Service\Queue::class);
|
||||
$queueService->run();
|
||||
|
||||
$cuota = $cuotaService->getById($cuota->id);
|
||||
|
Reference in New Issue
Block a user