first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export function generateCustomerNumber(): string {
|
||||
const timestamp = Date.now().toString(36).toUpperCase();
|
||||
const random = Math.random().toString(36).substring(2, 6).toUpperCase();
|
||||
return `K${timestamp}${random}`;
|
||||
}
|
||||
|
||||
export function generateContractNumber(type: string): string {
|
||||
const prefix = type.substring(0, 3).toUpperCase();
|
||||
const timestamp = Date.now().toString(36).toUpperCase();
|
||||
const random = Math.random().toString(36).substring(2, 5).toUpperCase();
|
||||
return `${prefix}-${timestamp}${random}`;
|
||||
}
|
||||
|
||||
export function paginate(page: number = 1, limit: number = 20) {
|
||||
const skip = (page - 1) * limit;
|
||||
return { skip, take: limit };
|
||||
}
|
||||
|
||||
export function buildPaginationResponse(
|
||||
page: number,
|
||||
limit: number,
|
||||
total: number
|
||||
) {
|
||||
return {
|
||||
page,
|
||||
limit,
|
||||
total,
|
||||
totalPages: Math.ceil(total / limit),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user