npm.io
0.0.17 • Published 8 years ago

efonelfo

Licence
MIT
Version
0.0.17
Deps
2
Size
22 kB
Vulns
1
Weekly
0

EfoNelfo

JavaScript library for parsing and writing EfoNelfo v4.0 documents.

Installation

npm install efonelfo

Examples

Parse CSV file
import {parseCSVFile} from 'efonelfo'
const [bh] = await parseCSVFile('B42.123.csv')

console.log(bh.KundeNr)
Parse CSV string
import {parseCSV} from 'efonelfo'
const csv ='BH;EFONELFO;4.0;;NO950349875MVA;2091;28579;;;19271;;19271;;;;;;;2091/19271;;;;20100602;;;;;;;;;;;;;;;;;;;;;;;;;;'
const [bh] = await parseCSV(csv)
Working with objects
import {PostTypes, toCSV} from 'efonelfo'
const {BH, BL} = PostTypes
const bh = BH({
  KjøpersId: '11233',
  BestNr: '231444',
  LevDato: new Date('2012-06-21')
})

bh.EksternRef = 'my reference'
bh.push({PostType: 'BL', LinjeNr: '1', Ant: 3, PrisEnhet: 'EA', DelLev: true})
bh.push(BL({LinjeNr: '2', Ant: 10, VareNr: '12345'}))

// Generate CSV
console.log(toCSV(bh))

/* Result:
BH;EFONELFO;4.0;;11233;231444;;;;;;;;;;;my reference;;;;;;20120621;;;;;;;;;;;;;;;;;;;;;;;;;;
BL;1;;;;;;300;EA;;;;J;J
BL;2;;;12345;;;1000;;;;;J;J
*/