npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qlink-pdi-client

v0.2.0

Published

A Node.js library to interact with the QLINK Standard Electronic Payroll Deduction Interface API (version 7.x.x). This is the initial release tailored for QLINK's payroll deduction services.

Downloads

127

Readme

Node LTS License

QLink Payroll Deduction Interface (PDI) QLinkClient Library

This library provides a client for sending requests to the QLink API, specifically supporting payroll deductions (SEPDI, FEPDI) and error handling.

Prerequisites

To use the qlink-pdi-client, ensure you have the following environment variables configured in a .env file:

QLINK_USER=yourUsername
QLINK_PASSWORD=yourPassword
QLINK_URL=https://govtest.qlink.co.za/cgi-bin/XmlProc
QLINK_INSTITUTION_ID=9999
QLINK_LOG_LEVEL=DEBUG

Usage Example

Here’s how to use the library to establish a connection, send a SEPDI deduction, and perform bulk FEPDI deductions. Note: All SEPDI and FEPDI transactions types (TRX) must be set to Q_LINK_TRANSACTIONS (5)

Step-by-Step Example


import dotenv from 'dotenv';
import { Configuration, CreateInsurancePayrollDeductionFields, DeductionType, DeleteInsurancePayrollDeductionFields, MandateCapture, PayrollIdentifier, QLinkClient, UpdateAmountFields, UpdateReferenceFields } from 'qlink-pdi-client';

dotenv.config();

const main = async () => {
  const qlink = new QLinkClient(
    {
      institution: Number(process.env.QLINK_INSTITUTION_ID),
      password: process.env.QLINK_PASSWORD,
      username: process.env.QLINK_USERNAME,
      baseUrl: process.env.QLINK_URL,
    } as Configuration
  )

  await qlink.testConnection();

  const governmentEmployeeNumber = "84177942";
  const employee = await qlink.queryEmployeeInfo({ employeeNumber: governmentEmployeeNumber, payrollIdentifier: PayrollIdentifier.PERSAL });
  console.log(employee);

  const beginDeductionFrom = new Date("2024-12");
  let amount: number = 10000;
  let refNumber: string = "ASQ6543FHAHDCS1";
  const deductionFields: CreateInsurancePayrollDeductionFields = {
    employeeNumber: governmentEmployeeNumber,
    amount: amount,
    beginDeductionFrom: beginDeductionFrom,
    referenceNumber: refNumber,
    deductionType: DeductionType.SEPDI_INSURANCE_LIFE,
    payrollIdentifier: PayrollIdentifier.PERSAL,
    mandateCapturedOn: MandateCapture.PAPER_MANDATE,
  }
  const results1 = await qlink.createInsurancePayrollDeduction(deductionFields);
  console.log(results1);

  amount += 10000;
  const updateDeductionFields: UpdateAmountFields = {
    employeeNumber: governmentEmployeeNumber,
    amount: amount,
    beginDeductionFrom: beginDeductionFrom,
    referenceNumber: refNumber,
    deductionType: DeductionType.SEPDI_INSURANCE_LIFE,
    payrollIdentifier: PayrollIdentifier.PERSAL,
  }
  console.log(updateDeductionFields);
  const results2 = await qlink.updateDeductionAmount(updateDeductionFields);
  console.log(results2);

  refNumber = "A222222";
  const fixDeductionFields: UpdateReferenceFields = {
    employeeNumber: governmentEmployeeNumber,
    amount: amount,
    beginDeductionFrom: beginDeductionFrom,
    referenceNumber: refNumber,
    deductionType: DeductionType.SEPDI_INSURANCE_LIFE,
    payrollIdentifier: PayrollIdentifier.PERSAL,
  }
  console.log(fixDeductionFields);
  const results3 = await qlink.updateDeductionReferences(fixDeductionFields);
  console.log(results3);

  const delDeductionFields: DeleteInsurancePayrollDeductionFields = {
    employeeNumber: governmentEmployeeNumber,
    payrollIdentifier: PayrollIdentifier.PERSAL,
    referenceNumber: refNumber,
    amount: amount,
    cancelDeductionFrom: beginDeductionFrom,
    deductionType: DeductionType.SEPDI_INSURANCE_LIFE,
  }
  console.log(delDeductionFields);
  const results4 = await qlink.deleteDeduction(delDeductionFields);
  console.log(results4);
};

main();

Explanation

  • QLinkClient Configuration: Initializes the connection using QLinkClient with environment-based configuration and transaction details. QlinkClient exposes service methods for retrieving employee information and managing payroll deductions.
  • Error Handling: Wrap calls in try/catch blocks to handle custom QLinkError or unexpected errors.

Development Environment Setup

  1. Ensure your public IP address is registered with QLink by running:

    curl ifconfig.me
  2. Set up the development environment:

    curl -o setup-remote-env.sh https://raw.githubusercontent.com/RootBank/qlink-pdi-client/refs/heads/main/setup-remote-env.sh
    chmod +x setup-remote-env.sh
    sudo ./setup-remote-env.sh
  3. Configure SSH access for your remote EC2 environment:

    # ~/.ssh/config
    Host sandbox-dev
        HostName <ip address> # from private subnet
        User ec2-user
        IdentityFile ~/.ssh/id_ed25519
        ProxyJump sandbox-jumphost
    
    Host sandbox-jumphost
        HostName <ip address> # from public subnet
        User ec2-user
        IdentityFile ~/.ssh/id_ed25519
        ForwardAgent yes

Design Notes

  1. Human-Readable Models: Models are designed with human-readable names (e.g., institution, transactionType) for code clarity.
  2. Explicit Serialization: Conversion to QLink’s format happens at the serialization stage, ensuring business logic remains readable.
  3. Separated Concerns: Business logic, core models, and serialization are distinct for maintainability.
  4. Error Handling: Custom errors are used for handling QLink-specific and HTTP errors gracefully.

Example Environment Variables

Make sure to include these environment variables in your .env file:

QLINK_USER=yourUsername
QLINK_PASSWORD=yourPassword
QLINK_URL=https://govtest.qlink.co.za/cgi-bin/XmlProc
QLINK_INSTITUTION_ID=9999
QLINK_LOG_LEVEL=DEBUG

Now you’re all set to integrate with the QLink API using qlink-pdi-client!