Correcciones

This commit is contained in:
Juan Pablo Vial
2025-03-03 21:41:43 -03:00
parent 5f69069aa0
commit aeeca65d94
9 changed files with 122 additions and 43 deletions

View File

@ -32,7 +32,7 @@ class Contract extends Ideal\Service
public function getByBroker(int $broker_rut): array
{
try {
return array_map([$this, 'broker'], $this->contractRepository->fetchByBroker($broker_rut));
return array_map([$this, 'process'], $this->contractRepository->fetchByBroker($broker_rut));
} catch (Implement\Exception\EmptyResult $exception) {
throw new ServiceAction\Read(__CLASS__, $exception);
}
@ -56,14 +56,14 @@ class Contract extends Ideal\Service
public function add(array $data): Model\Proyecto\Broker\Contract
{
try {
return $this->process($this->contractRepository->fetchActiveByProjectAndBroker($data['proyecto_id'], $data['broker_rut']));
return $this->process($this->contractRepository->fetchActiveByProjectAndBroker($data['project_id'], $data['broker_rut']));
} catch (Implement\Exception\EmptyResult) {}
try {
$filteredData = $this->contractRepository->filterData($data);
$contract = $this->contractRepository->create($filteredData);
$contract = $this->contractRepository->save($contract);
$type = Model\Proyecto\Broker\Contract\State\Type::ACTIVE;
$type = Model\Proyecto\Broker\Contract\State\Type::ACTIVE->value;
$date = new DateTimeImmutable();
if (isset($data['date'])) {
try {
@ -125,9 +125,9 @@ class Contract extends Ideal\Service
$contract->addFactory('states', (new Implement\Repository\Factory())
->setCallable([$this->stateRepository, 'fetchByContract'])
->setArgs(['contract_id' => $contract->id]));
$contract->addFactory('currentState', (new Implement\Repository\Factory())
/*$contract->addFactory('currentState', (new Implement\Repository\Factory())
->setCallable([$this->stateRepository, 'fetchActiveByContract'])
->setArgs(['contract_id' => $contract->id]));
->setArgs(['contract_id' => $contract->id]));*/
return $contract;
}
}