spryker-demo/sales-invoice-file-feature

Sales invoice file [feature]

1.0.0 2025-04-09 16:09 UTC

This package is auto-updated.

Last update: 2025-05-22 16:55:16 UTC


README

Minimum PHP Version

This feature handle generating pdf file foreach invoice and upload it to S3.

Install the required modules using Composer

composer require spryker-demo/sales-invoice-file-feature

Add SprykerDemo namespace to configuration

$config[KernelConstants::CORE_NAMESPACES] = [
    'SprykerDemo',
    ...
];

Add translations

# data/import/common/common/glossary.csv

customer.order.invoice_number,Invoice Nr.,en_US
customer.order.invoice_number,Rechnungsnummer,de_DE
customer.order.invoices,Invoices,en_US
customer.order.invoices,Rechnungen,de_DE
customer.order.no_invoices,No Invoices,en_US
customer.order.no_invoices,Keine Rechnungen,de_DE

Import translations

console data:import:glossary

Adjust configuration

In case you wish to use S3

config/Shared/config_default.php

// >>> FILESYSTEM
$config[FileSystemConstants::FILESYSTEM_SERVICE] = [
...
'invoice' => [
        'sprykerAdapterClass' => Aws3v3FilesystemBuilderPlugin::class,
        'root' => '',
        'path' => 'path_to_invoice_directory',
        'key' => getenv('AWS_S3_KEY') ?? '',
        'secret' => getenv('AWS_S3_SECRET') ?? '',
        'bucket' => 'bucket_name',
        'version' => 'version',
        'region' => 'region_name',
    ],
];

Add crontab job to generate invoices pdf

config/Zed/cronjobs/jenkins.php

$jobs[] = [
    'name' => 'sales-invoice-file-generate-pdf',
    'command' => '$PHP_BIN vendor/bin/console sales-invoice-file:generate-pdf',
    'schedule' => '* * * * *',
    'enable' => true,
    'stores' => $allStores,
];

Activate plugins:

src/Pyz/Zed/Sales/SalesDependencyProvider.php

use SprykerDemo\Zed\MerchantRegistration\Communication\Plugin\Mail\MerchantRegistrationMailTypePlugin;

class MailDependencyProvider extends SprykerMailDependencyProvider
{
    /**
     * @return array<\Spryker\Zed\SalesExtension\Dependency\Plugin\OrderExpanderPluginInterface>
     */
    protected function getOrderHydrationPlugins(): array
    {
        return [
            new SalesInvoiceFileOrderExpanderPlugin(),
          ];
    }
}