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