Jump to content

Custom Client Fields On Invoice


PhatPixel

Recommended Posts

Anyone else find this to be a useful addition?

 

Personally, I like the idea of custom client fields being available to invoices. I can see many cases where these might need to be displayed on an invoice. I'm just not sure the Terms section is the best/only place for them.

 

The alternative would be a much more complex system, whereby invoices can be customized by drag-n-drop of elements, allowing custom client fields, and default fields to be placed visually. This scenario is much more involved, and less likely to happen soon, but it's certainly a possibility.

Link to comment
Share on other sites

  • 9 months later...

Has this feature been scheduled into a future release at this stage?  I would really like to add a CCF to the Terms section of the invoice.

 

Can you advise which file I would need to edit in order to perform a str_replace($search,$replace,$subject) to achieve this?  $search would be a curly brace placeholder such as {reference}.  $replace would be the CCF.  $subject would be the Terms field.

Link to comment
Share on other sites

I don't think a task exists for custom client fields on invoices.

 

You can update the invoice PDF directly under /components/invoice_delivery/default_invoice/default_invoice_pdf.php.

 

You would need to add the appropriate logic for fetching client custom fields and replacing content.

Link to comment
Share on other sites

For those that may be interested in doing this, here's the procedure I followed to insert a placeholder into the PDF invoice Terms field:

  • Duplicate the /components/invoice_templates/default_invoice folder and rename as appropriate (I'll refer to it as new_invoice in this example)
  • Rename all files within this new_invoice folder from default_invoice to new_invoice
  • Open /components/invoice_templates/new_invoice/new_invoice.php and replace all instances of default_invoice to new_invoice and also replace all instances of DefaultInvoice to NewInvoice (note that I had some problems with CamelCase here when I tired using more than Two Uppercase letters here such as BrandNewInvoice, etc.)
  • Open /components/invoice_templates/new_invoice/new_invoice_pdf.php and replace all instances of DefaultInvoice to NewInvoice
  • Open any language definition file file under /components/invoice_templates/new_invoice/language/ and replace all instances of DefaultInvoice to NewInvoice -- also be sure to give the invoice template a new name as assigned by variable $lang['NewInvoice.name']
  • Open /components/invoice_templates/new_invoice/new_invoice_pdf.php and add the following code to the top of the drawTerms() function:
private function drawTerms(){
  $cf_data = array();
  if( property_exists( $this->invoice->client, "id" ) ){
    Loader::loadModels( $this, array( "Clients" ) );
    $field_id = 1;
    $values = $this->Clients->getCustomFieldValues( $this->invoice->client->id );
    foreach( $values as $value ){
      if( $value->id == $field_id ){
        $cf_data = array(
          'name' => $value->name . ":",
          'space' => null,
          'value' => $value->value
        );
        break;
      }
    }
    unset( $values, $value );
  }
  $data = array(
    array( Language::_("NewInvoice.terms_heading", true ) ),
    array( str_replace( "{crn}", $cf_data['value'], $this->meta['terms'] ) )
  );

...

Some notes about the above code:

  • Replace the value assigned to $field_id with the appropriate ID number of the Custom Client Field
  • Replace NewInvoice with the CamelCase name of the invoice as appropriate
  • Replace {crn} at the end of the code with the placeholder of your choice (you could potentially use arrays to replace multiple placeholders, if required as well)
  • Go to Settings > Company > Billing/Payment > Invoice Customization > Invoice Template and change as necessary

This process can easily be adapted for placeholders in other parts of the invoice too.  Good luck, I hope this helps anyone else that wants to achieve something similar.

Link to comment
Share on other sites

  • 2 months later...

Hi Paul, Tyson and co.

 

I am here looking up custom fields per line invoice item. It's something I've had to do in the past for another client with Blesta, and it's now something I need for myself.

 

Scenario - setting up a business with a partner and we need to track different types of tasks. In accounting software you have collations or categories for types of income and expenditure, so we need to assign a category code to each line. Eg. my partner does SEO and keyword research/social media, I do the server side development etc. We might issue an invoice containing a mix of components, and within each half of our business responsibilities, we might also like to track how a subtask is performing, ie. assign all keyword work to a separate sales category. I have an export script that dumps the data as CSV into a format that Xero likes to eat, and in seconds we have our sales in Xero where our accountant wants them, split into categories.

 

Now, currently we manually add codes to the end of item lines with a pipe delimiter, and I parse these with the export script to create the separate column, but with Blesta looking so nice these days, I do wonder why this feature has yet to be invoked as it seems to me a basic requirement of accounting software. But that's just me, and it doesn't sound like hordes of people are lining up requesting this. Maybe we're all quietly hacking our own solutions...?

 

Anyway, just my 5 cents on the issue. I personally don't like in-script hacks as it just complicates upgrades, so wouldn't be using this solution.

Link to comment
Share on other sites

Having custom fields per invoice line item is a bit different than the OP's request for custom client fields to appear on an invoice. Nonetheless, the scenario you've presented sounds like a reasonable work-around for exporting information to Xero for accounting purposes.

 

The main reason a feature like this doesn't currently exist in Blesta is because Blesta primarily focuses on providing a billing solution rather than an accounting solution. We would be interested in integration support between Blesta and other accounting software like Xero, and in fact a feature request has been brought up before. We do prioritize our development based on demand, and as you've noticed, additional accounting features have not been very widely requested.

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