1.5.0 • Published 3 years ago

3pm-timesheet-module v1.5.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

NPM

3PM Packages

Following included packages:
  • Timesheet Package
  • Leave Request Package
Please refer to the wiki for the following:

Adding checkboxes for approving timesheets

Adding API success and error logging

Timesheet Module

Installation

$ npm install 3pm-timesheet-module

You will also need to setup an express server if you haven't done so.

$ npm install express cors nodemon

Features

  • Sign in / Sign out
  • Start new jobs when signing out
  • Selecting multiple assets to assign hours too hasMultiAssets should be set to TRUE() in app.
  • Selecting one asset. hasOneAsset should be set to TRUE() in mobile app.

Usage

This is a basic example on how we can setup our server and implement the Timesheet module.

const express = require('express');
const cors = require('cors');
const { Timesheet } = require('3pm-timesheet-module');

const { knack } = require('./api') // Knack API functions

const app = express();
const PORT = process.env.PORT || 8000;

app.use(cors());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());

app.post('/api/timesheet', async (req, res) => {
  const payload = req.body.Entry;

  const {
    createRecord,
    updateRecord,
    getAllRecords
  } = knack; // API functions
  try {
    const fieldLookup = {
      timesheetID: "field_9",
      signinDateTime: "field_5",
      signoutDateTime: "field_10",
      staffConnection: "field_6",
      staffName: "field_16",
      jobConnection: "field_7",
      signinLocation: "field_8",
      signoutLocation: "field_11",
      lunch: "field_14",
      comments: "field_13",
    };

    await Timesheet(payload, fieldLookup, createRecord, updateRecord, getAllRecords);

    res.status(200).send('Successfully created/updated timesheet entry.');
  } catch(err) {
    res.status(400).json({
      message: 'Failed creating/updating timesheet.',
      error: err
    })
  }
})

👀 Timesheet Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create timesheet recordfn(obj_num, data, retry?)Yes
updateRecordFunction to update timesheet recordfn(obj_num, data, id, retry?)Yes
getAllRecordsFunction to get record by timesheet IDfn(obj_num, filer?, retry?)Yes
objectNumKnack object # for where payload is going toonumberYes
assetObjectFunction to get record by timesheet IDnumberNo

Leave Request Module

Here is a basic example on how we could implement the leave process.

app.post('/api/leave', async (req, res) => {
  const { createRecord } = knack;
  try {
    res.status(200).send('Successfully created leave entry.')
    const fieldLookup = {
      firstDay: "field_21",
      lastDay: "field_22",
      days: "field_23",
      staffConnection: "field_18",
      leaveType: "field_19",
      otherLeaveType: "field_20",
      leaveComments: "field_25",
    }
    const objectNum = 4;
    await Leave(req.body.Entry, fieldLookup, createRecord, objectNum)
  } catch (err) {
    res.status(400).json({
      message: 'Failed creating leave request.',
      error: err
    })
  }
})

👀 Leave Props

PropDescriptionTypeRequired
payloadData payload from appobjectYes
lookupObject to map keys / fields{key: field}Yes
createRecordFunction to create leave recordfn(obj_num, data, retry?)Yes
objectNumObject to create records innumberYes

📝 Changelog

For every major or minor release changelog/migration-guide will be available in releases

1.5.0

3 years ago

1.4.8

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago