Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/willingham/x12-utils
Utilities for generating and validating x12 EDI
https://github.com/willingham/x12-utils
edi x12
Last synced: 2 months ago
JSON representation
Utilities for generating and validating x12 EDI
- Host: GitHub
- URL: https://github.com/willingham/x12-utils
- Owner: willingham
- Created: 2019-04-21T01:53:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T14:08:22.000Z (4 months ago)
- Last Synced: 2024-09-24T16:36:16.511Z (3 months ago)
- Topics: edi, x12
- Language: Python
- Size: 20.5 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# X12 Utils
Lightweight utilities for working with x12 EDI## Background & Purpose
Around 2010, I started working with EDI in a limited capacity. At the time, I had no clue what it was, and didn't seem to find too much free help on the internet. So, after spending countless hours digging through vendor-specific companion guides and comparing them to previously generated EDI, I was finally able to understand what was going on.I've been writing Python packages to generate EDI for various organizations since around 2013. In those projects I have used string concatenatiion, Jinja templating, Django templating, and a few more methods to generate EDI. After much trial and error, I landed on a method to generate the EDI that was easy to maintain. That is the `x12_generator` included in this repository.
Since there is another crucial step, validating the resulting EDI, I have also included the `x12_validator` module which is a lightweight wrapper around the great work done on [pyx12](https://github.com/azoner/pyx12) by @azoner.
## Installation
``` sh
pip install x12-utils
```## Included Utilities
### Generator
The `x12_generator` is a small helper for generating syntactically correct x12 EDI, however, does not assist in ensuring correct structure at all.
#### Usage
``` py
from x12_utils.x12_generator import x12_generategenerator_input = [
("ISA", ["00", " ", "00", " ", "ZZ"]),
("GS", ["BE", " ", "00", " ", "ZZ"]),
("ST", ["00", " ", "00", " ", "ZZ"]),
("SE", ["00", " ", "00", " ", "ZZ"]),
("GE", ["00", " ", "00", " ", "ZZ"]),
("IEA", ["00", " ", "00", " ", "ZZ"]),
]edi = x12_generate(src=generator_input)
# `edi` will look like:
# ISA*00* *00* *ZZ~
# GS*BE* *00* *ZZ~
# ST*00* *00* *ZZ~
# SE*00* *00* *ZZ~
# GE*00* *00* *ZZ~
# IEA*00* *00* *ZZ~
#
# Note: This is not structurally valid EDI, just an example to show the format.```
### Validator
The `x12_validator` is a light wrapper around @azoner's [pyx12](https://github.com/azoner/pyx12) intended for use in other projects.
#### Usage
``` py
from x12_utils.x12_validator import x12_validateresult = x12_validate(
src=edi, # String or file-like object
params=None, # Valid [pyx12](https://github.com/azoner/pyx12) params or None
generate_html=False, # Passed to [pyx12](https://github.com/azoner/pyx12)
generate_997=False, # Passed to [pyx12](https://github.com/azoner/pyx12)
generate_xml=False, # Passed to [pyx12](https://github.com/azoner/pyx12)
)
# Assuming valid EDI, `result` will look like
# {
# "997": "",
# "errors": "",
# "html": "",
# "ok": True,
# "xml": ""
# }```
## Documentation
Just read the code. The docstrings explain it.