Herzlich willkommen

Developer

The extension can be connected to third-party modules via two adapter interfaces – for example for vouchers, store credit, reward points or additional discounts. Adapters are registered into a pool via dependency injection and taken into account automatically.

Supported third-party modules

Module Integration Handling
Aheadworks Gift Cards PrepaidAdapter BT-113 (prepaid amount)
Standard PDF (Magento Core), Magetrend, Mageplaza PDF embedding Hybrid ZUGFeRD PDF with embedded XML

AllowanceAdapterInterface

For amounts that are to be represented as an allowance at document level.

namespace Geissweb\ElectronicInvoicing\Api;

use Magento\Sales\Api\Data\InvoiceInterface;
use Magento\Sales\Api\Data\CreditmemoInterface;

interface AllowanceAdapterInterface
{
    public function isEnabled(): bool;

    /**
     * @return array<int, array<string, mixed>>
     */
    public function extractAllowances(InvoiceInterface|CreditmemoInterface $document): array;

    public function getModuleName(): string;

    public function getPriority(): int;
}

extractAllowances() returns, per allowance, an array with the keys amount (float, excluding VAT), vat_category (EN 16931 category, e.g. S), vat_rate (float, e.g. 19.0), reason (text) and reason_code (e.g. DISCOUNT).

PrepaidAdapterInterface

For amounts already paid (BT-113) such as vouchers, store credit or reward points.

namespace Geissweb\ElectronicInvoicing\Api;

use Magento\Sales\Api\Data\CreditmemoInterface;
use Magento\Sales\Api\Data\InvoiceInterface;

interface PrepaidAdapterInterface
{
    public function isEnabled(): bool;

    /**
     * @return array{amount: float, reference: string}
     */
    public function extractPrepaidAmount(InvoiceInterface|CreditmemoInterface $document): array;

    public function getModuleName(): string;

    public function getPriority(): int;
}

Both interfaces reside in the namespace Geissweb\ElectronicInvoicing\Api. getPriority() controls the execution order – lower values = higher priority (default 100).

Register your own adapter

Implement the appropriate interface and register the class in the respective pool in the etc/di.xml of your module:

<type name="Geissweb\ElectronicInvoicing\Model\Adapter\AllowanceAdapterPool">
    <arguments>
        <argument name="adapters" xsi:type="array">
            <item name="custom" xsi:type="object">Vendor\Module\Model\Adapter\CustomAllowanceAdapter</item>
        </argument>
    </arguments>
</type>

For prepaid adapters, use Geissweb\ElectronicInvoicing\Model\Adapter\PrepaidAdapterPool analogously.

Via isEnabled(), the adapter can check whether the target module is installed/active and enabled in the configuration. This keeps the integration inactive as long as it is not needed.