# 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=superfaktura.invoice.InvoiceModel(

  >   type=superfaktura.invoice.InvoiceType.PROFORMA, name=”Invoice 3”, due=superfaktura.invoice.Date(“2025-02-01”), invoice_currency=superfaktura.invoice.Currencies.CZK, header_comment=”We invoice you for services”, bank_accounts=[bank.default().as_dict()],

  > ), items=[

  > > superfaktura.invoice.InvoiceItem(name=”Services”, unit_price=100, quantity=1,

  > >   unit=”ks”, tax=21),

  > > superfaktura.invoice.InvoiceItem(name=”SIM card”, unit_price=50, quantity=1,

  > >   tax=21, unit=”ks”),

  > > superfaktura.invoice.InvoiceItem(

  > >   name=”SIM card 2”, unit_price=75, quantity=1, tax=21, unit=”ks”

  > > ),

  > ], contact=superfaktura.client_contacts.ClientContactModel(

  > > name=”Richard Kubíček”, email=”kubicekr@eledio.com”, phone=”+420 123 456 789”, address=”Jaroslava Foglara 861/1”, ico=”123”, update=True, country_id=57,

  > ),

  )

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=InvoiceModel(

    >   type=InvoiceType.PROFORMA, name=”Invoice 3”, due=Date(“2025-02-01”), invoice_currency=Currencies.CZK, header_comment=”We invoice you for services”, bank_accounts=[bank.default().as_dict()],

    > ), items=[

    > > InvoiceItem(name=”Services”, unit_price=100, quantity=1, unit=”ks”, tax=21), InvoiceItem(name=”SIM card”, unit_price=50, quantity=1, tax=21, unit=”ks”), InvoiceItem(

    > > > name=”SIM card 2”, unit_price=75, quantity=1, tax=21, unit=”ks”

    > > ),

    > ], contact=ClientContactModel(

    > > name=”Richard Kubíček”, email=”kubicekr@eledio.com”, phone=”+420 123 456 789”, address=”Jaroslava Foglara 861/1”, ico=”123”, update=True, country_id=57,

    > ),

    )

  add(invoice_model: InvoiceModel, items: List[InvoiceItem], contact: ClientContactModel)

    Creates a new invoice.

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
  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
  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.InvoiceType

  Bases: `object`

  ” Invoice Type Enumeration.

  This enumeration represents the different types of invoices that can be created.

  Usage:

    invoice_type = InvoiceType.PROFORMA

  INVOICE = 'regular'
  PROFORMA = 'proforma'