BlogUse Cases

How to Get Paid Fast: A Do-It-Yourself Automated Invoicing System

With 50+ million freelancers in the US alone, chances are that some of them don’t enjoy spending time on invoicing tasks.

It’s easy to understand why: Invoicing is a multi-step process that eats away a bit of time every month, and where minor mistakes can easily escalate to administrative nightmares. Time is money, and nobody knows that better than a freelancer.

The very nature of the invoicing process - dull, repetitive, prone to errors - makes it a prime target for automation, and that’s why we are here today.

In this use case, we will show how to create an automated invoicing system that will do the following for you:

  • Calculate hours worked
  • Create an invoice
  • Store the invoice in Google Drive
  • Send the invoice via email to the relevant stakeholder (i.e. HR, accounting)

This invoice automation solution will prove useful for freelancers, but also for companies that work with freelancers and wish for a standardized process capable of delivering instant productivity gains.

Now, let’s roll up our sleeves and create something new, together.

Basic requirements

Our automated invoicing system is suited for freelancers who work with time-tracking apps, such as Harvest, Clockify, or Toggl.

The resulting automated scenario relies on Harvest, but you can change this app for another time-tracking app as long as it is supported by Integromat.

On top of this, you will need an Integromat account (it can be a free one), a Google account, and the following invoice template.

Important note: Please do not request edit access to the template (it will not be provided).

We recommend you to make a copy of the template and add it to a folder in your Google Drive account before proceeding.

Here’s what the invoice template looks like:

invoice-template


The text wrapped in {{ }} are the variables that change with the latest values for every new invoice according to the data generated in the scenario. We’ll get to that later, don’t worry.

Now, let’s start creating the Integromat scenario

Step 1: Creating the Integromat scenario

The first step in creating an Integromat scenario is to open the scenario builder.

Once you log in to your Integromat account, you’ll be taken to your Dashboard.

On the top right of your screen, you’ll see a “Create a new scenario” button. Click it, and you will land on the scenario builder.

create-a-new-scenario-button-on-the-dashboard


In the scenario builder, you’ll notice a circle with a plus sign in it, and an animated cursor showing you where to click to get started.

scenario-builder

Once you click on the circle, the list of available apps will appear.

In the search box, type “Harvest” and click on the app. You will see all the available modules for the app (triggers, actions and searches).

harvest-modules-on-integromat


Since this automation will fetch all the time entries for the previous month in order to create the invoice for you, we will select the “List Time Entries” module as the scenario starter.

list-time-entries-action-module


After you do that, you will have to connect your Harvest account to Integromat.

Step 2: Configuring the Harvest module

In the configuration box, click the “Add” button on the right, and an authorization box will pop up.

Here you will have to grant Integromat authorization so that you can access your account’s data.

harvest-authorization-box


Once authorized, it’s time to configure the module.

In the “Number of entries to return” field, you don’t need to enter a number, since you probably won’t know how many entries there will be in any given month.

To bypass this, click in the field and map the “ignore” keyword function found under the “General functions” tab.

harvest-module-ignore-function-configuration


The other fields remained unchanged except for the “From” and “To” date fields (which you need to scroll down to).

Entering static dates in these fields won’t work, as the dates will need to change every month and there’s no option within the module to select the dates of the previous month.

So, in order to output the correct date we will have to use one of Integromat’s built-in functions - similar to those that you find on Excel.

Let’s see how to do this.

Where to find functions on Integromat

When configuring any module of an app, simply click in one of the fields and a box with all the functions that are available will appear.

built-in-integromat-functions


Integromat has a variety of functions that allow you to manipulate data in all types of ways so that your scenarios can perform exactly how you want it to.

Getting back to the Harvest module, to output the accurate dates you’ll need to use a few functions from the “Date and time” category. These are:

  • addDays: Returns a new date as a result of adding a given number of days to a date. Days are subtracted by entering a negative number
  • setDate: Returns a new date with the day of the month specified in parameters
  • formatDate: Returns a date in the requested format and optionally, in a specified timezone
  • parseDate: Parses a string with a date and returns the date

Scared? We understand that it takes a while to get used to formulas so to solve this, you can simply copy and paste the following formula in the “From” field in the module:

{{parseDate(formatDate(setDate(addDays(now; -1); 1); "DD/MM/YYYY"); "DD/MM/YYYY")}}

