Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
Vue JS: generate random numbers for invoice

i wanted to know the best way for generating random numbers for invoice and it shouldn't be duplicated .. in my project i'm posting invoice number for each user into API and ofc i should completely avoid duplication ... is there a way to do this in Vue js?

below i tried this code but i believe it might duplicate by chance :\

const Random = '0' + Math.ceil(Math.random()*1000000)+ moment(new Date()).format('DDMMYY');

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

As time cannot be repeated, you can use new Date().getTime()

about 4 years ago · Juan Pablo Isaza Report

0

Use UUID v4

  1. Install and import UUID
import { v4 as uuidv4 } from 'uuid';
  1. Set invoice ID
invoice.id = uuidv4(); // ⇨ '14cd6bcd-bbfd-4a2d-3b5d-ab8dfcbd4dea'
  1. At the backend side, don't forget to check that the invoice id is not already used.
  2. Best way is to define a database unique key.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!