1+ // Salary ranges by position (annual salary in USD)
2+ const SALARY_RANGES = {
3+ "Teacher" : { min : 45000 , max : 65000 } ,
4+ "Lecturer" : { min : 45000 , max : 65000 } ,
5+ "Assistant Professor" : { min : 65000 , max : 85000 } ,
6+ "Associate Professor" : { min : 80000 , max : 110000 } ,
7+ "Professor" : { min : 100000 , max : 140000 } ,
8+ "Head of Department" : { min : 90000 , max : 130000 } ,
9+ "Vice Principal" : { min : 85000 , max : 120000 } ,
10+ "Office Administrator" : { min : 40000 , max : 60000 } ,
11+ "Security Officer" : { min : 35000 , max : 50000 } ,
12+ "Accountant" : { min : 55000 , max : 80000 } ,
13+ "Researcher" : { min : 60000 , max : 90000 } ,
14+ "Lab Technician" : { min : 40000 , max : 55000 } ,
15+ "Clinical Professor" : { min : 90000 , max : 120000 }
16+ } ;
17+
18+ // Get monthly salary based on position
19+ function getMonthlySalary ( position ) {
20+ const range = SALARY_RANGES [ position ] || { min : 50000 , max : 80000 } ;
21+ const annualSalary = Math . floor ( Math . random ( ) * ( range . max - range . min + 1 ) ) + range . min ;
22+ return Math . round ( annualSalary / 12 ) ;
23+ }
24+
125export const generateRandomData = ( ) => {
226 const firstNames = [ "James" , "Mary" , "John" , "Patricia" , "Robert" , "Jennifer" , "Michael" , "Linda" , "William" , "Elizabeth" , "David" , "Barbara" , "Richard" , "Susan" , "Joseph" , "Jessica" , "Thomas" , "Sarah" , "Charles" , "Karen" , "Hiroshi" , "Yuki" , "Wei" , "Li" , "Fatima" , "Mohammed" , "Sven" , "Ingrid" ] ;
327 const lastNames = [ "Smith" , "Johnson" , "Williams" , "Brown" , "Jones" , "Garcia" , "Miller" , "Davis" , "Rodriguez" , "Martinez" , "Hernandez" , "Lopez" , "Gonzalez" , "Wilson" , "Anderson" , "Thomas" , "Taylor" , "Moore" , "Jackson" , "Martin" , "Lee" , "Perez" , "Thompson" , "White" , "Harris" , "Sanchez" , "Clark" , "Ramirez" , "Lewis" , "Robinson" , "Walker" , "Young" , "Allen" , "King" , "Wright" , "Scott" , "Torres" , "Nguyen" , "Hill" , "Flores" , "Green" , "Adams" , "Nelson" , "Baker" , "Hall" , "Rivera" , "Campbell" , "Mitchell" , "Carter" , "Roberts" ] ;
4- const positions = [ "Teacher" , "Head of Department " , "Vice Principal " , "Office Administrator " , "Security Officer " , "Accountant " , "Lecturer " , "Professor " , "Researcher" , "Lab Technician" ] ;
28+ const positions = [ "Teacher" , "Lecturer " , "Assistant Professor " , "Associate Professor " , "Professor " , "Head of Department " , "Vice Principal " , "Office Administrator " , "Researcher" , "Lab Technician" ] ;
529
630 const schools = [
731 { name : "Brooklyn Technical High School" , address : "29 Fort Greene Place, Brooklyn, NY 11217" , phone : "(718) 804-6400" , website : "www.bths.edu" } ,
@@ -48,16 +72,24 @@ export const generateRandomData = () => {
4872
4973 const random = ( arr ) => arr [ Math . floor ( Math . random ( ) * arr . length ) ] ;
5074 const randomInt = ( min , max ) => Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
51- const randomFloat = ( min , max ) => ( Math . random ( ) * ( max - min ) + min ) . toFixed ( 2 ) ;
5275
5376 const selectedSchool = random ( schools ) ;
77+ const selectedPosition = random ( positions ) ;
78+ const baseSalary = getMonthlySalary ( selectedPosition ) ;
5479
5580 // Generate realistic international address
5681 const streetNames = [ "Main St" , "High St" , "Park Ave" , "Broadway" , "Maple Dr" , "Oak St" , "Cedar Ln" , "Sunset Blvd" , "Victoria St" , "George St" ] ;
5782 const cities = [ "New York" , "London" , "Sydney" , "Tokyo" , "Paris" , "Berlin" , "Toronto" , "Singapore" , "Los Angeles" , "Melbourne" ] ;
5883
5984 const employeeAddress = `${ randomInt ( 1 , 999 ) } ${ random ( streetNames ) } , ${ random ( cities ) } ` ;
6085
86+ // Calculate deductions based on base salary
87+ const federalTax = Math . round ( baseSalary * ( 0.12 + Math . random ( ) * 0.10 ) ) ; // 12-22%
88+ const stateTax = Math . round ( baseSalary * ( 0.04 + Math . random ( ) * 0.06 ) ) ; // 4-10%
89+ const cityTax = Math . round ( baseSalary * ( 0.01 + Math . random ( ) * 0.02 ) ) ; // 1-3%
90+ const fica = Math . round ( baseSalary * 0.0765 ) ; // 7.65% FICA
91+ const medicare = Math . round ( baseSalary * 0.0145 ) ; // 1.45% Medicare
92+
6193 return {
6294 company : {
6395 name : selectedSchool . name ,
@@ -74,32 +106,27 @@ export const generateRandomData = () => {
74106 employee : {
75107 name : `${ random ( firstNames ) } ${ random ( lastNames ) } ` ,
76108 address : employeeAddress ,
77- position : random ( positions ) ,
78- employeeId : `NV${ randomInt ( 1000 , 9999 ) } ` ,
79- taxCode : [ "MST-001" , "MST-002" ] [ randomInt ( 0 , 1 ) ] ,
80- payRate : parseFloat ( randomFloat ( 50000 , 200000 ) ) // Adjusted for VND (hourly maybe? or just a base unit) - keeping simple number for now, user can adjust format later. Actually let's keep it somewhat compatible with the previous range but maybe higher if it's VND?
81- // The previous code had 35-85. If this is hourly in USD, it's high. If it's k VND, it's 35k-85k.
82- // Let's assume the user wants realistic numbers. 50k - 500k VND per hour is reasonable for teachers/staff.
83- // Let's use 50-500 for now to avoid breaking layout with millions if it expects small numbers.
84- // Wait, the earnings calculation uses this.
85- // Let's stick to a generic number range that looks okay, maybe 100-500.
109+ position : selectedPosition ,
110+ employeeId : `EMP-${ randomInt ( 100000 , 999999 ) } ` ,
111+ taxCode : [ "W-4" , "1040-ES" ] [ randomInt ( 0 , 1 ) ] ,
112+ payRate : baseSalary
86113 } ,
87114 meta : {
88115 payDate : new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
89- payPeriodStart : new Date ( Date . now ( ) - 30 * 24 * 60 * 60 * 1000 ) . toISOString ( ) . split ( 'T' ) [ 0 ] , // Monthly
116+ payPeriodStart : new Date ( Date . now ( ) - 30 * 24 * 60 * 60 * 1000 ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
90117 payPeriodEnd : new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
91118 } ,
92119 earnings : [
93- { id : 1 , description : "Regular Academic" , quantity : 1 , rate : 0 , amount : parseFloat ( randomFloat ( 3000 , 10000 ) ) } ,
94- { id : 2 , description : " Department Chair" , quantity : 1 , rate : 1000 , amount : 1000 } ,
95- { id : 3 , description : "Per Session" , quantity : randomInt ( 0 , 10 ) , rate : 50 , amount : 0 }
120+ { id : 1 , description : "Regular Academic" , quantity : 1 , rate : baseSalary , amount : baseSalary } ,
121+ { id : 2 , description : selectedPosition . includes ( "Professor" ) || selectedPosition . includes ( "Head" ) ? " Department Stipend" : "Per Diem" , quantity : 1 , rate : Math . round ( baseSalary * 0.1 ) , amount : Math . round ( baseSalary * 0.1 ) } ,
122+ { id : 3 , description : "Per Session" , quantity : randomInt ( 0 , 8 ) , rate : 75 , amount : 0 }
96123 ] . map ( item => ( { ...item , amount : item . amount || item . quantity * item . rate } ) ) ,
97124 deductions : [
98- { id : 1 , description : "Federal Tax" , amount : parseFloat ( randomFloat ( 200 , 1000 ) ) } ,
99- { id : 2 , description : "State Tax" , amount : parseFloat ( randomFloat ( 100 , 500 ) ) } ,
100- { id : 3 , description : "City Tax" , amount : parseFloat ( randomFloat ( 50 , 200 ) ) } ,
101- { id : 4 , description : "FICA" , amount : parseFloat ( randomFloat ( 100 , 300 ) ) } ,
102- { id : 5 , description : "Medicare" , amount : parseFloat ( randomFloat ( 50 , 150 ) ) }
125+ { id : 1 , description : "Federal Tax" , amount : federalTax } ,
126+ { id : 2 , description : "State Tax" , amount : stateTax } ,
127+ { id : 3 , description : "City Tax" , amount : cityTax } ,
128+ { id : 4 , description : "FICA" , amount : fica } ,
129+ { id : 5 , description : "Medicare" , amount : medicare }
103130 ]
104131 } ;
105132} ;
0 commit comments