In the “To” field, simply map the “now” variable, which returns the current date and time when the scenario is executed.

harvest-module-date-and-time-configuration


Once you do this, click “OK” and the Harvest module will be all set up.

You’re probably thinking that by using the “now” variable the scenario will pick up time entries corresponding to the 1st day of the month. We’ll show you how to solve this soon, but let’s not skip any steps before we do.

Step 3: Total hours by hourly rate calculation

In the first step, all the individual hours for the date range are fetched from Harvest.

In the second step, the hours are summed up and multiplied by your hourly rate to get the total amount for your invoice.

Let’s begin by calculating the total hours.

Integromat has a tool that can easily take care of this for you. To add this tool to the scenario, hover over the Harvest app and click the plus sign on the right. Search for “Tools” and select the Numeric Aggregator.

Hint: You can also select the Numeric Aggregator from the “Tools” menu at the bottom of the scenario builder.

numeric-aggregator-module-in-the-tools-menu


To configure the module, just select the “SUM” option under “Aggregate function”, and map the “Hours” data element from the Harvest module to the “Value” field.

numeric-aggregator-configuration


Remember the point at the end of step 1 about using the “now” variable and accidentally pulling through entries from the 1st of the new month? We will now see how to prevent this from happening.

Integromat has another built-in tool called “Filter”, in which you can set up conditions for data to meet before being able to continue on in the scenario.

In other words, you can set up a Filter to only allow time entries from the previous month to pass through, omitting the entries on 1st of the new month when the scenario executes.

Step 4: Setting up the filter

To set up a Filter, click on the route between the 2 modules to open the configuration box.

route-between-the-2-modules


You can start by giving the filter a name.

In the first field under “Condition”, you need to use the “formatDate” function combined with the “addDays” function to output only the name of the previous month.

Here is the formula to use in that field:

{{formatDate(addDays(now; -1); "MMM")}}

Below that, select the “Equal to” text operator.

top-field-of-condition-in-filter-setting


In the bottom field, you need to map the “Created at” data element from the Harvest module, and also convert this to the name of the month only.

By doing this, the Filter will compare the month in the top field (which is the previous month), to the month the entries were created in the bottom field (which can be either the previous or current month).

Only the entries that were created in the previous month will meet the condition and pass through to the subsequent modules, while the entries created on the 1st will be stopped at the Filter.

Use the following formula to achieve this, and map the “Created at” data element in the brackets as shown in the image below.

{{formatDate(;"MMM")}}

Bottom-field-of-condition-in-filter-setting

Step 5: Setting up the variables to calculate the due

Once you set up the Filter, it’s time to calculate the total amount by multiplying the total hours by your hourly rate.

You’ll need to create a few variables for the calculations so that you can use these variables in the next module to create the invoice.

The module to use here is the “Set multiple variables”, which is also found in the “Tools” menu.

set-multiple-variables-module-in-the-tools-menu


There are 5 variables that you’ll be creating:

  • Hours
  • Amount
  • Month
  • Name
  • Address

Let’s begin by adding a variable for the Hours. First, click the “Add item” button.

You need to manually enter the name of all the variables that you add in the “Variable name” field.

Below is the formula you can use in the “Variable value” field to round off the total hours outputted by the previous module.

Map the “result” data element, which contains the total hours from the Numeric aggregator module within the brackets.

Formula: {{round((* 100)) / 100}}

hours-variable-in-the-set-multiple-variables-module


Next, add the second variable for the Amount.

Again, use the round off formula below, map the “result” data element and replace the “your hourly rate” bit with your actual hourly rate (the number, without symbols).

Formula: {{(round((3.result * 100)) / 100) * "{your hourly rate}"}}

amount-variable-in-the-set-multiple-variables-module


The third variable is the for the Month. Since you want to output the previous month, use this formula to do that:

{{formatDate(addDays(now; -1); "MMM")}}

month-variable-in-the-set-multiple-variables-module

For the “Name” and “Address” variables, simply enter the details which you want displayed on the invoice every time it's created.

name-and-address-variables-in-the-set-multiple-variables-module


Step 6: Creating the invoice

Now for the juicy part, let’s move into the actual invoice part.

