Main resources¶
InvoiceBase¶
- class invoicing.models.InvoiceBase(full_init=True, *args, **kwargs)¶
Base class for all quotations and invoices (either payable or receivable).
- add_revision(revision=None, *args, **kwargs)¶
Add a InvoiceRevision.
The InvoiceRevision can be created with defaults by passing arguments.
- delete(*args, **kwargs)¶
Some InvoiceBase can only be deleted according to some rules.
- duplicate_revision(issuer=None)¶
Duplicate a InvoiceRevision.
The default behavior to keep an history of all modifications on the Invoice.
- filename¶
Return a filename based on invoice base type and reference
- gen_pdf()¶
Process PDF generation based on InvoiceBaseReport
- get_pdf(issuer=None, language=None)¶
Return the cached PDF or generate and cache it.
- is_cancelable()¶
Determine if the InvoiceBase could be canceled. Always False in the base class.
- is_credit_note()¶
Always False in the base class.
- is_deletable()¶
Determine if the InvoiceBase could be deleted. Always False in the base class.
- is_down_payment_invoice()¶
Always False in the base class.
- is_invoice()¶
Always False in the base class.
- is_invoice_instance()¶
Always False in the base class.
- is_issuable()¶
Determine if the InvoiceBase could be sent. Always False in the base class.
- is_modifiable()¶
Determine if the InvoiceBase could be modified. Always True in the base class.
- is_quotation()¶
Always False in the base class.
- is_quotation_instance()¶
Always False in the base class.
- keywords¶
Genere a keywords list for the PDF headers.
- manage_amounts()¶
Set total and amount of the Quotation/Invoice.
Includes InvoiceItem‘s unit prices and taxes.
- classmethod post_client_changed_invoice_state(sender, document, previous_state, **kwargs)¶
Post client changed invoice state hook handler
- Fire invoice registration signal
- Add timeline and notification entries
- classmethod post_delete(sender, document, **kwargs)¶
Post delete hook handler
- Deletes related attachments, if exists
- De-index invoice based document from elasticsearch
- Removes timeline and notification entries
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
- Removes related TTL
- Index invoice based document in elasticsearch
- Add timeline and notification entries
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler On creation:
- Add issuer to subscribers list
- Add organization name to revision
- Manage total / amount
- reload(*args, **kwargs)¶
Reload the Invoice from the database.
Delete the existing cached attributes.
- revision(revision_id=None, get_pos=False)¶
Returns the appropriate InvoiceRevision.
If there is no revision_id supplied, returns the lastest revision.
- send_by_mail(subject, message, to=[], cc=[], bcc=[], issuer=None)¶
Send the InvoiceBase by e-mail.
- set_state(new_state, force=False, issuer=None)¶
Set a new state to the Quotation/Invoice.
Parameters: - new_state – a state among the (CreditNote).STATES
- force – do not check for possible states (for automatic state assignation)
- issuer – a VosaeUser object to be associated to the state modification
- sub_total¶
Do a sum of the InvoiceItem prices and cache it.
This does not contains taxes.
- taxes_amounts¶
Do a sum of the InvoiceItem taxes and cache it.
This does not contains InvoiceItem unit prices.
- class invoicing.api.resources.InvoiceBaseResource(api_name=None)¶
- do_export(request, serializer, export_objects)¶
Export
- full_hydrate(bundle)¶
InvoiceBase hydratation:
- Handle current revision immutable state if InvoiceBase is not modifiable
- Process some automatic affectation
- Add history entry
- generate_pdf(request, **kwargs)¶
Generate a PDF
- hydrate(bundle)¶
If the InvoiceBase is modifiable, a new revision is added, otherwise the current_revision is cloned from the saved obj preventing data alteration but still allowing related updates such as attachments or notes.
- mark_as_state(request, invoicebase_state, **kwargs)¶
Set state for an InvoiceBase.
- obj_delete(bundle, **kwargs)¶
Raises a BadRequest if the InvoiceBase is not in a deletable state
- prepend_urls()¶
Add urls for resources actions.
- send_by_mail(request, **kwargs)¶
Send an InvoiceBase by mail.
Quotation¶
- class invoicing.models.Quotation(full_init=True, *args, **kwargs)¶
Quotations specific class.
- genere_reference(customer_settings)¶
Genere a unique reference for an Quotation object.
Use the VosaeCustomer quotations numbering counter.
- is_deletable()¶
A Quotation is deletable if not linked to any Invoice or DownPaymentInvoice.
- make_down_payment(issuer, percentage, tax, date)¶
Creates a down payment invoice based on the current quotation
- make_invoice(issuer)¶
Creates an invoice based on the current quotation
- static manage_states()¶
An Invoice state can be modified by the time.
This method allows tasks scripts to update Invoices state on a regular basis.
- classmethod post_make_down_payment_invoice(sender, document, new_document, **kwargs)¶
Post make down payment invoice hook handler
- Add timeline and notification entries
- Add a statistic entry
- classmethod post_make_invoice(sender, document, new_document, **kwargs)¶
Post make invoice hook handler
- Add timeline and notification entries
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
If created, increments the appropriate VosaeCustomer quotations numbering counter.
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
- Set the type and reference
Invoice¶
- class invoicing.models.Invoice(full_init=True, *args, **kwargs)¶
Invoices specific class.
- cancel(issuer)¶
Cancel the Invoice with the creation of an associated CreditNote
- down_payments¶
Property returning a list of down payment invoices (retrieved from related quotation)
- filename¶
Return a filename based on invoice base type and reference
- genere_reference(customer_settings)¶
Genere a unique reference for an Invoice object.
Use the VosaeCustomer invoices numbering counter.
- is_cancelable()¶
True if the Invoice is in a cancelable state. When cancelable, a credit note could be created.
- manage_amounts()¶
Set total and amount of the Invoice.
Includes InvoiceItem‘s unit prices and taxes.
Invoice checks for related down-payments and substracts their individual amounts to its amount.
- static manage_states()¶
An Invoice state can be modified by the time.
This method allows tasks scripts to update Invoices state on a regular basis.
- classmethod post_cancel_invoice(sender, document, credit_note, **kwargs)¶
Post cancel invoice hook handler
- Update related quotation state, if invoice
- Add timeline and notification entries
- classmethod post_delete(sender, document, **kwargs)¶
Post delete hook handler
- Update related quotation to remove linked invoices references
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
- Manage payments and balance
- Manage reference counters
DownPaymentInvoice¶
- class invoicing.models.DownPaymentInvoice(*args, **kwargs)¶
Base class for all down payments invoices (either payable or receivable).
- is_down_payment_invoice()¶
True if the DownPaymentInvoice is a down-payment invoice.
- is_modifiable()¶
A DownPaymentInvoice is automatically generated and can’t be modified at any time.
- manage_amounts()¶
Set total and amount of the DownPaymentInvoice.
Includes InvoiceItem‘s unit prices and taxes.
DownPaymentInvoices don’t care about since it is fixed on creation. Only balance is calculated.
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
A DownPaymentInvoice must not save its item because of the translations.
- class invoicing.api.resources.DownPaymentInvoiceResource(api_name=None)¶
CreditNote¶
- class invoicing.models.CreditNote(*args, **kwargs)¶
Class for all credit notes (either payable or receivable).
- genere_reference(customer_settings)¶
Genere a unique reference for an CreditNote object.
Use the VosaeCustomer credit notes numbering counter.
- is_issuable()¶
Determine if the CreditNote could be sent. It is automatically generated and so could be sent at any time.
- is_modifiable()¶
A CreditNote is automatically generated and can’t be modified at any time.
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
If created, increments the appropriate VosaeCustomer quotations numbering counter.
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
If credit note is in its creation process, affects the base type and the reference
- class invoicing.api.resources.CreditNoteResource(api_name=None)¶
Item¶
- class invoicing.models.Item(*args, **values)¶
An item represents an invoicable product or service.
- classmethod post_delete(sender, document, **kwargs)¶
Post save hook handler
- De-index item from elasticsearch
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
- Index item in elasticsearch
- class invoicing.api.resources.ItemResource(api_name=None)¶
Payment¶
- class invoicing.models.Payment(*args, **values)¶
A payment, representing money flows within the company.
Amount can be negative (debit) or positive (credit).
- classmethod post_delete(sender, document, **kwargs)¶
Post delete hook handler
Removes payment from related document
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
- Associates payment to related document
- Creates a payment statistic entry
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
Validates payment amount
Currency¶
- class invoicing.models.Currency(*args, **values)¶
Currencies are globals: they do not belongs to VosaeCustomers.
- static convert(currency_from, currency_to, amount)¶
Convert a Currency to another. Based on the current rates.
- display_symbol¶
The display symbol associated to the currency (e.g. ‘€’, ‘$’, ‘£’).
The symbol attribute is in the iso4217 format (e.g. ‘EUR’, ‘USD’, ‘GBP’)
- from_currency(currency_from, amount)¶
Convert a Currency to another. Based on the current rates.
Parameters: - currency_from – iso4217 representation of the source currency
- amount – int/float/decimal value to be converted
- get_snapshot()¶
Return the snapshot associated to the currency.
- rate(symbol)¶
Return the rate associated to the specified symbol.
Parameters: symbol – iso4217 representation of the target currency
- class invoicing.api.resources.CurrencyResource(api_name=None)¶