Invoice2storage

Easy handling for invoices in cooperate environments.

Workflow:

Each user gets a folder accessible for the office. Users can forward their invoices to a special email address like invoice+bob.allen@example.com

The office has one place where all invoices are collected.

Operation

This script is used a a email filter to process incoming invoice emails.

  1. This script parses emails from stdin or file
  2. It determines the user this invoice belongs to
  3. It tries to extracts all attachments of certain mime types, defaults to pdf files.
  4. It stores the extracted attachments according in the folder specified by template
  5. It stores the email in the folder and backend configured

Installation

Using cargo

bash cargo install invoice2storage

Using nix flake

You can add this repository to your NixOS flake configuration.

Configuration

All settings can be passed through command line arguments or put into a yaml file. See --help for a full list of options.

MTA configuration

Most MTA support .forward pipe support which allows you to configure invoice2storage like this:

~/.forward contains:

sh |/path/to/invoice2storage --arguments....

Development

All dev tools use the nix package manager, which can be used on any linux distribution. This allows 100% reproducible and working dev environments.

Development server

Integration test is done with a NixOS VM that is created with:

```bash nixos-rebuild build-vm --flake .#testvm

QEMU_OPTS="-netdev bridge,id=hn0,br=intern -device e1000,netdev=hn0" ./result/bin/run-i2s-test-vm ```

The QEMU_OPTS depend on your system, in this example, the VM is attached to local bridge intern.

The tests can be run with: bash env RUST_BACKTRACE=1 TARGET=10.0.42.158 /home/poelzi/b1/invoice2storage/scripts/nix-cargo test --package invoice2storage --bin invoice2storage -- --include-ignored

The environment variables TARGET is the VM address.

Suggested VSCode workspace settings

json "cSpell.customDictionaries": { "custom-dictionary-workspace": { "name": "custom-dictionary-workspace", "path": "${workspaceFolder:invoice2storage}/.cspell/custom-dictionary-workspace.txt", "addWords": true, "scope": "workspace" } }, "rust-analyzer.runnables.command": "${workspaceFolder}/scripts/nix-cargo", "cargo.automaticCheck": false,