custom fields in invoice template

805 views
Skip to first unread message

mich...@wush.net

unread,
Feb 27, 2015, 1:28:42 AM2/27/15
to killbill...@googlegroups.com
What is the best way to include custom fields in the invoices? e.g. if we store a system username as a custom field associated with a subscription and want that to show up on the invoice line items.

Pierre-Alexandre Meyer

unread,
Feb 27, 2015, 10:33:07 AM2/27/15
to Michael Ching, killbill...@googlegroups.com
On Fri, Feb 27, 2015 at 1:28 AM, <mich...@wush.net> wrote:
What is the best way to include custom fields in the invoices?  e.g. if we store a system username as a custom field associated with a subscription and want that to show up on the invoice line items.


If so, currently custom fields are not accessible (only the account and invoice objects are). These could be exposed by modifying the default generator though (see https://github.com/killbill/killbill/blob/master/invoice/src/main/java/org/killbill/billing/invoice/template/HtmlInvoiceGenerator.java).

--
Pierre

mich...@wush.net

unread,
Feb 27, 2015, 6:28:54 PM2/27/15
to killbill...@googlegroups.com, mich...@wush.net
> Are you using mustache templates (similar to https://github.com/killbill/killbill/blob/master/util/src/main/resources/org/killbill/billing/util/email/templates/HtmlInvoiceTemplate.mustache)?
>
>
> If so, currently custom fields are not accessible (only the account and invoice objects are). These could be exposed by modifying the default generator though (see https://github.com/killbill/killbill/blob/master/invoice/src/main/java/org/killbill/billing/invoice/template/HtmlInvoiceGenerator.java).

Yes, this is the method we were currently using. Is there another that is commonly used?

We initially implemented a Ruby plugin that returned a rendered view of the invoice. Using the API calls, we could easily pull all of the required data. The problem with this method is that everything internal such as the notifications and kaui would not be using this copy.

Pierre-Alexandre Meyer

unread,
Feb 27, 2015, 7:26:23 PM2/27/15
to Michael Ching, killbill...@googlegroups.com
On Fri, Feb 27, 2015 at 6:28 PM, <mich...@wush.net> wrote:
Yes, this is the method we were currently using.  Is there another that is commonly used?

Nope, that's the recommended way. Most often, the account information (company, address, etc.) and invoice line items are just what's required. We could expose more information however. I've created https://github.com/killbill/killbill/issues/284 for tracking.

We initially implemented a Ruby plugin that returned a rendered view of the invoice.  Using the API calls, we could easily pull all of the required data.  The problem with this method is that everything internal such as the notifications and kaui would not be using this copy.

Why do you need access to the notifications?

Regarding Kaui, because it's a mountable engine, you could customize the behavior in your own application (and call your custom plugin endpoint to render the invoice).

--
Pierre

mich...@wush.net

unread,
Feb 27, 2015, 8:18:02 PM2/27/15
to killbill...@googlegroups.com, mich...@wush.net
> Nope, that's the recommended way. Most often, the account information (company, address, etc.) and invoice line items are just what's required. We could expose more information however. I've created https://github.com/killbill/killbill/issues/284 for tracking.

Thank you, if we end up going down this route, we will update the ticket with a link to our code.

> We initially implemented a Ruby plugin that returned a rendered view of the invoice.  Using the API calls, we could easily pull all of the required data.  The problem with this method is that everything internal such as the notifications and kaui would not be using this copy.
>
>
> Why do you need access to the notifications?

Was referring to the built-in email notifications at https://github.com/killbill/killbill/blob/master/invoice/src/main/java/org/killbill/billing/invoice/notification/EmailInvoiceNotifier.java

It sounds like we either want to:
a) update HtmlInvoiceGenerator to provide the custom fields
or
b) expose an http endpoint that rendered the html invoice in a ruby plugin, then write a notification plugin to handle sending the emails ourselves

Pierre-Alexandre Meyer

unread,
Feb 27, 2015, 8:25:51 PM2/27/15
to Michael Ching, killbill...@googlegroups.com
Oh, got it.
 
It sounds like we either want to:
a) update HtmlInvoiceGenerator to provide the custom fields
or
b) expose an http endpoint that rendered the html invoice in a ruby plugin, then write a notification plugin to handle sending the emails ourselves

