# Avetmiss

**Elixir library to generate AVETMISS reports**

## Installation

Add `avetmiss` to your list of dependencies in `mix.exs`:

def deps do
    {:avetmiss, "~> 0.1.0"}

## Usage

import Avetmiss.Report
alias Avetmiss.Nat.{Nat010, Nat020, Nat030, Nat060 ...}

# define your generate_report function that exports all required files
def generate_report(destination) do
  files = [
    {'./nat00010.txt', generate_nat010()},
    {'./nat00020.txt', generate_nat020()},
    {'./nat00030.txt', generate_nat030()},
    {'./nat00060.txt', generate_nat060()},

  :zip.create("#{destination}/", files)

defp generate_nat010() do
  # collect the necessary data (typically from the db)
  rtos = ...

  # create your rows by feeding a Nat010 Struct into the nat010_row function, fn rto ->
          contact_name: rto.contact_name,
          telephone_number: rto.telephone_number,
          facsimile_number: rto.facsimile_number,
          email_address: rto.email_address
    # join your rows with Line Feeds to create the file content
    |> Enum.join("\n")

# ... repeat for other NAT files

## NAT Structs
As we saw above, the NAT Structs are at the core of the library's API. They are located in the `./lib/nat` folder.

I recommend to alias the NAT Structs that you need:
alias Avetmiss.Nat.{Nat010, Nat020, Nat030, Nat060 ...}

Once imported, all that's left to do is populate them with your data and feed them into the `nat*_row` functions as seen above.

## NAT row functions
The NAT Structs are then fed into `nat*_row` functions located in `./lib/report.ex`. I recommend to import them:
import Avetmiss.Report

## AVETMISS config
There is a config file exposed in `./lib/config.ex` in a `[{code, name}]` list of tuple format.

It exposes the standard AVETMISS config that you'll need for reporting such as genders, indigenous statuses, disabilities etc.

## What is this AVETMISS thing anyhow?

If you've never heard of it, you porbbaly don't need this libary.
AVETMISS is an acronym that stands for Australian Vocational Education and Training Management Information Statistical Standard.
Most Registered Training Organisations (RTOs) have to generate and submit AVETMISS reports for statistical purpose and for caliming funding. 
This library helps you to do so in Elixir. It defines a simple API based on Structs, and does all the formatting, validating etc. for you.

This here is a technical overview of how AVETMISS reports and NAT files work:
[What is Avetmiss, and how does it work? A technical dive](