Facturacion, se agrega PropiedadUnidad

This commit is contained in:
2023-11-29 20:09:08 -03:00
parent 094209823a
commit 39048e12b3
24 changed files with 716 additions and 55 deletions

View File

@ -62,34 +62,23 @@ class Money
}
return $this->data[$provider][$date->format('Y-m-d')];
}
/*public function uf(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService, Service\Money $moneyService): ResponseInterface
public function uf(ServerRequestInterface $request, ResponseInterface $response, Service\UF $ufService): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
'input' => $body,
'uf' => 0
];
$redisKey = 'uf';
$date = new DateTimeImmutable($body['fecha']);
try {
$ufs = $this->fetchRedis($redisService, $redisKey);
if (!isset($ufs[$date->format('Y-m-d')])) {
throw new EmptyRedis($redisKey);
}
} catch (EmptyRedis) {
error_log(var_export($ufs,true));
if (!isset($ufs)) {
$ufs = [];
}
$uf = $moneyService->getUF($date);
$ufs[$date->format('Y-m-d')] = $uf;
$this->saveRedis($redisService, $redisKey, $ufs, 60 * 60 * 24 * 30);
$now = new DateTimeImmutable();
if ($date > $now) {
return $this->withJson($response, $output);
}
$output['uf'] = $ufs[$date->format('Y-m-d')];
$output['uf'] = $ufService->get($date);
return $this->withJson($response, $output);
}*/
public function ipc(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
Service\Money $moneyService): ResponseInterface
}
public function ipc(ServerRequestInterface $request, ResponseInterface $response,
Service\IPC $ipcService): ResponseInterface
{
$data = $request->getParsedBody();
$output = [
@ -97,7 +86,6 @@ class Money
'date_string' => '',
'ipc' => 0
];
$redisKey = 'ipc';
$start = new DateTimeImmutable($data['start']);
$end = new DateTimeImmutable($data['end']);
$now = new DateTimeImmutable();
@ -105,23 +93,8 @@ class Money
return $this->withJson($response, $output);
}
$dateKey = "{$start->format('Y-m')}-{$end->format('Y-m')}";
$months = $start->diff($end)->m;
$current = new DateTimeImmutable((($start <= $end) ? $start : $end)->format('Y-m-15'));
$value = 0;
$ipcs = [];
try {
$ipcs = (array) $this->fetchRedis($redisService, $redisKey);
} catch (EmptyRedis) {}
for ($i = 1; $i < $months; $i ++) {
$current = $current->add(new DateInterval("P1M"));
if (!isset($ipcs[$current->format('Y-m')])) {
$ipcs[$current->format('Y-m')] = $moneyService->getIPC($current);
$this->saveRedis($redisService, $redisKey, $ipcs, $this->time);
}
$value += $ipcs[$current->format('Y-m')];
}
$output['date_string'] = $dateKey;
$output['ipc'] = $value;
$output['ipc'] = $ipcService->get($start, $end);
return $this->withJson($response, $output);
}
}