Jump to content
  • 0

Invoice - How To Create Extension


dait

Question

I've been discussing this topic a little bit with Paul over support tickets. The thing is that we need invoices to be completely different from what Blesta is capable to generate right now. We are in EU and the regulations here are quite extreme, the requirements for invoices are insane, but there is nothing we can do about it. So, we have to completely change our invoices that are generated in Blesta.

 

How do we do that? I would like to ask you for a help with following topics and please assume that we know nothing about Blesta and we have no experience with creating any kind of extensions for it:

 

1) Where do we start? What do we want? I think we want some kind of extension (but which one?).

 

2) What should we read (which part of the documentation)? Which functions are related to creating invoices.

 

3) How do we connect our extension to Blesta - i.e. how do we replace the current invoicing system with the new one?

 

I decided to go this way because requesting such a feature from the devs would be very demanding. Understanding what is needed in our country on invoices is hard and explaining that would take so much time that I think we will faster create such an extension ourselves. But this holds only if we receive good support here. We need to understand the process of creating new Blesta extensions from the very beginning. Kindly asking for as much information as possible on this topic. I expect to be asking more question during the process. Thanks!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

I've been discussing this topic a little bit with Paul over support tickets. The thing is that we need invoices to be completely different from what Blesta is capable to generate right now. We are in EU and the regulations here are quite extreme, the requirements for invoices are insane, but there is nothing we can do about it. So, we have to completely change our invoices that are generated in Blesta.

 

How do we do that? I would like to ask you for a help with following topics and please assume that we know nothing about Blesta and we have no experience with creating any kind of extensions for it:

 

1) Where do we start? What do we want? I think we want some kind of extension (but which one?).

 

copy and rename /components/invoice_templates/default_invoice/ to "custom_invoice" or whatever you want to call it, but here I'll assume "custom_invoice".

  1. Rename /components/invoice_templates/custom_invoice/default_invoice.php to custom_invoice.php.
  2. Rename /components/invoice_templates/custom_invoice/default_invoice_pdf.php to custom_invoice_pdf.php
  3. Rename /components/invoice_templates/custom_invoice/language/en_us/default_invoice.php to custom_invoice.php
  4. Open /components/invoice_templates/custom_invoice/custom_invoice.php and string replace "DefaultInvoice" with "CustomInvoice"
  5. Open /component/invoice_templates/custom_invoice/custom_invoice_pdf.php and string replace "DefaultInvoice" with "CustomInvoice"
  6. Open /components/invoice_templates/custom_invoice/language/en_us/custom_invoice.php and string replace "DefaultInvoice." with "CustomInvoice."

 

2) What should we read (which part of the documentation)? Which functions are related to creating invoices.

 

Unfortunately documentation is not currently available for Invoice Templates. Basically what you'll want to do is focus on making changes in /components/invoice_templates/custom_invoice/custom_invoice_pdf.php. It should be pretty self-explanatory.

 

3) How do we connect our extension to Blesta - i.e. how do we replace the current invoicing system with the new one?

 

Once you've copied/renamed as I've explained above Blesta will detect your custom invoice template.

 

I decided to go this way because requesting such a feature from the devs would be very demanding. Understanding what is needed in our country on invoices is hard and explaining that would take so much time that I think we will faster create such an extension ourselves. But this holds only if we receive good support here. We need to understand the process of creating new Blesta extensions from the very beginning. Kindly asking for as much information as possible on this topic. I expect to be asking more question during the process. Thanks!

 

Yes, please let us know what questions you have as it will help in creating/improving the documentation on the topic.

Link to comment
Share on other sites

  • 0

OK, I have done all 6 steps.

 

Note #1: custom_invoice.php now contains things like

 

// Use the Default Invoice PDF renderer for generating PDFs
Loader::load(dirname(__FILE__) . DS . "default_invoice_pdf.php");

..

        // Load language for this template
        Language::loadLang("default_invoice", null, dirname(__FILE__) . DS . "language" . DS);


should this be replaced too or not? I.e. string replace "default_invoice" -> "custom_invoice" in all files?

 

 

I think so because otherwise the files are not loaded properly. So please, just confirm.

Link to comment
Share on other sites

  • 0

Note #2: in language\en_us\custom_invoice.php

 

 

$lang['CustomInvoice.name'] = "Default";

 

This should be changed to something other than "Default", let's say "OurInvoices".

 

And then Blesta will offer you "OurInvoices" under Invoice Templates field in Settings > Company > Billing/Payment > Invoice Customization.
 

You have to select that new option and click UPDATE SETTINGS.

Link to comment
Share on other sites

  • 0

OK, I have done all 6 steps.

 

Note #1: custom_invoice.php now contains things like

 

// Use the Default Invoice PDF renderer for generating PDFs
Loader::load(dirname(__FILE__) . DS . "default_invoice_pdf.php");

..

        // Load language for this template
        Language::loadLang("default_invoice", null, dirname(__FILE__) . DS . "language" . DS);


should this be replaced too or not? I.e. string replace "default_invoice" -> "custom_invoice" in all files?

 

 

I think so because otherwise the files are not loaded properly. So please, just confirm.

 

 

Yes, replace those as well.

Link to comment
Share on other sites

  • 0

Note #2: in language\en_us\custom_invoice.php

 

 

$lang['CustomInvoice.name'] = "Default";

 

This should be changed to something other than "Default", let's say "OurInvoices".

 

And then Blesta will offer you "OurInvoices" under Invoice Templates field in Settings > Company > Billing/Payment > Invoice Customization.

 

You have to select that new option and click UPDATE SETTINGS.

 

Yes, that's correct.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...