All FiscGuy exceptions inherit from FiscalisationError. Import them from fiscguy.exceptions.
FiscalisationError
├── ReceiptSubmissionError
├── CloseDayError
├── FiscalDayError
├── ConfigurationError
├── CertificateError
├── DevicePingError
├── StatusError
├── DeviceRegistrationError
├── CryptoError
├── CertNotFoundError
├── PersistenceError
├── ZIMRAAPIError
├── ValidationError
├── AuthenticationError
├── TaxError
├── DeviceNotFoundError
├── TenantNotFoundError
└── ZIMRAClientError
ReceiptSubmissionErrorRaised when a receipt cannot be processed or submitted.
from fiscguy.exceptions import ReceiptSubmissionError
try:
submit_receipt(data)
except ReceiptSubmissionError as e:
print(e)
Common causes:
open_day() firstCloseDayErrorRaised when the fiscal day cannot be closed.
from fiscguy.exceptions import CloseDayError
try:
close_day()
except CloseDayError as e:
print(e)
Common causes and fixes:
| Error code | Cause | Fix |
|---|---|---|
CountersMismatch |
Closing string counters don’t match FDMS records | Check closing string format — date, tax percent format, L separator |
BadCertificateSignature |
Device signature cannot be verified | Certificate expired or wrong key — renew certificate |
FiscalDayCloseFailed |
FDMS validation failed | Check fiscalDayClosingErrorCode in logs |
| Empty response | FDMS returned nothing | Retry after a delay |
FiscalDayErrorRaised when a fiscal day cannot be opened.
Common causes:
ConfigurationErrorRaised when configuration is missing or sync fails.
Common causes:
init_device was not runopen_day() failed (day opened, config not updated)CertificateErrorRaised when certificate issuance or renewal fails.
Common causes:
DevicePingErrorRaised when the device ping to FDMS fails.
StatusErrorRaised when the status fetch from FDMS fails.
DeviceRegistrationErrorRaised during init_device if ZIMRA rejects the registration request.
Common causes:
CryptoErrorRaised when RSA signing, hashing, or key generation fails.
| HTTP Status | Meaning |
|---|---|
200 OK |
Success |
201 Created |
Receipt submitted successfully |
400 Bad Request |
Invalid request — fiscal day already open, no open day to close |
404 Not Found |
No device registered |
405 Method Not Allowed |
Wrong HTTP method |
422 Unprocessable Entity |
FDMS rejected the request |
500 Internal Server Error |
Unexpected server error |
FiscGuy uses loguru for structured logging. All service operations log at appropriate levels:
# In your Django project — configure loguru sink
from loguru import logger
logger.add("fiscguy.log", level="INFO", rotation="1 day")
Key log events:
| Level | Event |
|---|---|
INFO |
Receipt submitted, day opened/closed, client initialised |
WARNING |
FDMS offline (receipt queued), global number mismatch |
ERROR |
Receipt submission failed, close day failed |
EXCEPTION |
Unexpected errors with full traceback |