Issues (232)

Extension/Lib/PointOfSaleVoucher.php (6 issues)

1
<?php
2
/*
3
 * Copyright (C) 2023 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
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Lib;
19
20
use FacturaScripts\Core\Base\NumberTools;
0 ignored issues
show
The type FacturaScripts\Core\Base\NumberTools was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use FacturaScripts\Plugins\POS\Lib\PointOfSaleVoucher as PointOfSaleVoucherBase;
0 ignored issues
show
The type FacturaScripts\Plugins\POS\Lib\PointOfSaleVoucher was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
class PointOfSaleVoucher extends PointOfSaleVoucherBase
24
{
25
    public function __construct(BusinessDocument $document, int $width, bool $hidePrices = false)
0 ignored issues
show
The type FacturaScripts\Plugins\f...on\Lib\BusinessDocument was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
    {
27
        parent::__construct(null);
28
29
        $this->document = $document;
0 ignored issues
show
Bug Best Practice introduced by
The property document does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
        $this->hidePrices = $hidePrices;
0 ignored issues
show
Bug Best Practice introduced by
The property hidePrices does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
        $this->ticketType = $document->modelClassName();
0 ignored issues
show
Bug Best Practice introduced by
The property ticketType does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
32
    }
33
34
    /**
35
     * Builds the ticket body
36
     */
37
    protected function buildBody(): void
38
    {
39
        $this->printer->text($this->document->codigo, true, true);
40
        $this->printer->lineSeparator('-');
41
        $this->printer->text('NCF: ' . $this->document->numeroncf, true, true);
42
        //$this->printer->text('TIPO: ' . $this->document->descripcionTipoComprobante(), true, true);
43
        $this->printer->text('F. VENC. NCF: ' . $this->document->ncffechavencimiento, true, true);
44
        $this->printer->lineSeparator('-');
45
        $fechacompleta = $this->document->fecha . ' ' . $this->document->hora;
46
        $this->printer->text($fechacompleta, true, true);
47
48
        $this->printer->text('CLIENTE: ' . $this->document->nombrecliente);
49
        $this->printer->lineSeparator('=');
50
51
        $this->printer->text('ARTICULO');
52
        $this->printer->textColumns('UNITARIO', 'IMPORTE');
53
        $this->printer->lineSeparator('=');
54
55
        foreach ($this->document->getLines() as $line) {
56
            $this->printer->text("$line->cantidad x $line->referencia - $line->descripcion");
57
58
            if (false === $this->hidePrices) {
59
                $this->printer->textColumns('PU', NumberTools::format($line->pvpunitario));
60
                $this->printer->textColumns('IMPORTE', NumberTools::format($line->pvpsindto));
61
62
                $descuento = $line->pvpsindto - ($line->pvpsindto * $line->getEUDiscount());
63
                $this->printer->textColumns('Descuento:', '- ' . NumberTools::format($descuento));
64
65
                $impuestoLinea = $line->pvptotal * $line->iva / 100;
66
                $this->printer->textColumns("Impuesto $line->iva%:", '+ ' . NumberTools::format($impuestoLinea));
67
                $this->printer->textColumns('Total linea:', NumberTools::format($line->pvptotal + $impuestoLinea));
68
            }
69
70
            $this->printer->lineBreak();
71
        }
72
73
        if (false === $this->hidePrices) {
74
            $this->printer->lineSeparator('=');
75
            $this->printer->textColumns('BASE', NumberTools::format($this->document->neto));
76
            $this->printer->textColumns('IVA', NumberTools::format($this->document->totaliva));
77
            $this->printer->textColumns('TOTAL DEL DOCUMENTO:', NumberTools::format($this->document->total));
78
        }
79
    }
80
81
}
82