From cf19989ed93ff8287e85499a07a76e0d6b1946c7 Mon Sep 17 00:00:00 2001 From: Fadli Date: Fri, 18 Nov 2022 16:00:41 +0700 Subject: [PATCH] - fix generate id for transaction --- src/transaction/transaction.service.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index c6f83f9..c13654d 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -341,13 +341,10 @@ export class TransactionService { // ); // } else { - const d = new Date(); - let ms = d.getMilliseconds(); - const trxId = Array(6) .fill(null) .map(() => { - return Math.round(Math.random() * 16).toString(16) + ms.toString(); + return Math.round(Math.random() * 16).toString(16); }) .join(''); @@ -601,13 +598,17 @@ export class TransactionService { } //HIT API SUPPLIER - const d = new Date(); - let ms = d.getMilliseconds(); + let hexString = uuid.v4(); + + // remove decoration + hexString = hexString.replace(/-/g, ''); + + let base64String = Buffer.from(hexString, 'hex').toString('base64'); const trxId = Array(6) .fill(null) .map(() => { - return Math.round(Math.random() * 16).toString(16) + ms.toString(); + return Math.round(Math.random() * 16).toString(16) + base64String; }) .join(''); @@ -851,12 +852,10 @@ export class TransactionService { } //HIT API SUPPLIER - const d = new Date(); - let ms = d.getMilliseconds(); const trxId = Array(6) .fill(null) .map(() => { - return Math.round(Math.random() * 16).toString(16) + ms.toString(); + return Math.round(Math.random() * 16).toString(16); }) .join(''); @@ -1005,13 +1004,10 @@ export class TransactionService { userData.partner?.id, ); //HIT API SUPPLIER - const d = new Date(); - let ms = d.getMilliseconds(); - const trxId = Array(6) .fill(null) .map(() => { - return Math.round(Math.random() * 16).toString(16) + ms.toString(); + return Math.round(Math.random() * 16).toString(16); }) .join('');