Съфинансирано от Европейския съюз Програма Конкурентоспособност и иновации в предприятията

Наименование на проекта: BG16RFPR001-1.001-0325-C01

Documentation

Complete technical documentation for system modules — security, ERP, and the public Web/CMS layer.

ERP Core

Core installation and base setup before modules.

ERP Core installation

Complete guide for the initial installation and configuration of ERP Core – system requirements (PHP 8.4+), database, environment (.env.dev.local), composer install, sass:build, migrations, Admin group and user, checklist and troubleshooting. After these steps the core is ready for installing individual business modules.

Read more

Security and users

Authentication, 2FA, CSRF, users and groups.

Login and authentication

A complete and secure user authentication system has been implemented. It includes email-and-password login, CSRF protection, and “Remember me” functionality. Pre-authentication checks cover account state (active and verified), with optional two-factor authentication (2FA) via email using a one-time 6-digit code. The system supports role-based access. The flow covers session management, secure password hashing, logout, and clear redirect logic after a successful login. The implementation is modular, extensible, and focused on a high level of security.

Read more
Users

The users module provides creating, editing, deleting, and managing accounts with access control through roles and groups. It supports two-factor authentication, password changes and personal profile, as well as filtering, sorting, and pagination of lists. All operations are protected and follow security best practices.

Read more
User groups

The user groups management module allows creating, editing, and deleting groups of users with a set of roles (permissions). Users automatically inherit the roles of their groups, and all changes are applied centrally. The system provides access control, filtering, and easy rights management without needing individual settings for each user.

Read more
Password reset

A complete and secure forgotten-password reset system has been implemented. The flow covers requesting a reset by email, generating a cryptographically secure token with limited validity, sending an email with a reset link, and a form to set a new password. The system avoids revealing whether a user exists, manages tokens in the database, and ensures one-time token use. It includes protection against timing attacks, secure token storage in the session, and automatic cleanup after a successful reset. The implementation is modular, extensible, and focused on a high level of security.

Read more
Email verification

An email verification system has been implemented for user registration. When a new account is created, an email is sent with a cryptographically signed confirmation link that has limited validity. After the user clicks the link, its authenticity is validated and the account is marked as verified. Until the email is confirmed, access to the system is blocked. The solution improves security, prevents use of fake emails, and ensures controlled, reliable activation of user accounts.

Read more
Two-factor authentication (2FA)

The system implements optional two-factor authentication via email. After a successful password login, if 2FA is enabled for the user, a 6-digit code is generated and sent by email. The user enters the code in a form with CSRF protection and an option for a trusted device, which allows skipping 2FA on subsequent logins. Codes are cryptographically protected and valid for a limited time, and trusted devices can be invalidated centrally.

Read more
Google Authenticator

Two-factor authentication via Google Authenticator has been implemented, based on the TOTP algorithm with temporary 6-digit codes. Users can enable and disable this method from their profile; during initial setup a secret key and QR code are generated for scanning with a mobile app. At login, after successful username and password verification, the system requires an additional code from Google Authenticator. Support includes choosing among different 2FA methods, trusted devices, and protection against reuse and timing attacks, which significantly raises account security.

Read more
Trusted device

A “trusted device” feature has been implemented that, after successful two-factor authentication, allows a device to be remembered for a defined period (30 days by default). Trusted devices do not require re-entering a 2FA code on subsequent logins, which significantly improves the user experience. The mechanism uses cryptographically signed cookies with limited validity and a version tied to the user account, enabling simultaneous invalidation of all trusted devices when the password changes, if the account is compromised, or when 2FA is disabled. The solution balances convenience and security.

Read more
CSRF protection

A complete CSRF protection layer has been implemented for the web application, preventing unauthorized requests made on behalf of authenticated users. The implementation covers automatic and manual generation and validation of CSRF tokens for all sensitive operations such as login, logout, CRUD forms, 2FA, and API requests. Both stateful and stateless tokens are supported, suitable for forms and REST/API scenarios. Protection is integrated at the form, controller, and request levels, with clear error handling and security best practices.

