moco

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 8 Imported by: 0

README

moco

Coverage Status

moco/mo·co/ - Membaca

Library to parse Bank mutation CSV and extract information from it.

Installation

$ go get github.com/kitabisa/moco

How to use


import (
	moco "github.com/kitabisa/moco"
)

//Open file
f, err := os.Open("/dir/to/filename.csv")
if err != nil {
	panic(err)
}

r := moco.NewReader(f, moco.BankBCA)
err = r.ReadMutation()
if err != nil {
	panic(err)
}

success := r.GetSuccess() //Array of MutationBank
failure := r.GetFail() //Array of FailRecord

Documentation

Index

Constants

View Source
const (
	BcaMinimumRecordLength    = 2
	BcaIndexNumberDescription = 1
	BcaIndexNumberAmount      = 3
	BcaAmountCreditString     = "CR"
)
View Source
const (
	BniMinimumRecordLength       = 5
	BniIndexNumberDescription    = 4
	BniIndexNumberValidationDate = 0
	BniIndexNumberAmount         = 6
)
View Source
const (
	BriMinimumRecordLength       = 9
	BriIndexNumberDescription    = 8
	BriIndexNumberValidationDate = 6
	BriIndexNumberAmount         = 10
)
View Source
const (
	MandiriMinimumRecordLength          = 5
	MandiriIndexNumberSecondDescription = 5
	MandiriIndexNumberDescription       = 4
	MandiriIndexNumberValidationDate    = 2
	MandiriIndexNumberAmount            = 8
)
View Source
const (
	BankMandiri = "mandiri"
	BankBCA     = "bca"
	BankBRI     = "bri"
	BankBNI     = "bni"
)

Variables

View Source
var BCABlacklist = []string{"TRSF", "E-BANKING", "CR", "DB", "Wallet",
	"User", "BIAYA", "SME", "MFTS", "Dana", "YAY", "KITA", "BISA", "Recurring",
	"Auto", "Debet"}
View Source
var BniBlacklist = []string{"DARI", "TRANSFER", "Sdr", "Sdri", "|", "PEMINDAHAN"}
View Source
var BriBlacklist = []string{"DARI", "KE", "DATE", "TIME", "REMARK", "DEBET", "CREDIT", "TELLER ID"}
View Source
var MandiriBlacklist = []string{
	"SA", "OB", "CA", "No", "Book", "DARI", "Transfer",
	"Otomatis", "KE", "MCM", "InhouseTrf", "KITA", "BISA",
	"Auto", "Overbooking"}

Functions

func BlacklistTrim

func BlacklistTrim(ar, blacklist []string) []string

func NumericTrim

func NumericTrim(s string) (string, error)

func WhitespaceSplit

func WhitespaceSplit(s string) []string

Types

type CsvReader

type CsvReader interface {
	Read() ([]string, error)
	ReadAll() ([][]string, error)
}

func NewCsvReader

func NewCsvReader(r io.Reader, delimiter rune) CsvReader

type FailRecord

type FailRecord struct {
	Raw  string
	Hash string
	Err  error
}

type MutationBank

type MutationBank struct {
	AccountName   string
	AccountNumber string
	Amount        int
	Date          string
	Description   string
	Hash          string
}

type MutationParser

type MutationParser interface {
	LoadRecord(record []string) error
	GetAccountName() string
	GetAccountNumber() string
	GetDescription() string
	GetAmount() string
	GetDate() string
}

func NewBcaParser

func NewBcaParser() MutationParser

func NewBniParser

func NewBniParser() MutationParser

func NewBriParser

func NewBriParser() MutationParser

func NewMandiriParser

func NewMandiriParser() MutationParser

type Parser

type Parser interface {
	LoadRecord(record []string) error
	GetMutation() *MutationBank
}

func NewParser

func NewParser(bankName string) Parser

type RawRecord

type RawRecord struct {
	Raw  string
	Hash string
}

type Reader

type Reader interface {
	ReadMutation() error
	GetSuccess() []MutationBank
	GetFail() []FailRecord
	GetRaw() []RawRecord
}

func NewReader

func NewReader(ioReader io.Reader, bankType string) Reader

Jump to

Keyboard shortcuts

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