Yes. If you go with a), feel free to reach out if you need help.

--
Pierre

Михаил Можжерин

unread,
Aug 4, 2016, 9:02:03 AM8/4/16
to Kill Bill users mailing-list, mich...@wush.net
пятница, 27 февраля 2015 г., 9:28:42 UTC+3 пользователь mich...@wush.net написал:
> What is the best way to include custom fields in the invoices? e.g. if we store a system username as a custom field associated with a subscription and want that to show up on the invoice line items.

Hi! This problem is also actual for me. I need to get access to tax items and invoice items separately. I mean, i wanna print block with products, then total price, and after that a block with taxes

Pierre-Alexandre Meyer

unread,
Aug 4, 2016, 11:17:13 AM8/4/16
to Михаил Можжерин, Kill Bill users mailing-list
Hi Михаил,

All invoice items, including tax items, are already available, see: http://docs.killbill.io/0.16/internationalization.html#_invoice_templates.

The ability to display custom fields is tracked by https://github.com/killbill/killbill/issues/284 (it's not on our immediate roadmap, but the task shouldn't be too difficult if you want to give it a try).


--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-users+unsubscribe@googlegroups.com.
To post to this group, send email to killbilling-users@googlegroups.com.
Visit this group at https://groups.google.com/group/killbilling-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/killbilling-users/0d329fc6-7274-4d10-855b-18b2de157111%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pierre

Михаил Можжерин

unread,
Aug 4, 2016, 11:34:08 AM8/4/16
to Kill Bill users mailing-list, mich...@wush.net
Sorry, may be i'm not very expirienced, but how i undestrand, at the moment there is no possibility to separate invoice item and tax item in HTMLInvoiceTemplate.mustache, or i'm wrong?

Thanks for support...


пятница, 27 февраля 2015 г., 9:28:42 UTC+3 пользователь mich...@wush.net написал:
What is the best way to include custom fields in the invoices?  e.g. if we store a system username as a custom field associated with a subscription and want that to show up on the invoice line items.

Pierre-Alexandre Meyer

unread,
Aug 4, 2016, 11:42:26 AM8/4/16
to Михаил Можжерин, Kill Bill users mailing-list
Tax items are regular invoice items, with type TAX (https://github.com/killbill/killbill-api/blob/master/src/main/java/org/killbill/billing/invoice/api/InvoiceItemType.java#L40).

When you iterate through the items in your template (see the variable invoice.invoiceItems in the example here: http://docs.killbill.io/0.16/internationalization.html#_invoice_templates), you have access to the invoice item type. You could assign a different CSS class for instance to display these differently.

If you need even more flexibility, you could write custom code to format these invoices in a plugin (similar to what the notification plugin is doing: https://github.com/killbill/killbill-email-notifications-plugin).

--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-users+unsubscribe@googlegroups.com.
To post to this group, send email to killbilling-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Pierre

ma...@solarnetwork.net

unread,
Sep 16, 2017, 11:32:32 PM9/16/17
to Kill Bill users mailing-list
This is a reply to an old thread, but it was about something I was looking to accomplish too: display tax items separately from non-tax invoice items, i.e. not in the same area of the HTML output as the invoice items. Given Mustache templates can't so any actual logic, however, I wasn't able to use CSS classes to tweak the layout to my needs.

Rather than write a whole plugin to generate the email, I found I could augment the attributes available to the template by replacing the built-in InvoiceFormatter with a custom one, by configuring this property:

org.killbill.template.invoiceFormatterFactoryClass = <custom class>

I created a tiny project that extends the built-in InvoiceFormatter with some additional attributes like nonTaxInvoiceItems which simply filters out non-tax items from the invoiceItems list.

That code is available here:

https://github.com/SolarNetwork/killbill-invoice-formatter

-- m@

stephane brossier

unread,
Sep 18, 2017, 4:14:26 PM9/18/17
to Matt Magoffin, Kill Bill users mailing-list
Good job! 🙌

--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-users+unsubscribe@googlegroups.com.
To post to this group, send email to killbilling-users@googlegroups.com.
Visit this group at https://groups.google.com/group/killbilling-users.
Reply all
Reply to author
Forward
0 new messages