Invoice payments
The Invoice Payment Management module provides functionality to create, edit and manage payments related to regular invoices (InvoiceType::Invoice). Payments are used to track amounts received on an invoice and allow partial or full payment. The module only works with regular invoices (InvoiceType::Invoice) - not used for proforma, credit or debit notes. Payments are managed through a separate controller and routes that are linked to a specific invoice via a `invoiceId` parameter. The system uses the sum of all payments on a given invoice to calculate the `isPaid` (Yes/No/Part) status via a SQL query that compares `totalPrice` of the invoice with `SUM(price)` of all associated payments. InvoicePaymentController extends `CoreBaseController` and uses standard CRUD methods (`baseList()`, `baseCreate()`, `baseEdit()`, `baseDeletes()`), all routes are linked to a specific invoice (`invoiceId` parameter), validates that the invoice is of type Invoice (not proforma, credit or debit note), automatically sets `invoice`, `date` and `createdAt` on creation, and redirects to the payment list after operations. The InvoicePayment entity has a ManyToOne relationship with Invoice (required), fields: `date`, `price`, `description`, `transaction`, `createdAt`, and does not implement the `CoreEntity` interface. InvoicePaymentRepository implements `CoreRepositoryInterface`, filters payments by `invoiceId` automatically, and sorts payments by date (DESC - newest first). InvoicePaymentForm extends `EditForm` from the Core module and has fields: `date` (required, prefilled), `price` (required, decimal 10,2), `description` (optional), `transaction` (optional). InvoiceRepository uses a SQL query to calculate the `isPaid` status: compares the `totalPrice` of the invoice with the `SUM(price)` of all associated payments, and filters invoices by `isPaid` status in the list. In the UI there are tabs for navigation between invoice view/edit and payments (shown only for InvoiceType::Invoice). All operations are protected by role permissions (`ROLE_INVOICE_VIEW`, `CREATE`, `EDIT`, `DELETE`) and follow good practices for security, validation and atomicity of operations. This documentation covers InvoicePayment only - ordinary invoices, credit notes, debit notes and proformas are not included.