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\Mod; |
||
19 | |||
20 | use FacturaScripts\Core\Base\Contract\SalesLineModInterface; |
||
0 ignored issues
–
show
|
|||
21 | use FacturaScripts\Core\Base\Translator; |
||
0 ignored issues
–
show
The type
FacturaScripts\Core\Base\Translator 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
22 | use FacturaScripts\Core\Model\Base\SalesDocument; |
||
0 ignored issues
–
show
The type
FacturaScripts\Core\Model\Base\SalesDocument 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
23 | use FacturaScripts\Core\Model\Base\SalesDocumentLine; |
||
0 ignored issues
–
show
The type
FacturaScripts\Core\Model\Base\SalesDocumentLine 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
24 | use FacturaScripts\Plugins\fsRepublicaDominicana\Model\ImpuestoProducto; |
||
25 | |||
26 | class SalesLineMod implements SalesLineModInterface |
||
27 | { |
||
28 | |||
29 | public function apply(SalesDocument &$model, array &$lines, array $formData) |
||
30 | { |
||
31 | // TODO: Implement apply() method. |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param array $formData |
||
36 | * @param SalesDocumentLine $line |
||
37 | * @param string $id |
||
38 | * @return void |
||
39 | */ |
||
40 | public function applyToLine(array $formData, SalesDocumentLine &$line, string $id) |
||
41 | { |
||
42 | $line->rdtaxisc = $formData['rdtaxisc_' . $id] ?? null; |
||
43 | $line->rdtaxcdt = $formData['rdtaxcdt_' . $id] ?? null; |
||
44 | } |
||
45 | |||
46 | public function assets(): void |
||
47 | { |
||
48 | } |
||
49 | |||
50 | public function map(array $lines, SalesDocument $model): array |
||
51 | { |
||
52 | return []; |
||
53 | } |
||
54 | |||
55 | public function newModalFields(): array |
||
56 | { |
||
57 | return ['rdtaxisc', 'rdtaxcdt']; |
||
58 | } |
||
59 | |||
60 | public function newFields(): array |
||
61 | { |
||
62 | return []; |
||
63 | } |
||
64 | |||
65 | public function newTitles(): array |
||
66 | { |
||
67 | return []; |
||
68 | } |
||
69 | |||
70 | public function renderField(Translator $i18n, string $idlinea, SalesDocumentLine $line, SalesDocument $model, string $field): ?string |
||
71 | { |
||
72 | if ($field === 'rdtaxisc') { |
||
73 | return $this->rdTax($i18n, $idlinea, $line, $model, $field); |
||
74 | } |
||
75 | if ($field === 'rdtaxcdt') { |
||
76 | return $this->rdTax($i18n, $idlinea, $line, $model, $field); |
||
77 | } |
||
78 | return null; |
||
79 | } |
||
80 | |||
81 | public function renderTitle(Translator $i18n, SalesDocument $model, string $field): ?string |
||
82 | { |
||
83 | return null; |
||
84 | } |
||
85 | |||
86 | protected function rdTax($i18n, $idlinea, $line, $model, $field): string |
||
87 | { |
||
88 | $attributes = $model->editable ? |
||
89 | 'name="'. $field .'_' . $idlinea . '"' : |
||
90 | 'disabled=""'; |
||
91 | |||
92 | $title = $this->rdTaxTitle($i18n, $field); |
||
93 | $lineTax = $this->productoTaxValue($line->idproducto, $field); |
||
94 | //$line->$field = $lineTax->porcentaje; |
||
95 | $fieldValue = is_null($lineTax) ? 0 : $lineTax->porcentaje; |
||
96 | |||
97 | return '<div class="col-6">' |
||
98 | . $title |
||
99 | . '<input type="number" ' . $attributes . ' value="' . $fieldValue. '" class="form-control" readonly=""/>' |
||
100 | . '</div>' |
||
101 | . '</div>'; |
||
102 | } |
||
103 | |||
104 | protected function rdTaxTitle($i18n, $field): string |
||
105 | { |
||
106 | return '<div class="mb-2">' . $i18n->trans($field); |
||
107 | } |
||
108 | |||
109 | protected function productoTaxValue($idproducto, $rdtaxid): ?ImpuestoProducto |
||
110 | { |
||
111 | if (null !== $idproducto) { |
||
112 | $taxProducts = new ImpuestoProducto(); |
||
113 | $taxType = ($rdtaxid === 'rdtaxisc') ? "ISC" : "CDT"; |
||
114 | return $taxProducts->getTaxByProduct($idproducto, $taxType, 'venta'); |
||
115 | } |
||
116 | return null; |
||
117 | } |
||
118 | |||
119 | public function getFastLine(SalesDocument $model, array $formData): ?SalesDocumentLine |
||
120 | { |
||
121 | // TODO: Implement getFastLine() method. |
||
122 | } |
||
123 | } |
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