DEV Community

Olaf Ranai { dev-it-out }
Olaf Ranai { dev-it-out }

Posted on โ€ข Edited on

112 22

Building a simple invoice generator with Node Js

Why โ“๐Ÿค”

After each online coaching sessions, at the beginning, that was a pain to find a good invoice generator platform as I was not yet ready for a 20โ‚ฌ monthly subscription just for handling the invoice part.

None was enough flexible for my own use ๐Ÿ™„ so.. I decided to build my own mini-invoice generator with Node Js โœ… ( that took approx 1h max โŒ›๏ธ )

No more talk..Straight to the point ๐Ÿ’ช๐Ÿผ

The main parts โš™๏ธ:

1. Storing clients in Json :

Yep that one is simple..for now x)

(Note: these are fictional characters of course ๐Ÿ˜ )

Image description

2. Creating the route:
Using express router, just create a POST /invoice route.
const router = express.Router();
router.post('/', handleCreateInvoice);

Then add the Joi Schema. Why ? It allows to define schema and validate the schema before calling the controller/handler of invoice creation.

Source: https://joi.dev/

Image description

3. Handling the invoice creation:

I used the module pdf-kit to generate the pdf to be sent to the client.

pdf-kit

Image description

4. Email sending:
A small function using gmail-send npm module which accepts html as an input Image description

Yep..so what about the result ?

A snapshot of my first trials ^^ ( yep that email should be more personnalized and better structure ๐Ÿ˜Š )

Insomnia POST Call
Image description

Final result ๐Ÿ˜
Image description

The pdf:
Image description

Next steps:

  • Front-end ( React ๐Ÿค” )
  • Database ๐Ÿ’ฟ
  • make it online x)
  • Iterate ๐Ÿ‘€

And you ๐Ÿ’ช๐Ÿผ?

Tell us in the comments which mini-project you built ๐Ÿ‘€๐Ÿ˜Š

Wanna support me ?

I am blogging during my free time ^^ like most people on this platform ๐Ÿ˜Š however I'm not against a small coffee if you want to support me ๐Ÿ’ช๐Ÿผ Link below:

https://ko-fi.com/dev_it_out

P.S: I added the sample on Github ( https://github.com/njivaolafpro/invoice-management-sample

Image of Timescale

๐Ÿš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsโ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post โ†’

Top comments (28)

Collapse
 
laurencioscript profile image
Gabriel Laurencio โ€ข

i built a mini project for knowing new chapters of mangรกs in site and warn in my channel in discord when has new releases, basically my project did web scraping in specific web page.

github.com/laurencioScript/sakamot...

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

nice ^^ would love having an english version of the README though :/

Collapse
 
lalami profile image
Salah Eddine Lalami โ€ข

@ IDURAR , we use are using node.js react.js & redux

Here Tutorial about : ๐Ÿš€ Building and Generate Invoice PDF with React.js , Redux and Node.js : dev.to/idurar/building-an-invoice-...

 Building and Generate Invoice PDF with React.js , Redux and Node.js

Collapse
 
andrewbaisden profile image
Andrew Baisden โ€ข

Cool project.

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

thanks ^^ was just a small hobby ^^

Collapse
 
leanderd profile image

You could try to connect it to Toggl Track via their API.
Keep track of time, projects, clients etc.

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

Good idea ^^ will try that one ;) thanks

Collapse
 
cednore profile image
cednore โ€ข

So Nice!

Collapse
 
bam92 profile image
Abel Lifaefi Mbula โ€ข

A good short that goes straight to the main point. Hope you'll open source the project.

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

thanks ^^
It is on git

github.com/njivaolafpro/invoice-ma...
( need to clean up a bit the doc though ;) )

Collapse
 
kelseyjj profile image
Kelsey Jones โ€ข

Awesome article.

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

thank you ^^

Collapse
 
cjw profile image
Clifford Watson โ€ข

good read

Collapse
 
aaravrrrrrr profile image
Aarav Reddy โ€ข

Thanks for writing

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

no prob ;)

Collapse
 
felipegenuino profile image
Felipe Genuino โ€ข

Nice work

Collapse
 
olaf_ranai profile image
Olaf Ranai { dev-it-out } โ€ข

thanks x)

nextjs tutorial video

Youtube Tutorial Series ๐Ÿ“บ

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series ๐Ÿ‘€

Watch the Youtube series