Read more
Data table configuration

A unified system for displaying data in tabular form has been implemented, with support for filtering, sorting, pagination, and selecting items per page. The architecture uses a shared base controller, a standard interface for repository layers, and shared templates and macros, ensuring consistent behavior across all modules. Users can search by various criteria via modal forms, sort by one or more columns, navigate between pages, and dynamically change the number of records per page. The solution is modular, extensible, and optimized for reuse and easy maintenance.

Read more
Error email notifications

A centralized event and error logging system has been implemented with support for different environments (development, test, production). In production, errors at error level and above automatically trigger email notifications to administrators. Log buffering preserves context before the error, and a deduplication mechanism prevents duplicate emails for recurring issues. Logs are formatted as structured JSON for easy integration with monitoring systems, and emails are sent in HTML with a full stack trace and web context. The solution enables fast problem detection, reduces noise, and simplifies diagnostics in production.

Read more

ERP modules

Clients, products, warehouses, orders, invoices, deliveries and production.

Clients

The client management module provides CRUD for clients and client addresses (email recipients), a unique UIC/EGN, natural/legal person type, and integrations with VIES and the Bulgarian Commercial Register. Used by Order and Invoice as the counterparty; Client data is copied onto the invoice, while ClientAddress is used only for email sending. Includes APIs for Select2, an inline form and an invoice snapshot. Operations are protected by ROLE_CLIENT_VIEW/CREATE/EDIT/DELETE; deleting a client that has documents is blocked by ForeignKeyConstraintViolationException.

Suppliers

The supplier management module provides CRUD for suppliers (name, unique UIC, VAT, address, responsible person, contact, supplier number) and VIES SOAP integration. Used by Delivery as a required counterparty; includes APIs for Select2, an inline form, VIES lookup, DB ↔ VIES comparison and an invoice snapshot. Operations are protected by ROLE_SUPPLIER_VIEW/CREATE/EDIT/DELETE/APPROVE; deleting a supplier that has deliveries is blocked by ForeignKeyConstraintViolationException.

Products

The product management module provides full functionality for creating, editing, deleting and managing products in the system. The module is a critical component that is used by multiple other modules (Order, Invoice, Warehouse, Delivery, Production) as a reference for product information and units of measure. The module extends CoreBaseController and uses standard CRUD operations with filtering by name and unit of measure, sorting and pagination. Uses DomainTranslationService for multilingual support of the units of measure (KG, LITER, PIECE) and validates the name as a required field with a maximum length of 255 characters. Attempting to delete a product that is used in other modules throws a ForeignKeyConstraintViolationException. All operations are protected by role permissions (ROLE_PRODUCT_VIEW, ROLE_PRODUCT_CREATE, ROLE_PRODUCT_EDIT, ROLE_PRODUCT_DELETE) and follow good security and validation practices.

Warehouse

The warehouse management module provides full functionality to create, edit, delete and manage warehouses and inventory. The module consists of two main entities: Warehouse and WarehouseStock. WarehouseController manages repositories with basic CRUD operations. WarehouseStockController manages inventory with basic CRUD operations and handles the Unique Constraint for the inventory-product combination. The module extends CoreBaseController and uses standard CRUD operations with filtering by name and address for warehouses, and by warehouse, product and quantity range for stock, sorting and pagination. Automatically sets creation date and creator on creation, and validates quantities as positive or zero. The module integrates with the Product module for in-stock products, and the User module for creator tracking. WarehouseStockRepository provides special methods for searching by warehouse and product (findByWarehouseAndProduct, findByWarehouse, findByProduct). WarehouseService provides additional methods for working with stocks and calculations (getStocksByWarehouse, getStocksByProduct, getTotalStockForProduct). The module uses the Unique Constraint to ensure the uniqueness of the warehouse-product combination (a product can only have one stock in one warehouse). All operations are protected by role permissions (ROLE_WAREHOUSE_VIEW, ROLE_WAREHOUSE_CREATE, ROLE_WAREHOUSE_EDIT, ROLE_WAREHOUSE_DELETE, ROLE_WAREHOUSE_STOCK_VIEW, ROLE_WAREHOUSE_STOCK_CREATE, ROLE_WAREHOUSE_STOCK_EDIT, ROLE_WAREHOUSE_STOCK_DELETE) and follow good security and validation practices.

Warehouse stock

The warehouse stock module (WarehouseStock) is the central stock management module in the system and serves as a single source of truth for the quantity of products in warehouses. The module integrates with the Order module to issue products from the warehouse when adding an item to an order via OrderStockService, which checks availability, reduces the quantity and creates OrderStockMovement audit records. The module integrates with the Delivery module to receive products in the warehouse when adding an item to a delivery via WarehouseService and automatically via DeliveryListener (Doctrine Entity Listener), which listens to postPersist, postUpdate and postRemove events and automatically updates the stock without manual call. The module integrates with the Production module to receive the produced output into the warehouse when creating production and to issue raw materials from the warehouse when adding material via ProductionStockService, which checks availability before issuing and creates ProductionStockMovement records. WarehouseStockRepository provides central methods (findByWarehouseAndProduct, findByWarehouse, findByProduct) that are used by all services. The module uses the Unique Constraint to ensure the uniqueness of the warehouse-product combination and follows strict rules for stock validation, preventing negative stocks, and creating Stock Movement audit records. All operations are protected with role permissions and follow best practices for security, accuracy and inventory movement tracking.

Orders

The order management module provides full functionality to create, edit, delete and manage customer orders with multiple items. The module consists of two main entities: Order and OrderItem. OrderController manages orders and after creation redirects to edit page to add items. OrderItemController manages items in modal mode for better UX and uses database transactions for atomicity of operations. The module extends CoreBaseController and uses standard CRUD operations with filtering by customer and date range, sorting and pagination. Automatically sets order date and creator on creation, and validates quantities and prices as positive numbers. The module automatically recalculates the total order price using bcmath functions (bcadd, bcmul) for accuracy, both at the OrderItem (quantity * unitPrice) and Order (sum of all items) levels. It integrates with the Client module for customers, the Product module for products in items, the User module for tracking creators, and the Warehouse module as a reference in OrderItem. It uses API components to dynamically load items, modal forms to manage items, and an API endpoint to dynamically update the total price. OrderStockService manages products in orders and lists products from the warehouse when adding an item. All operations are protected by role permissions (ROLE_ORDER_VIEW, ROLE_ORDER_CREATE, ROLE_ORDER_EDIT, ROLE_ORDER_DELETE) and follow good practices for security, validation and calculation accuracy.

Deliveries

The delivery management module provides full functionality for creating, editing, deleting, and managing supplier deliveries with multiple line items. The module consists of two main entities: Delivery (delivery) and DeliveryItem (line item in a delivery). DeliveryController manages deliveries and after creation redirects to the edit page for adding line items. DeliveryItemController manages line items in modal mode for better UX. The module extends CoreBaseController and uses standard CRUD operations with filtering by supplier and warehouse, sorting, and pagination. It automatically sets the delivery date and creator on creation, and validates quantities and prices as positive numbers. The module integrates with the Supplier module for suppliers, the Product module for products in line items, the User module for tracking creators, and the Warehouse module as a reference. It uses API components for dynamic loading of line items and modal forms for line item management. All operations are protected by role-based permissions (ROLE_DELIVERY_VIEW, ROLE_DELIVERY_CREATE, ROLE_DELIVERY_EDIT, ROLE_DELIVERY_DELETE, ROLE_DELIVERY_APPROVE) and follow security and validation best practices.

Production

The production management module provides full functionality to create, edit, delete and manage multi-material production processes. The module consists of two main entities: Production (production operation) and ProductionMaterial (material for production). ProductionController manages the production operations and after creation receives the production in the warehouse through ProductionStockService. ProductionMaterialController manages materials in modal mode for better UX and lists raw materials from the warehouse when adding material. The module extends CoreBaseController and uses standard CRUD operations with filtering by name, product, warehouse and date ranges, sorting and pagination. Automatically sets creation date and creator on creation, and validates quantities as positive numbers. The module integrates with the Product module for products (such as manufactured products and materials), the User module for tracking creators, and the Warehouse module for reference. It uses API components for dynamic loading of materials, modal forms for managing materials, and ProductionStockService for managing warehouse operations (production receipt and raw material issue). All operations are protected by role permissions (ROLE_PRODUCTION_VIEW, ROLE_PRODUCTION_CREATE, ROLE_PRODUCTION_EDIT, ROLE_PRODUCTION_DELETE, ROLE_PRODUCTION_MATERIAL_VIEW, ROLE_PRODUCTION_MATERIAL_CREATE, ROLE_PRODUCTION_MATERIAL_EDIT, ROLE_PRODUCTION_MATERIAL_DELETE) and follow good security and validation practices.

Cash

The cash transaction management module provides full functionality for creating, editing, deleting, and managing income and expense cash operations. The module extends CoreBaseController and uses standard CRUD operations with filtering by transaction date, amount, transaction type, and creator, plus sorting and pagination. It automatically sets the creator when creating a transaction via a callback and validates amounts as positive numbers. The module integrates with the User module to track creators and uses an Enum for transaction types (Income/Expense). All operations are protected by role-based permissions (ROLE_CASH_VIEW, ROLE_CASH_CREATE, ROLE_CASH_EDIT, ROLE_CASH_DELETE) and follow security and validation best practices.

File sharing

The File Share module provides a personal file manager with folders and files, uploads with an extension whitelist, three visibility levels (private / restricted to users and groups / public link), inherited access down the tree, owner audit history, and public pages for shared resources. Files are stored outside public/ in fileshare/{ownerId}/. Access is protected with ROLE_FILE_SHARE_* and FileShareItemVoter (VIEW/MANAGE) — only the owner manages; recipients can only view and download. The module uses its own FileShareController (does not extend CoreBaseController) and the FileShareStorageService, FileShareAccessService, and FileShareAuditService services.

Bank accounts

Complete guide for installing and activating the Bank Account module on ERP Core – copying from GitHub, migrations, menu entry in Builder.php, ROLE_BANK_ACCOUNT_* roles, cache clear and troubleshooting. The module is merged into the Core project without a separate composer require.

Invoices

The invoice management module provides full functionality for creating, editing, deleting, and managing invoices in the system. The module supports creating invoices with multiple line items (InvoiceItem), automatic calculation of VAT, discounts, tax base, and total amount via JavaScript in the browser. InvoiceController does not extend CoreBaseController and implements functionality directly, using database transactions for operation atomicity. The Invoice entity does not implement the CoreEntity interface and has a Unique Constraint on the type + number combination, plus callback validation for consistency between VAT options and percentage. The module supports bilingual fields (Bulgarian and English) for note/noteEng and name/nameEng in InvoiceItem, PDF generation via Wkhtml2pdfService, integration with the Client module (copies client data on create), integration with the BankAccount module (shows bank details in the PDF), validation of invoice number and date against previous and next invoices of the same type, data export in TSV format, and role-based permissions for all operations. The module uses InvoiceService for business logic (getData, createInvoiceFile, checkForValidInvoiceNumberAndDate), InvoiceRepository with special validation methods (getPreviousInvoiceByNumberAndType, getNextInvoiceByNumberAndType), and InvoiceForm with CollectionType for managing InvoiceItem line items. All operations follow best practices for security, validation, and atomicity. This documentation covers only regular invoices (InvoiceType::Invoice) — credit invoices, debit invoices, proformas, and invoice payments are not included.

Proforma invoices

