From 4392f61db94226d927a2be0083420ea122e57de0 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 28 Nov 2024 12:02:02 -0300 Subject: [PATCH] Cuota abono a escritura --- app/src/Model/Venta/Abono/Cuota.php | 19 ++++++++ app/src/Repository/Venta/Abono/Cuota.php | 59 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 app/src/Model/Venta/Abono/Cuota.php create mode 100644 app/src/Repository/Venta/Abono/Cuota.php diff --git a/app/src/Model/Venta/Abono/Cuota.php b/app/src/Model/Venta/Abono/Cuota.php new file mode 100644 index 0000000..e43ef16 --- /dev/null +++ b/app/src/Model/Venta/Abono/Cuota.php @@ -0,0 +1,19 @@ + $this->venta->id, + 'pago' => $this->pago + ]); + } +} diff --git a/app/src/Repository/Venta/Abono/Cuota.php b/app/src/Repository/Venta/Abono/Cuota.php new file mode 100644 index 0000000..8de133f --- /dev/null +++ b/app/src/Repository/Venta/Abono/Cuota.php @@ -0,0 +1,59 @@ +register('venta_id', (new Implement\Repository\Mapper()) + ->setProperty('venta') + ->setFunction(function($data) { + return $this->ventaRepository->fetchById($data['venta_id']); + }) + ) + ->register('pago_id', (new Implement\Repository\Mapper()) + ->setProperty('pago') + ->setFunction(function($data) { + return $this->pagoRepository->fetchById($data['pago_id']); + }) + ); + return $this->parseData(new Model\Venta\Abono\Cuota(), $data, $map); + } + + public function save(Define\Model $model): Model\Venta\Abono\Cuota + { + $model->id = $this->saveNew(['venta_id', 'pago_id'], [$model->venta->id, $model->pago->id]); + return $model; + } + + public function edit(Define\Model $model, array $new_data): Model\Venta\Abono\Cuota + { + return $this->update($model, ['venta_id', 'pago_id'], $new_data); + } + + /** + * @throws EmptyResult + */ + public function fetchByVenta(int $venta_id): array + { + $query = $this->connection->getQueryBuilder() + ->select() + ->from($this->getTable()) + ->where('venta_id = ?'); + return $this->fetchMany($query, [$venta_id]); + } +}