superfaktura.invoice module
Invoice Module.
This module provides classes and functions for working with invoices in the SuperFaktura API. It allows for retrieving, creating, updating, and deleting invoices.
- Classes:
- InvoiceModel: Dataclass representing an invoice. 
- InvoiceItem: Dataclass representing an invoice item. 
- Invoice: Class for interacting with invoices. 
 
- Exceptions:
- NoDefaultBankAccountException: Exception for when no default bank account is found. 
 
- Functions:
- (none) 
 
- Usage:
- >>> import superfaktura.invoice >>> # Create an instance of Invoice >>> invoice = superfaktura.invoice.Invoice() >>> # Create an invoice >>> invoice.add( invoice_model=InvoiceModel( type=InvoiceType.INVOICE, name="My First Invoice", due=Date("2025-04-01"), invoice_currency=Currencies.EUR, header_comment="We invoice you for services", bank_accounts=[bank.default().as_dict()], ), items=[ InvoiceItem( name="Website Development", unit_price=1000.0, quantity=1, tax=20 ), InvoiceItem( name="Hosting Service (1 year)", unit_price=500.0, quantity=1, tax=20 ), ], contact=ClientContactModel( name="John Doe", email="john.doe@examle.com", phone="+1 555-1234", address="123 Main Street, New York", ico="987654321", update=True, country_id=225, ), ) 
- class superfaktura.invoice.Invoice
- Bases: - SuperFakturaAPI- Invoice Class. - This class provides methods for interacting with invoices in the SuperFaktura API. It allows for retrieving, creating, updating, and deleting invoices. - - add
- Creates a new invoice. 
 - - get
- Retrieves an invoice by ID. 
 - - list
- Retrieves a list of invoices. 
 - - update
- Updates an existing invoice. 
 - Usage:
- >>> invoice = Invoice() >>> invoice.add( invoice_model=InvoiceModel( type=InvoiceType.INVOICE, name="My First Invoice", due=Date("2025-04-01"), invoice_currency=Currencies.EUR, header_comment="We invoice you for services", bank_accounts=[bank.default().as_dict()], ), items=[ InvoiceItem( name="Website Development", unit_price=1000.0, quantity=1, tax=20 ), InvoiceItem( name="Hosting Service (1 year)", unit_price=500.0, quantity=1, tax=20 ), ], contact=ClientContactModel( name="John Doe", email="john.doe@example.com", phone="+1 555-1234", address="123 Main Street, New York", ico="987654321", update=True, country_id=225, ), ) 
 - add(invoice_model: InvoiceModel, items: List[InvoiceItem], contact: ClientContactModel, invoice_settings: InvoiceSettings | None = None) InvoiceRespModel
- Adds a new invoice. - Parameters:
- invoice_model (InvoiceModel) – The invoice model. 
- items (List[InvoiceItem]) – List of invoice items. 
- contact (ClientContactModel) – The client contact model. 
- invoice_settings (Optional[InvoiceSettings]) – The invoice settings. 
 
- Returns:
- The response model for the invoice. 
- Return type:
 
 - get_pdf(invoice: InvoiceRespModel, descriptor: IO[bytes], language: str = 'cze') None
- Retrieves the PDF of the invoice. - Parameters:
- invoice (InvoiceRespModel) – The response model for the invoice. 
- descriptor (IO[bytes]) – The descriptor to write the PDF data to. 
- language (str) – The language for the PDF. 
 
- Returns:
- None 
 
 
- class superfaktura.invoice.InvoiceItem(name: str, unit_price: float, description: str | None = None, discount: float | None = 0, discount_description: str | None = None, load_data_from_stock: int = 0, quantity: float | None = 1, sku: str | None = None, stock_item_id: int | None = None, tax: float | None = None, unit: str | None = None, use_document_currency: int | None = 0)
- Bases: - object- This dataclass represents an invoice item in the SuperFaktura API. - as_dict() dict
- Returns a dictionary representation of the InvoiceItem. 
 - description: str | None = None
 - discount: float | None = 0
 - discount_description: str | None = None
 - load_data_from_stock: int = 0
 - name: str
 - quantity: float | None = 1
 - sku: str | None = None
 - stock_item_id: int | None = None
 - tax: float | None = None
 - unit: str | None = None
 - unit_price: float
 - use_document_currency: int | None = 0
 
- class superfaktura.invoice.InvoiceModel(add_rounding_item: int | None = 0, already_paid: int | None = None, bank_accounts: List[dict] | None = None, comment: str | None = None, constant: str | None = None, created: Date | None = None, delivery: Date | None = None, delivery_type: str | None = None, deposit: float | None = None, discount: float | None = 0, discount_total: float | None = None, due: Date | None = None, estimate_id: int | None = None, header_comment: str | None = None, internal_comment: str | None = None, invoice_currency: str | None = None, invoice_no_formatted: str | None = None, issued_by: str | None = None, issued_by_email: str | None = None, issued_by_phone: str | None = None, issued_by_web: str | None = None, logo_id: int | None = None, mark_sent: int | None = None, mark_sent_message: str | None = None, mark_sent_subject: str | None = None, name: str | None = None, order_no: str | None = None, parent_id: int | None = None, paydate: Date | None = None, payment_type: str | None = None, proforma_id: str | None = None, rounding: str | None = None, sequence_id: int | None = None, specific: str | None = None, tax_document: int | None = None, type: str | None = None, variable: str | None = None, vat_transfer: int | None = None)
- Bases: - object- This dataclass represents an invoice in the SuperFaktura API. - add_rounding_item: int | None = 0
 - already_paid: int | None = None
 - as_dict() dict
- Returns a dictionary representation of the InvoiceModel. 
 - bank_accounts: List[dict] | None = None
 - comment: str | None = None
 - constant: str | None = None
 - delivery_type: str | None = None
 - deposit: float | None = None
 - discount: float | None = 0
 - discount_total: float | None = None
 - estimate_id: int | None = None
 - header_comment: str | None = None
 - internal_comment: str | None = None
 - invoice_currency: str | None = None
 - invoice_no_formatted: str | None = None
 - issued_by: str | None = None
 - issued_by_email: str | None = None
 - issued_by_phone: str | None = None
 - issued_by_web: str | None = None
 - logo_id: int | None = None
 - mark_sent: int | None = None
 - mark_sent_message: str | None = None
 - mark_sent_subject: str | None = None
 - name: str | None = None
 - order_no: str | None = None
 - parent_id: int | None = None
 - payment_type: str | None = None
 - proforma_id: str | None = None
 - rounding: str | None = None
 - sequence_id: int | None = None
 - specific: str | None = None
 - tax_document: int | None = None
 - to_dict() dict
- Converts the Record object to a dictionary for JSON serialization. 
 - type: str | None = None
 - variable: str | None = None
 - vat_transfer: int | None = None
 
- class superfaktura.invoice.InvoiceRespModel(error: int, error_message: str, invoice_id: int | None = None, invoice_token: str | None = None)
- Bases: - object- This dataclass represents the response model for an invoice in the SuperFaktura API. - - error
- The error code. - Type:
- int 
 
 - - error_message
- The error message. - Type:
- str 
 
 - - invoice_id
- The ID of the invoice. - Type:
- Optional[int] 
 
 - - invoice_token
- The token of the invoice. - Type:
- Optional[str] 
 
 - error: int
 - error_message: str
 - invoice_id: int | None = None
 - invoice_token: str | None = None
 
- class superfaktura.invoice.InvoiceSettings(language: str | None = None, bysquare: bool | None = None, callback_payment: str | None = None, online_payment: bool | None = None, payment_info: bool | None = None, paypal: bool | None = None, show_prices: bool | None = None, signature: bool | None = None, summary_bg_color: str | None = None)
- Bases: - object- This dataclass represents the settings for an invoice in the SuperFaktura API. - as_dict() dict
- Returns a dictionary representation of the InvoiceSettings. 
 - bysquare: bool | None = None
 - callback_payment: str | None = None
 - language: str | None = None
 - online_payment: bool | None = None
 - payment_info: bool | None = None
 - paypal: bool | None = None
 - show_prices: bool | None = None
 - signature: bool | None = None
 - summary_bg_color: str | None = None