The proforma management module provides functionality for creating, editing and managing proforma invoices in the system. Proformas are used as preliminary offers or draft invoices before a final invoice is issued and are created via a separate route `/invoices/proforma/create` and a separate method `proformaCreate()` in InvoiceController. The module uses the same Invoice entity as regular invoices, but with type InvoiceType::ProformaInvoice and has specific characteristics: it does not show the isPaid and isPosted fields in the form (unlike regular invoices), it automatically sets these fields to No on creation, and it can be created from scratch or copied from a parent invoice (optional). When creating a proforma, the system automatically sets isPaid = InvoicedStatus::No and isPosted = InvoicedStatus::No, generates an independent number for type ProformaInvoice, and if there is an invoiceId parameter, copies all data from the parent invoice (customer, prices, VAT, discounts, payment method, all items). InvoiceController uses database transactions for atomicity of operations, validates number and date against previous and subsequent proformas of the same type, and generates PDF files named "Invoice_{number}_{date}.pdf" (same as regular invoices). InvoiceForm does not show the isPaid and isPosted fields for proformas (logic: if (!$isProforma) { show the fields }), InvoiceRepository generates the next number for the ProformaInvoice type regardless of the numbering of the other document types, and InvoiceService validates the number and date against previous and subsequent proformas of the same type. The module uses the same forms, services and templates as regular invoices, but with specific logic for hiding the isPaid/isPosted fields and automatically setting these values. All operations are protected with role permissions and follow good practices for security, validation and atomicity of operations. This documentation only covers pro formas (InvoiceType::ProformaInvoice) - ordinary invoices, credit notes, debit notes and invoice payments are not included.

Credit notes

The credit note management module provides functionality for creating, editing, and managing credit notes in the system. Credit notes are used to cancel or correct issued invoices and are created from regular invoices (InvoiceType::Invoice) via the "Issue credit note" option in the invoice list. The module uses the same Invoice entity as regular invoices, but with type InvoiceType::CreditInvoice and a link to the parent invoice via the parent field (ManyToOne self-reference). When creating a credit note, the system automatically copies all data from the parent invoice (client, prices, VAT, discounts, payment method, all line items) and generates an independent number for type CreditInvoice. InvoiceController validates that the parent invoice is of type Invoice (a credit note cannot be created from another credit/debit note or proforma), uses database transactions for operation atomicity, and generates PDF files named "Credit_note_{number}_{date}.pdf" (different from regular invoices). InvoiceRepository generates the next number for type CreditInvoice independently of regular invoice numbering, and InvoiceService validates number and date against previous and next credit notes of the same type. The module uses the same forms, services, and templates as regular invoices, with specific logic for copying parent invoice data and validating the parent type. All operations are protected by role-based permissions and follow best practices for security, validation, and atomicity. This documentation covers only credit notes (InvoiceType::CreditInvoice) — regular invoices, debit notes, proformas, and invoice payments are not included.

Debit notes

The debit note management module provides functionality for creating, editing, and managing debit notes in the system. Debit notes are used to supplement or correct issued invoices and are created from regular invoices (InvoiceType::Invoice) via the "Issue debit note" option in the invoice list. The module uses the same Invoice entity as regular invoices, but with type InvoiceType::DebitInvoice and a link to the parent invoice via the parent field (ManyToOne self-reference). When creating a debit note, the system automatically copies all data from the parent invoice (client, prices, VAT, discounts, payment method, all line items) and generates an independent number for type DebitInvoice. InvoiceController validates that the parent invoice is of type Invoice (a debit note cannot be created from another credit/debit note or proforma), uses database transactions for operation atomicity, and generates PDF files named "Invoice_{number}_{date}.pdf" (the same as regular invoices, different from credit notes which use "Credit_note_{number}_{date}.pdf"). InvoiceRepository generates the next number for type DebitInvoice independently of regular invoice and credit note numbering, and InvoiceService validates number and date against previous and next debit notes of the same type. The module uses the same forms, services, and templates as regular invoices, with specific logic for copying parent invoice data and validating the parent type. All operations are protected by role-based permissions and follow best practices for security, validation, and atomicity. This documentation covers only debit notes (InvoiceType::DebitInvoice) — regular invoices, credit notes, proformas, and invoice payments are not included.

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.

Client addresses on invoices

The client address module (ClientAddress) manages recipient records (name, email, phoneNumber, isDefaultRecipient) for clients, used when sending invoices by email. The address and data printed on the invoice document itself (name, vat, eek, address, responsiblePerson, countryCode) come from Client and are copied into Invoice on create/edit — ClientAddress is not part of the invoice document content. ClientAddressController extends CoreBaseController and provides CRUD under /client/address/{clientId}; when creating with backToInvoice it redirects to invoice_send_email_to_client. In sendEmailToClient, recipients are chosen from the client's ClientAddress records; isDefaultRecipient preselects them. ClientAddress has a OneToMany with ClientInvoiceEmailLog. ClientAddressRepository.getPaginatedQuery filters by clientId, name, and email.

Invoice design

Invoice, proforma, debit note, and credit note design functionality provides a system for generating visual presentation and PDF files for all document types. The system uses a single Twig template (`invoice/template.html.twig`) for all document types (Invoice, CreditInvoice, DebitInvoice, ProformaInvoice), dynamically changing content based on document type. The design includes company logo, client and company information, a line-item table, VAT and total calculations, bank details, and signatures. The system uses `Wkhtml2pdfService` to convert HTML to PDF and `PriceTransformationService` to convert numeric amounts to text (in Bulgarian or English). InvoiceService prepares template data via the `getData()` method, which loads InvoiceItem line items, prepares client and company data, processes the logo (converts to base64), generates amount-in-words text, and returns an array with all required data. Wkhtml2pdfService converts HTML to PDF using the `wkhtmltopdf` binary, supports a custom footer with page number and text ("Generated by DevScale System"), and validates that the result is a valid PDF. PriceTransformationService provides `number2currency()` (Bulgarian) and `number2currencyNew()` (English) methods for converting numeric amounts to text. The template is fully styled with CSS (760+ lines of styles), supports different print modes (original/copy), and dynamically shows the document type (Invoice/CreditInvoice/DebitInvoice). For CreditInvoice amounts are shown with a minus sign (-); for other types without a minus. PDF files are named by type: CreditInvoice → "Credit_note_{number}_{date}.pdf", others → "Invoice_{number}_{date}.pdf". All document types use the same template, with different visual indicators and PDF names by type. The system is designed to be flexible and easily extensible for new document types or visual changes.

Invoice PDF generation

The PDF creation functionality provides a system for generating PDF documents from HTML templates for all types of invoices (Invoice, CreditInvoice, DebitInvoice, ProformaInvoice). The system uses `wkhtmltopdf` binary tool to convert HTML to PDF format via `Wkhtml2pdfService`. The process includes data preparation, rendering the Twig template, setting PDF options (footer, page numbers), and converting HTML to PDF binary string. InvoiceService prepares the data via method `getData()`, defines print modes (original/copy), renders the Twig template to HTML, sets footer options, and calls `Wkhtml2pdfService::savePdf()` to convert. Wkhtml2pdfService manages the conversion process via `proc_open()`, creates a process to execute the wkhtmltopdf binary, feeds HTML through the stdin pipe, reads the PDF from the stdout pipe, reads errors from the stderr pipe, validates that the PDF starts with `%PDF`, and returns the PDF binary string. InvoiceController generates a PDF via `createInvoiceFile()`, specifies a PDF file name according to the document type (CreditInvoice → "Credit_note_{number}_{date}.pdf", others → "Invoice_{number}_{date}.pdf"), sets HTTP headers (Content-type: application/pdf, Content-Disposition: attachment), and sends the PDF as a download. The system supports different print modes (original/copy), can generate both modes at the same time (result: PDF with 2 pages), and automatically sets the footer with page number and branding text ("Generated by DevScale System - https://www.devscale.bg"). The binary file is located in `bin/invoice/wkhtmltopdf` (Linux/Mac) or `bin/invoice/wkhtmltopdf.exe` (Windows/dev), is checked for existence on initialization, and runs as a process. The system handles errors correctly: it checks for the existence of the binary file, validates that the process was created successfully, and validates that the PDF result is valid. All document types use the same generation process, but with different PDF file names depending on the type. The system is designed to be reliable, with proper error handling and result validation.

