### edifact_orders_iso_16033

`1.1.1`
Need help reading this?

### Edi

Edi this class serves as an Edi writer

before writing a new message, you must call the `.reset` method

new Edi()
Static Members
▸ escape(str)

for internal use only

escape(str: any)
Parameters
str `(any)`
▸ compact(lines)

remove the leading,trailing and LF in order to be complient with EDIFACT EDIFACT strings are multiline in the test only for readability

compact(lines: any)
Parameters
lines `(any)`
▸ date(datestr)

return a Date from an edi date str compatible with SQL

date(datestr: any)
Parameters
datestr `(any)`
▸ datetime(dt)

convert dt to an datetime string YYYY-MM-DD HH:MM:SS

datetime(dt: any)
Parameters
dt `(any)` can either be an element ['YYYYMMD','HHMM'] or a YYYYMMDDHHMM string
Instance Members
▸ reset()

reset this method clear the current edifact string and reset the internal state of Edi

it has to be called before any new message.

reset()
▸ writeSegment(segment, elements)

writeSegement write a segment of name `segment` with a number of elements. if an element is a complex element (= with more than one component), all components should be passed as an array.

If an element must be empty, pass undefined if this is not the last defined element.

writeSegment(segment: any, elements: ...any)
Parameters
segment `(any)` {string} the name of the segment (3 UpperCase chars)
elements `(...any)` {... string | array}
Example

    let edi = new Edi();
    edi.writeSegment('UNB',['UNOC',1],'WS','ESTORE','NOV',['20181001','1255'],'253006',undefined,'ESTORE');

▸ writeElements(elements)

for internal use only

writeElements(elements: any)
Parameters
elements `(any)`
▸ writeComponent(component)

for internal use only

writeComponent(component: any)
Parameters
component `(any)`

### Segment

Segment this class represent a segment with all elements / component

new Segment(segment: any)
Parameters
segment `(any)`
Instance Members
▸ val(element, component)

return the value of a given element/component of the segment if the element or component doen't exist, return undefined.

val(element: int, component: int)
Parameters
element `(int)` the number of the element of the segment
component `(int)` the number of the compenent of the element or undefined if all components must be returned

### Message

Message The super class for all message interpreters.

Implement the mechanism of message interpretation but does noting in itself since it has no implementation of any segment

new Message(encoding: any, segments: any, elements: any)
Parameters
encoding `(any)`
segments `(any)`
elements `(any)`
Instance Members
▸ reset()

reset is called at the beginning of interpret and must clear all previous data.

should be overwritten by the class that extends Message

reset()
▸ interpret(edifact)

Interpret an EDIFACT Messaage by calling methods for each segment

Errors will be reported by exceptions

interpret(edifact: string)
Parameters
edifact `(string)` the edifact string
▸ expect(variable, values, message)

throw an error if variable has not an expected value

variable = the variable to check values an expected value or an array of expected value. if undefined, doesn't check, just print the message

returns variable if everything ok

expect(variable: any, values: any, message: any)
Parameters
variable `(any)`
values `(any)`
message `(any)`
▸ expectVal(elementNumber, componentNumber, values)

check that a given component has a given value or is in a given set of values

expectVal(elementNumber: any, componentNumber: any, values: any)
Parameters
elementNumber `(any)` of the current segment
componentNumber `(any)` in the element
values `(any)` either a string or an array of string
▸ setProp(obj, property, elementNumber, componentNumber)

set a property if the given element / component is defined

setProp(obj: object, property: string, elementNumber: number, componentNumber: number)
Parameters
obj `(object)` the object to set a property
property `(string)` the property name
elementNumber `(number)` the element number of the current segment
componentNumber `(number)` the number of the component to look for. if undefined, the array of components is put into the property

if either the element or element.component of the _currentSegment is undefined, nothing is done

▸ openSegment(segment)

understand the previous segment and open a new one in order to collect elements

openSegment(segment: any)
Parameters
segment `(any)` name of the segment

### Order16033

Order16033 a parser for ORDERS according to ISO16033

new Order16033()

Extends Message

Instance Members
▸ reset()

reset must be call before interpreting a new message.

reset()