Since the invoice template is a Google Doc, search for the Google Doc app and select the “Create a Document from a template” module.

google-docs-module


Hit the “Add” button and connect your Google account to Integromat.

google-docs-connection


Under the “Create a document from a template” menu, select “By Dropdown”.

Under the “Choose a Drive” menu, select “My Drive”.

In the “Document ID” field, choose the invoice template we provided at the beginning (and that you saved to your Google Drive).

google-docs-module-configuration


At this point you need to map the data to the fields in the “Google Docs” module.

Copy and paste the following date and time formulas in the corresponding module fields:

  • invoice_id: {{formatDate(now; "YYYYMMDD")}}
  • bill_date: {{formatDate(now; "DD/MM/YYYY HH:MM")}}
  • due_date: {{formatDate(addDays(now; 14); "DD/MM/YYYY")}}

The due_date above is set to the 15th of every month which you can change in the formula according to your preference.

Go ahead and map the data from the “Set multiple variables” module, as shown below:

google-docs-module-mapping-1


google-docs-module-mapping-2


In the “New Document’s Location” field, choose where you would like to upload the new invoice in your Google Drive.

After doing this, the Google Docs module will be fully set up. Let’s continue with the scenario.

Step 7: Download and email the invoice

At the end of the previous step, the new invoice gets uploaded to Google Drive. In the current step, the invoice will be downloaded from its location and emailed to the recipient (or recipients, if there’s more than one).

First, you’ll need to search for the Google Drive app and choose the “Download a file” module.

google-drive-module


Once you select your Google Drive account, map the “Document ID” data element from the Google Docs module to the “File ID” field.

Then, tick the “Show advanced settings” option at the bottom of the module and select “PDF” under the “Convert Google Documents Files to Format” option.

google-drive-module-configuration


That’s all we need to configure this module. Let’s move to the final step of this automation!

Step 8: Configuring the Gmail module

And finally, you can send the invoice via email to whoever you need by adding the “Send an email” Gmail module to your scenario.

gmail-send-an-email-module


This module is quite straightforward to configure.

After you add your Google connection, enter the recipient that you want to send the invoice to.

If you have multiple recipients, you need to add each one individually (one at a time).

gmail-module-recipient-field


You can compose the email by adding the “Subject” and “Content” in their respective fields.

All the data you need can be mapped from the “Set multiple variables” module, like in the image below.

Note: Our example uses some HTML for the spaces and the paragraph, but you can skip this if you want and enter whatever text you wish.

gmail-subject-content-fields


The last thing to do in this module (and the most important) is to attach the downloaded invoice to the email.

To do this, click “Add an attachment” and select the “Google Drive > Download a file” as the source file.

Source-file-under-attachment-option


You also have the option to CC and Blind CC recipients in the fields below the attachment.

cc-and-blind-cc- fields


Once you do this, just hit the “Save” button at the bottom of the scenario builder to save all the settings of your scenario.

auto-align-and-save-button


Almost there now! All we need to do at this point is make sure the automation works.

Step 9: Testing the scenario

The final step is to test the scenario and ensure it’s working exactly the way you want to.

The best day to test this will be on the 1st, so the scenario fetches the accurate time entries.

However you can still test the scenario on any other day to check if an invoice is actually sent (ignore the entries).

Simply hit the “Run once” button that you’ll find at the bottom left of the scenario.

The execution should look like this:

scenario-execution


If the execution was a success, you can then schedule it to run automatically on the 1st of the month.

To schedule the scenario, first turn the scenario on by toggling the switch below the “Run once” button.

scenario-switch


In the schedule setting configuration box, select “Days of the month” under “Run scenario”, tick “1” under “Days”, and enter the time you would like the scenario to run.

Then hit “Activate”.

scenario-schedule-setting


And that, friends, is all.

If you made it this far, you have created your own automated invoicing system from scratch.

Conclusion

Since we covered invoice automation and time-tracking apps in the past, it was only a matter of time to combine these tools into a solution that can make a difference for millions of people working by the hour out there.

In addition, companies working with freelancers and contractors can benefit from this automated scenario as well, since this solution can be cloned over and over.

Better processes lead to better results - all it takes is a little patience, and a powerful tool.

Happy automating!

Do you like this article?
Don't forget to share it!
Share

Get started now!

Sign up for a free Integromat account today!