Browse Source

update ledger tools

master
Michael Raitza 10 months ago
committed by Michael Raitza
parent
commit
4104ab089b
  1. 2
      default.nix
  2. 23
      gledger/default.nix
  3. 21
      ledger-tools/default.nix
  4. 0
      ledger-tools/gledger
  5. 5
      ledger-tools/ledger-camt-csv

2
default.nix

@ -51,6 +51,6 @@ let
# # pijul = callPackage ./pijul.nix { rustPlatform = super.makeRustPlatform { inherit (self.rustChannelOf { date = "2019-01-04"; channel = "nightly"; }) rustc cargo; }; };
# pijul = callPackage ./pijul.nix { rustPlatform = super.makeRustPlatform { inherit (_self.latest.rustChannels.nightly) rustc cargo; }; };
myR = super.rWrapper.override { packages = with super.rPackages; [ ggplot2 lintr tikzDevice rlang ]; };
gledger = callPackage ./gledger { };
ledgerTools = callPackage ./ledger-tools { };
};
in _self

23
gledger/default.nix

@ -1,23 +0,0 @@
{ stdenv, gnupg, ledger, writeScriptBin }:
let gledger = ''
'';
in stdenv.mkDerivation {
pname = "gledger";
version = "2";
phases = [ "installPhase" "fixupPhase" ];
binpath = stdenv.lib.makeBinPath [ gnupg ledger ];
installPhase = ''
mkdir -p $out/bin
substituteAll ${./gledger} $out/bin/gledger
cp ${./gledger-camt-csv} $out/bin/gledger-camt-csv
chmod +x $out/bin/*
'';
meta = with stdenv.lib; {
description = "GNUPG wrapper and tools for ledger";
maintainers = with maintainers; [ spacefrogg ];
};
}

21
ledger-tools/default.nix

@ -0,0 +1,21 @@
{ stdenv, gnupg, ledger, writeScriptBin }:
stdenv.mkDerivation {
pname = "ledger-tools";
version = "2";
phases = [ "installPhase" "fixupPhase" ];
binpath = stdenv.lib.makeBinPath [ gnupg ]; # use ledger once in nixpkgs
installPhase = ''
mkdir -p $out/bin
cp ${./ledger-camt-csv} $out/bin/ledger-camt-csv
substituteAllInPlace $out/bin/ledger-camt-csv
chmod +x $out/bin/*
'';
meta = with stdenv.lib; {
description = "ledger tools";
maintainers = with maintainers; [ spacefrogg ];
};
}

0
gledger/gledger → ledger-tools/gledger

5
gledger/gledger-camt-csv → ledger-tools/ledger-camt-csv

@ -3,8 +3,9 @@
# Sparkasse Germany VISA CSV format
set -e
PATH=@binpath@:$PATH
[ $# -ge 2 ] || { printf "Usage: gledger-camt-csv [-visa | -camt] CSV ACCOUNT\n">&2; exit 1; }
[ $# -ge 2 ] || { printf "Usage: ledger-camt-csv [-visa | -camt] CSV ACCOUNT\n">&2; exit 1; }
CAMT_HDR=",date,posted,,note,,,,,,,payee,pIBAN,pBIC,amount,,"
VISA_HDR=",date,posted,oAmount,oCommodity,,amount,,payee,note,,,,,,"
@ -34,7 +35,7 @@ OUTFILE=$BASEDIR/tmp/$(basename "${INFILE%.CSV}.ledger")
{ echo "$HDR"; tail -n+2 "$INFILE"; } |
sed -e 's/";"/","/g' |
iconv -f ISO-8859-1 -t UTF-8 >$MANGLED
gledger convert "$MANGLED" --input-date-format "$DATE_FMT" --invert --rich-data --account $2 >$OUTFILE
ledger convert "$MANGLED" --input-date-format "$DATE_FMT" --invert --rich-data --account $2 >$OUTFILE
echo "$BASEDIR/new/"$(basename "$OUTFILE") >&2
rm -f "$MANGLED"
mv "$INFILE" "$BASEDIR/cur"
Loading…
Cancel
Save