Cleanup
This commit is contained in:
@ -36,11 +36,22 @@ class Broker extends Common\Ideal\Repository
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Define\Model $model
|
||||
* @param array $new_data
|
||||
* @return Model\Proyecto\Broker
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Proyecto\Broker
|
||||
{
|
||||
return $this->update($model, ['rut', 'digit', 'name'], $new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Model\Proyecto\Broker|null
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByName(string $name): ?Model\Proyecto\Broker
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
|
@ -42,11 +42,23 @@ class Contract extends Common\Ideal\Repository
|
||||
[$model->broker->rut, $model->proyecto->id, $model->commission]);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Common\Define\Model $model
|
||||
* @param array $new_data
|
||||
* @return Model\Proyecto\Broker\Contract
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Proyecto\Broker\Contract
|
||||
{
|
||||
return $this->update($model, ['broker_rut', 'proyecto_id', 'commission'], $new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $brokerRut
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByBroker(int $brokerRut): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -55,6 +67,12 @@ class Contract extends Common\Ideal\Repository
|
||||
->where('broker_rut = :broker_rut');
|
||||
return $this->fetchMany($query, ['broker_rut' => $brokerRut]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $proyecto_id
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByProject(int $proyecto_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -63,6 +81,12 @@ class Contract extends Common\Ideal\Repository
|
||||
->where('proyecto_id = :proyecto_id');
|
||||
return $this->fetchMany($query, ['proyecto_id' => $proyecto_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $brokerRut
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchActiveByBroker(int $brokerRut): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -72,6 +96,12 @@ class Contract extends Common\Ideal\Repository
|
||||
->where('a.broker_rut = :broker_rut AND bcs.state = :state');
|
||||
return $this->fetchMany($query, ['broker_rut' => $brokerRut, 'state' => Model\Proyecto\Broker\Contract\Type::ACTIVE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $proyecto_id
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchActiveByProject(int $proyecto_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -81,6 +111,13 @@ class Contract extends Common\Ideal\Repository
|
||||
->where('a.proyecto_id = :proyecto_id AND bcs.state = :state');
|
||||
return $this->fetchMany($query, ['proyecto_id' => $proyecto_id, 'state' => Model\Proyecto\Broker\Contract\Type::ACTIVE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $proyecto_id
|
||||
* @param int $brokerRut
|
||||
* @return Model\Proyecto\Broker\Contract
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchActiveByProjectAndBroker(int $proyecto_id, int $brokerRut): Model\Proyecto\Broker\Contract
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
|
@ -50,11 +50,23 @@ class Data extends Common\Ideal\Repository
|
||||
[$model->broker->rut, $model->representative?->rut, $model->legalName]);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Common\Define\Model $model
|
||||
* @param array $new_data
|
||||
* @return Model\Proyecto\Broker\Data
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Proyecto\Broker\Data
|
||||
{
|
||||
return $this->update($model, ['representative_rut', 'legal_name'], $new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $broker_rut
|
||||
* @return Model\Proyecto\Broker\Data
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByBroker(int $broker_rut): Model\Proyecto\Broker\Data
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Venta;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use DateTimeInterface;
|
||||
use DateInterval;
|
||||
use PDO;
|
||||
use Incoviba\Common;
|
||||
use Incoviba\Model;
|
||||
@ -57,6 +58,13 @@ class Reservation extends Common\Ideal\Repository
|
||||
$this->savePromotions($model);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Common\Define\Model $model
|
||||
* @param array $new_data
|
||||
* @return Model\Venta\Reservation
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Venta\Reservation
|
||||
{
|
||||
return $this->update($model, ['buyer_rut', 'date', 'broker_rut'], $new_data);
|
||||
@ -71,6 +79,21 @@ class Reservation extends Common\Ideal\Repository
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $buyer_rut
|
||||
* @param DateTimeInterface $date
|
||||
* @return Model\Venta\Reservation
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByBuyerAndDate(int $buyer_rut, DateTimeInterface $date): Model\Venta\Reservation
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from('reservations')
|
||||
->where('buyer_rut = :buyer_rut AND date >= :date');
|
||||
return $this->fetchOne($query, ['buyer_rut' => $buyer_rut, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
||||
}
|
||||
|
||||
protected function saveUnits(Model\Venta\Reservation $reservation): void
|
||||
{
|
||||
if (empty($reservation->units)) {
|
||||
|
Reference in New Issue
Block a user