Package: sinli
SINLIIntroduction and purposeThis package is a libre-free implementation of theSINLI standard.
It builds on top of email to allow applications to communicate all sort of operations of the book sector in Spain.There are 3 main roles in this sector:bookshopsdistributorseditorsThere are some other implementations of this standard, but all of those we know about are closed-source, sell for an expensive yearly license, and work only in Window$ Opressing System.
Thus, small bookshops, independent editors and distributors get tied to these disrespectful technologies, and represent a huge economic drag for them.AtDevcontrolwe are coding for an initiative supported by a union of these independent entities and led byDescontrol.
This initiative is sharing the solution to a shared problem, and is adapting the Odoo ERP (business managing software) to be used for both distributors and bookshops. In order to be a complete replacement of those closed-source apps, we are trying to make Odoo speak SINLI ;)Organisation and code paradigmThis repository is organized following theguidelines for python packages. The actual code source is insidesrc/sinli/.This project is object oriented, and makes use of python@dataclassdecorator andEnumclass.
Namely, the main classes areDocumentandLine. Each SINLI message is aDocument, and each one has manyLines. These two classes must be subclassed for each different document type in a separate file, located insidesrc/sinli/doctype.
Additionaly,Linehas 2 subclasses,SubjectLineandIdentificationLinethat share a common format for all document types.SINLI detailsTransportSINLI uses the email as a common transport, but can be also fetched via FTP or other means if the parties agree to do so.StructureSINLI documents or messages are text-based, one file each, and line-based. There is no special syntax, instead, each line is to be processed separately,
and the different fields in each line are split by their byte position in the line. Therefore, each field has a fixed lenght. In fields where the data has variable lenght, the data is padded with spaces in case of text, and ascii 0 characters in case of numerical fields.SINLI versionsThere are no standard-wide versions in SINLI. Instead, each message type has its own version number. New versions are meant to be backwards compatible to older clients. The standaring committee tries to only add fields at the end of the line, not modifying the lengths or meanings of the existing ones. However, they do not commit to it and call for "get what you can" and for a human check before importing to a system. We support implementing different versions of a document type and parsing them accordingly, but will only implement older versions in a case by case basis. SINLI editors do not like developers implementing old versions because in their opinion, it makes users lazier to update. Because of this and other reasons, older versions specifications are not publicly available.Example codeRead a document from a SINLI filefromsinliimportDocumentd=Document.from_filename("/path/to/document.sinli")Generate a SINLI documentfromsinliimport*fromstdnumimportisbn# Create a catalog documentcatalog=libros.v9.LibrosDoc()catalog.long_id_line.FROM="LIB12345"catalog.long_id_line.TO="LIB98765"catalog.short_id_line.FROM="sinli@provider.example.org"catalog.short_id_line.TO="sinli@library.example.org"# Create the header line of the docheader=libros.v9.LibrosDoc.Header()header.TYPE="C"header.PROVIDER="Traficantes de Sueños"header.CURRENCY="E"catalog.doc_lines.append(header)# Create one book for the catalog documentbook=libros.v9.LibrosDoc.Book()book.EAN="9788494597879"book.ISBN_INVOICE=isbn.format(book.EAN)book.AUTHOR_NAME="Raquel Gutiérrez Aguilar"book.TITLE_FULL="Horizontes comunitario-populares"book.PRICE_PV=12.00book.TAX_IVA=4.00book.PRICE_PVP=book.PRICE_PV/(1+book.TAX_IVA/100)# precio sin IVAbook.PRICE_TYPE="F"catalog.doc_lines.append(book)# Final detailscatalog.long_id_line.LEN=len(catalog.doc_lines)+2# implementation of this field variesExport a SINLI document object to stringimportsinlicatalog:libros.v9.LibrosDoc# ...# SINLI message stringprint(str(catalog))# Debugging stringprint(repr(catalog))GoalsGenericBasic architecture for reading documents and linesRead LIBRO doctypePrepare the repo as an importable python packageImplement document writingManage different document versionsManage table-based fieldsManage different data typesFor bookshopsAlbarán de pedido del clienteAlbarán de devoluciónMensaje de textoFor distributorsFicha del libroCambio de precioAlbarán de envíoFacturaMensaje de texto