1.0.4 • Published 3 years ago

@angro/nav-composer v1.0.4

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

nav-composer

Compose NAV-compatible XML data for use in nav-connector (https://github.com/angro-kft/nav-connector/tree/master/src)

Installion

Tested with version 8.12.0 of Node.js.

$ npm install @angro/nav-composer

Example

const composeXML = require("@angro/nav-composer");

/* data object to compose  */
const request = {
      supplierInfo: {
        taxpayerId: "12345676",
        vatCode: "2",
        countyCode: "41",
        name: "ANGRO Kft.",
        countryCode: "HU",
        postalCode: "5600",
        city: "Békéscsaba",
        streetName: "Kétegyházi",
        publicPlaceCategory: "út.",
        number: "7"
      },
      customerInfo: {
        taxpayerId: "24291763",
        vatCode: "2",
        countyCode: "04",
        name: "VEVŐ Kft.",
        countryCode: "HU",
        postalCode: "5600",
        city: "Békéscsaba",
        streetName: "Kétegyházi",
        publicPlaceCategory: "út",
        number: "7"
      },
      invoiceData: {
        invoiceNumber: "000001-2019-K",
        invoiceCategory: "NORMAL",
        invoiceIssueDate: "2019-05-15",
        invoiceDeliveryDate: "2019-05-15",
        currencyCode: "HUF",
        exchangeRate: 1,
        paymentMethod: "CASH",
        paymentDate: "2019-05-15",
        invoiceAppearance: "PAPER"
      },
      invoiceLines: [
        {
          lineNumber: 1,
          lineDescription: "BOMBA",
          quantity: 10,
          unitOfMeasure: "PIECE",
          unitPrice: 120,
           lineDiscountData: {
              discountValue: 60
              discountRate: 0.05
          },
          lineAmountsNormal: {
            lineNetAmount: 1140,
            lineVatRate: { vatPercentage: 0.27 }
          },
        }
      ],
      invoiceSummary: {
        summaryByVatRate: [
          {
            vatRate: { vatPercentage: 0.27 },
            vatRateNetAmount: 1140,
            vatRateVatAmount: 307.8,
            vatRateVatAmountHUF: 307.8
          }
        ],
        invoiceNetAmount: 1140,
        invoiceVatAmount: 307.8,
        invoiceVatAmountHUF: 307.8,
        invoiceGrossAmount: 1450
      }
    };

      const base64Xml = composeXML(request);

API

composeXML

/**
 * Create an xml string from an object and encode it to Base64.
 * @param {Object} rawData object to compose.
 * @throws {string} will throw an error if any of the validation fails, or there is any error
 * @returns {string} Base64 encoded xml string.
 */
const base64Xml = composeXML(rawData);

Tests

$ npm run test
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago