|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2025 Joe Nilson <joenilson at gmail.com> |
|
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
|
|
|
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Lib\DGII; |
|
19
|
|
|
|
|
20
|
|
|
use FacturaScripts\Core\Tools; |
|
21
|
|
|
|
|
22
|
|
|
class CommonModelFunctions |
|
23
|
|
|
{ |
|
24
|
|
|
public static function setCFRango($actualBusinessContact, $ncfrango, $tipocomprobante, &$document): bool |
|
25
|
|
|
{ |
|
26
|
|
|
$ncfRangoToUse = $ncfrango->getByTipoComprobante($actualBusinessContact->idempresa, $tipocomprobante); |
|
27
|
|
|
if (!$ncfRangoToUse) { |
|
28
|
|
|
Tools::log()->error("no-ncf-range-for-$tipocomprobante"); |
|
29
|
|
|
return false; |
|
30
|
|
|
} |
|
31
|
|
|
$ncf = $ncfRangoToUse->generateNCF(); |
|
32
|
|
|
$document->numeroncf = $ncf; |
|
33
|
|
|
$document->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
|
34
|
|
|
$document->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
|
35
|
|
|
$ncfRangoToUse->correlativo++; |
|
36
|
|
|
return $ncfRangoToUse->save(); |
|
37
|
|
|
} |
|
38
|
|
|
} |