Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

paylocity-cli

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paylocity-cli - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

lib/models/configuration.js

@@ -43,8 +43,8 @@ "use strict";

encode(value) {
return new Buffer(value).toString('base64');
return Buffer.from(value, 'ascii').toString('base64');
}
decode(value = '') {
return new Buffer(value, 'base64').toString('ascii');
return Buffer.from(value, 'base64').toString('ascii');
}
}
exports.Configuration = Configuration;

@@ -35,9 +35,21 @@ "use strict";

try {
const data = await this.page.evaluate(() => {
const today = new Date();
const data = await this.page.evaluate(dayNumber => {
const hours = [];
// The rows with the times on the table
const timeRows = document
.querySelector(`#TimesheetContainer #Timesheet > tbody > #TimeSheet_${dayNumber - 1}_`)
.querySelectorAll('table .pay-type-description');
// Return the time by row using the passed index
const getTime = function (element, index) {
return element.children[index].children[0].textContent.trim();
};
// Get clockIn and clock out by row, number 2 is for clock in in the row
// and 3 for clock out
if (timeRows && timeRows.length > 0) {
timeRows.forEach(row => {
hours.push([getTime(row, 2), getTime(row, 3)]);
});
}
return {
clockIn: document
.querySelector(`#TimesheetContainer #Timesheet > tbody > #TimeSheet_${today.getDay() - 1}_`)
.querySelector('table tr')
.children[2].children[0].textContent.trim(),
timeRows: hours,
totalHours: document

@@ -49,4 +61,11 @@ .querySelector('#GroupTotals')

};
});
this.today = new today_1.Today(data.clockIn);
}, new Date().getDay());
this.today = new today_1.Today(data.timeRows[0][0], data.timeRows[0][1]);
// When there is more than 1 clock in/out in the day the times are added
// To the today object
if (data.timeRows.length > 1) {
for (let i = 1; i < data.timeRows.length; i++) {
this.today.setTimeRow(data.timeRows[i][0], data.timeRows[i][1]);
}
}
this.totalHours = Number(data.totalHours) + this.today.getCurrentHours();

@@ -53,0 +72,0 @@ resolve();

@@ -0,10 +1,41 @@

import * as moment from 'moment';
export declare class Today {
private currentHours;
private clockIn;
private date;
constructor(clockIn: string);
private clockOut;
/**
* Initializes the first clockIn/out of today
*
* @param clockIn
* @param clockOut
*/
constructor(clockIn: string, clockOut?: string);
/**
* Returns the first clockIn of the day
*/
getClockInHour(): string;
/**
* Returns the last clockOut time if exists as a new moment object
*/
getClockOutHour(): moment.Moment | null;
/**
* Returns the calculated current hours using the last clockOut - clockIn hours
*/
getCurrentHours(): number;
private setClockInHour;
/**
* Adds a new element in the clock in/out arrays
* this is useful when a user does clock in/out multiple times
* in a day
*
* @param clockIn
* @param clockOut
*/
setTimeRow(clockIn: string, clockOut?: string): void;
/**
* Returns a new moment object with the time of the string passed
*
* @param time The string hours to set to the time obj
* @param timeObj The time object reference, this must be an element from the clock in/out array
*/
private getMomentObject;
private getHoursToday;
}

@@ -6,23 +6,73 @@ "use strict";

class Today {
constructor(clockIn) {
this.date = new Date();
this.clockIn = moment();
this.setClockInHour(clockIn);
this.currentHours = this.getHoursToday(+this.date, +this.clockIn.toDate());
/**
* Initializes the first clockIn/out of today
*
* @param clockIn
* @param clockOut
*/
constructor(clockIn, clockOut) {
this.clockOut = [null];
this.clockIn = [this.getMomentObject(clockIn)];
if (clockOut) {
this.clockOut = [this.getMomentObject(clockOut)];
}
}
/**
* Returns the first clockIn of the day
*/
getClockInHour() {
return this.clockIn.format('HH:mm');
return this.clockIn[0].format('HH:mm');
}
/**
* Returns the last clockOut time if exists as a new moment object
*/
getClockOutHour() {
const index = this.clockOut.length - 1;
return this.clockOut[index] ? this.clockOut[index].clone() : null;
}
/**
* Returns the calculated current hours using the last clockOut - clockIn hours
*/
getCurrentHours() {
return this.currentHours;
const index = this.clockIn.length - 1;
// When last clock out exist the current hours would be 0
if (this.clockOut[index])
return 0;
const clockOut = this.clockOut[index] ? +this.clockOut[index] : +Date.now();
return this.getHoursToday(clockOut, +this.clockIn[0]);
}
setClockInHour(clockIn) {
const hour = new hour_1.Hour(clockIn);
this.clockIn.hours(hour.getHours());
this.clockIn.minutes(hour.getMinutes());
/**
* Adds a new element in the clock in/out arrays
* this is useful when a user does clock in/out multiple times
* in a day
*
* @param clockIn
* @param clockOut
*/
setTimeRow(clockIn, clockOut) {
this.clockIn.push(this.getMomentObject(clockIn));
if (clockOut) {
this.clockOut.push(this.getMomentObject(clockOut));
}
else {
this.clockOut.push(null);
}
}
getHoursToday(now, clockIn) {
return Number((Math.abs(now - clockIn) / 36e5).toFixed(2));
/**
* Returns a new moment object with the time of the string passed
*
* @param time The string hours to set to the time obj
* @param timeObj The time object reference, this must be an element from the clock in/out array
*/
getMomentObject(time) {
const date = moment();
const hour = new hour_1.Hour(time);
date.hours(hour.getHours());
date.minutes(hour.getMinutes());
return date;
}
getHoursToday(clockOut, clockIn) {
return Number((Math.abs(clockOut - clockIn) / 36e5).toFixed(2));
}
}
exports.Today = Today;

@@ -18,3 +18,3 @@ "use strict";

time.closePage();
const pace = new Pace_1.Pace(time.totalHours, time.today.getCurrentHours());
const pace = new Pace_1.Pace(time.totalHours, time.today.getCurrentHours(), time.today.getClockOutHour());
console.log(pace.getTable());

@@ -21,0 +21,0 @@ })

@@ -0,1 +1,2 @@

import * as moment from 'moment';
export declare class Pace {

@@ -6,3 +7,4 @@ private table;

private config;
constructor(totalHours: number, currentHours: number);
private clockOut;
constructor(totalHours: number, currentHours: number, clockOut: moment.Moment | null);
/**

@@ -42,4 +44,5 @@ * Returns table as string

* @param total Hours to reach
* @param clockOut When the user already did clockOut this object has the hour
*/
private getLeavingHour;
}

@@ -8,3 +8,4 @@ "use strict";

class Pace {
constructor(totalHours, currentHours) {
constructor(totalHours, currentHours, clockOut) {
this.clockOut = clockOut;
this.totalHours = totalHours;

@@ -29,5 +30,5 @@ this.currentHours = currentHours;

});
this.setRow(7);
this.setRow(8);
this.setRow(9);
this.setRow(7, 'Minimum');
this.setRow(8, 'Standard');
this.setRow(9, 'Overtime');
}

@@ -39,9 +40,9 @@ /**

*/
setRow(hoursPerDay) {
setRow(hoursPerDay, type) {
const goalToday = hoursPerDay * new Date().getDay();
this.table.push([
`Minimum (${hoursPerDay})`,
`${type} (${hoursPerDay})`,
`${this.totalHours.toFixed(2)} of ${goalToday}`,
this.difference(this.totalHours, goalToday),
this.getLeavingHour(this.totalHours, hoursPerDay),
this.getLeavingHour(this.totalHours, hoursPerDay, this.clockOut),
]);

@@ -94,6 +95,7 @@ }

* @param total Hours to reach
* @param clockOut When the user already did clockOut this object has the hour
*/
getLeavingHour(current, total) {
const date = moment();
getLeavingHour(current, total, clockOut) {
const targetToday = total * new Date().getDay();
const date = clockOut ? clockOut.clone() : moment();
const diff = Number((targetToday - current).toFixed(2));

@@ -100,0 +102,0 @@ date.add(diff, 'hours');

{
"name": "paylocity-cli",
"version": "1.1.0",
"version": "1.1.1",
"description": "This is a simple CLI to track the worked hours in the paylocity system by data scraping",

@@ -36,3 +36,4 @@ "main": "lib/index.js",

"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint -p tsconfig.json"
"lint": "tslint -p tsconfig.json",
"local": "tsc && node lib/index.js"
},

@@ -54,2 +55,2 @@ "repository": {

"license": "ISC"
}
}

@@ -18,2 +18,5 @@ # Paylocity time tracker

To use the fingerprint, you should indicate first to remember your username in order to prevent paylocity keep asking
for security questions.
- For the fingerprint:

@@ -26,1 +29,7 @@ - Go to Paylocity (https://access.paylocity.com/)

`{"uaPlatform":"Mac OS11.15.1","language":"en-US","timezone":"Central Standard Time","depth":24,"resolution":"1440x2537","browser":"Chrome85","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.3945.88 Safari/537.36","plugins":"Chrome PDF Plugin, Chrome PDF Viewer, Native Client","fonts":"Arial Black, Arial, Bauhaus 93, ","canvas":"3985551669"}`
# Contributing
- Fork the repository.
- To run the local changes type `npm run local`
- Create a Pull request using `Develop` branch as base.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc