|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2020 joenilson. |
|
4
|
|
|
* |
|
5
|
|
|
* This library is free software; you can redistribute it and/or |
|
6
|
|
|
* modify it under the terms of the GNU Lesser General Public |
|
7
|
|
|
* License as published by the Free Software Foundation; either |
|
8
|
|
|
* version 3 of the License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This library 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 GNU |
|
13
|
|
|
* Lesser General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Lesser General Public |
|
16
|
|
|
* License along with this library; if not, write to the Free Software |
|
17
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18
|
|
|
* MA 02110-1301 USA |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Model; |
|
22
|
|
|
|
|
23
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFRango; |
|
24
|
|
|
use FacturaScripts\Dinamic\Model\Cliente; |
|
|
|
|
|
|
25
|
|
|
use FacturaScripts\Core\App\AppSettings; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Description of FacturaCliente |
|
29
|
|
|
* |
|
30
|
|
|
* @author joenilson |
|
31
|
|
|
*/ |
|
32
|
|
|
class FacturaCliente |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
* @var date |
|
|
|
|
|
|
37
|
|
|
*/ |
|
38
|
|
|
public $ncffechavencimiento; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
public $tipocomprobante; |
|
43
|
|
|
/** |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
public $ncftipopago; |
|
48
|
|
|
/** |
|
49
|
|
|
* |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
public $ncftipoanulacion; |
|
53
|
|
|
|
|
54
|
|
|
public function saveInsert() |
|
55
|
|
|
{ |
|
56
|
|
|
return function () { |
|
57
|
|
|
$ncfrango = new NCFRango(); |
|
58
|
|
|
$cliente = new Cliente(); |
|
59
|
|
|
$actualCliente = $cliente->get($this->codcliente); |
|
|
|
|
|
|
60
|
|
|
$actualCliente->idempresa = AppSettings::get('default', 'idempresa'); |
|
61
|
|
|
$ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $actualCliente->codsubtipodoc); |
|
62
|
|
|
$ncf = $ncfRangoToUse->generateNCF(); |
|
63
|
|
|
$this->numero2 = $ncf; |
|
|
|
|
|
|
64
|
|
|
$this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
|
65
|
|
|
$this->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
|
66
|
|
|
$ncfRangoToUse->correlativo++; |
|
67
|
|
|
$ncfRangoToUse->save(); |
|
68
|
|
|
}; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: