Document Types
Quote
Non-binding price estimate. Sets linked service orders to
quote status.Invoice
Final billing document. Sets orders to
ready and consumes inventory stock.Type-Specific Behavior
- Quote
- Invoice
Characteristics:
- Does not consume inventory stock
- Sets linked orders to
OrderStatus::QUOTE - Can be converted to invoice later
- Used for customer approval
app/Services/BillingService.php:59-61
Document Sources
Billing documents can be created for three business scenarios:Repair (Reparación)
Service-based billing for equipment repairs:- Primary use: Service orders
- Item kind:
service - Links to: Order records
- Inventory impact: None directly
Sale (Venta)
Product-based billing for direct sales:- Primary use: Inventory items
- Item kind:
product - Links to: Inventory items
- Inventory impact: Stock deduction on invoice
Mixed (Mixto)
Combined services and products:- Primary use: Repairs requiring parts
- Item kinds: Both
serviceandproduct - Links to: Orders and inventory
- Inventory impact: Stock deduction for product items
app/Http/Requests/StoreBillingDocumentRequest.php:45
Customer Modes
Registered Customer
Registered Customer
Link document to existing customer record:Validation:
Walk-in Customer
Walk-in Customer
Create on-the-spot customer for immediate service:Automatic customer creation:For walk-in repairs, equipment and service orders are auto-generated with status
delivered.app/Services/BillingService.php:147-190
VAT Calculation
Tax Modes
ElectroFix supports two VAT calculation methods:- Tax Included
- Tax Excluded
Price already contains VAT (gross pricing):Example: Customer pays 121.00
- VAT rate: 21%
- Subtotal: 100.00 (121.00 ÷ 1.21)
- VAT: 21.00
- Total: 121.00
app/Services/BillingService.php:117-125
VAT Rate Source
VAT percentage comes from the company settings:Line Item Processing
Item Structure
Calculation Flow
See:
app/Services/BillingService.php:67-145
Document Numbering
Automatic sequential numbering per company:DOC-{company_id}-{sequence}
Examples:
- First document:
DOC-001-000001 - Company 42:
DOC-042-000123 - After 999,999:
DOC-001-1000000
app/Services/BillingService.php:246-263
Service Order Integration
Linking Existing Orders
For registered customers, link to existing service orders:app/Services/BillingService.php:193-214
Auto-Generated Orders (Walk-in)
For walk-in service items, orders are created automatically:app/Services/BillingService.php:168-189
PDF Generation
Generate downloadable PDFs using DomPDF:- A4 format
- Filename:
{document_number}.pdf(e.g.,DOC-001-000123.pdf) - Includes all line items, totals, company and customer info
app/Http/Controllers/Worker/BillingController.php:87-98
Validation Rules
Fromapp/Http/Requests/StoreBillingDocumentRequest.php:41-58:
| Field | Type | Rules |
|---|---|---|
document_type | string | Required, quote or invoice |
source | string | Required, repair, sale, or mixed |
customer_mode | string | Required, registered or walk_in |
customer_id | integer | Required if registered |
walk_in_name | string | Required if walk_in, max 180 |
tax_mode | string | Required, included or excluded |
notes | string | Optional, max 2000 |
items | array | Required, min 1 item |
items.*.item_kind | string | service or product |
items.*.description | string | Required, max 255 |
items.*.quantity | numeric | 0.01-999,999 |
items.*.unit_price | numeric | 0-99,999,999.99 |
Automatic Item Kind Detection
The request automatically setsitem_kind based on source:
app/Http/Requests/StoreBillingDocumentRequest.php:9-33
Customer Service Lookup
Fetch available service orders for billing:app/Http/Controllers/Worker/BillingController.php:100-133
Relations
Billing documents maintain these relationships:app/Models/BillingDocument.php:43-61 and app/Models/BillingDocumentItem.php:37-50