What is the best way to handle a client with multiple locations?

I run a commercial cleaning company. Some of my clients have multiple locations. For example: I have a pharmacy client with 21 different branches.

In the past, when I was manually creating invoice documents in MS Word, I had the Billing Address and then the Location Address for the branch where service was rendered. What’s the best way to accomplish the same thing in Invoice Ninja? (Initially I thought “Shipping Address” might be the solution, but it doesn’t look like I can have more than one per client.)

Thanks

Hi,

There are two options:

  • Create separate client records for each address, and optionally use groups to link them together.

  • Add the address field as a client contact custom field.

My invoice numbers are {$client_number}{$client_counter}. So the pharmacy client a specific number as a prefix for all of its invoices, as does each of my clients. I also need all of the pharmacy client’s invoices to have a shared counter. So I suspect Option 1 would not be possible because of these requirements. If I’m wrong and there is a way around it, please let me know.

As for Option 2: are you referring to Settings > Advanced > Custom Fields > Clients? There appears to only be 4 configurable Contact fields there - yet I need to accommodate 20 different addresses. Should I be looking elsewhere?

For option one you may be able to use the group counter.

You would create one custom contact field called address and then add 20 contacts to the client, one for each address.

Thanks - Option 2 worked for me.

Summarizing for anyone else that might have this need.

I created a Location Address field in Settings > Advanced > Custom Fields > Contact Field 1.
For any clients I have with multiple locations I either edited an existing contact or or added a new one. The contact details field will now have a Location Address field. Add as many addresses as needed.

When creating a new invoice there will be a checkbox in the upper left to select the applicable contact.

In your custom invoice template, add the $contact.custom1 variable where needed. I added it to the location-details div in the template body, below billing-details:

<div id="location-details">
                <p data-ref="location_address-label">Location Address:</p>
                <p data-ref="client_details-location-address">$contact.custom1</p>
</div>

I needed the City, State, and Zip on a separate line from the Street Address, so I added this script to the Footer section that splits the address at the first comma (this assumes you entered a Location Address in your contact info with a comma after the street address):

//Code generated with ChatGPT
<script>
    document.addEventListener('DOMContentLoaded', () => {
        const addressElement = document.querySelector('p[data-ref="client_details-location-address"]');
        if (addressElement) {
            const address = addressElement.textContent;
            const parts = address.split(','); // split the address at the comma
            if (parts.length > 1) {
                addressElement.innerHTML = parts[0] + '<br>' + parts.slice(1).join(',');
            }
        }
    });
</script>
1 Like

Glad to hear it’s working, thanks for sharing the solution!

I have the same kind of request, am able to do what I need to do with an invoice custom field and style it using html/css design but the problem when I am trying to save I have an error popping saying

422: The given data was invalid.

• The name field is required.

this is my css code if it can help

/** CSS (includes) for chantier **/

[data-ref=“entity_details-invoice.custom1_label”],
[data-ref=“entity_details-invoice.custom1”] {
position: relative;
left: 630px;
bottom:105px
}

[data-ref=“entity_details-invoice.custom1_label”] p{
text-transform: uppercase;
font-weight: bold;
}

#entity-details > tbody > tr:nth-child(7) {
display: flex;
flex-direction: column;
align-items:left; /* Adjust as needed */
}

thanks in advance

From the error it looks like you need to provide a name for the design.

Now i look dump lol sorry am fluent french…and thank you for that fast response

Now I’m facing another issue: when I use my template, I don’t see the style changes reflected on the invoice. Even though I’ve applied the design I created, the invoice appears differently. During the design preview, everything looked nice and stylish. and Yes, I have already selected the new design on the settings tab of the edit invoice screen.

sorry i have a limit for replying i fix my problem the code need to be put in the include tab of my design

Is the new design selected on the settings tab of the edit invoice screen?

1 Like