angro-kft / nav-connector Goto Github PK
View Code? Open in Web Editor NEWNode.js module which provides an interface for communicating with NAV online invoice service.
License: GNU General Public License v3.0
Node.js module which provides an interface for communicating with NAV online invoice service.
License: GNU General Public License v3.0
The NavConnector constructor should assign the argument object's properties to the instantiation.
The constructor should also do basic validation on the technicalUser argument.
The queryInvoiceStatus function returnOriginalRequest parameter does not work. The NAV service api does not return the originalRequest property in the response.
Could be a NAV api service upstream issue.
The module entry point should be en event emitter subclass which exposes public APIs and emits error and other events.
The request xml schema has sequential element order requirement. The softwareData object key order must be normalized before creating the request xml.
Az alábbi hibát írja teszt futtatás után:
- queryInvoiceStatus()
"before all" hook: before:
Error: An invoice is still under processing!
at retry (test/lib/wait-invoice-processing.js:81:15)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
A NAV felületén pedig ezt írja gondnak:
A megadott számlaszám egynél többször szerepel a kérésben
- Field [productCodes] contains error: [Invalid content was found starting with element 'productCodes'. One of '{"http://schemas.nav.gov.hu/OSA/1.0/data":lineNumber}' is expected.]
A function should be added to test connection, technicalUser and softwareData validity.
This should be a tokenExchange operation. It throws if connection, technicalUser or softwareData is invalid but an additional testing should be done on the exchange key.
The exchange key length should be 16 character and the returned token should match the [0-9A-Za-z][-] pattern.
The default timeout is 60 sec but the NAV service closes the connection after 60 sec (gateway timeout 504).
The default timeout should be increased to give a chance to the service to close the connection before force close it.
add a validation function which can validate software data with a predefined schema just like technical user validation
The manageInvoiceRequest invoiceOperations param objects key orders must be normalized.
The NavConnector constructor parameters should be extended with a timeout property.
This should set the axios default timeout option to 5500 milliseconds by default but it should be configured.
This is required because during NAV service outages, requests will never timeout if axios timeout option is not set.
The default 5500 milliseconds are sufficient because according to the NAV online invoice service documentation the request timeout is set to 5000 ms on the service side.
const navConnector = new NavConnector({
technicalUser,
softwareData,
baseURL
});
const invoiceData = {
invoiceNumber: '123456',
invoiceIssueDate: '2024-07-24',
supplierName: 'Szállító Kft.',
supplierCountryCode: 'HU',
supplierPostalCode: '1234',
supplierCity: 'Budapest',
supplierStreetName: 'Fő utca 1.',
customerName: 'Vevő Kft.',
customerCountryCode: 'HU',
customerPostalCode: '5678',
customerCity: 'Debrecen',
customerStreetName: 'Kossuth utca 2.',
productName: 'Termék',
quantity: '10',
unitPrice: '1000',
lineAmount: '10000'
};
const invoice = create({ version: '1.0', encoding: 'UTF-8' })
.ele('Invoice', { xmlns: 'http://schemas.nav.gov.hu/OSA/3.0/data' })
.ele('invoiceNumber').txt(invoiceData.invoiceNumber).up()
.ele('invoiceIssueDate').txt(invoiceData.invoiceIssueDate).up()
.ele('supplierInfo')
.ele('supplierName').txt(invoiceData.supplierName).up()
.ele('supplierAddress')
.ele('countryCode').txt(invoiceData.supplierCountryCode).up()
.ele('postalCode').txt(invoiceData.supplierPostalCode).up()
.ele('city').txt(invoiceData.supplierCity).up()
.ele('streetName').txt(invoiceData.supplierStreetName).up()
.up()
.up()
.ele('customerInfo')
.ele('customerName').txt(invoiceData.customerName).up()
.ele('customerAddress')
.ele('countryCode').txt(invoiceData.customerCountryCode).up()
.ele('postalCode').txt(invoiceData.customerPostalCode).up()
.ele('city').txt(invoiceData.customerCity).up()
.ele('streetName').txt(invoiceData.customerStreetName).up()
.up()
.up()
.ele('invoiceLines')
.ele('line')
.ele('lineNumber').txt('1').up()
.ele('productName').txt(invoiceData.productName).up()
.ele('quantity').txt(invoiceData.quantity).up()
.ele('unitPrice').txt(invoiceData.unitPrice).up()
.ele('lineAmount').txt(invoiceData.lineAmount).up()
.up()
.up()
.end({ prettyPrint: true });
const base64 = Buffer.from(invoice).toString('base64');
console.log(base64);
try {
await navConnector.testConnection();
} catch (error) {
console.error("Failed to connect to NAV Online", error);
}
try {
return navConnector.manageInvoice({
compressedContent: false,
invoiceOperation: [
{
index: 1,
invoiceOperation: 'CREATE',
invoice: base64,
},
],
})
login pattern [a-zA-Z0-9]{6,15} should be ^[a-zA-Z0-9]{6,15}$
taxNumber pattern [0-9]{8} should be ^[0-9]{8}$
This pattern validation is incorrect in the specification.
The sendRequest method normalizes error responses and renames schemaValidationMessages property to technicalValidationMessages to match documentation. After NAV service version 0.14 this functionality will be unnecesery because schemaValidationMessages will be technicalValidationMessages by default in the error response.
hello ewol123,
Is nav-connector ready to work with XSD 2.0?
Is branch nav2.0 functional?
Thank you and best regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.