Skip to content

Commit 4cf4be6

Browse files
authored
Merge pull request #18 from tonomolla6/feature/export-pdf-tax-summary
feat: add tax settlement summary to PDF export
2 parents a3d6d74 + f5381d3 commit 4cf4be6

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

Controller/EditRegularizacionImpuesto.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,55 @@ protected function execPreviousAction($action): bool
192192
*/
193193
protected function exportAction(): void
194194
{
195+
if (false === $this->views[$this->active]->settings['btnPrint'] ||
196+
false === $this->permissions->allowExport) {
197+
Tools::log()->warning('no-print-permission');
198+
return;
199+
}
200+
201+
$this->setTemplate(false);
195202
$this->exportManager->setOrientation('landscape');
196-
parent::exportAction();
203+
$this->exportManager->newDoc(
204+
$this->request->queryOrInput('option', ''),
205+
$this->title,
206+
(int)$this->request->input('idformat', ''),
207+
$this->request->input('langcode', '')
208+
);
209+
210+
// load data for all views before exporting
211+
foreach ($this->views as $name => $view) {
212+
$this->loadData($name, $view);
213+
}
214+
215+
foreach ($this->views as $name => $selectedView) {
216+
if (false === $selectedView->settings['active']) {
217+
continue;
218+
}
219+
220+
$activeTab = $this->request->inputOrQuery('activetab', '');
221+
if (!empty($activeTab) && $activeTab !== $name) {
222+
continue;
223+
}
224+
225+
$codes = $this->request->request->getArray('codes');
226+
if (false === $selectedView->export($this->exportManager, $codes)) {
227+
break;
228+
}
229+
}
230+
231+
// add tax settlement summary table
232+
if (!empty($this->modelo303)) {
233+
$concept = Tools::trans('concept');
234+
$amount = Tools::trans('amount');
235+
$rows = [
236+
[$concept => Tools::trans('total-accrued-fee'), $amount => Tools::money($this->modelo303['27'])],
237+
[$concept => Tools::trans('total-to-deduct'), $amount => Tools::money($this->modelo303['45'])],
238+
[$concept => Tools::trans('total-result-of-the-general-regime'), $amount => Tools::money($this->modelo303['46'])],
239+
];
240+
$this->exportManager->addTablePage([$concept, $amount], $rows);
241+
}
242+
243+
$this->exportManager->show($this->response);
197244
}
198245

199246
/**

0 commit comments

Comments
 (0)