Commerce Invoice

Provides invoice generation, management, and PDF export functionality for Drupal Commerce orders.

commerce_invoice
1,239 sites
34
drupal.org

Install

Drupal 11, 10 v8.x-2.2
composer require 'drupal/commerce_invoice:8.x-2.2'

Overview

Commerce Invoice is a comprehensive invoicing solution for Drupal Commerce that enables stores to generate, manage, and distribute invoices for customer orders. The module creates Invoice and Invoice Item entities that capture order information at a specific point in time, ensuring data integrity and compliance with accounting requirements.

The module integrates with Entity Print for PDF generation, supports multiple invoice types (including credit memos for refunds), and provides customizable workflows for invoice lifecycle management. Invoices can be automatically generated when orders are placed or manually created by administrators. Email notifications with PDF attachments can be sent to customers when invoices are confirmed or paid.

Key capabilities include customizable invoice numbering patterns, configurable payment terms and due dates, logo support, multilingual invoice generation, and a private file system for secure PDF storage.

Features

  • Invoice entity with full lifecycle management through customizable state machine workflows (draft, pending, paid, refund_pending, refunded, canceled)
  • Automatic invoice generation when orders are placed, configurable per order type
  • Manual invoice creation through admin interface with full control over invoice items and adjustments
  • Credit memo support for handling refunds and returns with separate numbering sequence
  • PDF invoice generation using Entity Print integration with support for Php Wkhtmltopdf engine
  • Customizable invoice numbering patterns using Commerce Number Pattern module
  • Email confirmation system with PDF attachment when invoices are confirmed or paid
  • Invoice type configuration including logo, payment terms, due date calculation, and footer text
  • Token support in payment terms and footer text for dynamic content
  • Secure PDF storage in private file system with configurable subdirectories per invoice type
  • Multilingual invoice support with automatic translation generation
  • Partial invoice support - generate multiple invoices for the same order
  • Invoice totals summary with subtotal, adjustments breakdown, and total price
  • Customer-facing invoice view with download capability
  • Integration with Commerce Log for invoice activity tracking

Use Cases

Automatic Invoice Generation on Order Placement

Configure order types to automatically generate invoices when orders are placed. Navigate to the order type edit form, enable 'Invoice orders of this type', select the invoice type, and check 'Invoice when the order is placed'. Invoices will be created automatically with all order items and adjustments.

Manual Invoice Creation for Custom Billing

For orders requiring custom invoicing, administrators can manually create invoices from the order's Invoices tab. This allows modifying invoice items, adjustments, and quantities before generating the invoice. Useful for partial invoicing or custom billing arrangements.

Credit Memo for Refunds

When processing refunds, create a credit memo from the order's Credit memos tab. Credit memos use a separate numbering sequence and can be used even for canceled orders. They help maintain proper accounting records for returned items.

Sending Invoice Confirmations

Enable 'Send confirmation' in invoice type settings to automatically email customers when invoices are confirmed or paid. The email includes the invoice PDF as an attachment. Optionally configure a BCC email to receive copies of all confirmations.

Customizing Invoice Appearance

Upload a logo, configure payment terms, and add footer text in invoice type settings. Use tokens like [commerce_invoice:invoice_number] for dynamic content. Override Twig templates for complete control over invoice layout and styling.

Multilingual Invoices

For multilingual stores, enable translation generation in invoice type language settings. Invoices will be automatically generated in all available languages, with translated product titles and content based on customer language preferences.

Tips

  • Configure the private filesystem path before enabling the module to ensure proper PDF storage security
  • Use the 'per_store_sequence' option in number patterns for separate invoice numbering per store
  • Customize invoice templates by copying commerce-invoice.html.twig to your theme and modifying the layout
  • The invoice file is regenerated when the invoice state changes (e.g., from pending to paid) to reflect the updated status
  • Use tokens in payment terms and footer text for dynamic content like due dates and store information
  • For partial invoicing, the module automatically tracks quantities already invoiced and prevents over-invoicing

Technical Details

Admin Pages 7
Invoices /admin/commerce/invoices

Main invoice listing page showing all invoices across all stores. Displays invoice number, customer, store, state, total price, and actions. Provides filtering and pagination capabilities.

Invoice View /admin/commerce/invoices/{commerce_invoice}

Detailed view of a single invoice showing invoice items, totals, customer information, billing information, and state transition buttons. Includes activity log if Commerce Log is enabled.

Invoice types /admin/commerce/config/invoice-types

Lists all available invoice types. Allows creating, editing, and deleting invoice types. Default types are 'Invoice' and 'Credit memo'.

Edit invoice type /admin/commerce/config/invoice-types/{commerce_invoice_type}/edit

Configuration form for invoice type settings including workflow, numbering, logo, email notifications, and payment terms.

Invoice item types /admin/commerce/config/invoices/invoice-item-types

Lists invoice item bundles which are dynamically created based on purchasable entity types in the system.

Order Invoices /admin/commerce/orders/{commerce_order}/invoices

Tab on order view page listing all invoices generated for this order. Allows creating new invoices for the order.

Order Credit Memos /admin/commerce/orders/{commerce_order}/credit-memos

Tab on order view page listing all credit memos generated for this order. Allows creating new credit memos for refunds.

Permissions 8
Administer invoice types

Maintain the types of invoices available and the fields that are associated with those types.

Administer invoices

Full administrative access to all invoice operations.

Access invoice overview

View the invoice listing page.

View any invoice

View any invoice regardless of ownership.

View own invoices

View invoices belonging to the current user.

Create invoices

Create new invoices.

Update invoices

Edit existing invoices.

Delete invoices

Delete invoices.

Troubleshooting 5
Invoice PDFs are not being generated

Ensure Entity Print is properly configured with a working PDF engine. Navigate to /admin/config/content/entityprint and configure the PDF engine settings. Php Wkhtmltopdf is recommended. Also verify the private filesystem is properly configured in settings.php.

Cannot create invoice for an order

Verify the order is not in draft state and has a total price. For invoices, orders must not be canceled. For credit memos, canceled orders are allowed. Also check that the total invoiced amount doesn't exceed the order total.

Invoice confirmation emails not being sent

Ensure 'Send confirmation' is enabled in the invoice type settings. A module like Symfony Mailer is required for HTML email support. Check that the invoice has a valid customer email address.

Invoice logo not appearing in PDF

Verify the logo file exists and is accessible. Check file permissions and ensure the logo URL is absolute. Some PDF engines may have issues with certain image formats - try converting to PNG.

Invoice numbers not incrementing correctly

Check the number pattern configuration at /admin/commerce/config/number-patterns. Verify the pattern is correctly assigned to the invoice type. Clear caches if numbers appear stuck.

Security Notes 4
  • Invoice PDFs are stored in the private filesystem to prevent unauthorized access
  • The 'administer commerce_invoice_type' permission is marked as restricted access due to its sensitive nature
  • Invoice confirmation emails include the customer's invoice PDF - ensure email security for sensitive financial data
  • The 'view own commerce_invoice' permission allows customers to view only their own invoices through a dedicated user page