Email invoice to client

The module describes sending an invoice by email to the client and the client's review flow. InvoiceController::sendEmailToClient shows a form with recipients (ClientAddress), subject, and body; it replaces {_INVOICE_CLIENT_LINK_} with a link to invoice_client_invoice?hash=sha256(...). For each selected recipient a ClientInvoiceEmailLog is created (hash, status Sent/Unsent) and an email is sent via MailService. clientInvoice(hash) is a public view: on open an InvoiceLog Viewed is recorded; if createdAt+30 days has passed, a modal for a new link is shown (POST newLink=1 sends a new email and a new ClientInvoiceEmailLog). With an open link: iframe with invoice_preview_by_hash; Approve/Reject buttons when status is sent, Download PDF when accepted (invoice_download_by_hash). InvoiceLog records Sent, Accepted, Refused (with text=objection). Client access is by hash only, without login.

Web and CMS

Public website, CMS menus, blog, SEO and frontend.

Website installation

Complete guide for installing and enabling Website (public site / CMS) on ERP Core – copying from GitHub, routes (attributes.yaml, cms_routes), security.yaml /admin prefix, CMS services, ERP_PREFIX, migrations, cache and troubleshooting. The module is merged into the Core project without a separate composer require. After install the public site is at / and the ERP panel at /admin.

Read more
CMS – Routing and page types

Functionality is implemented for dynamically generating public routes from the CMS menu and a central registry of page types. On application load, a custom routing loader reads menu records and creates routes with localized paths and a link to the corresponding frontend controller. A page_modules registry is implemented that describes which page types exist, whether they are single or multiple, and which controller serves them. The same registry is also used in the admin panel when creating new menu items. After a menu change, cache:clear is required so that routes are regenerated. Fallback access by identifier via /pageId-{id} is also added.

Read more
CMS – Menu entity and admin

Functionality is implemented for a hierarchical CMS menu model and a full administrative interface to manage it. The entity layer uses Single Table Inheritance and a nested tree structure so that each item can have parent/children and a different page type. Multilingual records (MenuLng) are implemented that store translations and SEO fields for each language. Tree view, CRUD operations, and drag-and-drop reordering are added in the admin panel. On edit, the system fills in missing language records and creates the correct entity/form according to the selected page type. The home page is a fixed root element; after changes, cache:clear is required.

Read more
CMS – Base controller and Home

Base frontend infrastructure for CMS pages and home page functionality is implemented. An abstract CmsController is implemented that loads the menu on construction, determines the active item, and provides a common contract for page controllers. Helper services and template functions are added for generating CMS URLs by id or discriminator. The home page is a single instance (without module_multiple), root in the tree, and immovable in the admin UI. The home page controller renders a marketing template through the skin layout, and SEO metadata comes from MenuLng. A fallback route /pageId-{id} is added that redirects to the canonical public address.

Read more
Web – Static and redirect pages

Functionality is implemented for static CMS pages and redirect pages. A static page controller is implemented that extends the CMS base controller, displays content from the menu, and integrates with the skin layout. For selected records a special template can be used (e.g. an ERP module grid with CTA). A redirect page type is added with a target to an external URL and/or another menu item, plus an option to open in a new tab. On request the controller applies priority: locale URL → CMS menu target → 404. Admin forms allow full configuration of both behaviors; template helpers support both types in links.

Read more
Web – Blog (frontend and admin)

Functionality is implemented for public display of blog posts and CMS administration over them. A frontend controller is implemented with a list, pagination, and a detail page by slug token; routing comes from the CMS blog page type with urls: true. Posts live in a separate table (Blog) with a unique slug, content, leading image, and an activity flag. An admin panel is added at /website/blog with CRUD, a rich-text editor, and file upload. The frontend filters only active records; on delete the admin handles constraint violations. The blog page menu item defines the URL and meta for the section without duplicating post content.

Read more
Web – Contact page

Functionality is implemented for a frontend “Contact us” page with a contact form and email notification. A controller is implemented that extends the CMS base layer, creates the form on GET, and validates submitted data on POST. On success a Mime email is built and sent via the mail service with safe send; the user sees a flash success/error and is redirected (PRG). The form includes name, email, subject, message, and CSRF protection. A template is added that combines the form with a hero section and static contact details. Contact page is a CMS page type that can have multiple instances (module_multiple: true).

Read more
Web – Skin and layout

A two-layer template hierarchy for the public site is implemented. A base CMS template (cms_base) is implemented that dynamically extends the skin file according to the skin field of the active menu item. The skin layout (main_skin and others) provides the common HTML skeleton: navbar, footer, cookie popup, and asset loading. A SkinMenu enum is added that describes available themes and returns the path to the corresponding template file. If the item has no skin set, MenuService inherits the value from the parent in the tree. Page templates extend cms_base and fill content/SEO blocks without duplicating the common layout.

Read more
Web – MenuService and navigation

Functionality is implemented for centralized menu logic and frontend navigation. MenuService is implemented; it loads menus, builds the tree, finds the active item, and prepares associated data with bubble-up of SEO/HTML fields. Filtering by tags (top, footer, left) is added, feeding the separate navigation zones in the layout. CMSUtils and a template extension provide functions for paths by id/discriminator and for menus by tag. CmsController invokes menu loading on initialization. In main_skin navigation is dynamic via cms_menus_by_tag, with a hardcoded fallback if tags are empty. Tags are edited in admin forms and stored together with the nested tree structure.

Read more
Web – Multilingual and SEO

Functionality is implemented for multilingual CMS infrastructure and SEO rendering of public pages. Configuration for available languages and the default language is implemented; the routing loader generates separate routes with a /{lng} prefix for non-default locales. On admin edit, missing MenuLng records are filled in automatically. At the translation level, URL, page title, meta description, and HTML injections are stored. Bubble-up of head/preBody/posBody HTML from parent elements via MenuService is added. The frontend cms_base layer renders title, meta, and HTML blocks in the layout; the skin template defines the slots that are filled.

Read more
Web – Frontend theme and assets

Functionality is implemented for managing the public site’s static resources — CSS, JavaScript, images, and third-party libraries from the frontend theme (Landrick/Bootstrap). Files are organized under assets/website/frontend/ with subdirectories for styles, scripts, images, and libs. Asset Mapper is implemented and registers assets/ as a mapped path; asset() generates public URLs. Skin templates load the standard pipeline: Bootstrap, icons, main CSS, bundle JS, sliders, and init scripts. Page templates (home, static, blog, contact) inherit the layout and use asset() for inline images. Integration with the skin, navigation, SEO, and image optimization layers is added.

Read more
Web – Image optimization

Functionality is implemented for on-demand resizing, format conversion, and caching of uploaded files. On a GET request to the optimized endpoint the controller validates requested sizes against configuration, reads the original, and generates a version with Intervention Image (GD). The result is written to an optimized/ subdirectory at a controlled quality and returned as BinaryFileResponse; subsequent requests use the cache. WebP conversion from jpg/jpeg/png originals is implemented. Entity/helper methods for URLs to optimized versions and a template function for access by id are added. Cleanup logic can clear the optimized directory when needed. The E2E/QA part of the original plan is in module 12.

Read more
Web – Final integration and QA

Functionality is implemented for final E2E integration and acceptance testing of the entire Web Presentation stack (modules 1–11). Smoke tests are implemented for all CMS page types: home, static, blog, contact, and redirect. A regression checklist is added after CRUD changes in the menu and the mandatory cache:clear procedure. Multilingual URLs (bg/en), SEO meta rendering, navigation by menu_tags, skin/layout (MainSkin, DarkSkin), the contact form with email, and image optimization are verified. Acceptance criteria for each preceding module and execution tools are documented (Panther or manual checklist, template lint, container lint). The goal is confirmation that the combined modules work together in a real flow.

Read more