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

node-tra-sdk

v0.1.4

Published

The **TRA SDK for Node.js** makes it easy for developers to access [TRA API](#) in their Javascript code, and build robust applications.

Downloads

36

Readme

TRA SDK for Node

The TRA SDK for Node.js makes it easy for developers to access TRA API in their Javascript code, and build robust applications.

This package implements TRA (Tanzania Revenue Authority) APIs currently supporting VFD API only

Documentation

Take a look at the API docs here.

Features

  • VFD API
  • TypeScript support
  • Latest Node.js support
  • Data Validation

🚀 Usage

Installation

via npm

npm install node-tra-sdk

via Yarn

yarn add node-tra-sdk

Load key certificate

Before calling any APIs, you will need to load your key certificate. You can use this helper function to do so.

import { loadKeyCertificate } from 'node-tra-sdk';

const { key } = await loadKeyCertificate('YOUR_KEY_FILE PATH', 'YOUR_KEY_PASSWORD');

Registration

To get details about your company you need to call registration API. You call this once. You can reuse the result in the next steps.

import { sendRegistrationRequest } from 'node-tra-sdk';

//test environment details
const hostname = 'virtual.tra.go.tz';
const path = '/efdmsRctApi/api/vfdRegReq';

const response = await sendRegistrationRequest({
  tin: 'YOUR TIN',
  certKey: 'YOUR CERT KEY',
  signKey: key, // key loaded from first step
  certSerial: 'YOUR CERT SERIAL',
  hostname: hostname,
  path: path,
});

//if successful, response.success == true
const { success, data } = response;

Token

To upload receipts/invoices you will need to provide a token to TRA API. To get the token call this helper function.

import { sendTokenRequest } from 'node-tra-sdk';

//test environment details
const hostname = 'virtual.tra.go.tz';
const path = '/efdmsRctApi/vfdtoken';

const response = await sendTokenRequest({
  username: 'USERNAME_FROM_REGISTRATION_API',
  password: 'PASSWORD_FROM_REGISTRATION_API',
  grantType: 'password',
  hostname: hostname,
  path: path,
});

// if successful, response.success == true
const { success, data } = response;

Upload invoice/receipt

import { sendUploadInvoiceRequest } from 'node-tra-sdk';

//test environment details
const hostname = 'virtual.tra.go.tz';
const path = '/efdmsRctApi/api/efdmsRctInfo';

const response = await sendUploadInvoiceRequest({
  tin: 'YOUR TIN',
  signKey: key, // key loaded from first step
  certSerial: 'YOUR CERT SERIAL',
  token: 'YOUR TOKEN',
  routingKey: 'ROUTING KEY FROM REGISTRATION API',
  hostname: hostname,
  path: path,
  date: '2021-02-03',
  time: '20:52:53',
  regId: 'REGID_FROM_REGISTRATION_API',
  efdSerial: 'EFDSERIAL_FROM_REGISTRATION_API',
  receiptCode: 'RECEIPTCODE_FROM_REGISTRATION_API',
  rctNum: '10103',
  zNum: '20210203',
  dc: '1',
  gc: '10103',
  customerId: '',
  customerIdType: '6',
  customerName: 'John Doe',
  mobileNumber: '255755123123',
  items: [
    {
      ID: 1,
      DESC: 'Product 1',
      QTY: 1,
      TAXCODE: 1,
      AMT: '118000.00',
    },
  ],
  totals: {
    TOTALTAXEXCL: '100000.00',
    TOTALTAXINCL: '118000.00',
    DISCOUNT: '0.00',
  },
  payments: {
    PMTTYPE: 'EMONEY',
    PMTAMOUNT: '118000.00',
  },
  vatTotals: {
    VATRATE: 'A',
    NETTAMOUNT: '100000.00',
    TAXAMOUNT: '18000.00',
  },
});

// If successful, response.success == true
const { success, data } = response;

📚 References

📝 License

This project is licensed under the MIT License.

🙌 Credits