Export invoice metafields (#3366)
This commit is contained in:
6
.github/release-drafter.yml
vendored
6
.github/release-drafter.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name-template: 'v$RESOLVED_VERSION'
|
||||
tag-template: 'v$RESOLVED_VERSION'
|
||||
name-template: '$RESOLVED_VERSION'
|
||||
tag-template: '$RESOLVED_VERSION'
|
||||
categories:
|
||||
- title: 'Enhancements'
|
||||
labels:
|
||||
@@ -35,7 +35,7 @@ version-resolver:
|
||||
- 'translation'
|
||||
default: patch
|
||||
template: |
|
||||
[Upgrade guide](https://www.kimai.org/documentation/updates.html) - [Installation docs](https://www.kimai.org/documentation/installation.html) - [Docker docs](https://tobybatch.github.io/kimai2/) - [Docker Hub](https://hub.docker.com/r/kimai/kimai2)
|
||||
[Upgrade Kimai](https://www.kimai.org/documentation/updates.html) - [Install Kimai](https://www.kimai.org/documentation/installation.html) - [Docker](https://tobybatch.github.io/kimai2/) & [Hub](https://hub.docker.com/r/kimai/kimai2)
|
||||
|
||||
**PHP Version compatibility:**
|
||||
- PHP 7.3 is [end-of-life](https://www.php.net/supported-versions.php): you need to update now
|
||||
|
||||
@@ -17,11 +17,11 @@ class Constants
|
||||
/**
|
||||
* The current release version
|
||||
*/
|
||||
public const VERSION = '1.20.4';
|
||||
public const VERSION = '1.20.5';
|
||||
/**
|
||||
* The current release: major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
public const VERSION_ID = 12004;
|
||||
public const VERSION_ID = 12005;
|
||||
/**
|
||||
* The current release status, either "stable" or "dev"
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ use App\Event\InvoiceCreatedMultipleEvent;
|
||||
use App\Event\InvoiceDocumentsEvent;
|
||||
use App\Event\InvoiceMetaDefinitionEvent;
|
||||
use App\Event\InvoiceMetaDisplayEvent;
|
||||
use App\Export\Spreadsheet\AnnotatedObjectExporter;
|
||||
use App\Export\Spreadsheet\EntityWithMetaFieldsExporter;
|
||||
use App\Export\Spreadsheet\Writer\BinaryFileResponseWriter;
|
||||
use App\Export\Spreadsheet\Writer\XlsxWriter;
|
||||
use App\Form\InvoiceDocumentUploadForm;
|
||||
@@ -359,7 +359,7 @@ final class InvoiceController extends AbstractController
|
||||
* @Route(path="/export", name="invoice_export", methods={"GET"})
|
||||
* @Security("is_granted('view_invoice')")
|
||||
*/
|
||||
public function exportAction(Request $request, AnnotatedObjectExporter $exporter)
|
||||
public function exportAction(Request $request, EntityWithMetaFieldsExporter $exporter)
|
||||
{
|
||||
$query = new InvoiceArchiveQuery();
|
||||
$query->setCurrentUser($this->getUser());
|
||||
@@ -370,7 +370,11 @@ final class InvoiceController extends AbstractController
|
||||
|
||||
$entries = $this->invoiceRepository->getInvoicesForQuery($query);
|
||||
|
||||
$spreadsheet = $exporter->export(Invoice::class, $entries);
|
||||
$spreadsheet = $exporter->export(
|
||||
Invoice::class,
|
||||
$entries,
|
||||
new InvoiceMetaDisplayEvent($query, InvoiceMetaDisplayEvent::INVOICE)
|
||||
);
|
||||
$writer = new BinaryFileResponseWriter(new XlsxWriter(), 'kimai-invoices');
|
||||
|
||||
return $writer->getFileResponse($spreadsheet);
|
||||
|
||||
@@ -443,4 +443,16 @@ class InvoiceControllerTest extends ControllerBaseTest
|
||||
self::assertEquals(1, $node->count(), 'Could not find upload form');
|
||||
// we do not test the upload here, just make sure that the action can be rendered properly
|
||||
}
|
||||
|
||||
public function testExportIsSecureForRole()
|
||||
{
|
||||
$this->assertUrlIsSecuredForRole(User::ROLE_USER, '/invoice/export');
|
||||
}
|
||||
|
||||
public function testExportAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
||||
$this->assertAccessIsGranted($client, '/invoice/export');
|
||||
$this->assertExcelExportResponse($client, 'kimai-invoices_');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user