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

taxapi

v1.1.0

Published

A Node.js module for Iranian tax API (سامانه مودیان مالیاتی)

Downloads

18

Readme

Iranian Tax Api (Version 1 only)

MIT License

INstall:

npm i taxapi

or use yarn:

yarn add taxapi

Table of contents

  1. Introduction
  2. What you need?
  3. Get Token
  4. Get Server Information
  5. Send Invoices
  6. Inquire Invoices
  7. Inquire Client Economic Code
  8. Inquire Fiscal ID
  9. Utils
  10. Types

Introduction

you need to read the full documentry of the "Modian" version 1 tax Api PDF. the pdf is available from intamedia.ir

this package is only for Nodejs not Browser.

What you need?

  1. Fiscal ID
  2. Private key
  3. Economic ID

also make sure that you have access to tax api from iranian ip address

Get Token

  import { TaxApiV1 } from "./v1";

  const api = new TaxApiV1(
    '[pem file path or content]', 
    '[fiscal id]', 
    '[economic id]', 
    'self-tsp'
  );

  const tokenResponse = await api.getToken();

  const {expiresIn, token} = tokenResponse.result.data

Get Server Information

  import { TaxApiV1 } from "./v1";

  const api = new TaxApiV1('[pem file path or content]', '[fiscal id]', '[economic id]', 'self-tsp');

  const serverInformation = await api.getServerInformation();

  const {publicKeys} = serverInformation.result.data;

  const publicKey = publicKeys[0]

Send Invoices

import { TaxApiV1 } from "./v1";

const api = new TaxApiV1('[pem file path or content]', '[fiscal id]', '[economic id]', 'self-tsp');

const response = await api.sendInvoiceNormal({
    invoices: {
        '[invoice-1-uid]': { ...},
        '[invoice-2-uid]': { ...},
        '[invoice-3-uid]': { ...},
        ...
    },
    publicKey,
    token
    retry: ['uid-of-retrying-invoice', ...],
});

response.result.forEach(invoiceResult => {
    const uid = invoiceResult.uid;

    // update invocie properties by uid
})

Inquire Invoices

import { TaxApiV1 } from "./v1";

const api = new TaxApiV1('[pem file path or content]', '[fiscal id]', '[economic id]', 'self-tsp');

const response = await api.inquireByUID(token, ['uid-1', 'uid-2', ...]);

response.result.data.forEach(item => {
    const status = item.status // SUCCESS | FAILED | PENDING | IN_PROGRESS
    if(status === "FAILED") {
        const errors: {code: string, message: string}[] = item.data.error
    }
    const uid = item.uid;
    //update invoices in database
})

Inquire Client Economic Code

import { TaxApiV1 } from "./v1";

const api = new TaxApiV1('[pem file path or content]', '[fiscal id]', '[economic id]', 'self-tsp');

// no token needed
const response = await api.inquiryEconomicCode()

const {nameTrade, nationalId, taxpayerStatus} = response

Inquire Fiscal ID

import { TaxApiV1 } from "./v1";

const api = new TaxApiV1('[pem file path or content]', '[fiscal id]', '[economic id]', 'self-tsp');

const response = await api.getFiscalId(token)

const {economicCode, fiscalStatus, nameTrade, saleThreshold} = response.result.data

Utils

import { generateTaxId, getRandomSerialDecimal } from "taxapi";

// if your client doesn't provide initial serial number
const initialSerialNumber = getRandomSerialDecimal();

//replace new Date() with date object of invoice date
const taxid = generateTaxId('fiscalId', new Date(), initialSerialNumber)

//convert serial to taxApi serial
const inno = initialSerialNumber.toString(16).padStart(10, '0')

Types

import { Version1, TaxApi_v1_InvoiceBody, TaxApi_v1_InvoiceHeader, TaxApi_v1_InvoicePayment } from "taxapi";


const header: TaxApi_v1_InvoiceHeader = {}
const body: TaxApi_v1_InvoiceBody = []
const payments: TaxApi_v1_InvoicePayment = []


const fullInvoice: Version1.TaxApiInvoice = {
    header,
    body,
    payments: []
}

Need Help? or want to donate?

call us if you want to donate or need help:

09038719255

License

MIT