From e39d5a14c3890d89828bccecc10a93f6068b3fbe Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 5 Feb 2020 08:16:56 -0800 Subject: [PATCH] ;examples: invoicing Files related to https://hledger.org/invoicing.html Working for me right now but not fully maintained. --- examples/invoicing/202001ab.md | 35 +++++++++ examples/invoicing/Makefile | 40 ++++++++++ examples/invoicing/README.md | 2 + examples/invoicing/accrual.journal | 9 +++ examples/invoicing/cash.journal | 9 +++ examples/invoicing/invoice.css | 117 +++++++++++++++++++++++++++++ 6 files changed, 212 insertions(+) create mode 100644 examples/invoicing/202001ab.md create mode 100644 examples/invoicing/Makefile create mode 100644 examples/invoicing/README.md create mode 100644 examples/invoicing/accrual.journal create mode 100644 examples/invoicing/cash.journal create mode 100644 examples/invoicing/invoice.css diff --git a/examples/invoicing/202001ab.md b/examples/invoicing/202001ab.md new file mode 100644 index 000000000..8ccc95010 --- /dev/null +++ b/examples/invoicing/202001ab.md @@ -0,0 +1,35 @@ +--- +papersize: letter +margin-left: 20mm +margin-right: 25mm +margin-top: 20mm +margin-bottom: 20mm +... + +![](logo.jpg){ width=100mm }\ +Joe Consultant | +1 (111) 111 1111 | joe@example.com | 500 Done Dr. #1, Work Ville, CA 10000, USA + +Carl Client\ +AB Inc.\ +PO Box 11111\ +CA 20000\ + +January 1, 2020 + +# Invoice 202001cv + + +| Description | Rate | Qty | Total | +|:--------------------------------------------|-------:|----:|-------:| +| Custom software development & maintenance | $ 100 | 10 | $ 1000 | +| Systems reliability engineering | $ 2000 | - | $ 2000 | +| On-call monitoring & tech support | $ 2000 | - | $ 2000 | +| Contractor/vendor management | $ 500 | - | $ 500 | +| Expenses (service providers, tools, dues..) | | | $ 0 | +|   | | | | +| Total due | | | $ 5500 | +| | | | | + +## Terms + +Now due. Your prompt payments are appreciated, thank you! diff --git a/examples/invoicing/Makefile b/examples/invoicing/Makefile new file mode 100644 index 000000000..2a6730959 --- /dev/null +++ b/examples/invoicing/Makefile @@ -0,0 +1,40 @@ +# Makefile +# Generates HTML/PDF invoices from a markdown template + +help: + @echo "make copy # copy last invoice to YYYYMMab.md, open in emacs" + @echo "(edit)" + @echo "make invoice # make YYYYMMab.pdf and YYYYMMab.html, git commit, add invoice transaction to journal" + +CSS=invoice.css +LAST=`ls -t 2*md | head -1` +# must end with "ab": +NEW=$(shell date +%Y%mab) + +copy: + @echo "copying invoice $(LAST) to $(strip $(NEW)).md" + @cp $(LAST) $(strip $(NEW)).md + emacsclient -s2 -n $(strip $(NEW)).md + +invoice: + @echo "making invoice $(NEW)" + @make $(NEW) + @git add $(NEW).{md,html,pdf} + @git commit -m "invoice $(NEW)" -- $(NEW).{md,html,pdf} + @printf "`date +%Y-%m-%d` * (`date +%Y%m`ab) AB Inc. | invoice\n (assets:receivable:ab) \$$1000 ; TODO:adjust\n\n" >>$$LEDGER_FILE + +%ab: + @make $@.pdf $@.html + +%.pdf: %.md $(CSS) #logo.jpg + pandoc $< -t html5 --css $(CSS) -o $@ --metadata title=" " +# --metadata title to silence warning, space to avoid unwanted display + +%.pdf-watch: + ls | entr make -s $*.pdf + +%.html: %.md $(CSS) #logo.jpg + pandoc $< -t html5 -s --css $(CSS) -o $@ --metadata title=" " + +%.html-watch: + ls | entr make -s $*.html diff --git a/examples/invoicing/README.md b/examples/invoicing/README.md new file mode 100644 index 000000000..2dc61d805 --- /dev/null +++ b/examples/invoicing/README.md @@ -0,0 +1,2 @@ +Example files related to https://hledger.org/invoicing.html +Adapted from a working setup, not guaranteed to be current or working. diff --git a/examples/invoicing/accrual.journal b/examples/invoicing/accrual.journal new file mode 100644 index 000000000..58d62dc99 --- /dev/null +++ b/examples/invoicing/accrual.journal @@ -0,0 +1,9 @@ +; https://hledger.org/invoicing.html + +2020-02-01 * (201602ab) AB Inc. | invoice + revenues:consulting:ab $-1000 + assets:receivable:ab $1000 + +2020-02-15 * AB Inc. | payment for 201602ab + assets:receivable:ab $-1000 ; = $0 ; assert this if fully paid (optional) + assets:checking $1000 diff --git a/examples/invoicing/cash.journal b/examples/invoicing/cash.journal new file mode 100644 index 000000000..aa325e1e1 --- /dev/null +++ b/examples/invoicing/cash.journal @@ -0,0 +1,9 @@ +; https://hledger.org/invoicing.html + +2020-02-01 * (201602ab) AB Inc. | invoice + (assets:receivable:ab) $1000 + +2020-02-15 * AB Inc. | payment for 201602ab + (assets:receivable:ab) $-1000 ; = $0 ; assert this if fully paid (optional) + revenues:consulting:ab $-1000 + assets:checking $1000 diff --git a/examples/invoicing/invoice.css b/examples/invoicing/invoice.css new file mode 100644 index 000000000..7f8585ca0 --- /dev/null +++ b/examples/invoicing/invoice.css @@ -0,0 +1,117 @@ +/* invoice.css */ + +@charset "utf-8"; + +body { +/* font-size: 10.5pt; */ +/* font-family: */ +/* "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", */ +/* "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; */ +hyphens: auto; +height: 250mm; /* 280 - 10 (top) - 20 (bottom) */ +line-height: 140%; +margin: 0; +padding: 0; +} + +code { +font-family: "Source Sans Code", Courier New, Courier, monospace; +margin-left: 1pt; +/* font-size:12pt; */ +} + +a { +color: black; +margin-left: 1pt; +} + +h1 { +font-size: 20pt; +margin-top: 10mm; +padding-top:0; +/* margin-top: 6pt; */ +/* margin-bottom: 0; */ +} + +h2 { +font-size: 16pt; +/* margin-top: 20pt; */ +margin-top: 10mm; +/* font-weight: normal; */ +/* margin-top: 0; */ +/* margin-bottom: 20pt; */ +} + +p { +width: 100%; +} + +p:first-of-type { +text-align: center; +font-size: 9pt; +word-spacing: 1pt; +} + +p:nth-of-type(2) { +margin-top: 10mm; +} + +p:nth-of-type(3) { +text-align: center; +font-weight:bold; +font-size:12pt; + +} + +/* p:nth-last-of-type(3) { */ +/* margin-top: 10mm; */ +/* } */ + +/* p:last-of-type { */ +/* text-align: center; */ +/* font-size: 9pt; */ +/* position: absolute; */ +/* bottom: 2mm; */ +/* margin-bottom: 0; */ +/* padding-bottom: 0; */ +/* color: #444; */ +/* } */ + +table { +width: 100%; +} + +table:nth-of-type(1) { +border: 1px solid black; +padding: 5pt; +} + +table:nth-of-type(1) td { +border-top: 1px solid #eee; +} + +table:nth-of-type(1) tr:nth-last-of-type(1) { +font-weight: bold; +} +table:nth-of-type(1) tr:nth-last-of-type(1) td { +/* border-top: 1px solid black; */ +padding-top: 1em; +} + +/* table:nth-of-type(1) td:nth-of-type(2) { */ +/* text-align: center; */ +/* } */ + +hr { +border: 1px solid #eee; +} + +hr:last-of-type { +position: absolute; +bottom: 14mm; +width: 100%; +} + +figure { +margin: 0; +}