1.0.4 • Published 6 years ago
@angro/nav-composer v1.0.4
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