APLT Module
Overview
Section titled “Overview”The APLT Module is a custom B2B ERP system built into the Medusa backend. It handles the complete quotation-to-invoice pipeline, including CRM, access control, PDF generation, and AI-assisted workflows.
APLT data lives in a separate database from standard Medusa data, connected via APLT_DB_* environment variables.
Document Flow
Section titled “Document Flow”Quotation ──► Order ──► Invoice │ │ │ │ │ └──► Credit Note │ │ └────────────┴──► PDF GenerationDocument Numbering
Section titled “Document Numbering”Thread-safe via aplt_number_sequences table with row-level locking:
| Prefix | Document | Example |
|---|---|---|
| Q | Quotation | Q-2024-0001 |
| O | Order | O-2024-0015 |
| F | Invoice (Factuur) | F-2024-0042 |
| C | Credit Note | C-2024-0003 |
| P | Proforma | P-2024-0001 |
Database Tables (47 total)
Section titled “Database Tables (47 total)”Documents (10 tables)
Section titled “Documents (10 tables)”| Table | Purpose |
|---|---|
aplt_quotation_headers | Quotation master records |
aplt_quotation_lines | Quotation line items |
aplt_quotation_line_setup_costs | Setup costs per quotation line |
aplt_order_headers | Order master records |
aplt_order_lines | Order line items |
aplt_invoice_headers | Invoice master records |
aplt_invoice_lines | Invoice line items |
aplt_invoice_vat_summary | VAT summary per invoice |
aplt_document_relations | Cross-document links (quotation->order->invoice) |
aplt_opstartkosten | Startup/setup costs |
Products & Pricing (8 tables)
Section titled “Products & Pricing (8 tables)”| Table | Purpose |
|---|---|
aplt_products | Product catalog (multi-language, tiered pricing) |
aplt_techniques | Print/decoration techniques per product |
aplt_technique_pricing | Pricing per technique |
aplt_categories | Product categories |
aplt_category_mappings | Product-to-category mappings |
aplt_colors | Color definitions |
aplt_suppliers | Supplier information |
aplt_discount_groups | Discount configurations |
CMS (6 tables)
Section titled “CMS (6 tables)”| Table | Purpose |
|---|---|
aplt_cms_settings | Key/value settings per brand |
aplt_cms_pages | Multi-language content pages |
aplt_cms_menu_items | Menu items |
aplt_cms_menus | Menu definitions |
aplt_cms_footer_sections | Footer section organization |
aplt_cms_footer_links | Footer links |
Configuration (6 tables)
Section titled “Configuration (6 tables)”| Table | Purpose |
|---|---|
aplt_brands | Brand configurations |
aplt_settings | General settings |
aplt_number_sequences | Thread-safe document numbering |
aplt_payment_terms | Payment term definitions |
aplt_vat_codes | VAT rates |
aplt_tenants | Tenant configurations |
Accounting (5 tables)
Section titled “Accounting (5 tables)”| Table | Purpose |
|---|---|
aplt_payments | Payment records |
aplt_payment_allocations | Payment-to-invoice allocations |
aplt_journal_entries | Journal entry headers |
aplt_journal_lines | Journal entry lines |
aplt_ledger_accounts | Chart of accounts |
CRM & Access (2 tables)
Section titled “CRM & Access (2 tables)”| Table | Purpose |
|---|---|
aplt_customers | B2B customer database |
aplt_access_requests | IP-based access requests |
3D / Design (3 tables)
Section titled “3D / Design (3 tables)”| Table | Purpose |
|---|---|
aplt_3d_config | 3D viewer configuration |
aplt_3d_products | 3D product models |
aplt_3d_products_config | 3D product-specific configuration |
System (7 tables)
Section titled “System (7 tables)”| Table | Purpose |
|---|---|
aplt_audit_log | Change audit trail |
aplt_deployment_logs | Deployment history |
aplt_logo_cache | Cached logo data |
aplt_migrations | Database migration tracking |
aplt_modules | Module registry |
aplt_tenant_modules | Module-to-tenant assignments |
aplt_releases | Release version tracking |
Franco Pricing System
Section titled “Franco Pricing System”B2B shipping with free-shipping threshold:
- Franco Limit: €750 (configurable via
APLT_FRANCO_LIMIT) - Above limit → Free shipping
- Below limit → Calculated per box or default cost (
APLT_SHIPPING_COST_DEFAULT: €12.99) - Shipping boxes tracked per quotation/order
PDF Generation
Section titled “PDF Generation”All documents can be generated as PDFs using PDFKit:
| Endpoint | Document |
|---|---|
GET /admin/aplt/orders/pdf?id=X | Order confirmation |
GET /admin/aplt/quotations/pdf?id=X | Quotation/offerte |
GET /admin/aplt/invoices/pdf?id=X | Invoice |
GET /admin/aplt/credit-notes/pdf?id=X | Credit note |
PDFs include:
- Company info from
aplt_cms_settings(name, address, KvK, BTW, IBAN) - Line items with techniques and pricing
- VAT calculations
- Terms and conditions (quotations)
- Payment terms (invoices)
Invoice PDFs are persisted to /mnt/data/brinxx_invoices/.
Email + PDF (.EML Export)
Section titled “Email + PDF (.EML Export)”Documents can be exported as .eml files with the PDF already attached. Opening the .eml file in any email client (Outlook, Thunderbird, Apple Mail) gives a ready-to-send draft with pre-filled To, Subject, body text, and PDF attachment.
| Endpoint | Document | Filename |
|---|---|---|
POST /admin/aplt/quotations/eml | Offerte | offerte-{number}.eml |
POST /admin/aplt/orders/eml | Orderbevestiging | orderbevestiging-{number}.eml |
POST /admin/aplt/invoices/eml | Factuur | factuur-{number}.eml |
Request body: { "id": <document_id> }
EML features:
X-Unsent: 1header — opens as draft (compose mode) in email clients- PDF fetched internally from existing PDF routes (no code duplication)
- Company info (From, name) from
aplt_cms_settings - Customer email pre-filled in To field
- Standard Dutch email body text per document type
- MIME multipart/mixed with base64-encoded PDF attachment
Admin UI: Green “Email + PDF” button with EnvelopeSolid icon on Quotations, Orders, and Invoices pages.
AI Integration
Section titled “AI Integration”Three AI-powered features using the Anthropic Claude API:
| Endpoint | Purpose |
|---|---|
POST /admin/aplt/wayne-assist | AI admin assistant |
POST /admin/aplt/ai-generate-lines | Auto-generate quotation line items |
POST /admin/agent/product-search | Intelligent product search |
Quotation Features
Section titled “Quotation Features”- 30-day default validity
- Discount group integration
- Franco pricing calculations
- Auto-recalculate totals on line changes
- Print colors specification per line
- Convert to order (
POST /admin/aplt/quotations/confirm)
Subscription Billing
Section titled “Subscription Billing”Scheduled job for recurring invoices:
// Schedule: 0 8 1 * * (1st of month at 08:00)// Status: Currently DISABLEDAdmin UI Pages
Section titled “Admin UI Pages”The APLT module adds 25+ admin pages organized in sections:
SALES Section
Section titled “SALES Section”01-quotations— Quotation management02-aplt-orders— Order management03-invoices— Invoice management04-customers— Customer management05-credit-notes— Credit notes06-payments— Payment tracking07-reports— Reporting dashboard08-subscriptions— Subscription management09-crm— CRM functionality
STIJL Section
Section titled “STIJL Section”11-cms— Content management12-brand-wizard— Brand configuration13-cms-modules— Module management14-page-manager— Page layout editor15-menu-manager— Menu configuration
ADVANCED Section
Section titled “ADVANCED Section”21-connectors— Supplier data connectors22-access-requests— Access approvals23-aplt-products— Product catalog24-category-manager— Categories25-technique-pricing— Technique pricing26-translations— Multi-language translations