> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with Invoices

An invoice is used to notify customers of their closing balance for the current billing cycle. You can define the number of days before a Billing Cycle closes for an Invoice to be issued.

An Invoice typically lists an opening balance, previously submitted invoices, payments, credit memos, debit memos, and an ending balance for a given billing cycle.

Subscribe automatically generates email messages in parallel with Invoice processing, to which a rendered Invoice template may be attached. You may create your own, custom template, or use one of the default templates provided. In either case, Subscribe saves an image of each Invoice sent to a customer, as a PDF, which may be retrieved at a later date for bookkeeping or record keeping purposes.

To generate Invoice emails from Subscribe:

* Supply an email template to Vindicia Client Technical Services. This template will be used to generate email notifications to your customers, and must be supplied or no invoice or dunning notifications will be mailed to your customers.
* Supply an invoice template to Vindicia Client Services. Vindicia provides a Default Invoice Template, which may be used in place of your own, customized template.
* Supply a dunning template to Vindicia. If no template is supplied, dunning notices will not be sent to your customers.

**Note:** If you supply a dunning template you must also provide an invoice template.

Work with Vindicia Client Technical Services to enable Invoice and Dunning Notice generation, and to define the timing for these notifications.

## Dunning Notices

Dunning is an extension of Invoicing, and is the process of systematically reminding a customer that payment is overdue, and informing them of the payment process. Dunning notices typically progress from reminders of overdue payment, to notice of imminent account closure. The last dunning notice usually informs the customer of account closure, and entitlement revocation.

Subscribe allows you to define the timing of each step in this process. By default, the first dunning/overdue notice is issued a week after the initial due date, to allow time for payments arriving on the due date to be processed and entered into the system. The sequence may be customized to change the timing, content, or inclusion of dunning notices.

(For all steps in this process, Subscribe recommends that you include appropriate links and phone numbers to contact your Customer Service department to arrange payment.)

As with all Subscribe customer notifications, you must supply Subscribe with an email template and a Dunning Notice template for these notices to be rendered and mailed.

**Note:** Dunning notice timing is set by Vindicia Client Technical Services. Please speak with your Vindicia representative to define these intervals for your company.

