update ledger tools

master
Michael Raitza 2020-11-28 20:42:02 +01:00 committed by Michael Raitza
parent 5569cb32d4
commit 4104ab089b
5 changed files with 25 additions and 26 deletions

View File

@ -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

View File

@ -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 Normal file
View File

@ -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 ];
};
}

View File

@ -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"