remp / crm-invoices-module
CRM Invoices Module
Installs: 34 663
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 3
Open Issues: 0
Requires
- php: ^8.1
- contributte/pdf: ^7.0
- dragonbe/vies: ^2.3
- mpdf/mpdf: ^8.0
- dev-master
- 3.6.1
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
- 0.39.0
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
This package is auto-updated.
Last update: 2024-11-28 09:24:10 UTC
README
Invoices module is an extension to Payments module to provide invoices for confirmed payments. You can customize the layout of invoices based on the section below.
For invoice to be generated, user needs to provide an invoice address. This is requested on the success page of the payment and can be changed in the customer zone any time.
Invoices are always generated on the fly - system doesn't store generated PDFs for later use. If the template changes, template of older invoices might change too. Invoice data used for generation are stored at the time of first generation and never change. Therefore the template can change, but data won't.
Due to the EU legislation, users are allowed to request invoice generation (if it wasn't generated automatically) only within 15-day period after the payment was made. Other cases need to be handled manually by you and your accounting team.
Installing module
We recommend using Composer for installation and update management.
composer require remp/crm-invoices-module
Enabling module
Add installed extension to your app/config/config.neon
file.
extensions: - Crm\InvoicesModule\DI\InvoicesModuleExtension
Scheduled commands
Module doesn't provide any commands, that should be scheduled for execution periodically.
Service commands
Module might provide service commands to be run in the deployed environment. Mostly to handle internal changes
and to prevent direct manipulation with the database. You can display required and optional arguments by using
--help
switch when running the command.
Invoice module provides:
invoice:send
: To manually send an invoice based on payment's variable symbol.
Invoice numbering
By default CRM generates invoice numbers with monthly sequences (each month within year has its own sequence) and based on the service delivery date (effectively payment date).
You can override the way how invoice number sequence is generated by adding your own implementation of InvoiceNumberInterface
and overriding the default implementation in your config.neon
:
services: # ... invoiceNumber: Crm\FooModule\Repository\InvoiceNumber
Invoice templates
Invoice generator uses .latte
template to generate an invoice PDF. By default the module uses simple and
generic layout that we prepared. You can see the source of the layout.
In the example you can see that presenter provides you with $invoice
variable. Invoice is generated based on
payment and reference to invoice is stored as invoice_id
attribute of payment. Invoice's reference
back to payment is variable_symbol
, though it's only indirect and not guaranteed (no foreign keys are present).
Each invoice has a reference to invoice number which is a list of unique generated string identifiers guaranteed
to maintain order based on delivery_date
for the purposes of accounting. You can read the number by accessing
$invoice->invoice_number->number
.
Here's the list of attributes invoice provides:
On top of these, application configuration allows you to set some extra values that can be used in invoice template. You can always create your own config fields within one of your module seeders - see Config seeder of Invoice module as an example.
This configuration values are system wide and can be fetched with $config->get('foo')
- replace foo
with
one of the following options:
Invoice items are fetchable with $invoice->related('invoice_items')
. Items are generated based on payment items
present at the time of invoice first generation. From that point, items are saved separately. Here's the list
of attributes each invoice item provides:
If you want to use your own layout, prepare your own template with the use of variables described above.
Once it's ready, add following snippet to your app/config/config.local.neon
file (alter as needed):
invoiceGenerator: setup: - setTemplateFile('%appDir%/modules/FooModule/templates/invoices/foo.latte')
The snippet tells to invoice generator to use template provided at given path instead of default template.
Attaching invoices to email notifications
PDF invoice is attached by default to each email notification containing reference to a payment (as a parameter in NotificationEvent
). In addition, this notification has to be emitted as a result of processing of a specific trigger (Hermes message) by the application. Typically, this happens when a Hermes message triggers a scenario (see ScenariosModule for details) that emits a NotificationEvent
(this is done by Email node).
To limit which Hermes messages shall be accepted when attaching an invoice (see PreNotificationEventHandler
for implementation details), add the following configuration to your config.local.neon
file, listing allowed Hermes message types:
invoicesPreNotificationEventHandler: setup: - enableForNotificationHermesTypes('new-subscription', 'payment-status-change', 'some-other-hermes-message')
Components
DownloadReceiptButton
Frontend/Admin download payment receipt button.
InvoiceButton
Frontend/Admin download payment invoice button.
InvoiceLabel
User details payments listing invoice label.
PaymentSuccessInvoiceWidget
Widget for downloading invoice from payments success page.