PointOfSaleVoucher   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 33
c 1
b 1
f 1
dl 0
loc 55
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildBody() 0 41 4
A __construct() 0 7 1
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
Bug introduced by
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\Core\Tools;
22
23
use FacturaScripts\Plugins\POS\Lib\PointOfSaleVoucher as PointOfSaleVoucherBase;
0 ignored issues
show
Bug introduced by
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...
24
25
class PointOfSaleVoucher extends PointOfSaleVoucherBase
26
{
27
    public function __construct(BusinessDocument $document, int $width, bool $hidePrices = false)
0 ignored issues
show
Bug introduced by
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...
28
    {
29
        parent::__construct(null);
30
31
        $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...
32
        $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...
33
        $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...
34
    }
35
36
    /**
37
     * Builds the ticket body
38
     */
39
    protected function buildBody(): void
40
    {
41
        $this->printer->text($this->document->codigo, true, true);
42
        $this->printer->lineSeparator('-');
43
        $this->printer->text('NCF: ' . $this->document->numeroncf, true, true);
44
        //$this->printer->text('TIPO: ' . $this->document->descripcionTipoComprobante(), true, true);
45
        $this->printer->text('F. VENC. NCF: ' . $this->document->ncffechavencimiento, true, true);
46
        $this->printer->lineSeparator('-');
47
        $fechacompleta = $this->document->fecha . ' ' . $this->document->hora;
48
        $this->printer->text($fechacompleta, true, true);
49
50
        $this->printer->text('CLIENTE: ' . $this->document->nombrecliente);
51
        $this->printer->lineSeparator('=');
52
53
        $this->printer->text('ARTICULO');
54
        $this->printer->textColumns('UNITARIO', 'IMPORTE');
55
        $this->printer->lineSeparator('=');
56
57
        foreach ($this->document->getLines() as $line) {
58
            $this->printer->text("$line->cantidad x $line->referencia - $line->descripcion");
59
60
            if (false === $this->hidePrices) {
61
                $this->printer->textColumns('PU', NumberTools::format($line->pvpunitario));
62
                $this->printer->textColumns('IMPORTE', NumberTools::format($line->pvpsindto));
63
64
                $descuento = $line->pvpsindto - ($line->pvpsindto * $line->getEUDiscount());
65
                $this->printer->textColumns('Descuento:', '- ' . NumberTools::format($descuento));
66
67
                $impuestoLinea = $line->pvptotal * $line->iva / 100;
68
                $this->printer->textColumns("Impuesto $line->iva%:", '+ ' . NumberTools::format($impuestoLinea));
69
                $this->printer->textColumns('Total linea:', NumberTools::format($line->pvptotal + $impuestoLinea));
70
            }
71
72
            $this->printer->lineBreak();
73
        }
74
75
        if (false === $this->hidePrices) {
76
            $this->printer->lineSeparator('=');
77
            $this->printer->textColumns('BASE', NumberTools::format($this->document->neto));
78
            $this->printer->textColumns('IVA', NumberTools::format($this->document->totaliva));
79
            $this->printer->textColumns('TOTAL DEL DOCUMENTO:', NumberTools::format($this->document->total));
80
        }
81
    }
82
83
}
84