Agregar datos propietario
This commit is contained in:
@ -2,10 +2,12 @@
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Error;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Exception\ServiceAction\Create;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service\Valor;
|
||||
@ -53,6 +55,10 @@ class FormaPago extends Ideal\Service
|
||||
return $formaPago;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\FormaPago
|
||||
*/
|
||||
public function add(array $data): Model\Venta\FormaPago
|
||||
{
|
||||
$fields = [
|
||||
@ -68,6 +74,9 @@ class FormaPago extends Ideal\Service
|
||||
$method = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
|
||||
$obj = $this->{$method}($data);
|
||||
$forma_pago->{$name} = $obj;
|
||||
} catch (Create $exception) {
|
||||
$this->logger->warning($exception);
|
||||
continue;
|
||||
} catch (Error $error) {
|
||||
$this->logger->critical($error);
|
||||
}
|
||||
@ -76,14 +85,19 @@ class FormaPago extends Ideal\Service
|
||||
return $forma_pago;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\Pie
|
||||
* @throws Create
|
||||
*/
|
||||
protected function addPie(array $data): Model\Venta\Pie
|
||||
{
|
||||
$fields = array_fill_keys([
|
||||
$fields = array_flip([
|
||||
'fecha_venta',
|
||||
'pie',
|
||||
'cuotas',
|
||||
'uf'
|
||||
], 0);
|
||||
]);
|
||||
$filtered_data = array_intersect_key($data, $fields);
|
||||
$mapped_data = array_combine([
|
||||
'fecha',
|
||||
@ -94,14 +108,20 @@ class FormaPago extends Ideal\Service
|
||||
$mapped_data['valor'] = $this->valorService->clean($mapped_data['valor']);
|
||||
return $this->pieService->add($mapped_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\Subsidio
|
||||
* @throws Create
|
||||
*/
|
||||
protected function addSubsidio(array $data): Model\Venta\Subsidio
|
||||
{
|
||||
$fields = array_fill_keys([
|
||||
$fields = array_flip([
|
||||
'fecha_venta',
|
||||
'ahorro',
|
||||
'subsidio',
|
||||
'uf'
|
||||
], 0);
|
||||
]);
|
||||
$filtered_data = array_intersect_key($data, $fields);
|
||||
$mapped_data = array_combine([
|
||||
'fecha',
|
||||
@ -113,13 +133,19 @@ class FormaPago extends Ideal\Service
|
||||
$mapped_data['subsidio'] = $this->valorService->clean($mapped_data['subsidio']);
|
||||
return $this->subsidioService->add($mapped_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\Credito
|
||||
* @throws Create
|
||||
*/
|
||||
protected function addCredito(array $data): Model\Venta\Credito
|
||||
{
|
||||
$fields = array_fill_keys([
|
||||
$fields = array_flip([
|
||||
'fecha_venta',
|
||||
'credito',
|
||||
'uf'
|
||||
], 0);
|
||||
]);
|
||||
$filtered_data = array_intersect_key($data, $fields);
|
||||
$mapped_data = array_combine([
|
||||
'fecha',
|
||||
@ -129,12 +155,18 @@ class FormaPago extends Ideal\Service
|
||||
$mapped_data['valor'] = $this->valorService->clean($mapped_data['valor']);
|
||||
return $this->creditoService->add($mapped_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\BonoPie
|
||||
* @throws Create
|
||||
*/
|
||||
protected function addBonoPie(array $data): Model\Venta\BonoPie
|
||||
{
|
||||
$fields = array_fill_keys([
|
||||
$fields = array_flip([
|
||||
'fecha_venta',
|
||||
'bono_pie'
|
||||
], 0);
|
||||
]);
|
||||
$filtered_data = array_intersect_key($data, $fields);
|
||||
$mapped_data = array_combine([
|
||||
'fecha',
|
||||
|
Reference in New Issue
Block a user