Cartola Diaria Manual

This commit is contained in:
Juan Pablo Vial
2024-02-23 10:20:44 -03:00
parent c784d1bee9
commit 415ba31270
4 changed files with 355 additions and 107 deletions

View File

@ -65,6 +65,28 @@ class Cartola extends Service
$cartola = $this->buildCartola($cuenta, $fecha, $cartolaData);
return compact('cartola', 'movimientos');
}
public function diariaManual(Model\Inmobiliaria\Cuenta $cuenta, DateTimeInterface $fecha, array $data): array
{
$cartolaData = [
'cargos' => 0,
'abonos' => 0,
'saldos' => 0
];
$movimientos = [];
foreach ($data as $row) {
$dataMovimiento = $row;
$dataMovimiento['fecha'] = $fecha->format('Y-m-d');
$dataMovimiento['documento'] = '';
$movimiento = $this->buildMovimiento($cuenta, $dataMovimiento);
$movimientos []= $movimiento;
$cartolaData['cargos'] += $movimiento->cargo;
$cartolaData['abonos'] += $movimiento->abono;
$cartolaData['saldo'] = $movimiento->saldo;
}
$cartola = $this->buildCartola($cuenta, $fecha, $cartolaData);
return compact('cartola', 'movimientos');
}
protected function getMovimientosDiarios(Model\Banco $banco, UploadedFileInterface $file): array
{
@ -85,12 +107,13 @@ class Cartola extends Service
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Movimiento
{
try {
$valor = ($data['cargo'] !== 0 and $data['cargo'] !== null) ? $data['cargo'] : $data['abono'];
return $this->movimientoRepository
->fetchByCuentaAndFechaAndMonto(
->fetchByCuentaAndFechaAndCargoAndAbonoAndSaldo(
$cuenta->id,
new DateTimeImmutable($data['fecha']),
$valor
$data['cargo'] ?? 0,
$data['abono'] ?? 0,
$data['saldo']
);
} catch (Exception\EmptyResult $exception) {
$data['cuenta_id'] = $cuenta->id;