2. Infrastructure functions

process

AppliGeneralLedger.processFunction
process(entries::Array{JournalEntry, 1}, path_journal="./journal.txt", path_ledger="./ledger.txt", )

It adds a JournalEntry to the file path_journal, converts it into Record's, and adds them to the file path_ledger.

@see also read_from_file

Example

julia> include("./src/infrastructure/infrastructure.jl")
process (generic function with 1 method)

julia> entry1 = create_journal_entry("20200700", "APPLI", "A1001", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
JournalEntry("20200700", 3, 2020-03-03T13:31:07.953, "APPLI", "A1001", 1300, 8000, 1000.0, 0.0, 210.0, "LS")

julia> entry2 = create_journal_entry("20201500", "PRG", "A1002", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
JournalEntry("20201500", 3, 2020-03-03T13:31:07.955, "PRG", "A1002", 1300, 8000, 1000.0, 0.0, 210.0, "LS")

julia> process([entry1, entry2])
source

read_from_file

AppliGeneralLedger.read_from_fileFunction
function read_from_file(path::String)::Array{Any, 1}

It reads (structured) data back from a file.

Example

julia> include("./src/infrastructure/infrastructure.jl")
process (generic function with 1 method)

julia> entry1 = create_journal_entry("20200700", "APPLI", "A1001", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
JournalEntry("20200700", 3, 2020-03-03T13:32:46.7, "APPLI", "A1001", 1300, 8000, 1000.0, 0.0, 210.0, "LS")

julia> entry2 = create_journal_entry("20201500", "PRG", "A1002", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
JournalEntry("20201500", 3, 2020-03-03T13:32:46.702, "PRG", "A1002", 1300, 8000, 1000.0, 0.0, 210.0, "LS")

julia> process([entry1, entry2])

julia> r = read_from_file("./test_journal.txt")
2-element Array{Any,1}:
 JournalEntry("20200700", 3, 2020-03-03T13:32:46.7, "APPLI", "A1001", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
 JournalEntry("20201500", 3, 2020-03-03T13:32:46.702, "PRG", "A1002", 1300, 8000, 1000.0, 0.0, 210.0, "LS")
source