Last night, I took a break from Cushion’s timeline beta and instead decided to launch a new feature—duplicating an invoice. I know with 100% certainty that certain Cushion users will spit out their coffee when they read this, as if Christmas came early. This is because duplicating an invoice is a significant feature that has been requested by every user and their grandma—and I built it in maybe 10 lines of code then launched it like it was no big deal. There’s a reason for this, which mainly revolves around me finally finding a way to build it using the API that I currently have.
Earlier last year, I tried to spend a day to quickly build invoice duplicating based on an idea I had—using query params. The current invoice form lets Cushion use query params to specify the client and project (for “New invoice” buttons that reside inside a client or project page), but that’s all there is. I hypothesized that I could use query params to pre-populate the fields in the invoice form, which would make duplicating an invoice pretty easy—simply set the params that Cushion would need to duplicate.
Before attempting this, I thought it was a fine idea. Then, I tried parameterizing line items. This instantly became a nightmare, along with potentially long-form fields, like invoice details, etc. At this point, query params were obviously not the right tool to use. Also, this approach didn’t feel right (devs know that feel), so I decided to put a fork in my one-day experiment, and return to the work I had planned. Then this weekend happened.
Over the past few days, I got several support messages from folks asking for the ability to duplicate an invoice. When I get a single message for a feature like this, I’d think to myself, “It’s definitely on the to-do list, but I can’t keep straying from my existing work.” But when I get a handful of these messages all at once, this is typically when I stop what I’m doing and think it through. Leading up to now, I’ve been working on a new invoicing redesign for Cushion, and it’d be ideal to have that launched before adding any new features to invoicing, but it’s not launching anytime soon. Because of this, I wondered if I could deliver invoice duplicating without much code. Then, it hit me.
Instead of taking the approach of setting up a client-side invoice that the user would need to save in order to create it (like the query param approach), I could use the API to create the invoice copy, then send the user to that invoice to edit it. This would only entail a single API call and a redirect—roughly 10 lines of code. As long as I empty out the fields I don’t want to copy (the invoice number and dates), I could achieve this much-wanted feature in a single sitting. And I did!
As of today, if you log into Cushion, you’ll now see a “Duplicate” button on the invoice page, which does exactly what it says on the tin. Although there’s much more I could do to fine-tune the feature (like options to specify which fields to duplicate, etc.), this dead-simple version works perfectly fine for now. I’m actually somewhat giddy at the thought of people stumbling upon the feature—especially those who have requested it. I know for sure that it’ll drastically improve some users’ workflows, since they no longer need to manually copy each field. In hindsight, this feels like a very necessary feature that should’ve made its way into Cushion from the start, but unfortunately, it took me eight years to realize that.