| Total Complexity | 213 |
| Total Lines | 1177 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
Complex classes like nueva_venta often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use nueva_venta, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 23 | class nueva_venta extends rd_controller |
||
| 24 | { |
||
| 25 | |||
| 26 | public $agencia; |
||
| 27 | public $agente; |
||
| 28 | public $almacen; |
||
| 29 | public $articulo; |
||
| 30 | public $cliente; |
||
| 31 | public $cliente_s; |
||
| 32 | public $direccion; |
||
| 33 | public $divisa; |
||
| 34 | public $fabricante; |
||
| 35 | public $familia; |
||
| 36 | public $forma_pago; |
||
| 37 | public $grupo; |
||
| 38 | public $impuesto; |
||
| 39 | public $nuevocli_setup; |
||
| 40 | public $pais; |
||
| 41 | public $results; |
||
| 42 | public $serie; |
||
| 43 | public $tipo; |
||
| 44 | public $cliente_rutas; |
||
| 45 | |||
| 46 | public function __construct() |
||
| 47 | { |
||
| 48 | parent::__construct(__CLASS__, 'Nueva venta...', 'ventas', FALSE, FALSE, TRUE); |
||
| 49 | } |
||
| 50 | |||
| 51 | protected function private_core() |
||
| 52 | { |
||
| 53 | parent::private_core(); |
||
| 54 | |||
| 55 | $this->agencia = new agencia_transporte(); |
||
|
|
|||
| 56 | $this->cliente = new cliente(); |
||
| 57 | $this->cliente_s = FALSE; |
||
| 58 | $this->direccion = FALSE; |
||
| 59 | $this->fabricante = new fabricante(); |
||
| 60 | $this->familia = new familia(); |
||
| 61 | $this->impuesto = new impuesto(); |
||
| 62 | $this->results = array(); |
||
| 63 | $this->grupo = new grupo_clientes(); |
||
| 64 | $this->pais = new pais(); |
||
| 65 | |||
| 66 | /// cargamos la configuración |
||
| 67 | $fsvar = new fs_var(); |
||
| 68 | $this->nuevocli_setup = $fsvar->array_get( |
||
| 69 | array( |
||
| 70 | 'nuevocli_cifnif_req' => 0, |
||
| 71 | 'nuevocli_direccion' => 0, |
||
| 72 | 'nuevocli_direccion_req' => 0, |
||
| 73 | 'nuevocli_codpostal' => 0, |
||
| 74 | 'nuevocli_codpostal_req' => 0, |
||
| 75 | 'nuevocli_pais' => 0, |
||
| 76 | 'nuevocli_pais_req' => 0, |
||
| 77 | 'nuevocli_provincia' => 0, |
||
| 78 | 'nuevocli_provincia_req' => 0, |
||
| 79 | 'nuevocli_ciudad' => 0, |
||
| 80 | 'nuevocli_ciudad_req' => 0, |
||
| 81 | 'nuevocli_telefono1' => 0, |
||
| 82 | 'nuevocli_telefono1_req' => 0, |
||
| 83 | 'nuevocli_telefono2' => 0, |
||
| 84 | 'nuevocli_telefono2_req' => 0, |
||
| 85 | 'nuevocli_email' => 0, |
||
| 86 | 'nuevocli_email_req' => 0, |
||
| 87 | 'nuevocli_codgrupo' => '', |
||
| 88 | ), FALSE |
||
| 89 | ); |
||
| 90 | |||
| 91 | if (isset($_REQUEST['tipo'])) { |
||
| 92 | $this->tipo = $_REQUEST['tipo']; |
||
| 93 | } else { |
||
| 94 | foreach ($this->tipos_a_guardar() as $t) { |
||
| 95 | $this->tipo = $t['tipo']; |
||
| 96 | break; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | if (isset($_REQUEST['buscar_cliente'])) { |
||
| 101 | $this->fbase_buscar_cliente($_REQUEST['buscar_cliente']); |
||
| 102 | } else if (isset($_REQUEST['datoscliente'])) { |
||
| 103 | $this->datos_cliente(); |
||
| 104 | } else if (isset($_REQUEST['new_articulo'])) { |
||
| 105 | $this->new_articulo(); |
||
| 106 | } else if ($this->query != '') { |
||
| 107 | $this->new_search(); |
||
| 108 | } else if (isset($_POST['referencia4precios'])) { |
||
| 109 | $this->get_precios_articulo(); |
||
| 110 | } else if (isset($_POST['referencia4combi'])) { |
||
| 111 | $this->get_combinaciones_articulo(); |
||
| 112 | } else if (isset($_POST['cliente'])) { |
||
| 113 | $this->cliente_s = $this->cliente->get($_POST['cliente']); |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Nuevo cliente |
||
| 117 | */ |
||
| 118 | if (isset($_POST['nuevo_cliente']) && $_POST['nuevo_cliente'] != '') { |
||
| 119 | $this->cliente_s = FALSE; |
||
| 120 | if ($_POST['nuevo_cifnif'] != '') { |
||
| 121 | $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']); |
||
| 122 | if ($this->cliente_s) { |
||
| 123 | $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.'); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | if (!$this->cliente_s) { |
||
| 128 | $this->cliente_s = new cliente(); |
||
| 129 | $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo(); |
||
| 130 | $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente']; |
||
| 131 | $this->cliente_s->tipoidfiscal = $_POST['nuevo_tipoidfiscal']; |
||
| 132 | $this->cliente_s->cifnif = $_POST['nuevo_cifnif']; |
||
| 133 | $this->cliente_s->personafisica = isset($_POST['personafisica']); |
||
| 134 | |||
| 135 | if (isset($_POST['nuevo_email'])) { |
||
| 136 | $this->cliente_s->email = $_POST['nuevo_email']; |
||
| 137 | } |
||
| 138 | |||
| 139 | if (isset($_POST['codgrupo']) && $_POST['codgrupo'] != '') { |
||
| 140 | $this->cliente_s->codgrupo = $_POST['codgrupo']; |
||
| 141 | } |
||
| 142 | |||
| 143 | if (isset($_POST['nuevo_telefono1'])) { |
||
| 144 | $this->cliente_s->telefono1 = $_POST['nuevo_telefono1']; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($_POST['nuevo_telefono2'])) { |
||
| 148 | $this->cliente_s->telefono2 = $_POST['nuevo_telefono2']; |
||
| 149 | } |
||
| 150 | |||
| 151 | if ($this->cliente_s->save()) { |
||
| 152 | if (isset($_POST['tipo_comprobante'])) { |
||
| 153 | $ncf_entidad_tipo = new ncf_entidad_tipo(); |
||
| 154 | $ncf_entidad_tipo->idempresa = $this->empresa->id; |
||
| 155 | $ncf_entidad_tipo->entidad = $this->cliente_s->codcliente; |
||
| 156 | $ncf_entidad_tipo->tipo_entidad = 'CLI'; |
||
| 157 | $ncf_entidad_tipo->tipo_comprobante = \filter_input(INPUT_POST, 'tipo_comprobante'); |
||
| 158 | $ncf_entidad_tipo->usuario_creacion = $this->user->nick; |
||
| 159 | $ncf_entidad_tipo->fecha_creacion = \Date('d-m-Y H:i:s'); |
||
| 160 | $ncf_entidad_tipo->usuario_modificacion = $this->user->nick; |
||
| 161 | $ncf_entidad_tipo->fecha_modificacion = \Date('d-m-Y H:i:s'); |
||
| 162 | $ncf_entidad_tipo->estado = true; |
||
| 163 | if (!$ncf_entidad_tipo->save()) { |
||
| 164 | $this->new_error_msg("¡Imposible actualizar información de NCF para Cliente " . $ncf_entidad_tipo->entidad . "!"); |
||
| 165 | } else { |
||
| 166 | $this->ncf_cliente_tipo = $this->ncf_entidad_tipo->get($this->empresa->id, $this->cliente_s->codcliente, 'CLI'); |
||
| 167 | } |
||
| 168 | } |
||
| 169 | if ($this->empresa->contintegrada) { |
||
| 170 | /// forzamos crear la subcuenta |
||
| 171 | $this->cliente_s->get_subcuenta($this->empresa->codejercicio); |
||
| 172 | } |
||
| 173 | |||
| 174 | $dircliente = new direccion_cliente(); |
||
| 175 | $dircliente->codcliente = $this->cliente_s->codcliente; |
||
| 176 | $dircliente->codpais = $this->empresa->codpais; |
||
| 177 | $dircliente->provincia = $this->empresa->provincia; |
||
| 178 | $dircliente->ciudad = $this->empresa->ciudad; |
||
| 179 | |||
| 180 | if (isset($_POST['nuevo_pais'])) { |
||
| 181 | $dircliente->codpais = $_POST['nuevo_pais']; |
||
| 182 | } |
||
| 183 | |||
| 184 | if (isset($_POST['nuevo_provincia'])) { |
||
| 185 | $dircliente->provincia = $_POST['nuevo_provincia']; |
||
| 186 | } |
||
| 187 | |||
| 188 | if (isset($_POST['nuevo_ciudad'])) { |
||
| 189 | $dircliente->ciudad = $_POST['nuevo_ciudad']; |
||
| 190 | } |
||
| 191 | |||
| 192 | if (isset($_POST['nuevo_codpostal'])) { |
||
| 193 | $dircliente->codpostal = $_POST['nuevo_codpostal']; |
||
| 194 | } |
||
| 195 | |||
| 196 | if (isset($_POST['nuevo_direccion'])) { |
||
| 197 | $dircliente->direccion = $_POST['nuevo_direccion']; |
||
| 198 | } |
||
| 199 | |||
| 200 | if ($dircliente->save()) { |
||
| 201 | $this->new_message('Cliente agregado correctamente.'); |
||
| 202 | } |
||
| 203 | } else { |
||
| 204 | $this->new_error_msg("¡Imposible guardar la dirección del cliente!"); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | if ($this->cliente_s) { |
||
| 210 | foreach ($this->cliente_s->get_direcciones() as $dir) { |
||
| 211 | if ($dir->domfacturacion) { |
||
| 212 | $this->direccion = $dir; |
||
| 213 | break; |
||
| 214 | } |
||
| 215 | } |
||
| 216 | if (class_exists('distribucion_clientes')) { |
||
| 217 | $this->cliente_rutas = $this->distribucion_clientes->get($this->empresa->id, $this->cliente_s->codcliente); |
||
| 218 | } |
||
| 219 | } |
||
| 220 | |||
| 221 | if (isset($_POST['codagente'])) { |
||
| 222 | $agente = new agente(); |
||
| 223 | $this->agente = $agente->get($_POST['codagente']); |
||
| 224 | } else { |
||
| 225 | $this->agente = $this->user->get_agente(); |
||
| 226 | } |
||
| 227 | |||
| 228 | $this->almacen = new almacen(); |
||
| 229 | $this->serie = new serie(); |
||
| 230 | $this->forma_pago = new forma_pago(); |
||
| 231 | $this->divisa = new divisa(); |
||
| 232 | |||
| 233 | if (isset($_POST['tipo'])) { |
||
| 234 | if ($_POST['tipo'] == 'factura') { |
||
| 235 | $this->nueva_factura_cliente(); |
||
| 236 | } else if ($_POST['tipo'] == 'albaran') { |
||
| 237 | $this->nuevo_albaran_cliente(); |
||
| 238 | } else if ($_POST['tipo'] == 'pedido' && class_exists('pedido_cliente')) { |
||
| 239 | $this->nuevo_pedido_cliente(); |
||
| 240 | } else if ($_POST['tipo'] == 'presupuesto' && class_exists('presupuesto_cliente')) { |
||
| 241 | $this->nuevo_presupuesto_cliente(); |
||
| 242 | } |
||
| 243 | |||
| 244 | /// si el cliente no tiene cifnif nos guardamos el que indique |
||
| 245 | if ($this->cliente_s->cifnif == '') { |
||
| 246 | $this->cliente_s->cifnif = $_POST['cifnif']; |
||
| 247 | $this->cliente_s->save(); |
||
| 248 | } |
||
| 249 | |||
| 250 | /// ¿Guardamos la dirección como nueva? |
||
| 251 | if ($_POST['coddir'] == 'nueva') { |
||
| 252 | $this->direccion = new direccion_cliente(); |
||
| 253 | $this->direccion->codcliente = $this->cliente_s->codcliente; |
||
| 254 | $this->direccion->codpais = $_POST['codpais']; |
||
| 255 | $this->direccion->provincia = $_POST['provincia']; |
||
| 256 | $this->direccion->ciudad = $_POST['ciudad']; |
||
| 257 | $this->direccion->codpostal = $_POST['codpostal']; |
||
| 258 | $this->direccion->direccion = $_POST['direccion']; |
||
| 259 | $this->direccion->apartado = $_POST['apartado']; |
||
| 260 | $this->direccion->save(); |
||
| 261 | } else if ($_POST['envio_coddir'] == 'nueva') { |
||
| 262 | $this->direccion = new direccion_cliente(); |
||
| 263 | $this->direccion->codcliente = $this->cliente_s->codcliente; |
||
| 264 | $this->direccion->codpais = $_POST['envio_codpais']; |
||
| 265 | $this->direccion->provincia = $_POST['envio_provincia']; |
||
| 266 | $this->direccion->ciudad = $_POST['envio_ciudad']; |
||
| 267 | $this->direccion->codpostal = $_POST['envio_codpostal']; |
||
| 268 | $this->direccion->direccion = $_POST['envio_direccion']; |
||
| 269 | $this->direccion->apartado = $_POST['envio_apartado']; |
||
| 270 | $this->direccion->domfacturacion = FALSE; |
||
| 271 | $this->direccion->domenvio = TRUE; |
||
| 272 | $this->direccion->save(); |
||
| 273 | } |
||
| 274 | } |
||
| 275 | } |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Devuelve los tipos de documentos a guardar, |
||
| 280 | * así para añadir tipos no hay que tocar la vista. |
||
| 281 | * @return type |
||
| 282 | */ |
||
| 283 | public function tipos_a_guardar() |
||
| 284 | { |
||
| 285 | $tipos = array(); |
||
| 286 | |||
| 287 | if ($this->user->have_access_to('ventas_presupuesto') && class_exists('presupuesto_cliente')) { |
||
| 288 | $tipos[] = array('tipo' => 'presupuesto', 'nombre' => ucfirst(FS_PRESUPUESTO) . ' para cliente'); |
||
| 289 | } |
||
| 290 | |||
| 291 | if ($this->user->have_access_to('ventas_pedido') && class_exists('pedido_cliente')) { |
||
| 292 | $tipos[] = array('tipo' => 'pedido', 'nombre' => ucfirst(FS_PEDIDO) . ' de cliente'); |
||
| 293 | } |
||
| 294 | |||
| 295 | if ($this->user->have_access_to('ventas_albaran')) { |
||
| 296 | $tipos[] = array('tipo' => 'albaran', 'nombre' => ucfirst(FS_ALBARAN) . ' de cliente'); |
||
| 297 | } |
||
| 298 | |||
| 299 | if ($this->user->have_access_to('ventas_factura')) { |
||
| 300 | $tipos[] = array('tipo' => 'factura', 'nombre' => 'Factura de cliente'); |
||
| 301 | } |
||
| 302 | |||
| 303 | return $tipos; |
||
| 304 | } |
||
| 305 | |||
| 306 | public function url() |
||
| 307 | { |
||
| 308 | return 'index.php?page=' . __CLASS__ . '&tipo=' . $this->tipo; |
||
| 309 | } |
||
| 310 | |||
| 311 | private function datos_cliente() |
||
| 312 | { |
||
| 313 | /// desactivamos la plantilla HTML |
||
| 314 | $this->template = FALSE; |
||
| 315 | |||
| 316 | header('Content-Type: application/json'); |
||
| 317 | echo json_encode($this->cliente->get($_REQUEST['datoscliente'])); |
||
| 318 | } |
||
| 319 | |||
| 320 | private function new_articulo() |
||
| 321 | { |
||
| 322 | /// desactivamos la plantilla HTML |
||
| 323 | $this->template = FALSE; |
||
| 324 | |||
| 325 | $art0 = new articulo(); |
||
| 326 | if ($_REQUEST['referencia'] != '') { |
||
| 327 | $art0->referencia = $_REQUEST['referencia']; |
||
| 328 | } else { |
||
| 329 | $art0->referencia = $art0->get_new_referencia(); |
||
| 330 | } |
||
| 331 | |||
| 332 | if ($art0->exists()) { |
||
| 333 | $this->results[] = $art0->get($art0->referencia); |
||
| 334 | } else { |
||
| 335 | $art0->descripcion = $_REQUEST['descripcion']; |
||
| 336 | $art0->codbarras = $_REQUEST['codbarras']; |
||
| 337 | $art0->set_impuesto($_REQUEST['codimpuesto']); |
||
| 338 | $art0->set_pvp(floatval($_REQUEST['pvp'])); |
||
| 339 | |||
| 340 | $art0->secompra = isset($_POST['secompra']); |
||
| 341 | $art0->sevende = isset($_POST['sevende']); |
||
| 342 | $art0->nostock = isset($_POST['nostock']); |
||
| 343 | $art0->publico = isset($_POST['publico']); |
||
| 344 | |||
| 345 | if ($_REQUEST['codfamilia'] != '') { |
||
| 346 | $art0->codfamilia = $_REQUEST['codfamilia']; |
||
| 347 | } |
||
| 348 | |||
| 349 | if ($_REQUEST['codfabricante'] != '') { |
||
| 350 | $art0->codfabricante = $_REQUEST['codfabricante']; |
||
| 351 | } |
||
| 352 | |||
| 353 | if ($art0->save()) { |
||
| 354 | $this->results[] = $art0; |
||
| 355 | } |
||
| 356 | } |
||
| 357 | |||
| 358 | header('Content-Type: application/json'); |
||
| 359 | echo json_encode($this->results); |
||
| 360 | } |
||
| 361 | |||
| 362 | private function new_search() |
||
| 435 | } |
||
| 436 | |||
| 437 | private function get_precios_articulo() |
||
| 438 | { |
||
| 439 | /// cambiamos la plantilla HTML |
||
| 440 | $this->template = 'ajax/nueva_venta_precios'; |
||
| 441 | |||
| 442 | $articulo = new articulo(); |
||
| 443 | $this->articulo = $articulo->get($_POST['referencia4precios']); |
||
| 444 | } |
||
| 445 | |||
| 446 | private function get_combinaciones_articulo() |
||
| 479 | ); |
||
| 480 | } |
||
| 481 | } |
||
| 482 | } |
||
| 483 | |||
| 484 | public function get_tarifas_articulo($ref) |
||
| 501 | } |
||
| 502 | |||
| 503 | private function nuevo_presupuesto_cliente() |
||
| 504 | { |
||
| 505 | $continuar = TRUE; |
||
| 506 | |||
| 507 | $cliente = $this->cliente->get($_POST['cliente']); |
||
| 508 | if (!$cliente) { |
||
| 509 | $this->new_error_msg('Cliente no encontrado.'); |
||
| 510 | $continuar = FALSE; |
||
| 511 | } |
||
| 512 | |||
| 513 | $almacen = $this->almacen->get($_POST['almacen']); |
||
| 514 | if ($almacen) { |
||
| 515 | $this->save_codalmacen($_POST['almacen']); |
||
| 516 | } else { |
||
| 517 | $this->new_error_msg('Almacén no encontrado.'); |
||
| 518 | $continuar = FALSE; |
||
| 519 | } |
||
| 520 | |||
| 521 | $eje0 = new ejercicio(); |
||
| 522 | $ejercicio = $eje0->get_by_fecha($_POST['fecha'], FALSE); |
||
| 523 | if (!$ejercicio) { |
||
| 524 | $this->new_error_msg('Ejercicio no encontrado.'); |
||
| 525 | $continuar = FALSE; |
||
| 526 | } |
||
| 527 | |||
| 528 | $serie = $this->serie->get($_POST['serie']); |
||
| 529 | if (!$serie) { |
||
| 530 | $this->new_error_msg('Serie no encontrada.'); |
||
| 531 | $continuar = FALSE; |
||
| 532 | } |
||
| 533 | |||
| 534 | $forma_pago = $this->forma_pago->get($_POST['forma_pago']); |
||
| 535 | if ($forma_pago) { |
||
| 536 | $this->save_codpago($_POST['forma_pago']); |
||
| 537 | } else { |
||
| 538 | $this->new_error_msg('Forma de pago no encontrada.'); |
||
| 539 | $continuar = FALSE; |
||
| 540 | } |
||
| 541 | |||
| 542 | $divisa = $this->divisa->get($_POST['divisa']); |
||
| 543 | if (!$divisa) { |
||
| 544 | $this->new_error_msg('Divisa no encontrada.'); |
||
| 545 | $continuar = FALSE; |
||
| 546 | } |
||
| 547 | |||
| 548 | $presupuesto = new presupuesto_cliente(); |
||
| 549 | |||
| 550 | if ($this->duplicated_petition($_POST['petition_id'])) { |
||
| 551 | $this->new_error_msg('Petición duplicada. Has hecho doble clic sobre el botón guardar |
||
| 552 | y se han enviado dos peticiones. Mira en <a href="' . $presupuesto->url() . '">Presupuestos</a> |
||
| 553 | para ver si el presupuesto se ha guardado correctamente.'); |
||
| 554 | $continuar = FALSE; |
||
| 555 | } |
||
| 556 | |||
| 557 | if ($continuar) { |
||
| 558 | $this->nuevo_documento($presupuesto, $ejercicio, $serie, $almacen, $forma_pago, $divisa, $cliente); |
||
| 559 | |||
| 560 | /// establecemos la fecha de finoferta |
||
| 561 | $presupuesto->finoferta = date("Y-m-d", strtotime($_POST['fecha'] . " +1 month")); |
||
| 562 | $fsvar = new fs_var(); |
||
| 563 | $dias = $fsvar->simple_get('presu_validez'); |
||
| 564 | if ($dias) { |
||
| 565 | $presupuesto->finoferta = date("Y-m-d", strtotime($_POST['fecha'] . " +" . intval($dias) . " days")); |
||
| 566 | } |
||
| 567 | |||
| 568 | /// función auxiliar para implementar en los plugins que lo necesiten |
||
| 569 | if (!fs_generar_numero2($presupuesto)) { |
||
| 570 | $presupuesto->numero2 = $_POST['numero2']; |
||
| 571 | } |
||
| 572 | |||
| 573 | if ($presupuesto->save()) { |
||
| 574 | $art0 = new articulo(); |
||
| 575 | $n = floatval($_POST['numlineas']); |
||
| 576 | for ($i = 0; $i <= $n; $i++) { |
||
| 577 | if (isset($_POST['referencia_' . $i])) { |
||
| 578 | $linea = new linea_presupuesto_cliente(); |
||
| 579 | $linea->idpresupuesto = $presupuesto->idpresupuesto; |
||
| 580 | $this->nueva_linea($linea, $i, $serie, $cliente); |
||
| 581 | |||
| 582 | $articulo = $art0->get($_POST['referencia_' . $i]); |
||
| 583 | if ($articulo) { |
||
| 584 | $linea->referencia = $articulo->referencia; |
||
| 585 | if ($_POST['codcombinacion_' . $i]) { |
||
| 586 | $linea->codcombinacion = $_POST['codcombinacion_' . $i]; |
||
| 587 | } |
||
| 588 | } |
||
| 589 | |||
| 590 | if ($linea->save()) { |
||
| 591 | if ($linea->irpf > $presupuesto->irpf) { |
||
| 592 | $presupuesto->irpf = $linea->irpf; |
||
| 593 | } |
||
| 594 | } else { |
||
| 595 | $this->new_error_msg("¡Imposible guardar la linea con referencia: " . $linea->referencia); |
||
| 596 | $continuar = FALSE; |
||
| 597 | } |
||
| 598 | } |
||
| 599 | } |
||
| 600 | |||
| 601 | if ($continuar) { |
||
| 602 | /// obtenemos los subtotales por impuesto |
||
| 603 | $due_totales = $this->fbase_calc_due([$presupuesto->dtopor1, $presupuesto->dtopor2, $presupuesto->dtopor3, $presupuesto->dtopor4, $presupuesto->dtopor5]); |
||
| 604 | foreach ($this->fbase_get_subtotales_documento($presupuesto->get_lineas(), $due_totales) as $subt) { |
||
| 605 | $presupuesto->netosindto += $subt['netosindto']; |
||
| 606 | $presupuesto->neto += $subt['neto']; |
||
| 607 | $presupuesto->totaliva += $subt['iva']; |
||
| 608 | $presupuesto->totalirpf += $subt['irpf']; |
||
| 609 | $presupuesto->totalrecargo += $subt['recargo']; |
||
| 610 | } |
||
| 611 | |||
| 612 | $presupuesto->total = round($presupuesto->neto + $presupuesto->totaliva - $presupuesto->totalirpf + $presupuesto->totalrecargo, FS_NF0); |
||
| 613 | |||
| 614 | if (abs(floatval($_POST['atotal']) - $presupuesto->total) >= .02) { |
||
| 615 | $this->new_error_msg("El total difiere entre el controlador y la vista (" . |
||
| 616 | $presupuesto->total . " frente a " . $_POST['atotal'] . "). Debes informar del error."); |
||
| 617 | $presupuesto->delete(); |
||
| 618 | } else if ($presupuesto->save()) { |
||
| 619 | /// Función de ejecución de tareas post guardado correcto del presupuesto |
||
| 620 | fs_documento_post_save($presupuesto); |
||
| 621 | |||
| 622 | $this->new_message("<a href='" . $presupuesto->url() . "'>" . ucfirst(FS_PRESUPUESTO) . "</a> guardado correctamente."); |
||
| 623 | $this->new_change(ucfirst(FS_PRESUPUESTO) . ' a Cliente ' . $presupuesto->codigo, $presupuesto->url(), TRUE); |
||
| 624 | |||
| 625 | if ($_POST['redir'] == 'TRUE') { |
||
| 626 | header('Location: ' . $presupuesto->url()); |
||
| 627 | } |
||
| 628 | } else { |
||
| 629 | $this->new_error_msg("¡Imposible actualizar el <a href='" . $presupuesto->url() . "'>" . FS_PRESUPUESTO . "</a>!"); |
||
| 630 | } |
||
| 631 | } else if ($presupuesto->delete()) { |
||
| 632 | $this->new_message(ucfirst(FS_PRESUPUESTO) . " eliminado correctamente."); |
||
| 633 | } else { |
||
| 634 | $this->new_error_msg("¡Imposible eliminar el <a href='" . $presupuesto->url() . "'>" . FS_PRESUPUESTO . "</a>!"); |
||
| 635 | } |
||
| 636 | } else { |
||
| 637 | $this->new_error_msg("¡Imposible guardar el " . FS_PRESUPUESTO . "!"); |
||
| 638 | } |
||
| 639 | } |
||
| 640 | } |
||
| 641 | |||
| 642 | private function nuevo_pedido_cliente() |
||
| 769 | } |
||
| 770 | } |
||
| 771 | } |
||
| 772 | |||
| 773 | private function nuevo_albaran_cliente() |
||
| 935 | } |
||
| 936 | } |
||
| 937 | } |
||
| 938 | |||
| 939 | private function nueva_factura_cliente() |
||
| 1114 | } |
||
| 1115 | } |
||
| 1116 | } |
||
| 1117 | |||
| 1118 | private function nuevo_documento(&$documento, $ejercicio, $serie, $almacen, $forma_pago, $divisa, $cliente) |
||
| 1170 | } |
||
| 1171 | |||
| 1172 | private function nueva_linea(&$linea, $i, $serie, $cliente) |
||
| 1173 | { |
||
| 1200 | } |
||
| 1201 | } |
||
| 1202 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths