Invoice¶
-
class
moco_wrapper.models.
Invoice
(moco)¶ Model for handling invoices.
-
create
(customer_id: int, recipient_address: str, created_date: datetime.date, due_date: datetime.date, service_period_from: datetime.date, service_period_to: datetime.date, title: str, tax: float, currency: str, items: list, status: moco_wrapper.models.invoice.InvoiceStatus = <InvoiceStatus.CREATED: 'created'>, change_address: moco_wrapper.models.invoice.InvoiceChangeAddress = <InvoiceChangeAddress.INVOICE: 'invoice'>, salutation: str = None, footer: str = None, discount: float = None, cash_discount: float = None, cash_discount_days: int = None, project_id: int = None, tags: list = [], custom_properties: dict = None)¶ Creates a new invoice.
Parameters: - customer_id (int) – Id of the customer/company
- recipient_address (str) – Customers address
- created_date (datetime.date, str) – Creation date of the invoice
- due_date (datetime.date, str) – Date the invoice is due
- service_period_from (datetime.date, str) – Service period start date
- service_period_to (datetime.date, str) – Service period end date
- title (str) – Title of the invoice
- tax (float) – Tax percent (between 0.0 and 100.0)
- currency (str) – Currency code (e.g. EUR)
- items (list) – Invoice items
- status (
InvoiceStatus
, str) – State of the invoice (defaultInvoiceStatus.CREATED
) - change_address (
InvoiceChangeAddress
, str) – Address propagation (defaultInvoiceChangeAddress.INVOICE
) - salutation (str) – Salutation text (default
None
) - footer (str) – Footer text (default
None
) - discount (float) – Discount in percent (between 0.0 and 100.0) (default
None
) - cash_discount (float) – Cash discount in percent (between 0.0 and 100.0) (default
None
) - cash_discount_days (float) – How many days is the cash discount valid (ex. 4) (default
None
) - project_id (int) – Id of the project the invoice belongs to (default
None
) - tags (list) – List of tags (default
[]
) - custom_properties (dict) – Dict of custom properties (default
None
)
Returns: The created invoice
Return type: Note
Note that if you create an invoice with a project, that project must also belong to the customer the invoice was created for.
-
static
endpoints
() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]¶ Returns all endpoints associated with the model
Returns: List of Endpoint objects Return type: moco_wrapper.util.endpoint.Endpoint
-
get
(invoice_id: int)¶ Retrieve a single invoice.
Parameters: invoice_id (int) – Invoice id Returns: Single invoice object Return type: moco_wrapper.util.response.ObjectResponse
-
getlist
(status: moco_wrapper.models.invoice.InvoiceStatus = None, date_from: datetime.date = None, date_to: datetime.date = None, tags: list = None, identifier: str = None, term: str = None, company_id: int = None, project_id: int = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)¶ Retrieve a list of invoices.
Parameters: - status (
InvoiceStatus
, str) – State of the invoice (defaultNone
) - date_from (datetime.date, str) – Starting date (default
None
) - date_to (datetime.date, str) – End date (default
None
) - tags (list) – List of tags (default
None
) - identifier (str) – Identifier string (e.g. R1903-003) (default
None
) - term (str) – Wildcard search term (default
None
) - company_id (int) – Company id of the invoice (default
None
) - project_id (int) – Project id of the invoice (default
None
) - sort_by (str) – Field to sort results by (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default
1
)
Returns: List of invoice objects
Return type: - status (
-
locked
(status: moco_wrapper.models.invoice.InvoiceStatus = None, date_from: datetime.date = None, date_to: datetime.date = None, identifier: str = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)¶ Retrieve a list of locked invoices.
Parameters: - status (
InvoiceStatus
, str) – State of the invoice (defaultNone
) - date_from (datetime.date, str) – Start date (default
None
) - date_to (datetime.date, str) – End date (default
None
) - identifier (str) – Identifier string (ex. R1903-003) (default
None
) - sort_by (str) – Field to sort results by (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default
1
)
Returns: List of invoice objects
Return type: - status (
-
pdf
(invoice_id: int)¶ Retrieve the invoice document as pdf.
Parameters: invoice_id (int) – Invoice id Returns: Invoice pdf Return type: moco_wrapper.util.response.FileResponse
-
send_email
(invoice_id: int, emails_to: str, subject: str, text: str, emails_cc: str = None, emails_bcc: str = None)¶ Send an invoice by mail
Parameters: - invoice_id (int) – Id of the invoice to send
- emails_to (str, list) – Target email address (or a list of multiple email addresses)
- subject (str) – Email subject
- text (str) – Email text
- emails_cc (str, list) – Email address for cc (or a list of multiple email addresses) (default
None
) - emails_bcc (str, list) – Email address for bcc (or a list of multiple email addresses) (default
None
)
Returns: Object containing the details of the sent mail
Return type: Note
If you want to send an email to the default recipient configured in the project or customer, set
emails_to
andemails_cc
ToNone
.
-
timesheet_activities
(invoice_id: int)¶ Retrieve all activities that are associated with the given invoice
Note
Invoices that have timesheets cannot be created over the api and must be created manually by billing unbilled tasks.
Parameters: invoice_id (int) – Invoice id Returns: List of activities Return type: moco_wrapper.util.response.ListResponse
-
timesheet_pdf
(invoice_id: int)¶ Retrieve the invoice timesheet document as pdf.
Note
Invoices that have timesheets cannot be created over the api and must be created manually by billing unbilled tasks.
Parameters: invoice_id (int) – Invoice id Returns: Invoice timesheet as pdf Return type: moco_wrapper.util.response.FileResponse
-
update_status
(invoice_id: int, status: moco_wrapper.models.invoice.InvoiceStatus)¶ Updates the state of an invoices.
Parameters: - invoice_id (int) – Invoice id
- status (
InvoiceStatus
, str) – New state of the invoice
Returns: Empty response on success
Return type:
-
-
class
moco_wrapper.models.invoice.
InvoiceStatus
¶ Enumeration for allowed values that can be supplied for the
status
argument ofInvoice.getlist()
,Invoice.update_status()
andInvoice.create()
.Example usage:
from moco_wrapper.models.invoice import InvoiceStatus from moco_wrapper import Moco m = Moco() new_invoice = m.Invoice.create( .. status = InvoiceStatus.DRAFT )
-
CREATED
= 'created'¶
-
DRAFT
= 'draft'¶
-
IGNORED
= 'ignored'¶ Warning
Do not use
IGNORED
for creating invoices, only updating and filtering.
-
OVERDUE
= 'overdue'¶
-
PAID
= 'paid'¶
-
PARTIALLY_PAID
= 'partially_paid'¶
-
SENT
= 'sent'¶
-
-
class
moco_wrapper.models.invoice.
InvoiceChangeAddress
¶ Enumeration for allowed values that can be supplied for
change_address
argument ofInvoice.create()
.from moco_wrapper.models.invoice import InvoiceChangeAddress from moco_wrapper import Moco m = Moco() new_invoice = m.Invoice.create( .. change_address = InvoiceChangeAddress.PROJECT )
-
CUSTOMER
= 'customer'¶
-
INVOICE
= 'invoice'¶
-
PROJECT
= 'project'¶
-