Invoicing

There is a built in support for creating invoices. This functionality brings powerful features like:
  • invoices are linked to orders,
  • invoices can have different shipping info,
  • invoices can be marked as “requiring shipment”
  • invoices can be previewed as HTML or PDF

Changing values of VAT tax and PLANS_INVOICE_ISSUER in a living system

Your system can be running for a while. You can have a multiple orders and you could have issued a multiple invoices already. There can be a situation that you need to change after a while a tax or your company. This can be easily done by changing those data in django settings. This will not affect any already created payment, order or invoice. System is designed in such way, that those information are duplicated and stored within proper object in the moment of those object creation.

After changing those settings every new order, payment, invoice will use those new values.

Warning

Remember that orders can be payed in some time window (e.g. 14 days). This mean that even if you change VAT tax rate, all your already created orders but not yet paid will have old tax. If this is what you don’t want you need to cancel those orders manually and remember to contact your client that theirs orders were cancelled!

This however is not a case with PLANS_INVOICE_ISSUER change, because those data are taken in the same moment of issuing invoice. Even an old order will use new PLANS_INVOICE_ISSUER when invoicing a new payment.

Billing data

First of all you should provide a way to input a billing data by the customer. Billing data are stored as model BillingInfo.

class plans.models.BillingInfo(*args, **kwargs)[source]

Stores customer billing data needed to issue an invoice

There are four class-based views to manage deleting and adding billing data:

class plans.views.BillingInfoRedirectView(**kwargs)[source]

Checks if billing data for user exists and redirects to create or update view.

class plans.views.BillingInfoCreateView(**kwargs)[source]

Creates billing data for user

class plans.views.BillingInfoUpdateView(**kwargs)[source]

Updates billing data for user

class plans.views.BillingInfoDeleteView(**kwargs)[source]

Deletes billing data for user

Described views are pointed by following urls name patterns:
  • billing_info,
  • billing_info_create,
  • billing_info_update,
  • billing_info_delete.
Described views require creating following templates:
  • billing_info,
  • plans/billing_info_create.html,
  • plans/billing_info_update.html,
  • plans/billing_info_delete.html.

Basically you need only to manage {{ form }} displaying and sending within these templates.

Invoice model class

class plans.models.Invoice(*args, **kwargs)[source]

Single invoice document.

class NUMBERING[source]

Used as a choices for settings.PLANS_INVOICE_COUNTER_RESET

Invoice.copy_from_order(order)[source]

Filling orders details likes totals, taxes, etc and linking provided Order object with an invoice

Parameters:order (Order) – Order object
Invoice.get_full_number()[source]

Generates on the fly invoice full number from template provided by settings.PLANS_INVOICE_NUMBER_FORMAT. Invoice object is provided as invoice variable to the template, therefore all object fields can be used to generate full number format.

Warning

This is only used to prepopulate full_number field on saving new invoice. To get invoice full number always use full_number field.

Returns:string (generated full number)
Invoice.set_buyer_invoice_data(billing_info)[source]

Fill buyer invoice billing and shipping data by copy them from provided user’s BillingInfo object.

Parameters:billing_info (BillingInfo) – BillingInfo object
Invoice.set_issuer_invoice_data()[source]

Fills models object with issuer data copied from settings.PLANS_INVOICE_ISSUER

Raise:ImproperlyConfigured