Cleanup
This commit is contained in:
@ -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