| Conditions | 18 |
| Paths | 2592 |
| Total Lines | 142 |
| Code Lines | 97 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 191 | protected function insertBusinessDocFooter($model) |
||
| 192 | { |
||
| 193 | if (!empty($model->observaciones)) { |
||
| 194 | $this->newPage(); |
||
| 195 | $this->pdf->ezText($this->i18n->trans('observations') . "\n", self::FONT_SIZE); |
||
| 196 | $this->newLine(); |
||
| 197 | $this->pdf->ezText(Tools::fixHtml($model->observaciones) . "\n", self::FONT_SIZE); |
||
| 198 | } |
||
| 199 | |||
| 200 | $this->newPage(); |
||
| 201 | |||
| 202 | // taxes |
||
| 203 | $taxHeaders = [ |
||
| 204 | 'tax' => $this->i18n->trans('tax'), |
||
| 205 | 'taxbase' => $this->i18n->trans('tax-base'), |
||
| 206 | 'taxp' => $this->i18n->trans('percentage'), |
||
| 207 | 'taxamount' => $this->i18n->trans('amount'), |
||
| 208 | 'taxsurchargep' => $this->i18n->trans('re'), |
||
| 209 | 'taxsurcharge' => $this->i18n->trans('amount') |
||
| 210 | ]; |
||
| 211 | $taxRows = $this->getTaxesRows($model); |
||
| 212 | $taxTableOptions = [ |
||
| 213 | 'cols' => [ |
||
| 214 | 'tax' => ['justification' => 'right'], |
||
| 215 | 'taxbase' => ['justification' => 'right'], |
||
| 216 | 'taxp' => ['justification' => 'right'], |
||
| 217 | 'taxamount' => ['justification' => 'right'], |
||
| 218 | 'taxsurchargep' => ['justification' => 'right'], |
||
| 219 | 'taxsurcharge' => ['justification' => 'right'] |
||
| 220 | ], |
||
| 221 | 'shadeCol' => [0.95, 0.95, 0.95], |
||
| 222 | 'shadeHeadingCol' => [0.95, 0.95, 0.95], |
||
| 223 | 'width' => $this->tableWidth |
||
| 224 | ]; |
||
| 225 | if (count($taxRows) > 1) { |
||
| 226 | $this->removeEmptyCols($taxRows, $taxHeaders, Tools::number(0)); |
||
| 227 | $this->pdf->ezTable($taxRows, $taxHeaders, '', $taxTableOptions); |
||
| 228 | $this->pdf->ezText("\n"); |
||
| 229 | } elseif ($this->pdf->ezPageCount < 2 && strlen($this->format->texto ?? '') < 400 && $this->pdf->y > static::INVOICE_TOTALS_Y) { |
||
| 230 | $this->pdf->y = static::INVOICE_TOTALS_Y; |
||
| 231 | } |
||
| 232 | |||
| 233 | // Tarea 2: Totales específicos |
||
| 234 | $headers = [ |
||
| 235 | 'label' => '', |
||
| 236 | 'value' => '' |
||
| 237 | ]; |
||
| 238 | $rows = [ |
||
| 239 | ['label' => $this->i18n->trans('total-exempt'), 'value' => Tools::number($model->totalexento)], |
||
| 240 | ['label' => $this->i18n->trans('total-taxed'), 'value' => Tools::number($model->neto - $model->totalexento)], |
||
| 241 | ]; |
||
| 242 | |||
| 243 | // Suma de cada impuesto adicional |
||
| 244 | $addedTaxes = [ |
||
| 245 | 'rdtaxisc' => 0, |
||
| 246 | 'rdtaxcdt' => 0, |
||
| 247 | 'rdtaxlegaltip' => 0, |
||
| 248 | 'rdtaxfirstplate' => 0 |
||
| 249 | ]; |
||
| 250 | foreach ($model->getLines() as $line) { |
||
| 251 | foreach (array_keys($addedTaxes) as $tax) { |
||
| 252 | if (!empty($line->{$tax})) { |
||
| 253 | $addedTaxes[$tax] += (float)$line->pvpsindto * (float)$line->{$tax} / 100.0; |
||
| 254 | } |
||
| 255 | } |
||
| 256 | } |
||
| 257 | $rows[] = ['label' => $this->i18n->trans('iva') . ' ' . $line->iva . '%', 'value' => Tools::number($model->totaliva)]; |
||
| 258 | foreach ($addedTaxes as $tax => $value) { |
||
| 259 | if ($value > 0) { |
||
| 260 | $rows[] = ['label' => $this->i18n->trans($tax) . ' ' . $line->{$tax} . '%', 'value' => Tools::number($value)]; |
||
| 261 | } |
||
| 262 | } |
||
| 263 | |||
| 264 | $rows[] = ['label' => $this->i18n->trans('total-added-taxes') , 'value' => Tools::number($model->totaladdedtaxes)]; |
||
| 265 | |||
| 266 | $total_final = ($model->totalplustaxes !== 0.0) ? $model->totalplustaxes : ($model->totaliva + $model->totaladdedtaxes + $model->neto); |
||
| 267 | |||
| 268 | $rows[] = ['label' => $this->i18n->trans('total'), 'value' => Tools::number($total_final)]; |
||
| 269 | |||
| 270 | // QR y Datos de Seguridad |
||
| 271 | $qrBlockWidth = 0; |
||
| 272 | $startY = $this->pdf->y; |
||
| 273 | $qrBottomY = $startY; |
||
| 274 | |||
| 275 | if ($model->modelClassName() === 'FacturaCliente' && (substr($model->numeroncf, 0, 1) === 'E')) { |
||
| 276 | $code = Tools::settings('default', 'idempresa', ''); |
||
| 277 | $company = new Empresa(); |
||
| 278 | if ($company->load($code)) { |
||
| 279 | $url = "https://fc.dgii.gov.do/ecf/consultatimbrefc?" . http_build_query([ |
||
| 280 | 'RncEmisor' => $company->cifnif, |
||
| 281 | 'ENCF' => $model->numeroncf, |
||
| 282 | 'FechaEmision' => $model->fecha, |
||
| 283 | 'MontoTotal' => $model->totalplustaxes, |
||
| 284 | 'FechaFirma' => $model->ecf_fecha_firma, |
||
| 285 | 'CodigoSeguridad' => $model->ecf_codigo_seguridad |
||
| 286 | ]); |
||
| 287 | |||
| 288 | $qrImage = TwoFactorManager::getQRCodeImage($url); |
||
| 289 | $qrBlockWidth = 130; |
||
| 290 | $this->renderQRimage($qrImage, null, null, $this->pdf->ez['leftMargin'], $startY + 15, 0, $qrBlockWidth); |
||
| 291 | |||
| 292 | // Manualmente agregamos los datos de seguridad debajo del QR |
||
| 293 | $qrSize = 110; |
||
| 294 | $qrX = $this->pdf->ez['leftMargin'] + 10 + ($qrBlockWidth - 10 - $qrSize) / 2; |
||
| 295 | $textX = $qrX + 6; |
||
| 296 | $textY = $startY - $qrSize; |
||
| 297 | $this->pdf->addText($textX, $textY, self::FONT_SIZE - 2, $this->i18n->trans('desc-ecf_codigo_seguridad') . ": " . $model->ecf_codigo_seguridad, 0, 'left'); |
||
| 298 | $this->pdf->addText($textX, $textY - self::FONT_SIZE, self::FONT_SIZE - 2, $this->i18n->trans('desc-ecf_fecha_firma') . ': ' . $model->ecf_fecha_firma, 0, 'left'); |
||
| 299 | $qrBottomY = $textY - self::FONT_SIZE - 10; |
||
| 300 | } |
||
| 301 | } |
||
| 302 | |||
| 303 | // Totales al lado del QR |
||
| 304 | $this->pdf->ezSetY($startY); |
||
| 305 | $tableOptions = [ |
||
| 306 | 'showHeadings' => 0, |
||
| 307 | 'shaded' => 0, |
||
| 308 | 'width' => $this->tableWidth - $qrBlockWidth, |
||
| 309 | 'cols' => [ |
||
| 310 | 'label' => ['justification' => 'right', 'width' => ($this->tableWidth - $qrBlockWidth) * 0.8], |
||
| 311 | 'value' => ['justification' => 'right', 'width' => ($this->tableWidth - $qrBlockWidth) * 0.2] |
||
| 312 | ] |
||
| 313 | ]; |
||
| 314 | |||
| 315 | $oldMarginLeft = $this->pdf->ez['leftMargin']; |
||
| 316 | $this->pdf->ez['leftMargin'] += $qrBlockWidth; |
||
| 317 | $this->pdf->ezTable($rows, $headers, '', $tableOptions); |
||
| 318 | $tableBottomY = $this->pdf->y; |
||
| 319 | $this->pdf->ez['leftMargin'] = $oldMarginLeft; |
||
| 320 | |||
| 321 | // Aseguramos que los siguientes elementos comiencen después de ambos bloques |
||
| 322 | $this->pdf->y = min($qrBottomY, $tableBottomY); |
||
| 323 | |||
| 324 | // receipts |
||
| 325 | if ($model->modelClassName() === 'FacturaCliente') { |
||
| 326 | $this->insertInvoiceReceipts($model); |
||
| 327 | } elseif (isset($model->codcliente)) { |
||
| 328 | $this->insertInvoicePayMethod($model); |
||
| 329 | } |
||
| 330 | |||
| 331 | if (!empty($this->format->texto)) { |
||
| 332 | $this->pdf->ezText("\n" . Tools::fixHtml($this->format->texto), self::FONT_SIZE); |
||
| 333 | } |
||
| 335 | } |
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