This invoice generator application includes German localization for businesses operating in Germany or German-speaking regions, and features a web-based interface for easier invoice generation.
- Reorganized Codebase: The entire codebase has been restructured following proper Go project practices with cmd, internal, and pkg directories
- Decoupled Dependencies: Interfaces for all services to improve testability and maintainability
- Fixed WebUI Issues: Resolved issues with tax exemption checkbox, footer settings, and company name display
- Command-line and web-based interfaces
- German localization (labels, date format, VAT)
- Euro (€) as default currency with support for other currencies
- Configurable invoice details via JSON/YAML files
- PDF generation with proper layout
- Dynamic positioning to handle various content lengths
- Support for extended invoice numbers with suffix
- Automatic file naming based on invoice ID
- Nextcloud integration for file sharing
- Tax exemption support (Kleinunternehmer-Regelung)
- Environment variable configuration support
- Proper service/handler separation for business logic
-
Clone the repository:
git clone https://github.com/cougz/invoice.git cd invoice -
Build the application:
go build -o invoice ./cmd/invoice
-
(Optional) Install to your PATH:
go install ./cmd/invoice
This will create the invoice executable that you can run from the command line.
The invoice generator includes a web server that provides a browser-based interface for creating invoices.
./invoice web [--config config/web_config.json]The web server will start on port 8080 by default (configurable). Access the interface by opening http://localhost:8080 in your browser.
Configure the web server by creating a config/web_config.json file:
{
"port": 8080,
"nextcloudUrl": "https://your-nextcloud-server.com",
"nextcloudShare": "/s/your-share-id",
"uploadScript": "./cloudsend.sh"
}You can also configure the application using environment variables:
INVOICE_WEB_PORT=8080 INVOICE_TAX_RATE=0.19 ./invoice webThe web interface supports uploading and viewing generated invoices directly to a Nextcloud share. To use this feature:
- Configure your Nextcloud settings in
config/web_config.json - Make sure the
cloudsend.shscript is executable (chmod +x cloudsend.sh) - After generating an invoice, click "Upload to Nextcloud" to share it
./invoice generate --from "Meine Firma GmbH" \
--to "Kunde GmbH" \
--item "Beratungsleistung" --quantity 10 --rate 120 \
--tax 0.19 \
--note "Zahlbar innerhalb von 14 Tagen ohne Abzug."./invoice generate --id "2023001" --id-suffix "-R1" \
--from "Meine Firma GmbH" \
--to "Kunde GmbH" \
--item "Software-Lizenz" --quantity 1 --rate 499 \
--tax 0.19Save repeated information with JSON / YAML:
{
"logo": "/path/to/logo.png",
"from": "Meine Firma GmbH\nMusterstraße 123\n10115 Berlin",
"tax": 0.19,
"currency": "EUR",
"note": "Bitte überweisen Sie den Betrag innerhalb von 14 Tagen.",
"footer": {
"companyName": "Meine Firma GmbH",
"registrationInfo": "Amtsgericht Berlin, HRB 123456",
"vatId": "USt-IdNr. DE123456789",
"address": "Musterstraße 123",
"city": "Berlin",
"zip": "10115",
"phone": "+49 30 1234567",
"email": "info@meinefirma.de",
"website": "www.meinefirma.de",
"bankName": "Sparkasse Berlin",
"bankIban": "DE12 3456 7890 1234 5678 90",
"bankBic": "BELADEBEXXX"
}
}Generate a new invoice by importing the configuration file:
./invoice generate --import config/data.json \
--to "Kunde GmbH\nKundenweg 42\n80331 München" \
--item "Support-Paket" --quantity 1 --rate 299The invoice generator supports custom currency configurations through JSON files.
View all available currencies and their symbols:
./invoice currency listExport the current currency configuration to a JSON file:
./invoice currency export my_currencies.jsonCreate or modify a currency configuration file (currency_config.json or config/currency.json):
{
"symbols": {
"USD": "$",
"EUR": "€",
"GBP": "£",
"CHF": "CHF",
"CAD": "C$",
"AUD": "A$",
"CUSTOM": "¤"
}
}The application will automatically load currency symbols from any of these locations:
currency_config.jsonin the current directoryconfig/currency.jsonin the current directory~/.config/invoice/currency.jsonin the user's home directory
The application follows a clean architecture pattern:
/invoice
├── cmd/ # Command-line applications
│ └── invoice/ # Main application
│ └── main.go # Entry point
├── internal/ # Private application code
│ ├── models/ # Data models
│ │ ├── invoice.go # Invoice data structures
│ │ └── config.go # Configuration models
│ ├── handlers/ # Request handlers
│ │ └── web.go # Web interface handlers
│ ├── services/ # Business logic
│ │ ├── pdf/ # PDF generation
│ │ │ └── renderer.go # PDF rendering logic
│ │ ├── currency/ # Currency handling
│ │ │ └── service.go # Currency service
│ │ ├── invoice/ # Invoice generation
│ │ │ └── service.go # Invoice service
│ │ └── storage/ # Data persistence (future use)
│ └── config/ # Config handling
│ └── loader.go # Configuration loading
├── pkg/ # Public libraries
│ └── templates/ # Invoice templates (future use)
├── web/ # Web assets and templates
│ ├── templates/ # HTML templates (future use)
│ └── static/ # Static assets
│ └── css/ # CSS stylesheets
└── config/ # Configuration files
├── currency.json # Currency configuration
└── web_config.json # Web server configuration
The codebase now supports further improvements:
- Adding proper unit and integration tests
- Implementing database storage for invoices
- Adding authentication and user management
- Creating customizable PDF templates
- Implementing a RESTful API
- Internationalization and additional localization support