========================================
FISCAL BRIDGE v1.0 - INSTALLATION GUIDE
========================================

OVERVIEW
--------
The Fiscal Bridge enables communication between your POS system 
and fiscal printers through a simple HTTP API.

REQUIREMENTS
------------
- Windows 7 or later
- Node.js 14.x or later (https://nodejs.org/)
- Serial port access to fiscal printer

INSTALLATION
------------
EASY METHOD (Recommended):
1. Extract all files to a folder
2. Double-click AUTO-INSTALL.bat
3. Follow the on-screen instructions
4. A desktop shortcut will be created automatically

MANUAL METHOD:
1. Run INSTALL.bat as Administrator
2. The installer will:
   - Create C:\FiscalBridge directory
   - Copy all necessary files
   - Install Node.js dependencies

CONFIGURATION
-------------
Edit C:\FiscalBridge\.env file to configure:

- SERIAL_PORT: Your fiscal printer's COM port (e.g., COM1, COM3)
- BAUD_RATE: Communication speed (default: 9600)
- PORT: HTTP server port (default: 3000)

IMPORTANT: Make sure the COM port matches your fiscal printer!

STARTING THE BRIDGE
------------------
1. Navigate to C:\FiscalBridge
2. Run START.bat
3. The server will start on http://localhost:3000

OR create a desktop shortcut to:
C:\FiscalBridge\START.bat

USAGE
-----
The bridge provides the following endpoints:

POST /print-receipt
- Prints fiscal receipts
- Format: Lines separated by ^ (e.g., S^Product^10.00)

POST /print-report
- Prints X or Z reports
- X Report: type=X
- Z Report: type=Z

GET /status
- Check bridge status and connection

RECEIPT FORMAT
--------------
Each line uses the format: TYPE^DESCRIPTION^AMOUNT

Types:
- S^  : Sale item
- P^  : Payment
- ST^ : Subtotal

Example:
S^Coffee^2.50
S^Sandwich^5.00
ST^7.50
P^Cash^10.00

VAT MAPPING
-----------
VAT categories are mapped as follows:
- A → 1
- B → 2
- C → 3
- D → 4

TROUBLESHOOTING
--------------
1. "Port already in use" error:
   - Another application is using port 3000
   - Change PORT in .env file

2. "Serial port not found" error:
   - Check COM port in Device Manager
   - Update SERIAL_PORT in .env file

3. Printer not responding:
   - Verify printer is turned on
   - Check cable connections
   - Confirm correct BAUD_RATE

4. Node.js not found:
   - Install from https://nodejs.org/
   - Restart computer after installation

SUPPORT
-------
For issues or questions:
- Check printer manual for COM settings
- Verify Windows Firewall allows Node.js
- Ensure printer drivers are installed

NOTES
-----
- Always run Z report at end of business day
- Keep backup of .env configuration
- Test with X report before production use

========================================
© 2024 Fiscal Bridge - Version 1.0
========================================