gosepa

module
v0.0.0-...-26d664d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2017 License: MIT

README

gosepa

Go Report Card

gosepa is a sepa xml file generator written in Go compatible with pain.002.001.03 schema (Customer Credit Transfer Initiation V03).

This generator uses shortcuts to simplify the norm implementation : for example, there is only one id used for several differents references (I never have to deal with multiple references)

Install

$ go get github.com/softinnov/gosepa/sepa

Usage

    package main

    import (
        "fmt"
        "github.com/softinnov/gosepa/sepa"
        "log"
    )

    func main() {

        doc := &sepa.Document{}
        err := doc.InitDoc("MSGID", "2017-06-07T14:39:33", "2017-06-09", "Emiter Name", "FR1420041010050500013M02606", "BKAUATWWP")
        if err != nil {
            log.Fatal("can't create sepa document : ", err)
        }

        err = doc.AddTransaction("F201705", 70000, "EUR", "DEF Electronics", "GB29NWBK60161331926819")
        if err != nil {
            log.Fatal("can't add transaction in the sepa document : ", err)
        }

        res, err := doc.PrettySerialize()
        if err != nil {
            log.Fatal("can't get the xml doc : ", err)
        }

        fmt.Println(string(res))
    }

Tests

Unit test the go way :

$ go test -v

You can use any xsd validation tool. I use xmllint from libxml.

$ sudo apt install libxml2-utils

You have to generate a file so xmllint can check it. From the sample in the 'tests' folder :

$ go run usage.go > test.xml
$ xmllint --noout --schema pain.001.001.03.xsd test.xml

Ressources

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL