|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2021 Joe Nilson <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Lesser General Public License as |
|
7
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
8
|
|
|
* License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Lesser General Public License for more details. |
|
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
15
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
require_once 'base/fs_controller.php'; |
|
19
|
|
|
require_once 'plugins/residentes/extras/residentes_controller.php'; |
|
20
|
|
|
require_once 'plugins/residentes/extras/residentesEnviarMail.php'; |
|
21
|
|
|
require_once 'plugins/residentes/extras/fpdf183/residentesFpdf.php'; |
|
22
|
|
|
|
|
23
|
|
|
class residentesFacturaDetallada |
|
24
|
|
|
{ |
|
25
|
|
|
public $archivo ; |
|
26
|
|
|
public $document; |
|
27
|
|
|
public $emailHelper; |
|
28
|
|
|
public $output; |
|
29
|
|
|
public $user; |
|
30
|
|
|
public $log; |
|
31
|
|
|
private $residentesController; |
|
32
|
|
|
public function __construct($orientation = 'L', $um = 'mm', $size = 'A5', $output = 'enviar', $archivo, $user) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->archivo = ($archivo) ?: \date('dmYHis') . ".pdf"; |
|
35
|
|
|
$this->output = $output; |
|
36
|
|
|
$this->user = $user; |
|
37
|
|
|
$this->log = new fs_core_log(); |
|
|
|
|
|
|
38
|
|
|
$this->emailHelper = new ResidentesEnviarMail(); |
|
39
|
|
|
$this->document = new ResidentesFpdf($orientation, $um, $size); |
|
|
|
|
|
|
40
|
|
|
$this->residentesController = new residentes_controller(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param object $companyInformation |
|
45
|
|
|
* @param object $invoice |
|
46
|
|
|
* @param object $customer |
|
47
|
|
|
*/ |
|
48
|
|
|
public function crearFactura(&$companyInformation, &$invoice, &$customer) |
|
49
|
|
|
{ |
|
50
|
|
|
$datosFactura = $this->invoiceData($companyInformation, $invoice); |
|
51
|
|
|
$datosEmpresa = (array) $companyInformation; |
|
52
|
|
|
$customerInfo = (array) $customer; |
|
53
|
|
|
$customerInfo['direccion'] = trim($customer->inmueble->codigo_externo()) . " numero " . $customer->inmueble->numero; |
|
54
|
|
|
$this->document->createDocument($datosEmpresa, $datosFactura[0], $datosFactura[1], $customerInfo); |
|
55
|
|
|
$this->residentesController->cliente_residente = $customer; |
|
56
|
|
|
$pendiente = $this->residentesController->pagosFactura(false); |
|
57
|
|
|
$this->document->addEstadoCuentaPendiente($pendiente); |
|
58
|
|
|
if ($this->output === 'enviar') { |
|
59
|
|
|
$this->document->Output( |
|
60
|
|
|
'F', |
|
61
|
|
|
'tmp/' . FS_TMP_NAME . 'enviar/' . $this->archivo, |
|
62
|
|
|
true |
|
63
|
|
|
); |
|
64
|
|
|
$this->emailHelper->invoiceEmail($companyInformation, $invoice, $customer, $this->user, $this->archivo); |
|
65
|
|
|
} else { |
|
66
|
|
|
$this->document->Output( |
|
67
|
|
|
'I', |
|
68
|
|
|
'factura_' .$datosFactura[0]['numero2']. '_' . \date('dmYhis') . '.pdf' |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
private function invoiceData($empresa, $invoice) |
|
74
|
|
|
{ |
|
75
|
|
|
$datosFacturaDetalle = []; |
|
76
|
|
|
$datosFacturaCabecera = (array) $invoice; |
|
77
|
|
|
if ($this->residentesController->RD_plugin) { |
|
78
|
|
|
$ncf = new ncf_ventas(); |
|
79
|
|
|
$ncfTipo = $ncf->get($empresa->id, $invoice->numero2); |
|
80
|
|
|
$datosFacturaCabecera['tiponcf'] = $ncfTipo[0]->tipo_descripcion; |
|
81
|
|
|
$datosFacturaCabecera['vencimientoncf'] = $ncfTipo[0]->fecha_vencimiento; |
|
82
|
|
|
} |
|
83
|
|
|
$lineas = $invoice->get_lineas(); |
|
84
|
|
|
$totalAntesDescuento = 0; |
|
85
|
|
|
$totalDescuento = 0; |
|
86
|
|
|
foreach ($lineas as $linea) { |
|
87
|
|
|
$totalAntesDescuento += $linea->pvpsindto; |
|
88
|
|
|
$totalDescuento += ($linea->pvpsindto - $linea->pvptotal); |
|
89
|
|
|
$datosFacturaDetalle[] = (array) $linea; |
|
90
|
|
|
} |
|
91
|
|
|
$datosFacturaCabecera['total_antes_descuento'] = $totalAntesDescuento; |
|
92
|
|
|
$datosFacturaCabecera['total_descuento'] = $totalDescuento; |
|
93
|
|
|
return [$datosFacturaCabecera, $datosFacturaDetalle]; |
|
94
|
|
|
} |
|
95
|
|
|
} |
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