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

@nomada-sh/mx-invoice-tax-calculation

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nomada-sh/mx-invoice-tax-calculation

These functions help you to obtain the tax calculation for an invoice in mexico. You can get the calculation for vat tranferred and witheld, isr and ieps.

  • 1.0.13
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Tax calculation for méxico

These functions help you to obtain the tax calculation for an invoice in mexico. You can get the calculation for vat tranferred and witheld, isr and ieps.

Install package

Install package

$ npm install @nomada-sh/mx-invoice-tax-calculation

or

$ yarn add @nomada-sh/mx-invoice-tax-calculation

How use this package

To use the calculation functions you need to know the structure of a concept, below you can see the interface of a concept

Concept interface

export interface IConcept {
    valorUnitario:            number;
    descuento:                number;
    porcDescuento:            number;
    descripcion:              string;
    cantidad:                 number;
    key:                      string;
    impuestos:                {traslados: ITax[], retenciones: ITax[]};
}

Tax interface

export interface ITax {
    tipoImpuesto         : 'traslado' | 'retencion';
    impuesto             : '001' | '002' | '003':
    nombreImpuesto       : 'IEPS' | 'IVA' | 'ISR';
    valorTasaOcuota      : number;
    valorTasaOcuotaPorc  : number;
    rangoFijo            : string;
    tipoFactor           : string;
    key                  : string;
};
  • 001 -> IEPS.
  • 002 -> IVA.
  • 003 -> ISR.
  • Key -> it's basically a uuid.

Import the functions into project

import { calcMannyConcepts, calculateConceptTax } from '@nomada-sh/mx-invoice-tax-calculation';
import { IConcept } from '@nomada-sh/mx-invoice-tax-calculation/dist/interfaces';
const conceptExample: IConcept = {
  key: '58efbeb4-0b7c-45b4-84e4-9588d3f47dc9',
  descripcion: 'concept1',
  cantidad: 6,
  valorUnitario: 55,
  descuento: 0,
  porcDescuento: 0,
  impuestos: {
    traslados: [
      {
        key: '1c1011aa-040f-496a-b170-0224cd632d53',
        tasaOcuota: '',
        valorTasaOcuota: 0.16,
        valorTasaOcuotaPorc: 16,
        impuesto: '002',
        nombreImpuesto: 'IVA',
        tipoImpuesto: 'traslado',
        rangoFijo: 'Fijo',
        tipoFactor: 'Tasa',
      },
      {
        tipoImpuesto: 'traslado',
        impuesto: '003',
        nombreImpuesto: 'IEPS',
        tasaOcuota: 'f27c5a1c-f445-473d-8727-5feb94a3cca1',
        valorTasaOcuota: 0.30,
        valorTasaOcuotaPorc: 30,
        importeImpuesto: '0.00',
        rangoFijo: 'Fijo',
        tipoFactor: 'Tasa',
        key: 'c2e20350-003c-4326-aabd-5f9c8d3e1121',
      },
    ],
    retenciones: [],
  },
};

Run the functions to get the calculations

calcMannyConcepts

Allows to calculate multiple concepts

const calculatedTaxes = calcMannyConcepts([conceptExample, conceptExample]);
console.log(calculatedTaxes);

calcMannyconcepts's answer

{
    "amount": 660,
    "discount": {
        "value": 0,
        "data": []
    },
    "ivaTransferred": {
        "value": 137.28,
        "data": [
            {
                "value": 68.64,
                "porcentage": 16,
                "desc": "concept1",
                "key": "58efbeb4-0b7c-45b4-84e4-9588d3f47dc9"
            },
            {
                "value": 68.64,
                "porcentage": 16,
                "desc": "concept1",
                "key": "58efbeb4-0b7c-45b4-84e4-9588d3f47dc9"
            }
        ]
    },
    "ivaWitheld": {
        "value": 0,
        "data": []
    },
    "ieps": {
        "value": 198,
        "data": [
            {
                "value": 99,
                "porcentage": 30,
                "desc": "concept1",
                "key": "58efbeb4-0b7c-45b4-84e4-9588d3f47dc9"
            },
            {
                "value": 99,
                "porcentage": 30,
                "desc": "concept1",
                "key": "58efbeb4-0b7c-45b4-84e4-9588d3f47dc9"
            }
        ]
    },
    "isr": {
        "value": 0,
        "data": []
    },
    "subtotal": 660,
    "total": 995.28
}

calculateConceptTax

allows to calculate only one concept

const calculatedTaxes= calculateConceptTax(conceptExample);
console.log(calculatedTaxes);

calculateConceptTax's answer

{
    "key": "58efbeb4-0b7c-45b4-84e4-9588d3f47dc9",
    "description": "concept1",
    "amount": 330,
    "discount": 0,
    "porcDescuento": 0,
    "subTotal": 330,
    "iepsT": {
        "type": "transferred",
        "percentage": 30,
        "valuePercentage": 0.3,
        "factorType": "Tasa",
        "taxName": "IEPS",
        "iepsValue": 99
    },
    "ivaT": {
        "type": "transferred",
        "percentage": 16,
        "valuePercentage": 0.16,
        "taxName": "IVA",
        "ivaValue": 68.64
    },
    "total": 497.64
}

Keywords

FAQs

Package last updated on 27 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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