From: Julien Moutinho Date: Sat, 2 Aug 2014 00:21:01 +0000 (+0200) Subject: Ajout : rangement. X-Git-Tag: v2014.08.02^0 X-Git-Url: http://git.cyclocoop.org/?p=tool%2Fhledger.git;a=commitdiff_plain;h=707b0a621cd3c97d5d7e22e855272b3f865a2d56 Ajout : rangement. --- diff --git a/.gitignore b/.gitignore index 52b380e..afed073 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1 @@ *.csv -*.o -*.hi -hledger-equity -hledger-print-csv -hledger-range-voting diff --git a/.gitmodules b/.gitmodules index 0310995..4450feb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lib/tool/asciidoc"] path = lib/tool/asciidoc - url = ./asciidoc + url = git://git.autogeree.net/tool/asciidoc diff --git a/Makefile b/Makefile deleted file mode 100644 index ebeb609..0000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -hs=$(wildcard *.hs) -chart=$(wildcard chart/*/*.hledger) - -all: $(hs:.hs=) $(chart:.hledger=.csv) - -c clean: \ - $(hs:.hs=.o/clean) \ - $(hs:.hs=.hi/clean) \ - $(hs:.hs=/clean) \ - $(chart:.hledger=.csv/clean) -%/clean: - $(if $(wildcard $*),rm -f "$*") - -%: %.hs - ghc $< - -chart/%.csv: chart/%.hledger ./hledger-print-csv.hs - ./hledger-print-csv \ - -f $< \ - >$@ diff --git a/README b/README new file mode 120000 index 0000000..e1d1217 --- /dev/null +++ b/README @@ -0,0 +1 @@ +doc/README.fr.manpage.ad \ No newline at end of file diff --git a/chart/Association_1901/Cyclofficine.Plan_comptable.hledger b/chart/Association_1901/Cyclofficine.Plan_comptable.hledger index d37296e..1a349a3 100644 --- a/chart/Association_1901/Cyclofficine.Plan_comptable.hledger +++ b/chart/Association_1901/Cyclofficine.Plan_comptable.hledger @@ -4,7 +4,7 @@ ; == Utilisation ; Doit être inclus ainsi dans un FICHIER.hledger l’utilisant : ; ---- -; !include Plan_comptable.hledger +; !include Cyclofficine.Plan_comptable.hledger ; ---- ; ATTENTION: rien n’empêche techniquement un FICHIER.hledger ; de rajouter des comptes après cette inclusion. diff --git a/chart/GNUmakefile b/chart/GNUmakefile new file mode 100644 index 0000000..300de06 --- /dev/null +++ b/chart/GNUmakefile @@ -0,0 +1,15 @@ +tool:=$(dir $(abspath $(dir $(lastword $(MAKEFILE_LIST))))) +chart=$(wildcard $(tool)/chart/*/*.hledger) + +all: $(chart:.hledger=.csv) +c clean: $(chart:.hledger=.csv/clean) +%/clean: + $(if $(wildcard $*),rm -f "$*") + +%.csv: %.hledger $(tool)/script/hledger-print-csv + $(tool)/script/hledger-print-csv \ + -f $< \ + >$@ + +$(tool)/script/hledger-print-csv: + $(MAKE) -C $(@D) $(@F) diff --git a/doc/GNUmakefile b/doc/GNUmakefile index 3ccf846..49727d1 100644 --- a/doc/GNUmakefile +++ b/doc/GNUmakefile @@ -1,4 +1,5 @@ tool:=$(dir $(lastword $(MAKEFILE_LIST))) +mul=$(foreach p,$1,$(foreach s,$2,$p$s)) all: $(HOME)/.asciidoc/backends/slidy2 @@ -7,6 +8,12 @@ $(HOME)/.asciidoc/backends/slidy2: \ $(tool)/.../lib/tool/asciidoc/backend/slidy2/install $< +$(call mul,$(patsubst %.ad,%,$(wildcard *.ad)),.roff .html): \ + $(tool)/.../script/hledger-equity \ + $(tool)/.../script/hledger-print-csv +$(tool)/.../script/%: + $(MAKE) -C $(@D) $(@F) + tool/asciidoc := $(tool)/.../lib/tool/asciidoc include $(tool/asciidoc)/GNUmakefile @@ -33,6 +40,6 @@ $(tool)/.../lib/tool/asciidoc/GNUmakefile: \ %.slidy.html: export ASCIIDOC_FLAGS+=-atabsize=0 %.slidy.html: export ASCIIDOC_FLAGS+=-alatexmath -$(patsubst %.ad,%.html,$(wildcard *.slidy.ad)): \ +$(patsubst %.ad,%.html,$(wildcard *.ad)): \ $(tool/asciidoc)/conf/latexmath.conf \ $(tool/asciidoc)/conf/vim.conf diff --git a/doc/README.fr.manpage.ad b/doc/README.fr.manpage.ad new file mode 100644 index 0000000..e912a6b --- /dev/null +++ b/doc/README.fr.manpage.ad @@ -0,0 +1,92 @@ += tool/hledger(README) +:location: ./tool/hledger +:toc: + +== Name +tool/hledger - outils autour de hledger + + +== script/ - script hledger +.Construction des fichiers exécutables des scripts +---- +% make -C script +---- + +.Nettoyage +---- +% make -C script clean +---- + +=== hledger-print-csv + +.Usage +---- +% script/hledger-print-csv -f $file.hledger $filter >$file.hledger.csv +% localc $file.hledger.csv +---- +WARNING: À l’ouverture du ++.csv++ sélectionner ++,++ comme séparateur, et ++"++ comme guillemet. + +=== hledger-equity + +.Usage +---- +% script/hledger-equity -f $file.hledger $filter +---- +Copier/coller l’écriture désirée dans le journal et adapter le nom de la balance +++equity:opening balances++ ou ++equity:closing balances++ + +=== hledger-check-dates + +Vérifie la monotonie (stricte) de la date de transactions. + +.Usage +---- +% script/hledger-check-dates -f $file.hledger [--strict] [--date2] $filter +---- + +[horizontal] +.Options +--strict:: comparaison stricte. +--date2:: considère la seconde d’une transaction (si présente) plutôt que sa date. + +.Exemple +---- +../script/hledger-check-dates -f data/exemple-dates-unordered.ledger +sys::[../script/hledger-check-dates -f data/exemple-dates-unordered.ledger] +---- + +== chart/ - plans comptables + +.Construction des ++.csv++ des plans comptables ++.hledger++ +---- +% make -C chart +---- + +.Nettoyage +---- +% make -C chart clean +---- + +== doc/ - documentation + +.Construction +---- +% make -C doc +---- + +.Déverminage +---- +% make -C doc all/trace +---- + +.Nettoyage +---- +% make -C doc clean +---- + +== vim/ - Configuration ViM + +.Installation +---- +% vim/install +---- diff --git a/doc/README.fr.manpage.d b/doc/README.fr.manpage.d new file mode 100644 index 0000000..10c79e7 --- /dev/null +++ b/doc/README.fr.manpage.d @@ -0,0 +1,2 @@ +README.fr.manpage.ad \ +README.fr.manpage.d: \ diff --git a/doc/README.fr.manpage.html b/doc/README.fr.manpage.html new file mode 100644 index 0000000..36409e0 --- /dev/null +++ b/doc/README.fr.manpage.html @@ -0,0 +1,45 @@ + + +tool/hledger

script/ - script hledger

Construction des fichiers exécutables des scripts.  +

% make -C script

+

Nettoyage.  +

% make -C script clean

+

hledger-print-csv

Usage.  +

% script/hledger-print-csv -f $file.hledger $filter >$file.hledger.csv +% localc $file.hledger.csv

+

[Avertissement]

À l’ouverture du .csv sélectionner , comme séparateur, et " comme guillemet.

hledger-equity

Usage.  +

% script/hledger-equity -f $file.hledger $filter

+

Copier/coller l’écriture désirée dans le journal et adapter le nom de la balance +equity:opening balances ou equity:closing balances

hledger-check-dates

Vérifie la monotonie (stricte) de la date de transactions.

Usage.  +

% script/hledger-check-dates -f $file.hledger [--strict] [--date2] $filter

+

Tableau 1. Options
+

+--strict +

+
+

+comparaison stricte. +

+
+

+--date2 +

+
+

+considère la seconde d’une transaction (si présente) plutôt que sa date. +

+

Exemple.  +

../script/hledger-check-dates -f data/exemple-dates-unordered.ledger

+

chart/ - plans comptables

Construction des .csv des plans comptables .hledger.  +

% make -C chart

+

Nettoyage.  +

% make -C chart clean

+

doc/ - documentation

Construction.  +

% make -C doc

+

Déverminage.  +

% make -C doc all/trace

+

Nettoyage.  +

% make -C doc clean

+

vim/ - Configuration ViM

Installation.  +

% vim/install

+

diff --git a/doc/README.fr.manpage.roff b/doc/README.fr.manpage.roff new file mode 100644 index 0000000..ae4ddb4 --- /dev/null +++ b/doc/README.fr.manpage.roff @@ -0,0 +1,235 @@ +'\" t +.\" Title: tool/hledger +.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] +.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Date: 02/08/2014 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: French +.\" +.TH "tool/hledger" "README" "02/08/2014" "\ \&" "\ \&" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "Nom" +tool/hledger \- outils autour de hledger +.SH "script/ - script hledger" +.PP +\fBConstruction des fichiers ex\('ecutables des scripts\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C script +.fi +.if n \{\ +.RE +.\} +.PP +\fBNettoyage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C script clean +.fi +.if n \{\ +.RE +.\} +.sp +.SS "hledger\-print\-csv" +.PP +\fBUsage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% script/hledger\-print\-csv \-f $file\&.hledger $filter >$file\&.hledger\&.csv +% localc $file\&.hledger\&.csv +.fi +.if n \{\ +.RE +.\} +.sp +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBAvertissement\fR +.ps -1 +.br +.sp +\(`A l\(cqouverture du \fB\&.csv\fR s\('electionner \fB,\fR comme s\('eparateur, et \fB"\fR comme guillemet\&. +.sp .5v +.RE +.SS "hledger\-equity" +.PP +\fBUsage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% script/hledger\-equity \-f $file\&.hledger $filter +.fi +.if n \{\ +.RE +.\} +.sp +Copier/coller l\(cq\('ecriture d\('esir\('ee dans le journal et adapter le nom de la balance \fBequity:opening balances\fR ou \fBequity:closing balances\fR +.SS "hledger\-check\-dates" +.sp +V\('erifie la monotonie (stricte) de la date de transactions\&. +.PP +\fBUsage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% script/hledger\-check\-dates \-f $file\&.hledger [\-\-strict] [\-\-date2] $filter +.fi +.if n \{\ +.RE +.\} +.sp +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.B Tableau\ \&1.\ \&Options +.TS +tab(:); +lt lt +lt lt. +T{ +.sp +\-\-strict +T}:T{ +.sp +comparaison stricte\&. +T} +T{ +.sp +\-\-date2 +T}:T{ +.sp +consid\(`ere la seconde d\(cqune transaction (si pr\('esente) plut\(^ot que sa date\&. +T} +.TE +.sp 1 +.PP +\fBExemple\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +\&.\&./script/hledger\-check\-dates \-f data/exemple\-dates\-unordered\&.ledger +.fi +.if n \{\ +.RE +.\} +.sp +.SH "chart/ - plans comptables" +.PP +\fBConstruction des .csv des plans comptables .hledger\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C chart +.fi +.if n \{\ +.RE +.\} +.PP +\fBNettoyage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C chart clean +.fi +.if n \{\ +.RE +.\} +.sp +.SH "doc/ - documentation" +.PP +\fBConstruction\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C doc +.fi +.if n \{\ +.RE +.\} +.PP +\fBD\('everminage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C doc all/trace +.fi +.if n \{\ +.RE +.\} +.PP +\fBNettoyage\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% make \-C doc clean +.fi +.if n \{\ +.RE +.\} +.sp +.SH "vim/ - Configuration ViM" +.PP +\fBInstallation\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +% vim/install +.fi +.if n \{\ +.RE +.\} +.sp diff --git a/doc/TODO.fr.manpage.ad b/doc/TODO.fr.manpage.ad new file mode 100644 index 0000000..776c4c1 --- /dev/null +++ b/doc/TODO.fr.manpage.ad @@ -0,0 +1,86 @@ += tool/hledger(TODO) +:location: ./tool/hledger +:toc: + +== Name +tool/hledger - réflexions et choses à faire + +== hledger-web +- Affichage des colonnes crédit/débit. + +NOTE: trop perturbant pour les habitudes des comptables sinon, +dont l’expérience montre que cela les handicape pour repérer certaines erreurs. + +== hledger-bilan-financier +- génére du html+css +- quelles données ? ➔ ébaucher un exemple + +== hledger-comptes-de-resultats +- génére du html+css +- quelles données ? ➔ ébaucher un exemple + +== hledger-pointing + +NOTE: https://fr.wikipedia.org/wiki/Lettrage_comptable#Lettrage_automatique[] + +=== Définir des critères et conventions impliquant un pointage + +Cas du rapprochement bancaire:: +Contrôle de la réciprocité du relevé de compte bancaire + +et du compte ++5.Finance:1.Etablissement:2.Banque++. ++ +NOTE: https://fr.wikipedia.org/wiki/%C3%89tat_de_rapprochement_bancaire#Enjeux_du_rapprochement_bancaire[] ++ +Différences possibles;; ++ +* Décalage légitime de dates +* Erreur de montants + +Cas des comptes tiers:: ++ +* Rapprocher les bulletins de salaire avec les paiements des salaires ; +* Rapprocher les cotisations avec leur paiement ; +* Rapprocher les factures avec leur paiement. + + +Construction du pointage:: + Un ensemble d’écritures E est pointé pour un compte C +__si et seulement si__ +* le compte C ou un sous-compte de C est crédité ou débité +par toutes les écritures de E tel que le solde de C +au sein de ces écritures soit nul ; +* et il n’existe pas de sous ensemble strict de E pointable pour C. + + +=== Définir une convention pour signifier un pointage + +Cas d’une écriture devant être pointée:: +Lui mettre un tag ++Pointage:++ qui sera rempli le pointage venu. + +Cas d’une écriture pointée:: +Un tag ++Pointage:++ avec pour valeur +une date suffisamment préçise pour être unique +à laquelle se situe la première écriture pointée de l’ensemble. ++ +[source,hledger] +.Exemple +---- +2014/01/01 12:00 ; Pointage:2014/01/01_12:00 <1> + A -1 + B 1 +2014/01/02 ; Pointage-Tiers:2014/01/01_12:00 <1> + B -1 + C 1 +2014/01/03 ; Pointage: <2> + A -1 + B 1 + + +; vim: set iskeyword+=/,_,38 +---- +<1> Écriture pointée. +<2> Écriture à pointer. + + +== Comptabilité analytique +Les tags suffisent-ils pour la faire ? diff --git a/doc/TODO.fr.manpage.d b/doc/TODO.fr.manpage.d new file mode 100644 index 0000000..a999634 --- /dev/null +++ b/doc/TODO.fr.manpage.d @@ -0,0 +1,2 @@ +TODO.fr.manpage.ad \ +TODO.fr.manpage.d: \ diff --git a/doc/TODO.fr.manpage.html b/doc/TODO.fr.manpage.html new file mode 100644 index 0000000..130cd18 --- /dev/null +++ b/doc/TODO.fr.manpage.html @@ -0,0 +1,71 @@ + + +tool/hledger

hledger-web

  • +Affichage des colonnes crédit/débit. +
[Note]

trop perturbant pour les habitudes des comptables sinon, +dont l’expérience montre que cela les handicape pour repérer certaines erreurs.

hledger-bilan-financier

  • +génére du html+css +
  • +quelles données ? ➔ ébaucher un exemple +

hledger-comptes-de-resultats

  • +génére du html+css +
  • +quelles données ? ➔ ébaucher un exemple +

hledger-pointing

Définir des critères et conventions impliquant un pointage

+Cas du rapprochement bancaire +

+Contrôle de la réciprocité du relevé de compte bancaire
+et du compte 5.Finance:1.Etablissement:2.Banque. +

+Différences possibles +
  • +Décalage légitime de dates +
  • +Erreur de montants +
+Cas des comptes tiers +
  • +Rapprocher les bulletins de salaire avec les paiements des salaires ; +
  • +Rapprocher les cotisations avec leur paiement ; +
  • +Rapprocher les factures avec leur paiement. +
+Construction du pointage +

+ Un ensemble d’écritures E est pointé pour un compte C +si et seulement si +

  • +le compte C ou un sous-compte de C est crédité ou débité +par toutes les écritures de E tel que le solde de C +au sein de ces écritures soit nul ; +
  • +et il n’existe pas de sous ensemble strict de E pointable pour C. +

Définir une convention pour signifier un pointage

+Cas d’une écriture devant être pointée +
+Lui mettre un tag Pointage: qui sera rempli le pointage venu. +
+Cas d’une écriture pointée +

+Un tag Pointage: avec pour valeur +une date suffisamment préçise pour être unique +à laquelle se situe la première écriture pointée de l’ensemble. +

Exemple.  +

2014/01/01 12:00 ; Pointage:2014/01/01_12:00 1 + A -1 + B 1 +2014/01/02 ; Pointage-Tiers:2014/01/01_12:00 2 + B -1 + C 1 +2014/01/03 ; Pointage: 3 + A -1 + B 1 + + +; vim: set iskeyword+=/,_,38

+

1 2

+Écriture pointée. +

3

+Écriture à pointer. +

Comptabilité analytique

Les tags suffisent-ils pour la faire ?

diff --git a/doc/TODO.fr.manpage.roff b/doc/TODO.fr.manpage.roff new file mode 100644 index 0000000..82a1784 --- /dev/null +++ b/doc/TODO.fr.manpage.roff @@ -0,0 +1,275 @@ +'\" t +.\" Title: tool/hledger +.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] +.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Date: 02/08/2014 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: French +.\" +.TH "tool/hledger" "TODO" "02/08/2014" "\ \&" "\ \&" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "Nom" +tool/hledger \- r\('eflexions et choses \(`a faire +.SH "hledger-web" +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Affichage des colonnes cr\('edit/d\('ebit\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +trop perturbant pour les habitudes des comptables sinon, dont l\(cqexp\('erience montre que cela les handicape pour rep\('erer certaines erreurs\&. +.sp .5v +.RE +.SH "hledger-bilan-financier" +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +g\('en\('ere du html+css +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +quelles donn\('ees ? ➔ \('ebaucher un exemple +.RE +.SH "hledger-comptes-de-resultats" +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +g\('en\('ere du html+css +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +quelles donn\('ees ? ➔ \('ebaucher un exemple +.RE +.SH "hledger-pointing" +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +https://fr\&.wikipedia\&.org/wiki/Lettrage_comptable#Lettrage_automatique +.sp .5v +.RE +.SS "D\('efinir des crit\(`eres et conventions impliquant un pointage" +.PP +Cas du rapprochement bancaire +.RS 4 +Contr\(^ole de la r\('eciprocit\('e du relev\('e de compte bancaire +.br +et du compte +\fB5\&.Finance:1\&.Etablissement:2\&.Banque\fR\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +https://fr\&.wikipedia\&.org/wiki/%C3%89tat_de_rapprochement_bancaire#Enjeux_du_rapprochement_bancaire +.sp .5v +.RE +.PP +Diff\('erences possibles +.RS 4 +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +D\('ecalage l\('egitime de dates +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Erreur de montants +.RE +.RE +.RE +.PP +Cas des comptes tiers +.RS 4 +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Rapprocher les bulletins de salaire avec les paiements des salaires\ \&; +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Rapprocher les cotisations avec leur paiement\ \&; +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Rapprocher les factures avec leur paiement\&. +.RE +.RE +.PP +Construction du pointage +.RS 4 +Un ensemble d\(cq\('ecritures E est point\('e pour un compte C +\fIsi et seulement si\fR +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +le compte C ou un sous\-compte de C est cr\('edit\('e ou d\('ebit\('e par toutes les \('ecritures de E tel que le solde de C au sein de ces \('ecritures soit nul\ \&; +.RE +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +et il n\(cqexiste pas de sous ensemble strict de E pointable pour C\&. +.RE +.RE +.SS "D\('efinir une convention pour signifier un pointage" +.PP +Cas d\(cqune \('ecriture devant \(^etre point\('ee +.RS 4 +Lui mettre un tag +\fBPointage:\fR +qui sera rempli le pointage venu\&. +.RE +.PP +Cas d\(cqune \('ecriture point\('ee +.RS 4 +Un tag +\fBPointage:\fR +avec pour valeur une date suffisamment pr\('e\(,cise pour \(^etre unique \(`a laquelle se situe la premi\(`ere \('ecriture point\('ee de l\(cqensemble\&. +.PP +\fBExemple\fR. +.sp +.if n \{\ +.RS 4 +.\} +.nf +2014/01/01 12:00 ; Pointage:2014/01/01_12:00 \fB(1)\fR + A \-1 + B 1 +2014/01/02 ; Pointage\-Tiers:2014/01/01_12:00 \fB(2)\fR + B \-1 + C 1 +2014/01/03 ; Pointage: \fB(3)\fR + A \-1 + B 1 +; vim: set iskeyword+=/,_,38 +.fi +.if n \{\ +.RE +.\} +.sp +.TS +tab(:); +r lw(\n(.lu*75u/100u). +\fB1.\fR\ \fB2.\fR\h'-2n':T{ +\('Ecriture point\('ee\&. +T} +\fB3.\fR\h'-2n':T{ +\('Ecriture \(`a pointer\&. +T} +.TE +.RE +.SH "Comptabilit\('e analytique" +.sp +Les tags suffisent\-ils pour la faire ? diff --git a/doc/css/docbook-xsl.css b/doc/css/docbook-xsl.css new file mode 100644 index 0000000..ee9ca46 --- /dev/null +++ b/doc/css/docbook-xsl.css @@ -0,0 +1,329 @@ +/* + CSS stylesheet for XHTML produced by DocBook XSL stylesheets. +*/ + +body { + font-family: Georgia,serif; +} + +code, pre { + font-family: "Courier New", Courier, monospace; +} + +span.strong { + font-weight: bold; +} + +body blockquote { + margin-top: .75em; + line-height: 1.5; + margin-bottom: .75em; +} + +html body { + margin: 1em 5% 1em 5%; + line-height: 1.2; +} + +body div { + margin: 0; +} + +h1, h2, h3, h4, h5, h6 +{ + color: #527bbd; + font-family: Arial,Helvetica,sans-serif; +} + +div.toc p:first-child, +div.list-of-figures p:first-child, +div.list-of-tables p:first-child, +div.list-of-examples p:first-child, +div.example p.title, +div.sidebar p.title +{ + font-weight: bold; + color: #527bbd; + font-family: Arial,Helvetica,sans-serif; + margin-bottom: 0.2em; +} + +body h1 { + margin: .0em 0 0 -4%; + line-height: 1.3; + border-bottom: 2px solid silver; +} + +body h2 { + margin: 0.5em 0 0 -4%; + line-height: 1.3; + border-bottom: 2px solid silver; +} + +body h3 { + margin: .8em 0 0 -3%; + line-height: 1.3; +} + +body h4 { + margin: .8em 0 0 -3%; + line-height: 1.3; +} + +body h5 { + margin: .8em 0 0 -2%; + line-height: 1.3; +} + +body h6 { + margin: .8em 0 0 -1%; + line-height: 1.3; +} + +body hr { + border: none; /* Broken on IE6 */ +} +div.footnotes hr { + border: 1px solid silver; +} + +div.navheader th, div.navheader td, div.navfooter td { + font-family: Arial,Helvetica,sans-serif; + font-size: 0.9em; + font-weight: bold; + color: #527bbd; +} +div.navheader img, div.navfooter img { + border-style: none; +} +div.navheader a, div.navfooter a { + font-weight: normal; +} +div.navfooter hr { + border: 1px solid silver; +} + +body td { + line-height: 1.2 +} + +body th { + line-height: 1.2; +} + +ol { + line-height: 1.2; +} + +ul, body dir, body menu { + line-height: 1.2; +} + +html { + margin: 0; + padding: 0; +} + +body h1, body h2, body h3, body h4, body h5, body h6 { + margin-left: 0 +} + +body pre { + margin: 0.5em 10% 0.5em 1em; + line-height: 1.0; + color: navy; +} + +tt.literal, code.literal { + color: navy; +} + +.programlisting, .screen { + border: 1px solid silver; + background: #f4f4f4; + margin: 0.5em 10% 0.5em 0; + padding: 0.5em 1em; +} + +div.sidebar { + background: #ffffee; + margin: 1.0em 10% 0.5em 0; + padding: 0.5em 1em; + border: 1px solid silver; +} +div.sidebar * { padding: 0; } +div.sidebar div { margin: 0; } +div.sidebar p.title { + margin-top: 0.5em; + margin-bottom: 0.2em; +} + +div.bibliomixed { + margin: 0.5em 5% 0.5em 1em; +} + +div.glossary dt { + font-weight: bold; +} +div.glossary dd p { + margin-top: 0.2em; +} + +dl { + margin: .8em 0; + line-height: 1.2; +} + +dt { + margin-top: 0.5em; +} + +dt span.term { + font-style: normal; + color: navy; +} + +div.variablelist dd p { + margin-top: 0; +} + +div.itemizedlist li, div.orderedlist li { + margin-left: -0.8em; + margin-top: 0.5em; +} + +ul, ol { + list-style-position: outside; +} + +div.sidebar ul, div.sidebar ol { + margin-left: 2.8em; +} + +div.itemizedlist p.title, +div.orderedlist p.title, +div.variablelist p.title +{ + margin-bottom: -0.8em; +} + +div.revhistory table { + border-collapse: collapse; + border: none; +} +div.revhistory th { + border: none; + color: #527bbd; + font-family: Arial,Helvetica,sans-serif; +} +div.revhistory td { + border: 1px solid silver; +} + +/* Keep TOC and index lines close together. */ +div.toc dl, div.toc dt, +div.list-of-figures dl, div.list-of-figures dt, +div.list-of-tables dl, div.list-of-tables dt, +div.indexdiv dl, div.indexdiv dt +{ + line-height: normal; + margin-top: 0; + margin-bottom: 0; +} + +/* + Table styling does not work because of overriding attributes in + generated HTML. +*/ +div.table table, +div.informaltable table +{ + margin-left: 0; + margin-right: 5%; + margin-bottom: 0.8em; +} +div.informaltable table +{ + margin-top: 0.4em +} +div.table thead, +div.table tfoot, +div.table tbody, +div.informaltable thead, +div.informaltable tfoot, +div.informaltable tbody +{ + /* No effect in IE6. */ + border-top: 3px solid #527bbd; + border-bottom: 3px solid #527bbd; +} +div.table thead, div.table tfoot, +div.informaltable thead, div.informaltable tfoot +{ + font-weight: bold; +} + +div.mediaobject img { + margin-bottom: 0.8em; +} +div.figure p.title, +div.table p.title +{ + margin-top: 1em; + margin-bottom: 0.4em; +} + +div.calloutlist p +{ + margin-top: 0em; + margin-bottom: 0.4em; +} + +a img { + border-style: none; +} + +@media print { + div.navheader, div.navfooter { display: none; } +} + +span.aqua { color: aqua; } +span.black { color: black; } +span.blue { color: blue; } +span.fuchsia { color: fuchsia; } +span.gray { color: gray; } +span.green { color: green; } +span.lime { color: lime; } +span.maroon { color: maroon; } +span.navy { color: navy; } +span.olive { color: olive; } +span.purple { color: purple; } +span.red { color: red; } +span.silver { color: silver; } +span.teal { color: teal; } +span.white { color: white; } +span.yellow { color: yellow; } + +span.aqua-background { background: aqua; } +span.black-background { background: black; } +span.blue-background { background: blue; } +span.fuchsia-background { background: fuchsia; } +span.gray-background { background: gray; } +span.green-background { background: green; } +span.lime-background { background: lime; } +span.maroon-background { background: maroon; } +span.navy-background { background: navy; } +span.olive-background { background: olive; } +span.purple-background { background: purple; } +span.red-background { background: red; } +span.silver-background { background: silver; } +span.teal-background { background: teal; } +span.white-background { background: white; } +span.yellow-background { background: yellow; } + +span.big { font-size: 2em; } +span.small { font-size: 0.6em; } + +span.underline { text-decoration: underline; } +span.overline { text-decoration: overline; } +span.line-through { text-decoration: line-through; } diff --git a/doc/css/docbook.css b/doc/css/docbook.css new file mode 100644 index 0000000..8889a56 --- /dev/null +++ b/doc/css/docbook.css @@ -0,0 +1,107 @@ + + +/********************************/ +/* start of styles in block.xsl */ + +.formalpara-title { + font-weight: bold; +} + +div.blockquote-title { + font-weight: bold; + margin-top: 1em; + margin-bottom: 1em; +} + +span.msgmain-title { + font-weight: bold; +} + +span.msgsub-title { + font-weight: bold; +} + +span.msgrel-title { + font-weight: bold; +} + +div.msglevel, div.msgorig, div.msgaud { + margin-top: 1em; + margin-bottom: 1em; +} + +span.msglevel-title, span.msgorig-title, span.msgaud-title { + font-weight: bold; +} + +div.msgexplan { + margin-top: 1em; + margin-bottom: 1em; +} + +span.msgexplan-title { + font-weight: bold; +} + +/* end of styles in block.xsl */ +/********************************/ + +/********************************/ +/* start of styles in autotoc.xsl */ + + font-weight: bold; + margin-top: 1em; + margin-bottom: 1em; +} + + +/* end of styles in autotoc.xsl */ +/********************************/ + +/********************************/ +/* start of styles in formal.xsl */ + +div.figure-title { + font-weight: bold; +} + +div.example-title { + font-weight: bold; +} + +div.equation-title { + font-weight: bold; +} + +div.table-title { + font-weight: bold; +} + +div.sidebar-title { + font-weight: bold; +} + + +/* end of styles in formal.xsl */ +/********************************/ + +/********************************/ +/* start of styles in verbatim.xsl */ + +div.programlisting { + white-space: pre; + font-family: monospace; +} + +div.screen { + white-space: pre; + font-family: monospace; +} + +div.synopsis { + white-space: pre; + font-family: monospace; +} + +/* end of styles in verbatim.xsl */ +/********************************/ diff --git a/doc/css/manpage.css b/doc/css/manpage.css new file mode 100644 index 0000000..07244be --- /dev/null +++ b/doc/css/manpage.css @@ -0,0 +1,403 @@ +html body { + color:#343434; + font-family:monospace,Arial,sans-serif; + font-size:10px; + margin:0 0; + padding:0 0 0 0; + } +/* sections */ + .refentry { + } + .refentry > .refsect1, + .refentry > .refsect2, + .refentry > .refsect3 { + -moz-box-sizing:border-box; + -webkit-box-sizing:border-box; + box-sizing:border-box; + clear:both; + display:table; + float:left; + margin:0 auto 0 auto; + padding:0 1em 0 1em; + width:100%; + } + + .refentry > .refsect1:last-child { + margin-bottom:2ex; + } + .refentry > .refsect1 * { + clear:both; + } + .refentry > .refnamediv > *, + .refentry > .refsect1 > *, + .refentry > .refsynopsisdiv > * { + margin:0 1em 0 1em; + } + .refentry .refnamediv { + margin:0 1em 1ex 1em; + } + .refentry .refnamediv h2 { + border-bottom:2px solid black; + color:green; + font-family:monospace,Arial,sans-serif; + font-size:120%; + font-variant:small-caps; + border-bottom:0 solid black; + margin:0 0 0.5ex 0; + padding:0 0 0 0; + } + .refentry .refnamediv p { + margin:0 0 0 0; + padding:0 0 0 0; + text-align:justify; + } + .refentry > .refsect1 > .refsect2 { + margin-left:0; + } + .refentry > .refsect1 > .refsect2 > * { + margin-left:1em; + } + .refentry > .refsect1 > .refsect2 > .refsect3 > * { + margin-left:2em; + } +/* text */ + a:empty { + margin:0 0 0 0; + padding:0 0 0 0; + } + .refentry em { + color:black; + } + .refentry .emphasis { + text-decoration:underline; + } + .refentry p { + margin:0 0 0 0; + max-width:86ex; + padding:1ex 0 0 0; + text-align:justify; + } + .refentry h2 + p { + margin-top:0; + padding-top:0.25ex; + } + .refentry h3 + p, + .refentry h3 + p[title] { + margin-top:0; + padding-top:0; + } +/* citations */ + .refentry code, + .refentry code.literal { + background-color:#EEEEEE; + color:inherit !important; + font-family:monospace,Courier; + font-size:10px; + white-space:pre; + } + .refentry pre { + font-family:monospace,Courier; + line-height:1.3; /* TODO: 1.2 ? */ + } + .refentry pre.literallayout { + border-left:1ex solid navy; + margin-left:0; + padding-left:1ex; + } + .refentry .screen { + border-width:0px 0px 0px 5px; + color:black; + display:inline-block; + margin-top:0.5ex; + margin-bottom:0; + } + .refentry .programlisting { + color:black; + margin-top:0.5ex; + margin-bottom:0; + } + .refentry .listitem > .simpara { + display:inline; + margin-bottom:0; + } +/* titles */ + .refentry > .refsect1 > h2 { + border-bottom:2px solid black; + /*box-shadow:0px 1px 00px #888888;*/ + color:green; + font-family:monospace,Arial,sans-serif; + font-size:120%; + /*font-variant:small-caps;*/ + line-height:1.2; + margin:1ex 0 0.5ex 0; + padding:0 0 0.5ex 0; + } + .refentry > .refnamediv > h2, + .refentry > .refsynopsisdiv > h2 { + font-variant:small-caps; + } + .refentry > .refsect1 > .refsect2 > h3 { + color:DarkGreen; + font-family:monospace,Arial,sans-serif; + font-size:100%; + padding:1.5ex 0 0.5ex 0; + margin:0 0 0 0; + } + .refentry > .refsect1 > h2 + .refsect2 > h3 { + padding-top:0; + } + .refentry > .refsect1 > .refsect2 > h3:before, + .refentry .toc .refsect2:before { + color:black; + content:"► "; + font-family:monospace,Arial,sans-serif; + float:left; + } + .refentry > .refsect1 > .refsect2 > .refsect3 > h4 { + color:DarkGreen; + font-family:monospace,Arial,sans-serif; + font-size:100%; + padding:1em 0 0 0; + margin:0 0 0 0; + } + .refentry > .refsect1 > .refsect2 > .refsect3 > h4:before, + .refentry .toc .refsect3:before { + color:black; + content:"►► "; + font-family:monospace,Arial,sans-serif; + float:left; + } + .refentry li.listitem > p.simpara:first-child { + margin-top:0; + } + .refentry p .formalpara-title { + /* XXX: there is a docbook-xsl bug here: + * https://lists.oasis-open.org/archives/docbook-apps/201107/msg00003.html + */ + color:black; + font-weight:bold; + line-height:1.4; + margin:0 0 0 0; + padding:0 0 0 0; + text-align:left; + } + .refentry p[title] { + margin-top:1ex; + max-width:none; + padding:0 0 0 0; + } + .refentry span.citerefentry > span.refentrytitle { + white-space:nowrap; + } +/* lists */ + .refentry .calloutlist p { + padding:0 0 0 0; + } + .refentry .calloutlist td { + padding:0 0 0 0; + } + .refentry .calloutlist td p { + } + .refentry .calloutlist td:first-child { + padding-right:1em; + } + .refentry .calloutlist td:first-child p { + text-align:right; + } + .refentry .itemizedlist { + padding:0 0 0 0; + margin:0 0 0 0; + } + .refentry .orderedlist { + padding:0 0 0 0; + margin:0 0 0 1ex; + } + .refentry .itemizedlist ul, + .refentry .orderedlist ol { + padding:0 0 0 0; + margin:0 0 0 1.5em; + list-style-position:outside; + } + .refentry .itemizedlist ul li, + .refentry .orderedlist ol li { + margin:0 0 0 0; + max-width:51em; + padding:0 0 0 0; + } + .refentry .variablelist { + padding:0 0 0 0; + margin:0 0 0 0; + } + .refentry .variablelist dl { + list-style-position:outside; + margin:0 0 0 0; + padding:0.5ex 0 0 0; + } + .refentry .variablelist dl dt { + margin:0 0 0 0; + padding-left:1px; + } + .refentry .variablelist dl dd { + border-left:1px dotted black; + margin:0.5ex 0 0.5ex 0.9ex; + max-width:51em; + padding-left:1.1ex; + text-align:justify; + } + .refentry .variablelist dl dd > p:first-child { + padding-top:0; + } + .refentry .variablelist dl dd > p:last-child { + padding-bottom:0; + } + .refentry .variablelist dt .term:before, + .refentry .toc dt .term:before { + color:black; + content:"▪ "; + font-family:monospace,Arial,sans-serif; + float:left; + } + .refentry h2 + .itemizedlist ul, + .refentry h2 + .orderedlist ol, + .refentry h2 + .variablelist dl { + padding-top:0; + } + .refentry .horizontal { + } + .refentry .horizontal .horizontal-contents { + } + .refentry .horizontal .horizontal-contents > table > tbody > tr > td:first-child { + font-weight:bold; + } + .refentry .horizontal .horizontal-contents > table > tbody > tr > td > p:first-child { + padding-top:0; + } +/* fhs */ + .refentry a[href^="#fhs:"] { + white-space:pre; + } + .refentry .toc a[href^="#fhs:"] { + white-space:normal; + } +/* sidebar */ + .sidebar ~ .refsect1, + .sidebar ~ .refsect2, + .sidebar ~ .refsect3 { + padding-left:32em; + } + .refentry .sidebar { + -moz-box-sizing:border-box; + -webkit-box-sizing:border-box; + background:none repeat scroll 0 0 #FFFFEE; + border:1px solid #C0C0C0; + box-sizing:border-box; + clear:both; + float:left; + height:96%; + left:0; + margin:1em 0 0 1em; + overflow:auto; + padding:1ex 1em 1ex 1em; + position:fixed; + top:0; + width:30em; + } + .refentry .sidebar .refnamediv { + margin:0 0 1ex 0; + } + .refentry .sidebar .refnamediv h2 { + border-bottom:2px solid black; + color:green; + font-family:monospace,Arial,sans-serif; + font-size:120%; + font-variant:small-caps; + border-bottom:0 solid black; + margin:0 0 0.5ex 0; + padding:0 0 0 0; + } + .refentry .sidebar .refnamediv p { + margin:0 0 0 0; + padding:0 0 0 0; + text-align:justify; + } + .refentry .sidebar .location { + margin:0 0 0 0; + } + .refentry .sidebar .language { + margin:0 0 0 0; + } +/* location */ + .refentry .location { + margin:0 1em 0 1em; + } + .refentry .location .location-title { + display:inline-block; + } + .refentry .location .location-path { + display:inline-block; + margin-left:1em; + margin-bottom:0.5ex; + } + .refentry .location .location-path a { + display:inline-block; + } + .refentry .location .location-path .dir { + color:blue; + font-weight:bold; + } + .refentry .location .location-path .dir .slash { + color:black; + } + .refentry .location .location-path .file { + font-weight:bold; + } +/* language */ + .refentry .language { + margin:0 1em 0 1em; + } + .refentry .language .language-title { + display:inline-block; + } + .refentry .language .language-list { + display:inline-block; + font-weight:bold; + margin-left:1em; + } + .refentry .language .language-list .lang-available { + color:blue; + } + .refentry .language .language-list .lang-current { + color:black; + } +/* toc */ + .refentry .toc { + } + .refentry .toc dl { + clear:left; + margin-left:0; + padding-left:0; + } + .refentry .toc dl dd { + border-left:1px dotted #333; + margin-bottom:1px; + margin-left:0.1ex; + padding-left:1.9ex; + } + .refentry .toc dl dt span.refsynopsisdiv { + } + .refentry .toc .refsect1:before { + color:black; + content:"§ "; + font-family:monospace,Arial,sans-serif; + float:left; + } + .refentry .toc .toc-title, + .refentry .language .language-title, + .refentry .location .location-title { + border-bottom:0 solid black; + color:green; + font-size:120%; + font-variant:small-caps; + font-weight:bold; + margin-bottom:0.5ex; + } diff --git a/doc/data/exemple-dates-unordered.ledger b/doc/data/exemple-dates-unordered.ledger new file mode 100644 index 0000000..ca74a69 --- /dev/null +++ b/doc/data/exemple-dates-unordered.ledger @@ -0,0 +1,7 @@ +Y 2014 + +2014/01/02=2014/01/01 + A 0 + +2014/01/01=2014/01/02 + B 0 diff --git a/doc/data/exemple-lettrage.ledger b/doc/data/exemple-lettrage.ledger new file mode 100644 index 0000000..7cf1858 --- /dev/null +++ b/doc/data/exemple-lettrage.ledger @@ -0,0 +1,16 @@ +; Exemple of countable lettering on Tiers' account +; with two transactions reflecting the reality (dates and evidence of money movements) + + +2014/01/01 Sell of a service + ; Transaction of engagement (accounting evidence : invoice) + Product:Sell:Service -700 + Tiers:Client:Service:John_Doe 700 ; Letter-Tiers:2014/01/01 +2014/01/14 Wire payment + ; Transaction of payment (accounting evidence : bank statement) + Tiers:Client:Service:John_Doe -700 ; Letter-Tiers:2014/01/01 + Finance:Establishment:Bank:Current 700 + +; WARNING: value of Letter-Tiers:2014/01/01 MUST be unique, +; usualy a strictly monotonic sequel: A..Z AA..ZZ AAA..ZZZ .. +; or any unique data mentioned in the evidence diff --git a/doc/data/exemple-syntaxe.ledger b/doc/data/exemple-syntaxe.ledger index 754cd24..c6b0082 100644 --- a/doc/data/exemple-syntaxe.ledger +++ b/doc/data/exemple-syntaxe.ledger @@ -1,4 +1,4 @@ -D 1000.00€ ; directive préçisant le format par défaut des montants +D 1000,00€ ; directive préçisant le format par défaut des montants 2014/01/01 Libellé de l’écriture ; UN_TAG:, Autre_tag:Avec_Valeur A:AA -42 ; flux créditant diff --git a/doc/hledger.fr.slidy.ad b/doc/hledger.fr.slidy.ad index 4da058a..3c58e72 100644 --- a/doc/hledger.fr.slidy.ad +++ b/doc/hledger.fr.slidy.ad @@ -1,5 +1,5 @@ = Informatiser une comptabilité avec confiance -:author: git://git.autogeree.net/tool/hledger +:author: git://git.cyclocoop.org/tool/hledger :copyright: © 2014 (CC) BY Julien Moutinho <julm+hledger@autogeree.net> :icons: :iconsdir: ./icons @@ -9,9 +9,9 @@ :slidefontsizeadjust: -3 :incremental: :revremark: -//:max-width: 45em :scriptsdir: $PWD/javascripts -ifdef::backend-slidy2[:data-uri:] +:data-uri: +//:max-width: 45em ifdef::backend-slidy2[:slidebackground!:] @@ -506,7 +506,7 @@ sys::[hledger balance --daily --historical -f data/exemple-syntaxe.ledger | sed \begin{array}{l} (\textcolor{#083194}{\textbf{compte}}=c´, \textcolor{#083194}{\textbf{montant}}=m) \\ \|\ m ← (\mathbf{\mbox{solde_de_compte}}\,\mathbb E\,c´) \\ - \|\ c´ ← (\mathbf{plan\mbox{_}comptable}\,c) \\ + \|\ c´ ← (\mathbf{hi\acute{e}rarchie\mbox{_}de\mbox{_}compte}\,c) \\ \|\ c ← (\mathbf{comptes}\,\mathbb E) \end{array}}\right\rbrack$] @@ -546,19 +546,19 @@ d’ouverture:: pour les réinitialiser à leur solde du précédent exercice. [source,sh] ---- % hledger-equity -f data/exemple-syntaxe.ledger -sys::[hledger-equity -f data/exemple-syntaxe.ledger] +sys::[.../script/hledger-equity -f data/exemple-syntaxe.ledger] ---- [source,sh] ---- % hledger-equity -f data/exemple-syntaxe.ledger '^A' -sys::[hledger-equity -f data/exemple-syntaxe.ledger '^A'] +sys::[.../script/hledger-equity -f data/exemple-syntaxe.ledger '^A'] ---- [source,sh] ---- % hledger-equity -f data/exemple-syntaxe.ledger '^B' -sys::[hledger-equity -f data/exemple-syntaxe.ledger '^B'] +sys::[.../script/hledger-equity -f data/exemple-syntaxe.ledger '^B'] ---- | @@ -885,10 +885,10 @@ http://en.wikipedia.org/wiki/Comma-separated_values[CSV] [source,sh] ---- % hledger-print-csv -f data/exemple-syntaxe.ledger -sys::[hledger-print-csv -f data/exemple-syntaxe.ledger] +sys::[.../script/hledger-print-csv -f data/exemple-syntaxe.ledger] ---- -++*.ledger.rules++:: http://hledger.org/manual#csv-files[] +++*.csv.rules++:: http://hledger.org/manual#csv-files[] + [source,txt] ---- diff --git a/doc/hledger.fr.slidy.html b/doc/hledger.fr.slidy.html index eb6587d..6a97990 100644 --- a/doc/hledger.fr.slidy.html +++ b/doc/hledger.fr.slidy.html @@ -6877,8 +6877,8 @@ else @@ -7109,7 +7109,51 @@ car cela les empêcherait aussi de réaliser des actes ingénieux. »
-Note +Note Mais possibilité de vérifications d’invariants conventionnels avec des scripts.
@@ -7240,7 +7284,51 @@ Relisible
@@ -7301,7 +7389,51 @@ Simon Michael (sm) <simon@joyful.com>
-Note +Note À équivalence fonctionnelle, OpenERPv7 ≈80 000 lignes de Python (≈1 000 écrans).
-Note +Note Dons @ https://www.gittip.com/simonmichael/
@@ -7369,7 +7501,51 @@ au lieu d’être captif d’une interface.
-Note +Note L’interface Web est simple, et s’améliore.
@@ -7388,7 +7564,51 @@ de s’informer sur sa syntaxe, sa sémantique et son utilisati
-Note +Note http://hledger.org/manual/.
@@ -7423,7 +7643,7 @@ qui forme une succession d’écritures comptables, classées librement.

Fichier data/exemple-syntaxe.ledger
-D 1000.00€ ; directive préçisant le format par défaut des montants
+D 1000,00€ ; directive préçisant le format par défaut des montants
 
 2014/01/01 Libellé de l’écriture ; UN_TAG:, Autre_tag:Avec_Valeur
 	A:AA      -42 ; flux créditant
@@ -7770,7 +7990,51 @@ des expressions rationnelles peuvent être utilisées à cette fin.

-Note +Note Cf. manuel : http://hledger.org/manual#query-arguments
@@ -7779,32 +8043,32 @@ des expressions rationnelles peuvent être utilisées à cette fin.

 % hledger print 'A' -f data/exemple-syntaxe.ledger
 2014/01/01 Libellé de l’écriture    ; UN_TAG:, Autre_tag:Avec_Valeur
-    A:AA           -42.00€    ; flux créditant
-    B:BB:BBB        40.00€    ; flux débitant
-    B:A              2.00€    ; flux débitant ventilé
+    A:AA           -42,00€    ; flux créditant
+    B:BB:BBB        40,00€    ; flux débitant
+    B:A              2,00€    ; flux débitant ventilé
 
 2014/01/02 Libellé d’une autre écriture
-    A:AA       100.00€    ; UN_TAG_de_flux:
-    B         -100.00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
+    A:AA       100,00€    ; UN_TAG_de_flux:
+    B         -100,00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
 
 % hledger print '^A' -f data/exemple-syntaxe.ledger
 2014/01/01 Libellé de l’écriture    ; UN_TAG:, Autre_tag:Avec_Valeur
-    A:AA           -42.00€    ; flux créditant
-    B:BB:BBB        40.00€    ; flux débitant
-    B:A              2.00€    ; flux débitant ventilé
+    A:AA           -42,00€    ; flux créditant
+    B:BB:BBB        40,00€    ; flux débitant
+    B:A              2,00€    ; flux débitant ventilé
 
 2014/01/02 Libellé d’une autre écriture
-    A:AA       100.00€    ; UN_TAG_de_flux:
-    B         -100.00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
+    A:AA       100,00€    ; UN_TAG_de_flux:
+    B         -100,00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
 
 % hledger print '^B$' -f data/exemple-syntaxe.ledger
 2014/01/02 Libellé d’une autre écriture
-    A:AA       100.00€    ; UN_TAG_de_flux:
-    B         -100.00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
+    A:AA       100,00€    ; UN_TAG_de_flux:
+    B         -100,00€    ; ATTENTION: au moins deux espaces requises entre le compte et le montant
 
Afficher des « journaux auxiliaires » (exemples approximatifs)
@@ -7913,17 +8177,61 @@ cellspacing="0" cellpadding="4">
Balance de toutes les écritures
 % hledger balance -f data/exemple-syntaxe.ledger
-              58.00€  A:AA
-             -58.00€  B
-               2.00€    A
-              40.00€    BB:BBB
+              58,00€  A:AA
+             -58,00€  B
+               2,00€    A
+              40,00€    BB:BBB
 ‑-------------------
                    0
 
@@ -7933,18 +8241,18 @@ cette balance sur toutes les écritures est également nulle.
Balance sur des comptes filtrés par expression rationnelle
 % hledger balance 'A' -f data/exemple-syntaxe.ledger
-              58.00€  A:AA
-               2.00€  B:A
+              58,00€  A:AA
+               2,00€  B:A
 ‑-------------------
-              60.00€
+              60,00€
 
Balance sur un compte racine
 % hledger balance '^A' -f data/exemple-syntaxe.ledger
-              58.00€  A:AA
+              58,00€  A:AA
 ‑-------------------
-              58.00€
+              58,00€
 
Sans accumulation des soldes d’une période à l’autre
@@ -7954,10 +8262,10 @@ Balance changes in 2014 || 2014/01/01-2014/01/01 2014/01/02-2014/01/02 ==========++=============================================== - A:AA || -42.00€ 100.00€ - B || 0 -100.00€ - B:A || 2.00€ 0 - B:BB:BBB || 40.00€ 0 + A:AA || -42,00€ 100,00€ + B || 0 -100,00€ + B:A || 2,00€ 0 + B:BB:BBB || 40,00€ 0 ‑---------++----------------------------------------------- || 0 0
@@ -7969,10 +8277,10 @@ Ending balances (historical2014/01/012014/01/02==========++========================= - A:AA || -42.00€ 58.00€ - B || 0 -100.00€ - B:A || 2.00€ 2.00€ - B:BB:BBB || 40.00€ 40.00€ + A:AA || -42,00€ 58,00€ + B || 0-100,00€ + B:A || 2,00€ 2,00€ + B:BB:BBB || 40,00€ 40,00€ ‑---------++------------------------- || 00 @@ -8015,7 +8323,7 @@ Ending balances (historical

@@ -8110,45 +8418,45 @@ cellspacing="0" cellpadding="4">
-Note +Note Toutes les écritures devant avoir leur balance nulle, cette balance sur toutes les écritures est également nulle.
 % hledger-equity -f data/exemple-syntaxe.ledger
-2014/07/30
-    A:AA                          -58.00€
-    B                             100.00€
-    B:A                            -2.00€
-    B:BB:BBB                      -40.00€
+2014/08/02
+    A:AA                          -58,00€
+    B                             100,00€
+    B:A                            -2,00€
+    B:BB:BBB                      -40,00€
     equity:closing balances             0
 
-2014/07/30
-    A:AA                           58.00€
-    B                            -100.00€
-    B:A                             2.00€
-    B:BB:BBB                       40.00€
+2014/08/02
+    A:AA                           58,00€
+    B                            -100,00€
+    B:A                             2,00€
+    B:BB:BBB                       40,00€
     equity:opening balances             0
 
 % hledger-equity -f data/exemple-syntaxe.ledger '^A'
-2014/07/30
-    A:AA                          -58.00€
-    equity:closing balances        58.00€
+2014/08/02
+    A:AA                          -58,00€
+    equity:closing balances        58,00€
 
-2014/07/30
-    A:AA                           58.00€
-    equity:opening balances       -58.00€
+2014/08/02
+    A:AA                           58,00€
+    equity:opening balances       -58,00€
 
 % hledger-equity -f data/exemple-syntaxe.ledger '^B'
-2014/07/30
-    B                             100.00€
-    B:A                            -2.00€
-    B:BB:BBB                      -40.00€
-    equity:closing balances       -58.00€
-
-2014/07/30
-    B                            -100.00€
-    B:A                             2.00€
-    B:BB:BBB                       40.00€
-    equity:opening balances        58.00€
+2014/08/02
+    B                             100,00€
+    B:A                            -2,00€
+    B:BB:BBB                      -40,00€
+    equity:closing balances       -58,00€
+
+2014/08/02
+    B                            -100,00€
+    B:A                             2,00€
+    B:BB:BBB                       40,00€
+    equity:opening balances        58,00€
 
Solde des comptes de gestion et calcul du compte de résultat
@@ -8222,7 +8530,51 @@ cellspacing="0" cellpadding="4">
@@ -8442,7 +8794,7 @@ Date [2014/; == Utilisation; Doit être inclus ainsi dans un FICHIER.hledger l’utilisant :; ---- -; !include Plan_comptable.hledger +; !include Cyclofficine.Plan_comptable.hledger; ----; ATTENTION: rien n’empêche techniquement un FICHIER.hledger; de rajouter des comptes après cette inclusion. @@ -8855,11 +9207,6 @@ Date [2014/ -
-
-

+

-
-
 01/01 Prestation ; Écriture d’engagement (pièce comptable : facture)
@@ -8896,7 +9243,51 @@ Total chèques à encaisser (5112) == Total remises de chèques à la banque (51
 
-Note +Note Si ces deux commandes ne donnent pas le même montant final c’est qu’il reste des chèques à encaisser.
-Note +Note vérifier qu’il ne reste plus de chèques comptabilisés dans le tiroir
@@ -8945,15 +9336,15 @@ Solde du compte caisse (531) == Total entrées espèces en caisse - Total des so
 % hledger-print-csv -f data/exemple-syntaxe.ledger
 "nth","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","status","posting-comment"
-"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","A:AA","-42.00","€","42.00","","","flux créditant"
-"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","B:BB:BBB","40.00","€","","40.00","","flux débitant"
-"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","B:A","2.00","€","","2.00","","flux débitant ventilé"
-"1","2014/01/02","","","","Libellé d’une autre écriture","","A:AA","100.00","€","","100.00","","UN_TAG_de_flux:"
-"1","2014/01/02","","","","Libellé d’une autre écriture","","B","-100.00","€","100.00","","","ATTENTION: au moins deux espaces requises entre le compte et le montant"
+"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","A:AA","-42,00","€","42,00","","","flux créditant"
+"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","B:BB:BBB","40,00","€","","40,00","","flux débitant"
+"0","2014/01/01","","","","Libellé de l’écriture","UN_TAG:, Autre_tag:Avec_Valeur","B:A","2,00","€","","2,00","","flux débitant ventilé"
+"1","2014/01/02","","","","Libellé d’une autre écriture","","A:AA","100,00","€","","100,00","","UN_TAG_de_flux:"
+"1","2014/01/02","","","","Libellé d’une autre écriture","","B","-100,00","€","100,00","","","ATTENTION: au moins deux espaces requises entre le compte et le montant"
 
-*.ledger.rules +*.csv.rules

@@ -9135,7 +9526,51 @@ Complètement automatique des comptes (<Tab>)

-Note +Note Besoin de rajouter vim/autoload/neocomplcache/filters/sorter_bytes.vim.
@@ -9235,21 +9670,8961 @@ Chercher des écritures doublonnes.
-data/Luca_Pacioli_(Gemaelde).jpeg +data/Luca_Pacioli_(Gemaelde).jpeg
Figure 1. Luca Pacioli
-hledgersplash +hledgersplash
diff --git a/doc/make b/doc/make deleted file mode 100644 index baa921c..0000000 --- a/doc/make +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -efux -tool=$(readlink -e "${0%/*}"/...) - -VERSION=$(which git >/dev/null && - cd "$tool" && - git describe --tags --match 'v[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]' --always || - TZ=UTC date +'v%Y.%m.%d') -VERSION=git://git.autogeree.net/tool/hledger - -if test ! -e "$tool"/lib/tool/asciidoc/.git - then - (cd "$tool" && git submodule update --init --recursive -- lib/tool/asciidoc) - (cd "$tool"/lib/tool/asciidoc/ && git checkout -f HEAD && git clean -dfx) - fi - -MAKE=$(which gmake >/dev/null && echo gmake || echo make) - -cd "${0%/*}" -VERSION=${VERSION#v} \ -ASCIIDOC_FLAGS="${ASCIIDOC_FLAGS:+$ASCIIDOC_FLAGS }-a revnumber=$VERSION -a tabsize=0 -a latexmath" \ -conf=etc \ -SRCDIR=. \ -xsl=docbook-xsl \ -slidy=slidy2 \ -$MAKE ${MAKE_FLAGS-} \ - -f "$tool"/lib/tool/asciidoc/GNUmakefile \ - "$@" diff --git a/doc/slidy2-install b/doc/slidy2-install deleted file mode 120000 index 3c7df74..0000000 --- a/doc/slidy2-install +++ /dev/null @@ -1 +0,0 @@ -.../lib/tool/asciidoc/backend/slidy2/install \ No newline at end of file diff --git a/hledger-equity.hs b/hledger-equity.hs deleted file mode 100755 index 43ca0ff..0000000 --- a/hledger-equity.hs +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env runhaskell -{- - -Like ledger's equity command, print a journal entry posting the total -balance of all accounts (or the specified account and its subaccounts) -in the default journal. - -An entry like this is useful in the transition to a new journal file, -to zero out asset/liability balances in the old file and initialise -them in the new one. This way you get correct balances when reporting -on either file, and when including both files at once. - -Usage: hledger-equity [ACCTPAT] --} - -import Data.Maybe (fromMaybe) -import Hledger.Cli - -argsmode :: Mode RawOpts -argsmode = (defCommandMode ["equity"]) - { modeHelp = "print a journal entry posting the total balance of all accounts" - ++ " (or the specified account and its subaccounts)" - , modeGroupFlags = Group - { groupNamed = - [ ("Input",inputflags) - , ("Reporting",reportflags) - , ("Misc",helpflags) - ] - , groupUnnamed = [] - , groupHidden = [] - } - } - -main :: IO () -main = do - opts <- getCliOpts argsmode - withJournalDo opts $ - \CliOpts{reportopts_=ropts} j -> do - today <- getCurrentDay - let ropts_ = ropts{flat_=True} - q = queryFromOpts today ropts_ - (acctbals,_) = balanceReport ropts_ q j - balancingamt = negate $ sum $ map (\((_,_,_),b) -> b) acctbals - ps = [posting{paccount=a, pamount=b} | ((a,_,_),b) <- acctbals] - ++ [posting{paccount="equity:opening balances", pamount=balancingamt}] - enddate = fromMaybe today $ queryEndDate (date2_ ropts_) q - nps = [posting{paccount=a, pamount=negate b} | ((a,_,_),b) <- acctbals] - ++ [posting{paccount="equity:closing balances", pamount=negate balancingamt}] - putStr $ showTransactionUnelided (nulltransaction{tdate=enddate, tpostings=nps}) - putStr $ showTransactionUnelided (nulltransaction{tdate=enddate, tpostings=ps}) diff --git a/hledger-of-oxygen-csv.pl b/hledger-of-oxygen-csv.pl deleted file mode 100755 index 194a612..0000000 --- a/hledger-of-oxygen-csv.pl +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/perl -# DESCRIPTION: import from [Oxygène](http://www.memsoft.fr) to [hledger](http://hledger.org) -# AUTHOR: Julien Moutinho -# LICENSE: [GPLv3+](https://www.gnu.org/licenses/gpl-3.0.html) -# NOTE: should be easily hackable to import from other .csv -# USAGE: -# % hledger-print-csv -f Chart_of_accounts.hledger >Chart_of_accounts.csv -# % iconv -f latin1 -t utf8 EXPORT.oxygen.hledger -# -# FORMAT of EXPORT.oxygen.csv: -# ---- -# NUMJL;LIBJL;DTOPE;NPIEC;NUMCP;LIBCP;CODCP;LIBEC;MTDEB;MTCRE;COTVA;TXTVA -# 60;Achats;01/01/2012;ACH01/76;401REGIEQUART;REGIE DE QUARTIER;REGIE DE QUARTI;LOYER LOCAL DEC. 2011+1T 2012 REGIE QUAR;0,00;1410,91;;0,00 -# 60;Achats;01/01/2012;ACH01/76;6132000;LOYER LOCAL 15 rue P. BONNARD;LOYER BONNARD;LOYER LOCAL DEC. 2011+1T 2012 REGIE QUAR;1076,25;0,00;;0,00 -# 60;Achats;01/01/2012;ACH01/76;6165000;Responsabilité civile;;ASSURANCE LOCAL 2012 VIA REGIEQUARTIER;86,47;0,00;;0,00 -# 60;Achats;01/01/2012;ACH01/76;6140000;Charges locatives et de copropriété;;CHARGES LOCAL 1T 2012;248,19;0,00;;0,00 -# ; ... And so on.. and so forth.. -# ---- -# -# FORMAT of Chart_of_accounts.hledger: -# -# Pattern: -# ---- -# 01/01 -# 0.ZZZ:1.YYY:2.XXX 0; 012. Description -# 0.ZZZ:1.YYY:3.WWW 0; 013. Description -# 0.ZZZ:1.YYY:3.WWW.4.VVV 0; 0134. Description -# ; ... And so on.. and so forth.. -# ---- -# -# For exemple: -# ---- -# 01/01 Plan comptable des associations -# 1.Capital 0 ; 1. COMPTES DE CCOAITAUX -# 1.Capital:0.Fonds 0 ; 10. Fonds associatifs et reserves -# 2.Immobilisation 0 ; 2. COMPTES D'IMMOBILISATIONS -# 2.Immobilisation:1.Corporelle 0 ; 21. Immobilisations corporelles -# 4.Tiers 0 ; 4. COMPTES TIERS -# 4.Tiers:0.Fournisseur 0 ; 40. Fournisseurs et comptes rattachés -# 5.Finance 0 ; 5. COMPTES FINANCIERS -# 5.Finance:1.Etablissement 0 ; 51. Banques, établissements financiers et assimilés -# 5.Finance:1.Etablissement:1.Valeur 0 ; 511. Valeurs à l’encaissement -# 5.Finance:1.Etablissement:1.Valeur:2.Chèque_à_encaisser 0 ; 5112. Chèques à encaisser -# 5.Finance:1.Etablissement:2.Banque:001.Courant 0 ; 512001. Crédit Coopératif - Compte courant -# 5.Finance:1.Etablissement:2.Banque:002.Livret 0 ; 512002. Crédit coopératif - Livret -# 6.Charge 0 ; 6. COMPTES D'ACHATS -# 6.Charge:1.Service 0 ; 61. Services extérieurs -# 6.Charge:2.Autre_service 0 ; 62. Autres services extérieurs -# 6.Charge:3.Impôt 0 ; 63. Impôts, taxes et versements assimilés -# 6.Charge:4.Personnel 0 ; 64. Charges de personnel -# 6.Charge:5.Gestion 0 ; 65. Autres charges de gestion courantes -# 6.Charge:8.Dotation 0 ; 68. Dotations aux amortissements, dépréciations, provisions et engagements -# 7.Produit 0 ; 7. COMPTES DE PRODUITS -# 7.Produit:0.Vente 0 ; 70. ventes de produits finis, prestations de services, marchandises -# ; ... And so on.. and so forth.. -# ---- - -our $VERSION = '2014.07.22'; -use strict; -use warnings FATAL => qw(all); -use utf8; -use open qw/:std :utf8/; -require Data::Dumper; -require Encode; -require IO::Wrap; -require Text::CSV; -#require Text::CSV::Encoded; -require Text::Trim; - -sub parse_date (@) { - ($_) = @_; - my ($jj,$mm,undef,$yy) = ($_ =~ m{^\s*([0-3]?[0-9])\s*/\s*([0-1]?[0-9])\s*/\s*(20)?([0-9][0-9])\s*$}); - return "20$yy/$mm/$jj"; - } -sub parse_code (@) { - ($_) = @_; - my ($code) = ($_ =~ m{^([0-9]*?)0*$}); - return (defined $code ? $code : $_); - } -sub parse_journal (@) { - ($_) = @_; - $_ = Text::Trim::trim($_); - s/\s/_/g; - return $_; - } - -sub parse_csv_line (@) { - my ($nth, $h, $c) = @_; - #print STDERR ("parse_csv_line: csv_line($nth)=".Data::Dumper::Dumper($c)); - my $date = parse_date($c->{date}); - $h->{$date} = {} - unless defined $h->{$date}; - my $t; - if (exists $h->{$date}->{$c->{transaction}}) { - $t = $h->{$date}->{$c->{transaction}}; - } - else { - $t = - { journal => parse_journal($c->{journal}) - , journal_code => $c->{journal_code} - , postings => [] - }; - $h->{$date}->{$c->{transaction}} = $t; - } - - my $amount; - if (defined $c->{debit} and $c->{debit} eq '0,00') { - $amount = "-$c->{credit}"; - } - elsif (defined $c->{credit} and $c->{credit} eq '0,00') { - $amount = "$c->{debit}"; - } - else { die "ERROR: wrong credit/debit: CSV#$nth: ".Data::Dumper::Dumper($c); } - - push $t->{postings}, - { account => parse_code($c->{account}) - , amount => $amount - , comment => $c->{account_name} - , csv_nth => $nth+2 - } - } -sub print_hledger (@) { - my ($h, $ap) = @_; - foreach my $date (sort {$a cmp $b} (keys %$h)) { - my $transactions = $h->{$date}; - while (my ($transaction, $t) = each %$transactions) { - print STDOUT "$date $transaction ; Journal:$t->{journal}\n"; - my $wmax = 0; - foreach my $a (@{$t->{postings}}) { - if (not defined $a->{account}) { - print STDERR Data::Dumper::Dumper($t); - die "ERROR: wrong account in t=$transaction"; - } - if (defined $ap->{$a->{account}}) { - $a->{account} = $ap->{$a->{account}}->{account} - } - my $w = 0 + length ($a->{account}); - $wmax = $w - if $wmax < $w; - } - my $p = $t->{postings}; - foreach my $a (sort {$a->{account} cmp $b->{account}} @$p) { - print STDOUT "\t$a->{account} $a->{amount} ; $a->{comment} CSV#.$a->{csv_nth}\n"; - } - } - } - } -sub parse_chart_of_accounts (@) { - my ($coa_file) = @_; - my %ap = (); - my $csv = Text::CSV->new - ({binary => 1 - , eol => $/ - , sep_char => ',' - }); - print STDERR ("Chart_of_accounts: ", $coa_file, "\n"); - open (my $COA, "<:encoding(utf8)", $coa_file) - or die "ERROR: opening accounting plan given as first argument"; - #my $coa_in = IO::Wrap::wraphandle($COA); - my $coa_head = $csv->getline($COA); - print STDERR ("coa_head: ", join("|", @$coa_head), "\n"); - $csv->column_names(@$coa_head); - my $nth = 1; - while (my $csv_line = $csv->getline_hr($COA)) { - $nth++; - my $post_cmt = $csv_line->{'posting-comment'}; - die "ERROR: no posting-comment COA#$nth: ".Data::Dumper::Dumper($csv_line) - if not defined $post_cmt; - my ($code, $description) = ($post_cmt =~ m{^([0-9]+)\.\s*(.*)$}); - die "ERROR: cannot extract code in accounting plan: posting-comment COA#$nth: $csv_line->{'posting-comment'}" - if not defined $code; - $ap{$code} = - { account => $csv_line->{account} - , description => $description - }; - } - print STDERR "Chart_of_accounts: ".Data::Dumper::Dumper(\%ap); - return \%ap; - } - -sub main () { - my $ap = parse_chart_of_accounts($ARGV[0]); - my $csv = Text::CSV->new - ({binary => 1 - , eol => $/ - , sep_char => ';' - }); - my $in = IO::Wrap::wraphandle(\*STDIN); - binmode STDOUT, ':utf8'; - my $csv_head = $csv->getline($in); - #print STDERR ("head: ", join("|", @$csv_head), "\n"); - #$csv->column_names(@$csv_head); - $csv->column_names (qw ( - journal_code - journal - date - transaction - account - account_name - account_code - description - debit - credit - COTVA - TXTVA - )); - my $hledger_data = {}; - - my $members = {}; - my $nth = 0; - while (my $csv_line = $csv->getline_hr($in)) { - #print STDERR ("csv_line: ", join("|", @$csv_line), "\n"); - parse_csv_line(2 + $nth++, $hledger_data, $csv_line); - } - #print STDERR "hledger_data=".Data::Dumper::Dumper($hledger_data); - print_hledger($hledger_data, $ap); - #my $out = IO::Wrap::wraphandle(\*STDERR); - } - -main; diff --git a/hledger-print-csv.hs b/hledger-print-csv.hs deleted file mode 100755 index cac402a..0000000 --- a/hledger-print-csv.hs +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env runhaskell -{-| -hledger-print-csv [-f JOURNALFILE] - -Print matched journal entries as CSV -Reads the default or specified journal. -|-} - -import Hledger.Cli -import Text.CSV -import Data.Char (isSpace) -import Data.List (mapAccumL) - -argsmode :: Mode RawOpts -argsmode = (defCommandMode ["print-csv"]) - { modeHelp = "print matched journal entries as CSV" - , modeGroupFlags = Group - { groupNamed = - [ ("Input",inputflags) - , ("Reporting",reportflags) - , ("Misc",helpflags) - ] - , groupUnnamed = [] - , groupHidden = [] - } - } - -chomp :: String -> String -chomp = reverse . dropWhile isSpace . reverse . dropWhile isSpace - -postingToCSV :: Posting -> CSV -postingToCSV p = - map (\(a@(Amount {aquantity=q,acommodity=c})) -> - let a_ = a{acommodity=""} in - let amount = showAmount a_ in - let commodity = c in - let credit = if q < 0 then showAmount $ negate a_ else "" in - let debit = if q > 0 then showAmount a_ else "" in - account:amount:commodity:credit:debit:status:comment:[]) - amounts - where - Mixed amounts = pamount p - status = if pstatus p then "*" else "" - account = showAccountName Nothing (ptype p) (paccount p) - comment = chomp $ pcomment p - -postingsToCSV :: [Posting] -> CSV -postingsToCSV ps = - concatMap postingToCSV ps - -transactionToCSV :: Integer -> Transaction -> CSV -transactionToCSV n t = - map (\p -> show n:date:date2:status:code:description:comment:p) - (postingsToCSV (tpostings t)) - where - description = tdescription t - date = showDate (tdate t) - date2 = maybe "" showDate (tdate2 t) - status = if tstatus t then "*" else "" - code = tcode t - comment = chomp $ tcomment t - -main :: IO () -main = do - opts <- getCliOpts argsmode - withJournalDo opts $ - \CliOpts{reportopts_=ropts} j -> do - d <- getCurrentDay - let ropts_ = ropts{flat_=True} - let q = queryFromOpts d ropts_ - putStrLn $ printCSV $ concat $ - ([["nth","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","status","posting-comment"]]:).snd $ - mapAccumL (\n e -> (n + 1, transactionToCSV n e)) 0 $ - entriesReport ropts_ q j diff --git a/hledger-range-voting.hs b/hledger-range-voting.hs deleted file mode 100755 index 2bcc330..0000000 --- a/hledger-range-voting.hs +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/env runhaskell -{-| -hledger-range-voting [-f JOURNALFILE] - -Perform range voting calculus -on the default or specified journal. -|-} - -import Data.List ---import Data.List (mapAccumL) -import Data.Maybe -import Data.Ord -import Data.Time.Calendar -import System.Console.CmdArgs.Explicit -import Text.Printf -import qualified Data.Map as Map - -import Hledger -import Hledger.Cli -import Hledger.Cli.Options --- import Prelude hiding (putStr) -import Hledger.Utils.UTF8IOCompat (putStr) - - -argsmode :: Mode RawOpts -argsmode = (defCommandMode ["range-voting"]) - { modeHelp = "perform range voting" - , modeGroupFlags = Group - { groupNamed = - [ ("Input",inputflags) - , ("Reporting",reportflags) - , ("Misc",helpflags) - ] - , groupUnnamed = [] - , groupHidden = [] - } - } - - --- like Register.summarisePostings --- | Print various statistics for the journal. -main :: IO () -main = do - opts <- getCliOpts argsmode - withJournalDo opts $ - \CliOpts{reportopts_=reportopts_} j -> do - d <- getCurrentDay - let q = queryFromOpts d reportopts_ - let l = ledgerFromJournal q j - let reportspan = (ledgerDateSpan l) `spanDefaultsFrom` (queryDateSpan False q) - let intervalspans = splitSpan (intervalFromOpts reportopts_) reportspan - let s = intercalate "\n" $ map (showRangeVoting reportopts_{empty_=True} l d) intervalspans - putStr s - -data Stats = - Stats - { stats_choice :: String - , stats_sum :: Double - , stats_blank_count :: Int - , stats_null_count :: Int - , stats_null_value :: Double - , stats_values :: [(Int,Int)] - } -stats :: Stats -stats = Stats - { stats_choice = "" - , stats_sum = 0.0 - , stats_blank_count = 0 - , stats_null_count = 0 - , stats_null_value = 0.0 - , stats_values = [] - } - - -showRangeVoting :: ReportOpts -> Ledger -> Day -> DateSpan -> String -showRangeVoting ropts l today span = - unlines $ map (\(label,value) -> concatBottomPadded [printf fmt1 label, value]) main - where - fmt1 = "%-" ++ show w1 ++ "s: " - -- fmt2 = "%-" ++ show w2 ++ "s" - w1 = maximum $ map (length . fst) main - -- w2 = maximum $ map (length . show . snd) main - main = - concat $ - [ [("Span vote (official)", printf "%s to %s (%d days)" (show $ (tdate opening)) (show $ (tdate2 opening)) votedays) - ,("Span vote (actual)", printf "%s to %s (%d days)" (start span) (end span) days) - ,("Cardinal", printf "%d" cardinal) - ,("Values", "{"++(intercalate "," $ map (printf "%d") values)++"}") - ,("Quorum", printf "%d/%d (%f%%)" votesnum votersnum (fromIntegral votesnum*100.0/fromIntegral votersnum::Double)) - ,("Blanks", printf "%d" $ foldl (\acc t -> acc + stats_blank_count t) 0 stats) - ,("Nulls", printf "%d" $ foldl (\acc t -> acc + stats_null_count t) 0 stats) - ,("Medians", "") - ] - , map (\t -> - ( printf " - %s" (stats_choice t) - , printf "sum: %+.f" (stats_sum t) - ) ) medians - , [("Choices", printf "%d" nchoices) - ] - , map - (\t -> - ( printf " - %s" (stats_choice t) - , printf "sum: %+f = %d*(0:blank) + %d*(%+.2f:null) + %s" - (stats_sum t) - (stats_blank_count t) - (stats_null_count t) - (stats_null_value t) - (intercalate " + " $ map (\(value,sum) -> printf "%d*(%+d)" sum value) (stats_values t)) - ) - ) stats - --,("Commodities", printf "%s (%s)" (show $ length cs) (intercalate ", " cs)) - ] - where - j = ljournal l - ts = sortBy (comparing tdate) $ filter (spanContainsDate span . tdate) $ jtxns j - as = nub $ map paccount $ concatMap tpostings ts - cs = Map.keys $ canonicalStyles $ concatMap amounts $ map pamount $ concatMap tpostings ts - showelapsed Nothing = "" - showelapsed (Just days) = printf " (%d %s)" days' direction - where days' = abs days - direction | days >= 0 = "days ago" :: String - | otherwise = "days from now" - start (DateSpan (Just d) _) = show d - start _ = "" - end (DateSpan _ (Just d)) = show d - end _ = "" - days = fromMaybe 0 $ daysInSpan span - votedays = fromMaybe 0 $ daysInSpan - (DateSpan - (Just (tdate opening)) - (maybe Nothing Just (tdate2 opening))) - acctnum = length as - openings = filter ((== "Opening") . tdescription) $ ts - opening | null openings = error' "\"Opening\" transaction is missing" - | otherwise = head $ openings - cardinals = filter ((== "Cardinal") . fst) $ ttags opening - cardinal | null cardinals = error' "\"Cardinal\" tag is missing on \"Opening\" transaction" - | otherwise = read $ snd $ head $ cardinals :: Int - values | (cardinal `mod` 2 == 0) = delete 0 [-cardinal`div`2..cardinal`div`2] - | otherwise = [-(cardinal-1)`div`2..(cardinal-1)`div`2] - choices = - map paccount $ - filter (isPrefixOf "Choice:" . paccount) $ - tpostings opening - - votes = filter ((== "Vote") . tdescription) $ ts - stats = - sortBy (\a b -> (stats_sum b) `compare` (stats_sum a)) $ - map (\s -> - let mean = fromIntegral (foldl (\acc (v,c) -> acc + (v * c)) 0 (stats_values s)) / fromIntegral (length (stats_values s)) in - s - { stats_null_value = mean - , stats_sum = (stats_sum s) + (mean * fromIntegral (stats_null_count s)) - }) $ - foldl (\s vote -> - map (\s -> - case filter ((== stats_choice s) . paccount) (tpostings vote) of - [] -> s { stats_blank_count = stats_blank_count s + 1 } - [choice_posting] -> - case pamount choice_posting of - Mixed [Amount{acommodity="", aquantity=q, aprice=NoPrice}] -> - let i = floor q in - if snd (properFraction q) == 0.0 && i `elem` values - then s - { stats_sum = stats_sum s + fromIntegral i - , stats_values = map (\(v,c) -> if v == i then (v,c+1) else (v,c)) (stats_values s) - } - else s { stats_null_count = stats_null_count s + 1 } -- error' $ printf "TODO: null vote: invalid value: %f" q - _ -> s { stats_null_count = stats_null_count s + 1 } -- error' "TODO: null vote: too much informations" - _ -> s { stats_null_count = stats_null_count s + 1 } - ) - s - ) - [ Stats - { stats_choice = choice - , stats_sum = 0.0 - , stats_blank_count = 0 - , stats_null_count = 0 - , stats_null_value = 0.0 - , stats_values = [(value,0) | value<-values] - } - | choice<-choices ] - votes - - medians = - filter (\c -> stats_sum c `elem` medians) stats - where medians = - if length choices `mod` 2 == 0 - then map (stats_sum . (!!) stats) [nchoices `div` 2 - 1, nchoices `div` 2 + 1] - else map (stats_sum . (!!) stats) [(nchoices - 1) `div` 2] - - nchoices = length choices - - -- choicesbalancesropts = ropts{query_="Choice:"} - -- choicesbalances = tail $ fst $ balanceReport ropts (queryFromOpts today choicesbalancesropts) j - - voteras = filter (isPrefixOf "Voter:" . paccount) $ tpostings opening - votests = filter ((== "Vote") . tdescription) $ ts - votesnum = length votests - votersnum = length voteras - votechoicesps = filter (isPrefixOf "Choice:" . paccount) $ tpostings opening diff --git a/lib/tool/asciidoc b/lib/tool/asciidoc index 4e7d282..956919b 160000 --- a/lib/tool/asciidoc +++ b/lib/tool/asciidoc @@ -1 +1 @@ -Subproject commit 4e7d282984a4125b912a744b98e2a85b0cb931db +Subproject commit 956919bf8e65c4d234361d80a1ed56067035457b diff --git a/script/.gitignore b/script/.gitignore new file mode 100644 index 0000000..99a44a7 --- /dev/null +++ b/script/.gitignore @@ -0,0 +1,6 @@ +*.o +*.hi +hledger-check-dates +hledger-equity +hledger-print-csv +hledger-range-voting diff --git a/script/GNUmakefile b/script/GNUmakefile new file mode 100644 index 0000000..5730e3b --- /dev/null +++ b/script/GNUmakefile @@ -0,0 +1,13 @@ +hs=$(wildcard *.hs) + +all: $(hs:.hs=) + +c clean: \ + $(hs:.hs=.o/clean) \ + $(hs:.hs=.hi/clean) \ + $(hs:.hs=/clean) +%/clean: + $(if $(wildcard $*),rm -f "$*") + +%: %.hs + ghc $< diff --git a/script/ghc-pkg-clean b/script/ghc-pkg-clean new file mode 100755 index 0000000..99b23e6 --- /dev/null +++ b/script/ghc-pkg-clean @@ -0,0 +1,15 @@ +#!/bin/sh -eux + +# DESCRIPTION: unregister broken GHC packages. +# Run this a few times to resolve dependency rot in installed packages. +# ghc-pkg-clean -f cabal/dev/packages*.conf also works. +packages=$(ghc-pkg check $* 2>&1 | + grep problems | + awk '{print $6}' | + sed -e 's/:$//' + ) +for p in $packages + do + echo unregistering $p + ghc-pkg "$@" unregister $p + done diff --git a/script/ghc-pkg-reset b/script/ghc-pkg-reset new file mode 100755 index 0000000..3870706 --- /dev/null +++ b/script/ghc-pkg-reset @@ -0,0 +1,12 @@ +#!/bin/sh -eux + +# DESCRIPTION: remove all installed GHC/cabal packages, +# leaving ~/.cabal binaries and docs in place. +# When all else fails, use this to get out of dependency hell and start over. +read -p 'erasing all your user ghc and cabal packages - are you sure (y/n) ? ' ans +test x$ans == xy && ( \ + echo 'erasing directories under ~/.ghc'; rm -rf `find ~/.ghc -maxdepth 1 -type d`; \ + echo 'erasing ~/.cabal/lib'; rm -rf ~/.cabal/lib; \ + # echo 'erasing ~/.cabal/packages'; rm -rf ~/.cabal/packages; \ + # echo 'erasing ~/.cabal/share'; rm -rf ~/.cabal/share; \ + ) diff --git a/script/hledger-check-dates.hs b/script/hledger-check-dates.hs new file mode 100755 index 0000000..8c47351 --- /dev/null +++ b/script/hledger-check-dates.hs @@ -0,0 +1,81 @@ +#!/usr/bin/env runhaskell +{-| +hledger-check-dates [--strict] [--date2] [-f JOURNALFILE] + +Check that transactions' date are monotonically increasing. +Reads the default or specified journal. +|-} + +import Hledger +import Hledger.Cli +import Text.Printf + +argsmode :: Mode RawOpts +argsmode = (defCommandMode ["check-dates"]) + { modeHelp = "check that transactions' date are monotonically increasing" + , modeGroupFlags = Group + { groupNamed = + [ ("Input",inputflags) + , ("Reporting",reportflags) + , ("Misc",helpflags) + ] + ,groupUnnamed = [ + flagNone ["strict"] (\opts -> setboolopt "strict" opts) "makes date comparing strict" + ] + , groupHidden = [] + } + } + +data FoldAcc a b = FoldAcc + { fa_error :: Maybe a + , fa_previous :: Maybe b + } + +foldWhile :: (a -> FoldAcc a b -> FoldAcc a b) -> FoldAcc a b -> [a] -> FoldAcc a b +foldWhile fold acc [] = acc +foldWhile fold acc (a:as) = + case fold a acc of + acc@FoldAcc{fa_error=Just a} -> acc + acc -> foldWhile fold acc as + +checkTransactions :: (Transaction -> Transaction -> Bool) + -> [Transaction] -> FoldAcc Transaction Transaction +checkTransactions compare ts = + foldWhile fold FoldAcc{fa_error=Nothing, fa_previous=Nothing} ts + where + fold current acc@FoldAcc{fa_previous=Nothing} = acc{fa_previous=Just current} + fold current acc@FoldAcc{fa_previous=Just previous} = + if compare previous current + then acc{fa_previous=Just current} + else acc{fa_error=Just current} + +main :: IO () +main = do + opts <- getCliOpts argsmode + withJournalDo opts $ + \cliopts@CliOpts{rawopts_=opts,reportopts_=ropts} j -> do + d <- getCurrentDay + let ropts_ = ropts{flat_=True} + let q = queryFromOpts d ropts_ + let ts = filter (q `matchesTransaction`) $ + jtxns $ journalSelectingAmountFromOpts ropts j + let strict = boolopt "strict" opts + let date = transactionDateFn ropts + let compare a b = + if strict + then date a < date b + else date a <= date b + case checkTransactions compare ts of + FoldAcc{fa_previous=Nothing} -> putStrLn "ok (empty journal)" + FoldAcc{fa_error=Nothing} -> putStrLn "ok" + FoldAcc{fa_error=Just error, fa_previous=Just previous} -> + putStrLn $ printf ("ERROR: transaction out of%s date order" + ++ "\nPrevious date: %s" + ++ "\nDate: %s" + ++ "\nLocation: %s" + ++ "\nTransaction:\n\n%s") + (if strict then " STRICT" else "") + (show $ date previous) + (show $ date error) + (show $ tsourcepos error) + (showTransactionUnelided error) diff --git a/script/hledger-equity.hs b/script/hledger-equity.hs new file mode 100755 index 0000000..43ca0ff --- /dev/null +++ b/script/hledger-equity.hs @@ -0,0 +1,50 @@ +#!/usr/bin/env runhaskell +{- + +Like ledger's equity command, print a journal entry posting the total +balance of all accounts (or the specified account and its subaccounts) +in the default journal. + +An entry like this is useful in the transition to a new journal file, +to zero out asset/liability balances in the old file and initialise +them in the new one. This way you get correct balances when reporting +on either file, and when including both files at once. + +Usage: hledger-equity [ACCTPAT] +-} + +import Data.Maybe (fromMaybe) +import Hledger.Cli + +argsmode :: Mode RawOpts +argsmode = (defCommandMode ["equity"]) + { modeHelp = "print a journal entry posting the total balance of all accounts" + ++ " (or the specified account and its subaccounts)" + , modeGroupFlags = Group + { groupNamed = + [ ("Input",inputflags) + , ("Reporting",reportflags) + , ("Misc",helpflags) + ] + , groupUnnamed = [] + , groupHidden = [] + } + } + +main :: IO () +main = do + opts <- getCliOpts argsmode + withJournalDo opts $ + \CliOpts{reportopts_=ropts} j -> do + today <- getCurrentDay + let ropts_ = ropts{flat_=True} + q = queryFromOpts today ropts_ + (acctbals,_) = balanceReport ropts_ q j + balancingamt = negate $ sum $ map (\((_,_,_),b) -> b) acctbals + ps = [posting{paccount=a, pamount=b} | ((a,_,_),b) <- acctbals] + ++ [posting{paccount="equity:opening balances", pamount=balancingamt}] + enddate = fromMaybe today $ queryEndDate (date2_ ropts_) q + nps = [posting{paccount=a, pamount=negate b} | ((a,_,_),b) <- acctbals] + ++ [posting{paccount="equity:closing balances", pamount=negate balancingamt}] + putStr $ showTransactionUnelided (nulltransaction{tdate=enddate, tpostings=nps}) + putStr $ showTransactionUnelided (nulltransaction{tdate=enddate, tpostings=ps}) diff --git a/script/hledger-of-oxygen-csv.pl b/script/hledger-of-oxygen-csv.pl new file mode 100755 index 0000000..194a612 --- /dev/null +++ b/script/hledger-of-oxygen-csv.pl @@ -0,0 +1,223 @@ +#!/usr/bin/perl +# DESCRIPTION: import from [Oxygène](http://www.memsoft.fr) to [hledger](http://hledger.org) +# AUTHOR: Julien Moutinho +# LICENSE: [GPLv3+](https://www.gnu.org/licenses/gpl-3.0.html) +# NOTE: should be easily hackable to import from other .csv +# USAGE: +# % hledger-print-csv -f Chart_of_accounts.hledger >Chart_of_accounts.csv +# % iconv -f latin1 -t utf8 EXPORT.oxygen.hledger +# +# FORMAT of EXPORT.oxygen.csv: +# ---- +# NUMJL;LIBJL;DTOPE;NPIEC;NUMCP;LIBCP;CODCP;LIBEC;MTDEB;MTCRE;COTVA;TXTVA +# 60;Achats;01/01/2012;ACH01/76;401REGIEQUART;REGIE DE QUARTIER;REGIE DE QUARTI;LOYER LOCAL DEC. 2011+1T 2012 REGIE QUAR;0,00;1410,91;;0,00 +# 60;Achats;01/01/2012;ACH01/76;6132000;LOYER LOCAL 15 rue P. BONNARD;LOYER BONNARD;LOYER LOCAL DEC. 2011+1T 2012 REGIE QUAR;1076,25;0,00;;0,00 +# 60;Achats;01/01/2012;ACH01/76;6165000;Responsabilité civile;;ASSURANCE LOCAL 2012 VIA REGIEQUARTIER;86,47;0,00;;0,00 +# 60;Achats;01/01/2012;ACH01/76;6140000;Charges locatives et de copropriété;;CHARGES LOCAL 1T 2012;248,19;0,00;;0,00 +# ; ... And so on.. and so forth.. +# ---- +# +# FORMAT of Chart_of_accounts.hledger: +# +# Pattern: +# ---- +# 01/01 +# 0.ZZZ:1.YYY:2.XXX 0; 012. Description +# 0.ZZZ:1.YYY:3.WWW 0; 013. Description +# 0.ZZZ:1.YYY:3.WWW.4.VVV 0; 0134. Description +# ; ... And so on.. and so forth.. +# ---- +# +# For exemple: +# ---- +# 01/01 Plan comptable des associations +# 1.Capital 0 ; 1. COMPTES DE CCOAITAUX +# 1.Capital:0.Fonds 0 ; 10. Fonds associatifs et reserves +# 2.Immobilisation 0 ; 2. COMPTES D'IMMOBILISATIONS +# 2.Immobilisation:1.Corporelle 0 ; 21. Immobilisations corporelles +# 4.Tiers 0 ; 4. COMPTES TIERS +# 4.Tiers:0.Fournisseur 0 ; 40. Fournisseurs et comptes rattachés +# 5.Finance 0 ; 5. COMPTES FINANCIERS +# 5.Finance:1.Etablissement 0 ; 51. Banques, établissements financiers et assimilés +# 5.Finance:1.Etablissement:1.Valeur 0 ; 511. Valeurs à l’encaissement +# 5.Finance:1.Etablissement:1.Valeur:2.Chèque_à_encaisser 0 ; 5112. Chèques à encaisser +# 5.Finance:1.Etablissement:2.Banque:001.Courant 0 ; 512001. Crédit Coopératif - Compte courant +# 5.Finance:1.Etablissement:2.Banque:002.Livret 0 ; 512002. Crédit coopératif - Livret +# 6.Charge 0 ; 6. COMPTES D'ACHATS +# 6.Charge:1.Service 0 ; 61. Services extérieurs +# 6.Charge:2.Autre_service 0 ; 62. Autres services extérieurs +# 6.Charge:3.Impôt 0 ; 63. Impôts, taxes et versements assimilés +# 6.Charge:4.Personnel 0 ; 64. Charges de personnel +# 6.Charge:5.Gestion 0 ; 65. Autres charges de gestion courantes +# 6.Charge:8.Dotation 0 ; 68. Dotations aux amortissements, dépréciations, provisions et engagements +# 7.Produit 0 ; 7. COMPTES DE PRODUITS +# 7.Produit:0.Vente 0 ; 70. ventes de produits finis, prestations de services, marchandises +# ; ... And so on.. and so forth.. +# ---- + +our $VERSION = '2014.07.22'; +use strict; +use warnings FATAL => qw(all); +use utf8; +use open qw/:std :utf8/; +require Data::Dumper; +require Encode; +require IO::Wrap; +require Text::CSV; +#require Text::CSV::Encoded; +require Text::Trim; + +sub parse_date (@) { + ($_) = @_; + my ($jj,$mm,undef,$yy) = ($_ =~ m{^\s*([0-3]?[0-9])\s*/\s*([0-1]?[0-9])\s*/\s*(20)?([0-9][0-9])\s*$}); + return "20$yy/$mm/$jj"; + } +sub parse_code (@) { + ($_) = @_; + my ($code) = ($_ =~ m{^([0-9]*?)0*$}); + return (defined $code ? $code : $_); + } +sub parse_journal (@) { + ($_) = @_; + $_ = Text::Trim::trim($_); + s/\s/_/g; + return $_; + } + +sub parse_csv_line (@) { + my ($nth, $h, $c) = @_; + #print STDERR ("parse_csv_line: csv_line($nth)=".Data::Dumper::Dumper($c)); + my $date = parse_date($c->{date}); + $h->{$date} = {} + unless defined $h->{$date}; + my $t; + if (exists $h->{$date}->{$c->{transaction}}) { + $t = $h->{$date}->{$c->{transaction}}; + } + else { + $t = + { journal => parse_journal($c->{journal}) + , journal_code => $c->{journal_code} + , postings => [] + }; + $h->{$date}->{$c->{transaction}} = $t; + } + + my $amount; + if (defined $c->{debit} and $c->{debit} eq '0,00') { + $amount = "-$c->{credit}"; + } + elsif (defined $c->{credit} and $c->{credit} eq '0,00') { + $amount = "$c->{debit}"; + } + else { die "ERROR: wrong credit/debit: CSV#$nth: ".Data::Dumper::Dumper($c); } + + push $t->{postings}, + { account => parse_code($c->{account}) + , amount => $amount + , comment => $c->{account_name} + , csv_nth => $nth+2 + } + } +sub print_hledger (@) { + my ($h, $ap) = @_; + foreach my $date (sort {$a cmp $b} (keys %$h)) { + my $transactions = $h->{$date}; + while (my ($transaction, $t) = each %$transactions) { + print STDOUT "$date $transaction ; Journal:$t->{journal}\n"; + my $wmax = 0; + foreach my $a (@{$t->{postings}}) { + if (not defined $a->{account}) { + print STDERR Data::Dumper::Dumper($t); + die "ERROR: wrong account in t=$transaction"; + } + if (defined $ap->{$a->{account}}) { + $a->{account} = $ap->{$a->{account}}->{account} + } + my $w = 0 + length ($a->{account}); + $wmax = $w + if $wmax < $w; + } + my $p = $t->{postings}; + foreach my $a (sort {$a->{account} cmp $b->{account}} @$p) { + print STDOUT "\t$a->{account} $a->{amount} ; $a->{comment} CSV#.$a->{csv_nth}\n"; + } + } + } + } +sub parse_chart_of_accounts (@) { + my ($coa_file) = @_; + my %ap = (); + my $csv = Text::CSV->new + ({binary => 1 + , eol => $/ + , sep_char => ',' + }); + print STDERR ("Chart_of_accounts: ", $coa_file, "\n"); + open (my $COA, "<:encoding(utf8)", $coa_file) + or die "ERROR: opening accounting plan given as first argument"; + #my $coa_in = IO::Wrap::wraphandle($COA); + my $coa_head = $csv->getline($COA); + print STDERR ("coa_head: ", join("|", @$coa_head), "\n"); + $csv->column_names(@$coa_head); + my $nth = 1; + while (my $csv_line = $csv->getline_hr($COA)) { + $nth++; + my $post_cmt = $csv_line->{'posting-comment'}; + die "ERROR: no posting-comment COA#$nth: ".Data::Dumper::Dumper($csv_line) + if not defined $post_cmt; + my ($code, $description) = ($post_cmt =~ m{^([0-9]+)\.\s*(.*)$}); + die "ERROR: cannot extract code in accounting plan: posting-comment COA#$nth: $csv_line->{'posting-comment'}" + if not defined $code; + $ap{$code} = + { account => $csv_line->{account} + , description => $description + }; + } + print STDERR "Chart_of_accounts: ".Data::Dumper::Dumper(\%ap); + return \%ap; + } + +sub main () { + my $ap = parse_chart_of_accounts($ARGV[0]); + my $csv = Text::CSV->new + ({binary => 1 + , eol => $/ + , sep_char => ';' + }); + my $in = IO::Wrap::wraphandle(\*STDIN); + binmode STDOUT, ':utf8'; + my $csv_head = $csv->getline($in); + #print STDERR ("head: ", join("|", @$csv_head), "\n"); + #$csv->column_names(@$csv_head); + $csv->column_names (qw ( + journal_code + journal + date + transaction + account + account_name + account_code + description + debit + credit + COTVA + TXTVA + )); + my $hledger_data = {}; + + my $members = {}; + my $nth = 0; + while (my $csv_line = $csv->getline_hr($in)) { + #print STDERR ("csv_line: ", join("|", @$csv_line), "\n"); + parse_csv_line(2 + $nth++, $hledger_data, $csv_line); + } + #print STDERR "hledger_data=".Data::Dumper::Dumper($hledger_data); + print_hledger($hledger_data, $ap); + #my $out = IO::Wrap::wraphandle(\*STDERR); + } + +main; diff --git a/script/hledger-print-csv.hs b/script/hledger-print-csv.hs new file mode 100755 index 0000000..cac402a --- /dev/null +++ b/script/hledger-print-csv.hs @@ -0,0 +1,74 @@ +#!/usr/bin/env runhaskell +{-| +hledger-print-csv [-f JOURNALFILE] + +Print matched journal entries as CSV +Reads the default or specified journal. +|-} + +import Hledger.Cli +import Text.CSV +import Data.Char (isSpace) +import Data.List (mapAccumL) + +argsmode :: Mode RawOpts +argsmode = (defCommandMode ["print-csv"]) + { modeHelp = "print matched journal entries as CSV" + , modeGroupFlags = Group + { groupNamed = + [ ("Input",inputflags) + , ("Reporting",reportflags) + , ("Misc",helpflags) + ] + , groupUnnamed = [] + , groupHidden = [] + } + } + +chomp :: String -> String +chomp = reverse . dropWhile isSpace . reverse . dropWhile isSpace + +postingToCSV :: Posting -> CSV +postingToCSV p = + map (\(a@(Amount {aquantity=q,acommodity=c})) -> + let a_ = a{acommodity=""} in + let amount = showAmount a_ in + let commodity = c in + let credit = if q < 0 then showAmount $ negate a_ else "" in + let debit = if q > 0 then showAmount a_ else "" in + account:amount:commodity:credit:debit:status:comment:[]) + amounts + where + Mixed amounts = pamount p + status = if pstatus p then "*" else "" + account = showAccountName Nothing (ptype p) (paccount p) + comment = chomp $ pcomment p + +postingsToCSV :: [Posting] -> CSV +postingsToCSV ps = + concatMap postingToCSV ps + +transactionToCSV :: Integer -> Transaction -> CSV +transactionToCSV n t = + map (\p -> show n:date:date2:status:code:description:comment:p) + (postingsToCSV (tpostings t)) + where + description = tdescription t + date = showDate (tdate t) + date2 = maybe "" showDate (tdate2 t) + status = if tstatus t then "*" else "" + code = tcode t + comment = chomp $ tcomment t + +main :: IO () +main = do + opts <- getCliOpts argsmode + withJournalDo opts $ + \CliOpts{reportopts_=ropts} j -> do + d <- getCurrentDay + let ropts_ = ropts{flat_=True} + let q = queryFromOpts d ropts_ + putStrLn $ printCSV $ concat $ + ([["nth","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","status","posting-comment"]]:).snd $ + mapAccumL (\n e -> (n + 1, transactionToCSV n e)) 0 $ + entriesReport ropts_ q j diff --git a/script/hledger-range-voting.hs b/script/hledger-range-voting.hs new file mode 100755 index 0000000..2bcc330 --- /dev/null +++ b/script/hledger-range-voting.hs @@ -0,0 +1,201 @@ +#!/usr/bin/env runhaskell +{-| +hledger-range-voting [-f JOURNALFILE] + +Perform range voting calculus +on the default or specified journal. +|-} + +import Data.List +--import Data.List (mapAccumL) +import Data.Maybe +import Data.Ord +import Data.Time.Calendar +import System.Console.CmdArgs.Explicit +import Text.Printf +import qualified Data.Map as Map + +import Hledger +import Hledger.Cli +import Hledger.Cli.Options +-- import Prelude hiding (putStr) +import Hledger.Utils.UTF8IOCompat (putStr) + + +argsmode :: Mode RawOpts +argsmode = (defCommandMode ["range-voting"]) + { modeHelp = "perform range voting" + , modeGroupFlags = Group + { groupNamed = + [ ("Input",inputflags) + , ("Reporting",reportflags) + , ("Misc",helpflags) + ] + , groupUnnamed = [] + , groupHidden = [] + } + } + + +-- like Register.summarisePostings +-- | Print various statistics for the journal. +main :: IO () +main = do + opts <- getCliOpts argsmode + withJournalDo opts $ + \CliOpts{reportopts_=reportopts_} j -> do + d <- getCurrentDay + let q = queryFromOpts d reportopts_ + let l = ledgerFromJournal q j + let reportspan = (ledgerDateSpan l) `spanDefaultsFrom` (queryDateSpan False q) + let intervalspans = splitSpan (intervalFromOpts reportopts_) reportspan + let s = intercalate "\n" $ map (showRangeVoting reportopts_{empty_=True} l d) intervalspans + putStr s + +data Stats = + Stats + { stats_choice :: String + , stats_sum :: Double + , stats_blank_count :: Int + , stats_null_count :: Int + , stats_null_value :: Double + , stats_values :: [(Int,Int)] + } +stats :: Stats +stats = Stats + { stats_choice = "" + , stats_sum = 0.0 + , stats_blank_count = 0 + , stats_null_count = 0 + , stats_null_value = 0.0 + , stats_values = [] + } + + +showRangeVoting :: ReportOpts -> Ledger -> Day -> DateSpan -> String +showRangeVoting ropts l today span = + unlines $ map (\(label,value) -> concatBottomPadded [printf fmt1 label, value]) main + where + fmt1 = "%-" ++ show w1 ++ "s: " + -- fmt2 = "%-" ++ show w2 ++ "s" + w1 = maximum $ map (length . fst) main + -- w2 = maximum $ map (length . show . snd) main + main = + concat $ + [ [("Span vote (official)", printf "%s to %s (%d days)" (show $ (tdate opening)) (show $ (tdate2 opening)) votedays) + ,("Span vote (actual)", printf "%s to %s (%d days)" (start span) (end span) days) + ,("Cardinal", printf "%d" cardinal) + ,("Values", "{"++(intercalate "," $ map (printf "%d") values)++"}") + ,("Quorum", printf "%d/%d (%f%%)" votesnum votersnum (fromIntegral votesnum*100.0/fromIntegral votersnum::Double)) + ,("Blanks", printf "%d" $ foldl (\acc t -> acc + stats_blank_count t) 0 stats) + ,("Nulls", printf "%d" $ foldl (\acc t -> acc + stats_null_count t) 0 stats) + ,("Medians", "") + ] + , map (\t -> + ( printf " - %s" (stats_choice t) + , printf "sum: %+.f" (stats_sum t) + ) ) medians + , [("Choices", printf "%d" nchoices) + ] + , map + (\t -> + ( printf " - %s" (stats_choice t) + , printf "sum: %+f = %d*(0:blank) + %d*(%+.2f:null) + %s" + (stats_sum t) + (stats_blank_count t) + (stats_null_count t) + (stats_null_value t) + (intercalate " + " $ map (\(value,sum) -> printf "%d*(%+d)" sum value) (stats_values t)) + ) + ) stats + --,("Commodities", printf "%s (%s)" (show $ length cs) (intercalate ", " cs)) + ] + where + j = ljournal l + ts = sortBy (comparing tdate) $ filter (spanContainsDate span . tdate) $ jtxns j + as = nub $ map paccount $ concatMap tpostings ts + cs = Map.keys $ canonicalStyles $ concatMap amounts $ map pamount $ concatMap tpostings ts + showelapsed Nothing = "" + showelapsed (Just days) = printf " (%d %s)" days' direction + where days' = abs days + direction | days >= 0 = "days ago" :: String + | otherwise = "days from now" + start (DateSpan (Just d) _) = show d + start _ = "" + end (DateSpan _ (Just d)) = show d + end _ = "" + days = fromMaybe 0 $ daysInSpan span + votedays = fromMaybe 0 $ daysInSpan + (DateSpan + (Just (tdate opening)) + (maybe Nothing Just (tdate2 opening))) + acctnum = length as + openings = filter ((== "Opening") . tdescription) $ ts + opening | null openings = error' "\"Opening\" transaction is missing" + | otherwise = head $ openings + cardinals = filter ((== "Cardinal") . fst) $ ttags opening + cardinal | null cardinals = error' "\"Cardinal\" tag is missing on \"Opening\" transaction" + | otherwise = read $ snd $ head $ cardinals :: Int + values | (cardinal `mod` 2 == 0) = delete 0 [-cardinal`div`2..cardinal`div`2] + | otherwise = [-(cardinal-1)`div`2..(cardinal-1)`div`2] + choices = + map paccount $ + filter (isPrefixOf "Choice:" . paccount) $ + tpostings opening + + votes = filter ((== "Vote") . tdescription) $ ts + stats = + sortBy (\a b -> (stats_sum b) `compare` (stats_sum a)) $ + map (\s -> + let mean = fromIntegral (foldl (\acc (v,c) -> acc + (v * c)) 0 (stats_values s)) / fromIntegral (length (stats_values s)) in + s + { stats_null_value = mean + , stats_sum = (stats_sum s) + (mean * fromIntegral (stats_null_count s)) + }) $ + foldl (\s vote -> + map (\s -> + case filter ((== stats_choice s) . paccount) (tpostings vote) of + [] -> s { stats_blank_count = stats_blank_count s + 1 } + [choice_posting] -> + case pamount choice_posting of + Mixed [Amount{acommodity="", aquantity=q, aprice=NoPrice}] -> + let i = floor q in + if snd (properFraction q) == 0.0 && i `elem` values + then s + { stats_sum = stats_sum s + fromIntegral i + , stats_values = map (\(v,c) -> if v == i then (v,c+1) else (v,c)) (stats_values s) + } + else s { stats_null_count = stats_null_count s + 1 } -- error' $ printf "TODO: null vote: invalid value: %f" q + _ -> s { stats_null_count = stats_null_count s + 1 } -- error' "TODO: null vote: too much informations" + _ -> s { stats_null_count = stats_null_count s + 1 } + ) + s + ) + [ Stats + { stats_choice = choice + , stats_sum = 0.0 + , stats_blank_count = 0 + , stats_null_count = 0 + , stats_null_value = 0.0 + , stats_values = [(value,0) | value<-values] + } + | choice<-choices ] + votes + + medians = + filter (\c -> stats_sum c `elem` medians) stats + where medians = + if length choices `mod` 2 == 0 + then map (stats_sum . (!!) stats) [nchoices `div` 2 - 1, nchoices `div` 2 + 1] + else map (stats_sum . (!!) stats) [(nchoices - 1) `div` 2] + + nchoices = length choices + + -- choicesbalancesropts = ropts{query_="Choice:"} + -- choicesbalances = tail $ fst $ balanceReport ropts (queryFromOpts today choicesbalancesropts) j + + voteras = filter (isPrefixOf "Voter:" . paccount) $ tpostings opening + votests = filter ((== "Vote") . tdescription) $ ts + votesnum = length votests + votersnum = length voteras + votechoicesps = filter (isPrefixOf "Choice:" . paccount) $ tpostings opening diff --git a/script/timelog b/script/timelog new file mode 100755 index 0000000..58e519b --- /dev/null +++ b/script/timelog @@ -0,0 +1,64 @@ +#!/bin/sh -eu + +# ACTION: initialize from ./ + test -L "$0" && tool="$(readlink -e "$0")" || tool=$0 + tool=$(readlink -e "${tool%/*}"/.) + root=$(readlink -e "${root:-"${0%/*}"/.}") + +TIMELOG=${TIMELOG:-"$root"/time.log} + +rule_edit () { + touch "$TIMELOG" + ${EDITOR:-vim} "$@" "$TIMELOG" + } +rule_in () { + date=$(date '+%Y-%m-%d %H:%M:%S') + touch "$TIMELOG" + { + last=$(tail -n 1 "$TIMELOG") + if test ! "$last" = "${last#i}" + then printf 'o %s %s\n' "$date" + fi + printf 'i %s %s\n' "$date" "$*" + } | tee /dev/stderr >>"$TIMELOG" + } +rule_help () { + cat >&2 <<-EOF + Syntax: + ${0##*/} [e|edit] + ${0##*/} [i|in] Path:To:Task Comment + ${0##*/} [s|server] + ${0##*/} [o|out] + ${0##*/} \$hledger_command + EOF + } +rule_hledger () { + set -x + hledger ${HLEDGER_FLAGS-} -f "$TIMELOG" "$@" + } +rule_server () { + cd "$root" + set -x + hledger-web --server ${HLEDGER_WEB_FLAGS-} -f "$TIMELOG" "$@" + } +rule_out () { + last=$(tail -n 1 "$TIMELOG") + if test "$last" = "${last#o}" + then + date=$(date '+%Y-%m-%d %H:%M:%S') + { + printf 'o %s %s\n' "$date" "$*" + } | tee /dev/stderr >>"$TIMELOG" + fi + } + +rule=${1:-help} +test $# = 0 || shift +case $rule in + (i|'in') rule_in "$@";; + (o|out) rule_out "$@";; + (e|edit) rule_edit "$@";; + (s|server) rule_server "$@";; + (h|help|-h|--help|'') rule_help $rule "$@";; + (*) rule_hledger $rule "$@";; + esac diff --git a/timelog b/timelog deleted file mode 100755 index 58e519b..0000000 --- a/timelog +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -eu - -# ACTION: initialize from ./ - test -L "$0" && tool="$(readlink -e "$0")" || tool=$0 - tool=$(readlink -e "${tool%/*}"/.) - root=$(readlink -e "${root:-"${0%/*}"/.}") - -TIMELOG=${TIMELOG:-"$root"/time.log} - -rule_edit () { - touch "$TIMELOG" - ${EDITOR:-vim} "$@" "$TIMELOG" - } -rule_in () { - date=$(date '+%Y-%m-%d %H:%M:%S') - touch "$TIMELOG" - { - last=$(tail -n 1 "$TIMELOG") - if test ! "$last" = "${last#i}" - then printf 'o %s %s\n' "$date" - fi - printf 'i %s %s\n' "$date" "$*" - } | tee /dev/stderr >>"$TIMELOG" - } -rule_help () { - cat >&2 <<-EOF - Syntax: - ${0##*/} [e|edit] - ${0##*/} [i|in] Path:To:Task Comment - ${0##*/} [s|server] - ${0##*/} [o|out] - ${0##*/} \$hledger_command - EOF - } -rule_hledger () { - set -x - hledger ${HLEDGER_FLAGS-} -f "$TIMELOG" "$@" - } -rule_server () { - cd "$root" - set -x - hledger-web --server ${HLEDGER_WEB_FLAGS-} -f "$TIMELOG" "$@" - } -rule_out () { - last=$(tail -n 1 "$TIMELOG") - if test "$last" = "${last#o}" - then - date=$(date '+%Y-%m-%d %H:%M:%S') - { - printf 'o %s %s\n' "$date" "$*" - } | tee /dev/stderr >>"$TIMELOG" - fi - } - -rule=${1:-help} -test $# = 0 || shift -case $rule in - (i|'in') rule_in "$@";; - (o|out) rule_out "$@";; - (e|edit) rule_edit "$@";; - (s|server) rule_server "$@";; - (h|help|-h|--help|'') rule_help $rule "$@";; - (*) rule_hledger $rule "$@";; - esac diff --git a/vim/.vimrc b/vim/.vimrc deleted file mode 100644 index 83a8432..0000000 --- a/vim/.vimrc +++ /dev/null @@ -1,250 +0,0 @@ -function! GetFoldExprFromIndent() - " Calcule l'indentation en fonction des tabulations - " et espaces au début des lignes - let line = getline(v:lnum) - let tabs = strlen(matchstr(line,"^\t*")) - let spaces = strlen(matchstr(line,"^[ \t]*")) - tabs - return tabs + ((spaces + 3) / 4) - endfunction -hi FoldColumn ctermfg=black ctermbg=none cterm=bold -hi Folded ctermfg=black ctermbg=none cterm=bold -hi LineNr ctermfg=black ctermbg=none cterm=bold -hi Pmenu cterm=none ctermfg=white ctermbg=blue guibg=blue -hi PmenuSel cterm=bold ctermfg=white ctermbg=red guibg=red -hi Search ctermbg=yellow -hi SpecialKey ctermfg=black cterm=bold -hi StatusLine term=bold,reverse ctermfg=grey ctermbg=blue cterm=none -hi StatusLineNC term=reverse ctermfg=blue ctermbg=none cterm=underline -hi Visual guibg=yellow -nmap * :set hls:let @/="\\<\\>"/ -nmap µ :set hls:let @/=""/ -nnoremap i -nnoremap k -nnoremap j -nnoremap l -xnoremap i -xnoremap k -xnoremap j -xnoremap l -nnoremap K J -nnoremap J w -nnoremap L -set autochdir -set cmdheight=1 -set completeopt=longest,menu -set directory=$HOME/var/cache/vim/swap -set encoding=utf-8 -set foldcolumn=0 -set foldenable -set foldexpr=GetFoldExprFromIndent() -set foldmethod=expr -set foldminlines=0 -set history=2048 -set hlsearch -set incsearch -set laststatus=2 -set lazyredraw -set list -set path=.,/usr/include,/usr/local/include,, -set scroll=0 -set scrolloff=0 -set sidescroll=0 -set sidescrolloff=0 -set swapfile -set matchpairs+=<:> -set maxmempattern=2000 -set nocompatible -set noerrorbells -set noignorecase -set loadplugins -set nowrap -set nowrapscan -set number -set ruler -set runtimepath=$HOME/.vim,$VIMRUNTIME,$VIM -set sessionoptions=curdir,folds -set shiftwidth=2 -set showcmd -set smartindent -set statusline=%F%=\ %m%R\ %l:%c\ x%02B\ %Y\ %{&encoding} -set tabstop=2 -set ttyfast -set undolevels=512 -set updatetime=4096 -set verbose=0 -set viewdir=$HOME/var/lib/vim/view -set viminfo+=n$HOME/var/cache/vim/info -set novisualbell -set visualbell t_vb= -set whichwrap+=<,>,[,] -set wildignore=*.a,*.d,*.o,*.so,*~,*.cmo,*.cmi,*.cmx,*.cmxs,*.cma,*.cmxa,*.byte,*.native -set wildmenu -set wildmode=longest,list,full -syntax on -if (&term == "linux") - set foldtext=substitute(getline(v\:foldstart),'\\t','\|_','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' - set fillchars=fold:_ - set list listchars=nbsp:+,tab:\|_,trail:_,extends:>,precedes:< - else - set foldtext=substitute(getline(v\:foldstart),'\\t','⎢·','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' - set fillchars=fold:· - set list listchars=nbsp:¬,tab:⎢·,trail:·,extends:>,precedes:< - endif -if (v:version >= 700) - hi TabLine term=bold,reverse ctermfg=white ctermbg=blue cterm=none - hi TabLineFill term=bold,reverse ctermfg=none ctermbg=blue cterm=none - hi TabLineSel term=reverse ctermfg=white ctermbg=none cterm=bold - inoremap :tabpreviousi - inoremap :tabnew - inoremap :tabnexti - nnoremap :tabprevious - nnoremap :tabprevious - nnoremap :tabnew - nnoremap :tabnext - nnoremap :tabprevious - nnoremap td :tabclose - nnoremap ti :tabfirst - nnoremap tj :tabprev - nnoremap tk :tablast - nnoremap tl :tabnext - nnoremap tm :tabm - nnoremap tn :tabnew - nnoremap tt :tabedit - set tabpagemax=1000 - set sessionoptions+=tabpages - endif -if (v:version >= 703) - set undodir=$HOME/var/cache/vim/undo/ - set undofile - endif -""" -""" filetypes -""" -autocmd BufNewFile,BufRead *.hledger,*.ledger,*.journal setfiletype hledger -autocmd Filetype hledger set iskeyword+=.,38,39,40,41,44,45,58 -""" -""" plugins -""" -runtime plugin/gundo.vim -runtime plugin/gzip.vim -runtime macros/justify.vim -let b:match_words = '«:»,“:”' -runtime plugin/matchit.vim -let g:netrw_liststyle = 3 -"let g:netrw_cursorline = 0 -let s:netrw_usercul = 0 -runtime plugin/netrwPlugin.vim - -" EasyAlign - vmap (EasyAlign) - nmap a (EasyAlign) - let g:easy_align_ignore_groups = ['Comment', 'String', 'hledgerTransaction'] - -" neocomplcache - " Disable automatic completion popup - let g:neocomplcache_disable_auto_complete = 1 - " Disable AutoComplPop. - let g:acp_enableAtStartup = 0 - " Use neocomplcache. - let g:neocomplcache_enable_at_startup = 1 - " Use smartcase. - let g:neocomplcache_enable_smart_case = 1 - " Set minimum syntax keyword length. - let g:neocomplcache_min_syntax_length = 2 - let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' - - " Define dictionary. - let g:neocomplcache_dictionary_filetype_lists = { - \ 'default' : '', - \ 'vimshell' : $HOME.'/.vimshell_hist', - \ 'scheme' : $HOME.'/.gosh_completions' - \ } - - " Define keyword. - if !exists('g:neocomplcache_keyword_patterns') - let g:neocomplcache_keyword_patterns = {} - endif - let g:neocomplcache_keyword_patterns['default'] = '\h\w*' - - " Plugin key-mappings. - inoremap neocomplcache#undo_completion() - inoremap neocomplcache#complete_common_string() - - " Complete with . - "inoremap pumvisible() ? "\" : check_back_space() ? "\" : "\\" - inoremap pumvisible() ? neocomplcache#complete_common_string() : check_back_space() ? "\" : "\\" - - function! s:check_back_space() - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~ '\s' - endfunction - - " Choose candidate with . - inoremap neocomplcache#smart_close_popup() . “\” - - " Recommended key-mappings. - " : close popup and save indent. - inoremap =my_cr_function() - function! s:my_cr_function() - return neocomplcache#smart_close_popup() . "\" - " For no inserting key. - "return pumvisible() ? neocomplcache#close_popup() : "\" - endfunction - " : completion. - "inoremap pumvisible() ? neocomplcache#complete_common_string() : "\" - "inoremap neocomplcache#complete_common_string() - " , : close popup and delete backword char. - inoremap neocomplcache#smart_close_popup()."\" - inoremap neocomplcache#smart_close_popup()."\" - inoremap neocomplcache#close_popup() - inoremap neocomplcache#cancel_popup() - " Close popup by . - inoremap pumvisible() ? neocomplcache#close_popup() : "\" - - " Sort choices by bytes - call neocomplcache#custom_source('_', 'sorters', ['sorter_bytes']) - - " For cursor moving in insert mode(Not recommended) - "inoremap neocomplcache#close_popup() . "\" - "inoremap neocomplcache#close_popup() . "\" - "inoremap neocomplcache#close_popup() . "\" - "inoremap neocomplcache#close_popup() . "\" - " Or set this. - "let g:neocomplcache_enable_cursor_hold_i = 1 - " Or set this. - "let g:neocomplcache_enable_insert_char_pre = 1 - - " AutoComplPop like behavior. - "let g:neocomplcache_enable_auto_select = 1 - - " Enable heavy features. - " Use camel case completion. - "let g:neocomplcache_enable_camel_case_completion = 1 - " Use underbar completion. - let g:neocomplcache_enable_underbar_completion = 1 - - " Shell like behavior(not recommended). - "set completeopt+=longest - "let g:neocomplcache_enable_auto_select = 1 - "let g:neocomplcache_disable_auto_complete = 1 - "inoremap pumvisible() ? "\" : "\\" - - " Enable omni completion. - autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS - autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags - autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS - autocmd FileType python setlocal omnifunc=pythoncomplete#Complete - autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags - - " Enable heavy omni completion. - if !exists('g:neocomplcache_omni_patterns') - let g:neocomplcache_omni_patterns = {} - endif - let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' - let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' - let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' - - " For perlomni.vim setting. - " https://github.com/c9s/perlomni.vim - let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::' - runtime plugin/neocomplcache.vim diff --git a/vim/config/easy_align.vim b/vim/config/easy_align.vim new file mode 100644 index 0000000..980d163 --- /dev/null +++ b/vim/config/easy_align.vim @@ -0,0 +1,3 @@ +nmap a (EasyAlign) +vmap (EasyAlign) +let g:easy_align_ignore_groups = ['Comment', 'String', 'hledgerTransaction'] diff --git a/vim/config/julm.vim b/vim/config/julm.vim new file mode 100644 index 0000000..ea26b40 --- /dev/null +++ b/vim/config/julm.vim @@ -0,0 +1,131 @@ +function! GetFoldExprFromIndent() + " Calcule l'indentation en fonction des tabulations + " et espaces au début des lignes + let line = getline(v:lnum) + let tabs = strlen(matchstr(line,"^\t*")) + let spaces = strlen(matchstr(line,"^[ \t]*")) - tabs + return tabs + ((spaces + 3) / 4) + endfunction +hi FoldColumn ctermfg=black ctermbg=none cterm=bold +hi Folded ctermfg=black ctermbg=none cterm=bold +hi LineNr ctermfg=black ctermbg=none cterm=bold +hi Pmenu cterm=none ctermfg=white ctermbg=blue guibg=blue +hi PmenuSel cterm=bold ctermfg=white ctermbg=red guibg=red +hi Search ctermbg=yellow +hi SpecialKey ctermfg=black cterm=bold +hi StatusLine term=bold,reverse ctermfg=grey ctermbg=blue cterm=none +hi StatusLineNC term=reverse ctermfg=blue ctermbg=none cterm=underline +hi Visual guibg=yellow +nmap * :set hls:let @/="\\<\\>"/ +nmap µ :set hls:let @/=""/ +nnoremap i +nnoremap k +nnoremap j +nnoremap l +xnoremap i +xnoremap k +xnoremap j +xnoremap l +nnoremap K J +nnoremap J w +nnoremap L +set autochdir +set cmdheight=1 +set completeopt=longest,menu +"set directory=~/var/cache/vim/swap +set directory=~/.vim/swap +set encoding=utf-8 +set foldcolumn=0 +set foldenable +set foldexpr=GetFoldExprFromIndent() +set foldmethod=expr +set foldminlines=0 +set history=2048 +set hlsearch +set incsearch +set laststatus=2 +set lazyredraw +set list +set path=.,/usr/include,/usr/local/include,, +set scroll=0 +set scrolloff=0 +set sidescroll=0 +set sidescrolloff=0 +set swapfile +set matchpairs+=<:> +set maxmempattern=2000 +set nocompatible +set noerrorbells +set noignorecase +set loadplugins +set nowrap +set nowrapscan +set number +set ruler +set runtimepath=~/.vim,$VIMRUNTIME,$VIM +set sessionoptions=curdir,folds +set shiftwidth=2 +set showcmd +set smartindent +set statusline=%F%=\ %m%R\ %l:%c\ x%02B\ %Y\ %{&encoding} +set tabstop=2 +set ttyfast +set undolevels=512 +set updatetime=4096 +set verbose=0 +"set viewdir=~/var/lib/vim/view +"set viminfo+=n~/var/cache/vim/info +set novisualbell +set visualbell t_vb= +set whichwrap+=<,>,[,] +set wildignore=*.a,*.d,*.o,*.so,*~,*.cmo,*.cmi,*.cmx,*.cmxs,*.cma,*.cmxa,*.byte,*.native,*.hi,*.ho +set wildmenu +set wildmode=longest,list,full +syntax on +if (&term == "linux") + set foldtext=substitute(getline(v\:foldstart),'\\t','\|_','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' + set fillchars=fold:_ + set list listchars=nbsp:+,tab:\|_,trail:_,extends:>,precedes:< + else + set foldtext=substitute(getline(v\:foldstart),'\\t','⎢·','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' + set fillchars=fold:· + set list listchars=nbsp:¬,tab:⎢·,trail:·,extends:>,precedes:< + endif +if (v:version >= 700) + hi TabLine term=bold,reverse ctermfg=white ctermbg=blue cterm=none + hi TabLineFill term=bold,reverse ctermfg=none ctermbg=blue cterm=none + hi TabLineSel term=reverse ctermfg=white ctermbg=none cterm=bold + inoremap :tabpreviousi + inoremap :tabnew + inoremap :tabnexti + nnoremap :tabprevious + nnoremap :tabprevious + nnoremap :tabnew + nnoremap :tabnext + nnoremap :tabprevious + nnoremap td :tabclose + nnoremap ti :tabfirst + nnoremap tj :tabprev + nnoremap tk :tablast + nnoremap tl :tabnext + nnoremap tm :tabm + nnoremap tn :tabnew + nnoremap tt :tabedit + set tabpagemax=1000 + set sessionoptions+=tabpages + endif +if (v:version >= 703) + "set undodir=~/var/cache/vim/undo/ + set undodir=~/.vim/undo/ + set undofile + endif +""" +""" plugins +""" +runtime macros/justify.vim +let b:match_words = '«:»,“:”' +runtime plugin/matchit.vim +let g:netrw_liststyle = 3 +"let g:netrw_cursorline = 0 +let s:netrw_usercul = 0 +runtime plugin/netrwPlugin.vim diff --git a/vim/config/neocomplcache.vim b/vim/config/neocomplcache.vim new file mode 100644 index 0000000..bbe9975 --- /dev/null +++ b/vim/config/neocomplcache.vim @@ -0,0 +1,107 @@ +" Disable automatic completion popup +let g:neocomplcache_disable_auto_complete = 1 +" Disable AutoComplPop. +let g:acp_enableAtStartup = 0 +" Use neocomplcache. +let g:neocomplcache_enable_at_startup = 1 +" Use smartcase. +let g:neocomplcache_enable_smart_case = 1 +" Set minimum syntax keyword length. +let g:neocomplcache_min_syntax_length = 2 +let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' + +" Define dictionary. +let g:neocomplcache_dictionary_filetype_lists = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + +" Define keyword. +if !exists('g:neocomplcache_keyword_patterns') + let g:neocomplcache_keyword_patterns = {} +endif +let g:neocomplcache_keyword_patterns['default'] = '\h\w*' + +" Plugin key-mappings. +inoremap neocomplcache#undo_completion() +inoremap neocomplcache#complete_common_string() + +" Complete with . +"inoremap pumvisible() ? "\" : check_back_space() ? "\" : "\\" +inoremap pumvisible() ? neocomplcache#complete_common_string() : check_back_space() ? "\" : "\\" + +function! s:check_back_space() + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' + endfunction + +" Choose candidate with . +inoremap neocomplcache#smart_close_popup() . “\” + +" Recommended key-mappings. +" : close popup and save indent. +inoremap =my_cr_function() +function! s:my_cr_function() + return neocomplcache#smart_close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplcache#close_popup() : "\" + endfunction +" : completion. +"inoremap pumvisible() ? neocomplcache#complete_common_string() : "\" +"inoremap neocomplcache#complete_common_string() +" , : close popup and delete backword char. +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#close_popup() +inoremap neocomplcache#cancel_popup() +" Close popup by . +inoremap pumvisible() ? neocomplcache#close_popup() : "\" + +" Sort choices by bytes +call neocomplcache#custom_source('_', 'sorters', ['sorter_bytes']) + +" For cursor moving in insert mode(Not recommended) +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +"inoremap neocomplcache#close_popup() . "\" +" Or set this. +"let g:neocomplcache_enable_cursor_hold_i = 1 +" Or set this. +"let g:neocomplcache_enable_insert_char_pre = 1 + +" AutoComplPop like behavior. +"let g:neocomplcache_enable_auto_select = 1 + +" Enable heavy features. +" Use camel case completion. +"let g:neocomplcache_enable_camel_case_completion = 1 +" Use underbar completion. +let g:neocomplcache_enable_underbar_completion = 1 + +" Shell like behavior(not recommended). +"set completeopt+=longest +"let g:neocomplcache_enable_auto_select = 1 +"let g:neocomplcache_disable_auto_complete = 1 +"inoremap pumvisible() ? "\" : "\\" + +" Enable omni completion. +autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS +autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags +autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS +autocmd FileType python setlocal omnifunc=pythoncomplete#Complete +autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags + +" Enable heavy omni completion. +if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} +endif +let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' +let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + +" For perlomni.vim setting. +" https://github.com/c9s/perlomni.vim +let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::' +runtime plugin/neocomplcache.vim diff --git a/vim/ftdetect/hledger.vim b/vim/ftdetect/hledger.vim new file mode 100644 index 0000000..5a14852 --- /dev/null +++ b/vim/ftdetect/hledger.vim @@ -0,0 +1,2 @@ +autocmd BufNewFile,BufRead *.hledger,*.ledger,*.journal setfiletype hledger +autocmd Filetype hledger set iskeyword+=.,38,39,40,41,44,45,58 diff --git a/vim/install b/vim/install new file mode 100755 index 0000000..fa5aa88 --- /dev/null +++ b/vim/install @@ -0,0 +1,45 @@ +#!/bin/sh -eux +test -L "$0" && tool="$(readlink -e "$0")" || tool=$0 +tool=$(readlink -e "${tool%/*}"/.) + +install -d -D -m 700 \ + ~/.vim \ + ~/.vim/swap \ + ~/.vim/view \ + ~/.vim/undo + +( +cd ~/.vim && +for d in autoload config ftdetect syntax + do cp -frs "$tool"/$d . + done +) + +install_plugin () { + dst=~/.vim/git/$1 + url=$2 + if test -d "$dst" + then ( cd "$dst" && git pull -v ) + else git clone --depth 1 "$url" "$dst" + fi && + ( + cd ~/.vim && + for d in autoload plugin + do cp -frs "$dst"/$d . + done + ) + } + +install_plugin gundo https://github.com/sjl/gundo.vim.git +install_plugin vim-easy-align https://github.com/junegunn/vim-easy-align.git +install_plugin neocomplcache https://github.com/Shougo/neocomplcache.vim.git + +cat <<-EOF + Lignes de configuration pouvant être mises + dans votre ~/.vimrc selon vos goûts : + $( + cd "$tool" + find config -name '*.vim' \ + -exec echo 'source '{} \; + ) + EOF diff --git a/vim/syntax/hledger.vim b/vim/syntax/hledger.vim index 2f1665b..32c5c9e 100644 --- a/vim/syntax/hledger.vim +++ b/vim/syntax/hledger.vim @@ -22,15 +22,15 @@ syn region hledgerInclude start=/^!include/ end=/^/ syn region hledgerDirective start=/^[A-Z]/ end=/^/ contains=hledgerComment syn region hledgerTransaction start=/^\d[^ ]\+/ end=/^\s*$/ -syn match hledgerTransactionHead "^[0-9/]\+\(=[0-9/]\+\)\?\(\s\+[!*]\)\?" contained containedin=hledgerTransaction nextgroup=hledgerTransactionDescription -syn match hledgerTransactionDate "[0-9/]\+" contained containedin=hledgerTransactionHead +syn match hledgerTransactionHead "^[0-9/]\+\( [0-9:]\+\)\?\(=[0-9/]\+\( [0-9:]\+\)\?\)\?\(\s\+[!*]\)\?" contained containedin=hledgerTransaction nextgroup=hledgerTransactionDescription +syn match hledgerTransactionDate "[0-9/]\+\( [0-9:]\+\)\?" contained containedin=hledgerTransactionHead syn match hledgerTransactionDescription "\s[^;]\+"ms=s+1 contained containedin=hledgerTransaction syn match hledgerTransactionComment ";.*" contained containedin=hledgerTransaction,hledgerPosting,hledgerPostingOdd syn match hledgerPostingAmountOdd " \(\s*[^; ]\+\)\+"ms=s+0 contained containedin=hledgerPostingOdd contains=hledgerNumberOdd syn match hledgerPostingAmount " \(\s*[^; ]\+\)\+"ms=s+0 contained containedin=hledgerPosting contains=hledgerNumber -syn match hledgerPostingAccountOdd "^\s\+[^; ]\([^; ]\|[ ][^; ]\)*" contained containedin=hledgerPostingOdd nextgroup=hledgerPostingAmountOdd contains=hledgerNumberOdd,hledgerAccountSeparatorOdd -syn match hledgerPostingAccount "^\s\+[^; ]\([^; ]\|[ ][^; ]\)*" contained containedin=hledgerPosting nextgroup=hledgerPostingAmount contains=hledgerNumber,hledgerAccountSeparator +syn match hledgerPostingAccountOdd "^\s\+[^; ]\([^; ]\|\s[^; ]\+\)*" contained containedin=hledgerPostingOdd nextgroup=hledgerPostingAmountOdd contains=hledgerNumberOdd,hledgerAccountSeparatorOdd +syn match hledgerPostingAccount "^\s\+[^; ]\([^; ]\|\s[^; ]\+\)*" contained containedin=hledgerPosting nextgroup=hledgerPostingAmount contains=hledgerNumber,hledgerAccountSeparator syn region hledgerPostingOdd start=/^\s\+[^; ]/ end=/^/ contained containedin=hledgerTransaction nextgroup=hledgerPosting syn region hledgerPosting start=/^\s\+[^; ]/ end=/^/ contained containedin=hledgerTransaction nextgroup=hledgerPostingOdd @@ -65,8 +65,8 @@ if version >= 508 || !exists("did_hledger_syntax_inits") hi hledgerTransaction cterm=bold ctermbg=none gui=bold hi hledgerTransactionComment term=bold cterm=bold ctermfg=6 ctermbg=none gui=bold guifg=#4169E1 hi hledgerTransactionDate cterm=bold ctermfg=5 ctermbg=none gui=bold guibg=lightgoldenrod - hi hledgerTransactionDescription cterm=bold ctermfg=5 ctermbg=none gui=bold guibg=lightgoldenrod - hi hledgerTransactionHead term=bold cterm=bold ctermfg=3 ctermbg=none gui=bold guifg=black guibg=lightgreen + hi hledgerTransactionDescription cterm=bold ctermfg=5 ctermbg=none gui=bold + hi hledgerTransactionHead term=bold cterm=bold ctermfg=3 ctermbg=none gui=bold guifg=purple guibg=lightgoldenrod delcommand HiLink endif