* **[Subscribe Invoicing Events](../topics/Working_with_Invoices#)**

* **[Creating Invoice Templates](../topics/Working_with_Invoices#)**

**Parent topic:**[Customer Notifications](../topics/ProgGuide_CustomerNotifications)

## Subscribe Invoicing Events

Subscribe provides several pre-defined invoice events, which will automatically generate an email notification to your customers. Emails will be sent to the email address specified on the `Account` on the `AutoBill`, with the subject line "Invoice `<invoice number>` dated `<date>,`" and your email address (if supplied) as the `From:` field.

**Note:** If you do not supply Subscribe with an email template, no invoices will be issued. An Invoice will be rendered, but it will not be mailed to your customer.

Work with Vindicia Client Services if you wish to alter the invoicing schedule or if you wish to send more than two dunning notices.

Subscribe can be configured to render and issue the following emails in relation to the Invoicing cycle:

| Notice / Event | Suggested Content |
| - | - |
| **Open Invoice** An `open` invoice may be generated a merchant-specified number of days before the end of every billing cycle. | An email message to the customer, with the invoice attached as a PDF, or inline as plain text or HTML (depending on the customer’s email preferences). |
| **Payment Due (1st dunning Notice)** An invoice becomes `Due` a merchant-defined number of days after the billing cycle closes. | A reminder that payment is now due. This may include notice of any interest charges or penalties will be added to the account. |
| **Overdue (2nd Dunning Notice)** An account becomes `Overdue` a merchant-defined number of days after the Due date. | A notice that payment is overdue, which may include any interest charges or penalties that have been added to the account. This notice often includes information on future action, including account closure and collection agency involvement. |
| **Parent topic:**[Working with Invoices](../topics/Working_with_Invoices#) | |

## Creating Invoice Templates

Invoice templates allow you to create custom Invoices. They may include custom text, like customer support information, marketing information, or custom graphics. Subscribe also provides a generic Invoice Template, if you do not wish to create your own.

If you create a customized template, create both a plain text, and an HTML version, to provide for customers' email preferences settings. You may use text and standard HTML markup in the template.

The tags used in Invoice Templates map directly to your Subscribe database, as described in [Creating\_Invoice\_Templat.md#table\_hwt\_gmr\_hlb](Creating_Invoice_Templat#table_hwt_gmr_hlb).

### Default Invoice Template

Subscribe supplies a default Invoice template in both plain text and HTML. This Template includes the most common Invoice components.

| \[% format\_amount=format(%10.2f);-%] | |
| - | - |
| \[% merchant %] \[% cust\_name %] \[%cust\_address %] Previous Balance | Invoice #: \[% invoice\_num %] Date: \[% invoice\_date %] \[% format\_amount(balance\_forward) %] |
| Payments: \[% FOR x IN payments %] \[% x.amount %] \[% x.date %] \[% END %] | \[% format\_amount %] |
| Total Payments: | \[% format\_amount(total\_payments %] |
| Balance: | \[% format\_amount(opening\_balance) %] |
| Current Charges: \[% FOR x IN charges %] \[% x.product %] \[% x.desc %] \[% x.quantity %] \[% x.total %] \[% END %] | \[% format\_amount %] |
| Total Current Charges: Credits: \[% FOR x IN credits %] \[% x.date %] \[% END %] | \[% format\_amount(total\_charges) %] \[% format\_amount %] |
| Total Credits: Tax: | \[% format\_amount(total\_credits) %] \[% format\_amount(tax) %] |
| Total Amount Due: Pay By: | \[% format\_amount(balance\_due) %] \[% payment\_due\_date %] |

### Invoice Template Tags

Tags are used to provide a place holder in the template where Subscribe data will be inserted when the Invoice is rendered. Subscribe Invoice templates support looping, to allow for multiple charges, credits, or payments.

The following tags may be used in an Invoice template:

**Note:** Because Subscribe allows for complex charge calculations, the charges tags are called out separately in the table.

**Note:** Arrays are shown in Vindicia Red in the following table.

| Subscribe Tag | Description |
| - | - |
| **Invoice Information** | |
| \[% date %] | Today’s date. |
| \[% merchant %] | Your merchant name as it is currently defined in Subscribe. **Note:** If this value is not as you expect, please work with your Vindicia Client Support contact to change it. |
| \[% invoice\_num %] | The auto-generated Invoice Number. This will be based on the Merchant AutoBill Identifier with a sequence number identifying the billing covered, for example: SUBMONTHLYAhd38-00000003. If you do not define Merchant AutoBill Identifiers for subscriptions, the VID will be used in its place. |
| \[% opening\_balance %] | The amount after payments have been subtracted from the balance forward. |
| \[% payment\_type %] | The payment type (MAP, CC, EDD, etc.) used to make payment of the balance due. |
| \[% balance\_forward %] | The balance carried forward from previous invoices. |
| \[% balance\_due %] | The balance due after all payments, credits, charges and taxes have been applied to the balance forward. |
| \[% transaction\_id %] | Unique identifier, generated by Subscribe for the Invoice. **Note:** This field will be populated only after a payment is made against the Invoice. |
| \[% invoice\_date %] | The date the invoice was created and sent. |
| \[% currency %] | The currency used for the transaction. |
| \[% payment\_due\_date %] | The date the invoice becomes due. |
| **Customer Information** | |
| \[% cust\_name %] | The customer’s name. |
| \[% cust\_email\_address %] | The customer’s email address. |
| \[% cust\_address %] | The customer’s address. A concatenation of all available customer address information. For example: 1820 Gateway St$\&#123;sep\&#125;Apt. A$\&#123;sep\&#125;Foster City, California 94403\$\&#123;sep\&#125;US |
| \[% cust\_address\_street1 %] | The customer’s street address (1st line). |
| \[% cust\_address\_street2 %] | The customer’s street address (2nd line). |
| \[% cust\_address\_street3 %] | The customer’s street address (3rd line). |
| \[% cust\_address\_city %] | The customer’s city. |
| \[% cust\_address\_district %] | The customer’s state. |
| \[% cust\_address\_postal\_code %] | The customer’s zip code. |
| \[% cust\_address\_city\_dist %] | The customer’s city, state, and zip code. For example: Foster City, California 94403 |
| **Payments** | |
| \[% total\_payments %] | Currency value of all the payments. |
| \[% payments %] | An array of payments applied to the AutoBill. \[% FOR x IN payments %] \[% x.type %] \[% x.date %] \[% x.amount %] \[% END %] |
| type | Used with the \[% payments %] tag to retrieve the type of payment used. |
| date | Used with the \[% payments %] tag to retrieve the date the payment was applied to the account. |
| amount | Used with the \[% payments %] tag to retrieve the payment amount. |
| **Credits** | |
| \[% total\_credits %] | Currency value total of all credits. |
| \[% credits %] | An array of credits applied to the AutoBill. \[% FOR y IN credits %] \[% y.credit\_date %] \[% y.credit\_amount %] \[% END %] |
| date | Used with the \[% credits %] tag to retrieve the date the credit was made to the account. |
| amount | Used with the \[% credits %] tag to retrieve the credit amount. |
| **Charges** | |
| \[% total\_charges %] | Currency value total of all charges. |
| \[% charges %] | An array of charges applied to the AutoBill. \[% FOR c IN charges %] \[% c.product %] \[% c.desc %] \[% c.price %] \[% c.quantity %] \[% c.total %] \[% c.rate\_plan\_id %] \[% c.rate\_plan\_description %] \[% c.included\_units %] \[% c.min\_fee %] \[% c.max\_fee %] \[% c.unit\_name\_singular %] \[% c.unit\_name\_plural %] \[% c.unit\_total\_amount %] \[% c.unit\_amount\_and\_name %] \[% c.rate\_plan\_tiers %] \[% c.rated\_unit\_events %] \[% END %] |
| product | Used with the \[% charges %] tag to retrieve the Product’s ID. |
| desc | Used with the \[% charges %] tag to retrieve the Product’s description. |
| price | Used with the \[% charges %] tag to retrieve the Product’s price. |
| quantity | Used with the \[% charges %] tag to retrieve the number of Products. |
| total | Used with the \[% charges %] tag to retrieve the total charge. |
| rate\_plan\_id | Your Rate Plan ID. |
| rate\_plan\_description | Your description for the Rate Plan. |
| included\_units | The number of Units included with the Rate Plan. |
| min\_fee | The minimum fee for the Rate Plan. |
| max\_fee | The maximum fee for the Rate Plan. |
| unit\_name\_singular | The singular version of the Unit name. |
| unit\_name\_plural | The plural version of the Unit name. |
| unit\_total\_amount | The total number of reported Units. |
| unit\_amount\_and\_name | The number and name of the reported Units. (Subscribe will automatically return the singular or plural name, dependent upon the reported number of Units.) |
| \[% rate\_plan\_tiers %] | An array of all the Tiers in the Rate Plan. \[% FOR t in c.rate\_plan\_tiers %] \[% t.tier\_name %] \[% t.tier\_begins\_at\_level %] \[% t.tier\_ends\_at\_level %] \[% t.tier\_rate\_price %] \[% t.tier\_rated\_units\_tier\_total %] \[% t.tier\_cost\_total %] \[% END %] |
| tier\_name | Used with the \[% rate\_plan\_tiers %] tag to retrieve the name of the Tier. |
| tier\_begins\_at\_level | Used with the \[% rate\_plan\_tiers %] tag to retrieve the beginsAtLevel for the Tier. |
| tier\_ends\_at\_level | Used with the \[% rate\_plan\_tiers %] tag to retrieve the endsAtLevel for the Tier. |
| tier\_rate\_price | Used with the \[% rate\_plan\_tiers %] tag to retrieve the ratePrice for the Tier. |
| tier\_rated\_units\_tier\_total | Used with the \[% rate\_plan\_tiers %] tag to retrieve the number of Rated Units reported for the Tier. |
| tier\_cost\_total | Used with the \[% rate\_plan\_tiers %] tag to retrieve the total charge for the Tier. |
| \[% rated\_unit\_events %] | An array of all (unbilled) Rated Unit Events applied to the AutoBill. \[% FOR e IN c.rated\_unit\_events %] \[% e.event\_date %] \[% e.received\_date %] \[% e.amount %] \[% e.unit\_name %] // singular or plural, based on # of units \[% e.description %] \[% e.rate\_plan\_id %] \[% e.rate\_plan\_description %] \[% e.product\_id %] \[% e.product\_description %] \[% END %] |
| event\_date | Used with the \[% rated\_unit\_events %] tag to retrieve the date the specified Event occurred, or the date the Event was reported to Subscribe. |
| received\_date | Used with the \[% rated\_unit\_events %] tag to retrieve the date the event was received. |
| amount | Used with the \[% rated\_unit\_events %] tag to retrieve the number of Rated Units included in the Event. |
| unit\_name | Used with the \[% rated\_unit\_events %] tag to retrieve the name for the Unit associated with the Event. Subscribe will automatically return the singular or plural version of the name, dependent upon the number of Units reported for the Event. |
| description | Used with the \[% rated\_unit\_events %] tag to retrieve the description for the Event. |
| rate\_plan\_id | Used with the \[% rated\_unit\_events %] tag to retrieve the Rate Plan ID for the Event. |
| rate\_plan\_description | Used with the \[% rated\_unit\_events %] tag to retrieve the description for the Rate Plan associated with the Event. |
| product\_id | Used with the \[% rated\_unit\_events %] tag to retrieve the Product ID associated with the Event. |
| product\_description | Used with the \[% rated\_unit\_events %] tag to retrieve the description for the Product associated with the Event. |
| **Taxes** | |
| \[% tax %] | The total of all taxes applied to the Invoice. |
| \[% taxes %] | An array of taxes applied to the AutoBill. \[% FOR t IN taxes %] \[% t.description %] \[% t.amount %] \[% END %] |
| description | Used with the \[% taxes %] tag to retrieve the description of the tax. |
| amount | Used with the \[% taxes %] tag to retrieve the amount of the tax. |
| tax\_exemption\_id | The Tax Exemption Code for the primary Sales Tax Exemption defined for this Account. The most common example is the customer VAT ID—also known as the VAT Registration Number or VAT Identification number (VATIN). |
| \[% cust\_address\_city\_dist\_country %] | The customer city, state, zip/postal code, and country. For example: Foster City, California, 94403 US. |
| **Parent topic:**[Working with Invoices](../topics/Working_with_Invoices#) | |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.