A comprehensive Genropy/Erpy package for managing accommodation facilities, guest tracking, and tourist tax reporting.
- Davide Paci (@dgpaci)
The Host Management System is designed for accommodation facilities (hotels, B&Bs, vacation rentals) to manage:
- Facility information and types
- Guest registry with document tracking
- Stay records with automatic night calculation
- Tourist tax calculation and tracking
- Police report generation (Italian ISTAT format)
- Register multiple accommodation facilities
- Link facilities to owner/manager registry (via
erpyready.anagrafica) - Categorize facilities by type (hotel, B&B, apartment, etc.)
- Complete guest information linked to
erpyready.anagrafica - Document tracking (passport, identity card) for group leaders
- Personal data: name, surname, birth date, birthplace, citizenship
- Automatic linkage to existing registry records
- Record check-in and check-out dates
- Automatic calculation of number of nights
- Group management with designated group leader
- Multiple guests per stay with individual tax rates
- Configurable tax rates with exemption codes
- Italian tourist tax compliance (códigos de exención)
- Automatic tax calculation based on:
- Number of nights
- Guest age (exemptions for children under 12)
- Specific exemption categories
- Individual tax tracking per guest
- Generate TXT files for Italian police (Questura) reporting
- 178-character fixed-width format per guest
- ISTAT code integration for municipalities and countries
- Compliance with official Italian accommodation reporting requirements
Types of accommodation facilities
id(PK)code- Type codedescription- Type description
Guest type classification (Tipo Alloggiato)
id(PK)code- Guest type codedescription- Guest type descriptionis_leader- Calculated field (TRUE if code is '17' or '18')
Official Codes:
16: OSPITE SINGOLO (Single guest)17: CAPO FAMIGLIA (Family head) - Leader18: CAPO GRUPPO (Group head) - Leader19: FAMILIARE (Family member)20: MEMBRO GRUPPO (Group member)
Types of identification documents (96 official Italian codes)
id(PK)code- Document code (e.g., "IDENT", "PASOR")description- Document description (e.g., "CARTA DI IDENTITA'", "PASSAPORTO ORDINARIO")
Standard Codes (partial list):
IDENT: CARTA DI IDENTITA'IDELE: CARTA IDENTITA' ELETTRONICAPASOR: PASSAPORTO ORDINARIOPATEN: PATENTE DI GUIDA- (See initial_data.sql for complete list of 96 document types)
Tourist tax rates and exemptions
id(PK)code- Tax code (e.g., "0000000001" to "0000000009")description- Tax description/exemption reasonamount- Tax amount per night (EUR)
Standard Codes (from Italian tourist tax regulations):
0000000001: Exemption for minors under 12 years0000000002: Exemption for residents0000000003: Exemption for tour guides (groups of 25+)0000000004: Exemption for facility staff0000000005: NO EXEMPTION (standard rate)0000000006: Exemption for non-self-sufficient persons with medical certificate0000000007: Exemption for Civil Protection volunteers0000000008: Exemption for police and military personnel on duty0000000009: Exemption for guests with free accommodation
Accommodation facilities registry
id(PK)anagrafica_id(FK toerpyready.anagrafica) - Owner/Managername- Facility namefacility_type_id(FK tofacility_type)
Accommodation stays
id(PK)facility_id(FK tofacility)check_in_date- Check-in datecheck_out_date- Check-out datearrival_time- Arrival time (optional)flight_number- Flight number (optional)safe_code- Safe code for apartment access (optional)nights- Calculated field (check_out_date - check_in_date)
Calculated Fields:
nights: Automatically calculated from date differencestay_caption: Display caption combining facility name and datesgroup_leader_name: Calculated from guests with leader role
Validation:
- Check-out date must be after check-in date
Guest records for stays
id(PK)stay_id(FK tostay) - Stay referenceanagrafica_id(FK toerpyready.anagrafica) - Personal dataguest_type_id(FK toguest_type) - Guest type (single, family head, group head, member)tourist_tax_id(FK totourist_tax) - Tax rate or exemptiondocument_type_id(FK todocument_type) - Document typedocument_number- Document numberdocument_issued_by- Issuing authority/placedocument_issue_date- Issue datedocument_expiry_date- Expiry datetax_amount- Calculated field (nights × tax rate per municipality)
Business Logic:
- Each guest belongs to one stay (one-to-many relationship)
- Document fields are required only for group leaders (guest types 17, 18)
- If the same person returns, create a new guest record referencing the same anagrafica
- Each stay should have at least one group leader (guest_type code '17' or '18')
- Tax amount is automatically calculated via trigger based on:
- Number of nights from stay
- Tax rate from tourist_tax for the facility's municipality
- Exemptions (tax_rate = 0)
-
Copy the
hostpackage to your Erpy packages directory:cp -r host /path/to/erpy_projects/your_instance/packages/
-
The package requires
erpyreadyfor the anagrafica (registry) integration -
Restart your Genropy instance to load the package
-
The package will automatically create the
hostSQL schema and tables
Host Management
- Master Data
- Facilities
- Facility Types
- Guests
- Guest Types
- Document Types
- Tourist Tax Rates
- Operations
- Stays
-
Setup Master Data
- Guest types are pre-loaded (5 official codes)
- Document types are pre-loaded (96 official codes)
- Create facility types (Hotel, B&B, Apartment, etc.)
- Configure tourist tax rates with exemption codes
-
Register Facilities
- Link to existing anagrafica record (owner/manager)
- Specify facility name and type
-
Create Stays
- Select facility
- Enter check-in and check-out dates (nights calculated automatically)
- Optional: arrival time, flight number, safe code
- Add guests to the stay:
- Link to existing anagrafica or create new inline
- Select guest_type for each guest (16=single, 17=family head, 18=group head, 19=family member, 20=group member)
- At least one guest must be a leader (type 17 or 18)
- For group leaders: enter document information
- Assign tourist tax rate for each guest
- Tax amount calculated automatically based on nights and facility municipality
-
Export Police Report
- From the stay form, click "Export TXT for Police"
- Generated file contains 178-character lines per guest
- Format complies with Italian police reporting requirements
The export generates a fixed-width text file (178 characters per guest) with the following fields:
| Field | Length | Type | Description |
|---|---|---|---|
| Guest Type | 2 | N | 16=single, 17=family head, 18=group head, 19=family member, 20=group member |
| Arrival Date | 10 | AN | Format: gg/mm/aaaa |
| Days of Stay | 2 | N | Maximum 30 days |
| Surname | 50 | A | Guest surname |
| Name | 30 | A | Guest first name |
| Gender | 1 | N | 1=Male, 2=Female |
| Birth Date | 10 | AN | Format: gg/mm/aaaa |
| Birth Municipality | 9 | N | ISTAT code |
| Birth Province | 2 | A | Province code |
| Birth Country | 9 | N | Country code |
| Citizenship | 9 | N | Country code |
| Document Type | 5 | AN | Document type code |
| Document Number | 20 | AN | Document number |
| Document Issue Place | 9 | N | Municipality ISTAT code |
| Tourist Tax Code | 10 | N | Tax/exemption code (optional) |
Legend:
- N = Numeric (padded left with zeros)
- A = Alphabetic (padded right with spaces)
- AN = Alphanumeric (padded right with spaces)
The package integrates with erpyready for:
Guest and facility owner data is stored in erpyready.anagrafica which includes:
cognome(surname)nome(name)ragione_sociale(full name)sesso(gender): M/Fdata_nascita(birth date)luogo_nascita,comune_nascita,provincia_nascita,stato_nascita(birth place)cittadinanza(citizenship)- Address, phone, email, etc.
glbl.comune: Italian municipalities with ISTAT codesglbl.nazione: Countries with codes for police reporting
host/
├── main.py # Package configuration
├── menu.py # Menu structure
├── model/ # Database models
│ ├── facility.py
│ ├── facility_type.py
│ ├── guest.py
│ ├── guest_type.py
│ ├── document_type.py
│ ├── stay.py
│ ├── stay_guest.py
│ └── tourist_tax.py
├── resources/
│ ├── services/
│ │ └── police_export.py # Police report export service
│ └── tables/ # Table handlers (UI)
│ ├── facility/
│ │ └── th_facility.py
│ ├── facility_type/
│ │ └── th_facility_type.py
│ ├── guest/
│ │ └── th_guest.py
│ ├── guest_type/
│ │ └── th_guest_type.py
│ ├── document_type/
│ │ └── th_document_type.py
│ ├── stay/
│ │ └── th_stay.py
│ ├── stay_guest/
│ │ └── th_stay_guest.py
│ └── tourist_tax/
│ └── th_tourist_tax.py
└── README.md
- Anagrafica Integration: Personal data stored in centralized registry to avoid duplication
- Guest-Stay Relationship: Each guest belongs to one stay (one-to-many). If the same person returns, create a new guest record referencing the same anagrafica
- Guest Type System: Uses official Italian codes (16-20) to classify guests with mandatory sysRecord
- Group Leader Model: Only group leaders (types 17, 18) require document tracking
- Calculated Fields: Nights and tax amounts calculated automatically via triggers
- Tourist Tax Management: Tax rates configured per municipality using bag structure; 9 official exemption codes as mandatory sysRecord
- Stay-centric View: UI shows stays with group leader, not individual guests
- Lookup Tables as Code-based: All lookup tables use
codeas primary key instead of auto-generated id - Italian Compliance:
- 5 official guest types (Tipo Alloggiato) - mandatory sysRecord
- 96 official document types
- 9 official tourist tax exemption codes - mandatory sysRecord
- Police export follows official ISTAT format (178 chars)
from host.resources.services.police_export import PoliceExportService
service = PoliceExportService(db)
content = service.export_stay(stay_id)Methods:
export_stay(stay_id): Export all guests for a stay- Returns string with 178-character lines (one per guest)
Usage:
# Export to string
content = service.export_stay(stay_id)
# Export to file
from host.resources.services.police_export import export_stay_to_file
file_path = export_stay_to_file(db, stay_id, '/path/to/output.txt')- Genropy framework
- Erpy base package (
erpyready) - PostgreSQL or compatible database
- Python 3.7+
Proprietary - Softwell S.r.l.
For issues, questions, or contributions, contact:
- Davide Paci (@dgpaci)
-
2.0.0 (2026-01-26): Major refactoring
- Simplified data model: guest belongs to one stay (one-to-many instead of many-to-many)
- Integration with
er_core:erpy_readyinstead oferpy:erpy_base - All lookup tables use
codeas primary key - Mandatory sysRecord for guest types and tourist tax codes
- Improved tax calculation with municipality-specific rates via bag structure
-
1.0.0 (2026-01-23): Initial release
- Complete facility and guest management
- Stay tracking with automatic calculations
- Tourist tax management
- Police report export (Italian format)