Update Requirements
Part 1: Complete Invoice/Quotation Document Layout
Implement a professional document template (Bon de Livraison, Facture, Devis) with the following structure:
1. Header Section (3-Column Layout)
Left Block - Company Information:

Company name (bold, prominent)
Activity line (e.g., "Vente Produits Sanitaires & Quincaillerie")
Complete address (street, city, postal code)
Phone number(s) (support multiple)
Email address
Current page date
Page number

Center Block:

Company logo (centered, appropriately sized)

Right Block - Legal & Fiscal Info:

Identifiant Fiscal (Code TVA)
Registre de Commerce (RC)
Document date
Document number with type prefix:

"Bon de Livraison Nº [number]"
"Facture Nº [number]"
"Devis Nº [number]"



Layout Requirements:

Equal left/right margins
Proper vertical spacing
Clean horizontal alignment
Professional typography


2. Client Information Block
Create a bordered box containing:

Client: [Client name]
Adresse: [Full address]
Ident. Fisc.: [Client fiscal ID]
Chauf / Livr.: [Driver name]
Véhicule: [Vehicle reference]

Style:

Thin border around entire block
Vertical layout with label-value pairs
Clean spacing between lines


3. Products Table (Main Content)
Create a table with columns in this exact order:
CodeArticle / DésignationUnitéQtéPrix Unit HTRemiseTotal HTTVATotal TTC
Column Specifications:

Code: Product reference code
Article / Désignation: Full product description (allow text wrapping)
Unité: Unit of measure (pcs, kg, m², etc.)
Qté: Quantity ordered
Prix Unit HT: Unit price excluding tax
Remise: Discount amount or percentage
Total HT: Line total before tax (Prix Unit HT × Qté - Remise)
TVA: Tax rate (e.g., "19.0 %")
Total TTC: Line total including tax

Table Styling:

Bold header row
Thin borders on all cells
Right-align all numeric values
Left-align text fields
Alternating row colors (optional, subtle)


4. Summary Section
Display totals in a right-aligned vertical list:
Total Brut HT        [amount]
Total Remise         [amount]
Total Net HT         [amount]
Total TVA            [amount]
━━━━━━━━━━━━━━━━━━━━━━━━━━
NET À PAYER          [amount]
Requirements:

Clear visual separation (line or bold) for NET À PAYER
Right-aligned amounts
Proper spacing between lines


5. TVA Detail Table
Create a small table showing VAT breakdown:
LibelléBaseTauxMontantTVA 19%421.69319%80.122
Below the table, show:
Total Base:     [amount]
Total TVA:      [amount]

6. Footer Section
Three signature areas (horizontal layout):

Le Magasinier: _______________
Service Commercial: _______________
Décharge Client: _______________

Service line:
"Vous avez été servi par : [Employee Name]"
Footer bar:

Horizontal bar with company address repeated
Subtle background color
Centered text


Part 2: Product Discount System
Add a comprehensive discount feature for products.
Admin Panel - Discount Management
Create interface for setting product discounts:
Discount Types:

Percentage discount (e.g., 15%)
Fixed amount discount (e.g., 50 DT)

Admin Controls:

Select product from list
Choose discount type (percentage/fixed)
Enter discount value
Set discount status (active/inactive)
Optional: Start/end date for temporary discounts
Save discount configuration

Database Schema Addition:
sqlProduct Discounts Table:
- product_id (foreign key)
- discount_type (enum: 'percentage', 'fixed')
- discount_value (decimal)
- is_active (boolean)
- start_date (optional)
- end_date (optional)

Frontend - Shop Display
Product Page/Card Display:

Show original price (crossed out if discount active)
Display discount badge (e.g., "-15%" or "-50 DT")
Show final discounted price (prominent, larger font)
Calculate savings amount: "Économisez: [amount]"

Visual Example:
Product Name
̶5̶0̶0̶ ̶D̶T̶  →  425 DT  [-15%]
Économisez: 75 DT

Documents - Discount Representation
In Invoices/Quotations Table:
The "Remise" column must show:

Discount percentage: "15.0 %"
OR discount amount: "50.00 DT"
The "Total HT" already reflects the discount applied

Calculation Logic:
javascript// For percentage discount
discountAmount = prixUnitHT * quantity * (discountValue / 100)
totalHT = (prixUnitHT * quantity) - discountAmount

// For fixed discount
discountAmount = discountValue
totalHT = (prixUnitHT * quantity) - discountAmount
Important: Ensure discount is applied before TVA calculation:
Total HT (after discount) → Apply TVA → Total TTC

Implementation Guidelines
Critical Rules

DO NOT modify existing code unless necessary for integration
DO NOT touch the existing TVA system - it's already implemented
Preserve all current functionality - only add new features
Use existing database connections and models
Follow the project's current coding style and conventions

Integration Checklist

 Add discount fields to product database schema
 Create admin discount management interface
 Update product display to show discounts
 Modify cart/checkout to apply discounts correctly
 Update invoice/quotation generation to include all required fields
 Implement the complete document layout (header, client block, table, summary, footer)
 Test discount calculations with TVA system
 Verify document formatting matches specifications
 Ensure discount status can be toggled on/off
 Test with different discount types (percentage and fixed)

Technical Notes
Discount Priority:

If both percentage and fixed discounts exist, admin chooses which to apply
Only one discount type active per product at a time

Edge Cases to Handle:

Discount greater than product price (cap at 0)
Expired discount (auto-deactivate)
Minimum quantity for discount (optional enhancement)

Performance Considerations:

Cache active discounts to avoid repeated database queries
Pre-calculate discounted prices for listings


File Structure Additions
/admin
  /discounts
    - manage-discounts.php (or .jsx)
    - discount-api.php

/models
  - Discount.php (or discount.js)

/views
  /documents
    - invoice-template.php
    - quotation-template.php
    - delivery-note-template.php

/public
  /css
    - documents.css (invoice styling)
  /js
    - discount-calculator.js

Testing Requirements
Before marking complete, verify:

Discount System:

Admin can create percentage discount
Admin can create fixed amount discount
Discounts display correctly on shop
Discounts apply correctly in cart
Discount calculations are accurate


Document Layout:

All header sections render properly
Client info block displays correctly
Product table has all 9 columns in correct order
Summary calculations are accurate
TVA detail table shows breakdown
Footer signature areas appear
Print/PDF generation works


Integration:

Existing features still work
TVA calculations remain unchanged
No conflicts with current codebase




Summary
Add these features ONLY:

Complete invoice/quotation document layout (8 sections as specified)
Product discount system (percentage and fixed amount)

Do NOT:

Rewrite existing code
Modify TVA system
Change other platform features
Break current functionality

This is an incremental update. Preserve everything that works and add only what's specified above.