Markus Michalski FAQ

Small Business: Technical details

Small Business §19 UStG for Shopware 6.7 - lifecycle, stored configuration values, plugin structure, overridden templates, Twig function and the differences of the Shopware 6.6 line.

Deutsche Version

Back to overview

Small Business: Technical details

How the parts fit together

The plugin has three independent parts: the lifecycle (creating the tax rate), the migration (changing product data) and the display (templates, controlled by the active setting). There is no cart processor or tax processor of its own.

graph TD
    A["Activate plugin"] --> B["Create or reuse 0 percent tax rate"]
    B --> C["Set as the shop default tax rate"]
    D["Deactivate plugin"] --> E["Restore remembered default tax rate"]
    F["Uninstall plugin"] --> G["Delete tax rate created by the plugin"]
    H["Setting active"] --> I["Storefront templates"]
    H --> J["Document templates"]
    K["Migration via admin card or CLI"] --> L["Products: tax rate and prices"]

Lifecycle

The plugin class Mmd\Kleinunternehmer\MmdKleinunternehmer uses these values:

Value Meaning
Tax rate name Kleinunternehmer §19 UStG (0%) The tax rate is looked up and created under this name (rate 0, position 0).
core.tax.defaultTaxRate Shopware setting for the default tax rate. The plugin sets it to the 0% tax rate on activation.
MmdKleinunternehmer.config.originalDefaultTaxId The previous default tax rate remembered on activation. Deactivation restores it.
MmdKleinunternehmer.config.createdTaxId The ID of the tax rate newly created by the plugin. Uninstall only deletes the tax rate if this is set.
MmdKleinunternehmer.config.active The "Small business regulation active" setting (bool, default false), overridable per sales channel.

If a tax rate with this name already exists on activation, the plugin uses it and does not record it as created by itself. It is then not deleted on uninstall.

Plugin structure

Class or file Purpose
Service\ConfigService Reads active with an optional sales channel ID.
Service\ProductMigrationService Finds the 0% tax rate and products by tax rate, writes tax rate and prices in steps of 100 products. Shared by CLI and API.
Command\MigrateProductTaxCommand CLI command mmd:kleinunternehmer:migrate-products.
Controller\Api\MigrationController The two Admin API routes, see Admin API.
Twig\SmallBusinessExtension Twig function mmd_small_business_active().
Resources/views/storefront/... Storefront template overrides, see Storefront.
Resources/views/documents/... Template overrides for invoice, cancellation and credit note, see Documents and emails.
Resources/snippet/... Storefront snippets (storefront.de-DE, storefront.en-GB) and the document notice (messages.de-DE, messages.en-GB).
Resources/app/administration/... Module with the migration card (component mmd-kleinunternehmer-migration) and its own admin snippets.

Twig function

mmd_small_business_active() returns true if active is switched on for the current sales channel. It determines the sales channel from the variable context (storefront) or from the variable order (documents). If neither exists, the general value applies.

Differences in the Shopware 6.6 line

The 6.6 line (mmd/sw66-kleinunternehmer, shopware/core ~6.6.0) has the same structure. Compared with the code of the 6.7 line there are these differences:

Area 6.7 line 6.6 line
Notice texts Snippets only. Additionally two text fields in the configuration (card "Notice Texts"): invoiceHint ("Notice text for invoices (optional)") and priceHint ("Notice text for price display (optional)"). A filled-in value overrides the respective snippet, an empty value uses the snippet.
Document notice Snippet document.smallBusinessNotice. Value of invoiceHint, otherwise snippet document.smallBusinessNotice. Applies to invoice, cancellation and credit note.
Price notice product page Snippet mmd-kleinunternehmer.grossTaxInformation as a link to the shipping and payment information. Value of priceHint, otherwise snippet mmd-kleinunternehmer.taxInfo ("Price without VAT acc. §19 UStG") as plain text without a link.
Price notice offcanvas cart Snippet mmd-kleinunternehmer.grossTaxInformation. Value of priceHint, otherwise snippet mmd-kleinunternehmer.taxInfo.
Product listing Own override of the product box with the price notice. No override, the listing shows Shopware's default texts.
Twig functions mmd_small_business_active() Additionally mmd_small_business_price_hint() and mmd_small_business_invoice_hint().
Admin migration card Confirmation dialog before the migration and a warning above 1,500 products. Migration starts directly on click, without dialog and without warning.
CLI command Progress bar during the migration. Same command with the same options, without a progress bar.
Admin API permissions product:read (status), product:update and system_config:read (migration) product.viewer (status), product.editor (migration)

Identical in both lines are plugin class and technical name, lifecycle (tax rate, default tax rate), the configuration key active, the Admin API routes, the name of the CLI command and its options, the price logic, the overrides of the document templates (apart from the notice text), the checkout override and the footer override.