Jump to content

Option To Add Attachment (Invoice Specification) To Invoice


Max

Recommended Posts

Would be nice if it was possible to bundle a .pdf attachment with an invoice.

And have the attachment sent to the customer whenever the invoice is e-mailed, have it printed when using paper invoicing and allow the user to view it in the clientarea.

 

Typical use case would be invoices created manually for custom web development jobs.

Attaching a detailed hour specification listing start/stop times generated by a time tracking app to a normal Blesta invoice for XX hours development at $ YY/hour.

Link to comment
Share on other sites

With a custom invoice template and a plugin, this is definitely possible. Though you will probably need pdftk so your invoice template can merge the documents together.

In some cases you may not need anything more than a custom invoice template, which is able to fetch information regarding a specific service and include that data on the invoice template.

Link to comment
Share on other sites

  • 2 weeks later...

With a custom invoice template and a plugin, this is definitely possible. Though you will probably need pdftk so your invoice template can merge the documents together.

In some cases you may not need anything more than a custom invoice template, which is able to fetch information regarding a specific service and include that data on the invoice template.

 

Problem with changing core files like the invoice template myself is that it complicates things when upgrading.

Was wondering if it would be possible to get something a little more generic in Blesta itself instead, that could be used by various modules and external applications using the Blesta API to create an invoice with additional extra pages.

 

Can imagine that my original request for .pdf attachments might be too complicated, if it generates dependencies on external software like pdftk.

But perhaps something more basic.

I recall tcpdf that you are using for the invoices also has a writeHTML() method that can transform simple HTML (with tables and images) to a pdf page.

Perhaps that would be sufficient to achieve this.

 

 

E.g. external application could specify the HTML content when creating the invoice.

$api = new BlestaApi($url, $user, $key);
 
$data = array(
    'vars' => array(
        'client_id' => 1,
        'date_billed' => date("c"),
        'date_due' => date("c"),
        'currency' => "USD",
        'lines' => array(
            array(
                'description' => "Development hours",
                'amount' => "22"
            )
        ),
        'delivery' => array("email"),
        'specification' => '<h1>Hour specification</h1> <table> ...HTML table code with start/stop times... </table>'
    )
);
$response = $api->post("invoices", "add", $data);

And Blesta could stick that it in the database, and add a few lines to the invoice generation code, among the lines of this:

    /**
     * Generates one or more invoices for a single document
     *
     * @param array $invoice_data An numerically indexed array of stdClass objects each representing an invoice
     */
    public function makeDocument($invoice_data) {
        $num_invoices = count($invoice_data);
        
        // Loop through all of the given invoices
        for ($i=0; $i<$num_invoices; $i++) {
            // Set the invoice data for this invoice
            $this->invoice = $invoice_data[$i];
            
            // Set the invoice data for this PDF
            $this->pdf->invoice = $this->invoice;
            
            // Start a new page group for each individual invoice
            $this->pdf->startPageGroup();
            
            // Add a new page so that each group starts on its own page
            $this->pdf->AddPage();

            // Draw all line items for this invoice
            $this->pdf->drawInvoice();

            // Add the invoice specification if present
            if ( !empty($this->invoice->specification) )  {
                 $this->pdf->AddPage();
                 $this->pdf->writeHTML($this->invoice->specification);
            }
        }
    }
Link to comment
Share on other sites

  • 3 months later...

This 
"Attaching a detailed hour specification listing start/stop times generated by a time tracking app to a normal Blesta invoice for XX hours development at $ YY/hour."

Would be awesome. 

I saw this 
http://www.blesta.com/forums/index.php?/topic/2692-free-time-tracking-for-freelancers-plugin/?hl=time+tracking but I am not sure that this is the complete solution as its reliant on pushes to GitLab. 

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
Reply to this topic...

×   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...