Skip to content

Commit

Permalink
Added rename feature
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashGordon committed Jun 10, 2020
1 parent 905bbeb commit 7ca729b
Show file tree
Hide file tree
Showing 20 changed files with 664 additions and 57 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@
buchhaltung-osx-386
profile.cov
buchhaltung
types/output.json
pdf/339px-Opensource.svg.png
.DS_Store
pdf/Roboto/*
pdf/Roboto.zip
pdf/test.pdf
pdf/testRead1.pdf
r1.pdf
pdfrename/Roboto.zip
pdfrename/Roboto/*
config_example.json
.vscode/launch.json
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go:
- 1.14
env:
global:
- TRAVIS_TAG=v1.0.1
- TRAVIS_TAG=v1.0.2
matrix:
fast_finish: true
before_install:
Expand All @@ -23,7 +23,7 @@ before_deploy:
- git config --local user.name "SlashGordon"
- git config --local user.email "slash.gordon.dev@gmail.com"
- git tag $TRAVIS_TAG || true
#- gox -os="linux darwin windows" -arch="386 amd64" -output="buchhaltung-{{.OS}}-{{.Arch}}" ./buchhaltung.go
#- gox -os="linux darwin windows" -arch="386 amd64" -output="buchhaltung-{{.OS}}-{{.Arch}}" buchhaltung.go
#- env GOOS=darwin GOARCH=386 go build -o buchhaltung-osx-386 buchhaltung.go
- env GOOS=darwin GOARCH=amd64 go build -o buchhaltung-osx-amd64 buchhaltung.go
#- env GOOS=linux GOARCH=386 go build -o buchhaltung-linux-386 buchhaltung.go
Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
[![Build Status](https://travis-ci.org/SlashGordon/buchhaltung.svg?branch=master)](https://travis-ci.org/SlashGordon/buchhaltung)
[![Coverage Status](https://coveralls.io/repos/github/SlashGordon/buchhaltung/badge.svg?branch=master)](https://coveralls.io/github/SlashGordon/buchhaltung?branch=master)
# buchhaltung
# buchhaltung

## rename invoice

The renaming function reads the PDF and extracts variables for the renaming.

build binary with:

```shell
go get -d -v ./... && go build buchhaltung.go
```

Move all PDF invoices to a directory. At the moment we only support pure PDFs and not scans.

Create a json config file like:

```json
[
{
"outputname": "{number}_{company}.pdf",
"identifyers": {
"number": "Belegnummer\\s+(WF\\d{11})",
"company": "(weinfreunde)"
}
},
{
"outputname": "{number}_{company}.pdf",
"identifyers": {
"number": "Rechnungsnr.:\\s+(F\\d{11})",
"company": "(klarmobil)"
}
}
]
```

And run buchhaltung:
```shell
buchhaltung invoice -i /Users/test/bills -o /Users/test/bills/output -c /Users/test/
config_example.json
```
12 changes: 10 additions & 2 deletions buchhaltung.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package main

import (
"fmt"

"github.com/SlashGordon/buchhaltung/cmd"
"github.com/SlashGordon/buchhaltung/utils"
)

func main() {
utils.Logger.Info("Buchhaltung")
const banner = `
___ _ _ _ _
| _ ) _ _ __ | |_ | |_ __ _ | | | |_ _ _ _ _ __ _
| _ \ | || | / _| | ' \ | ' \ / _| | | | | _| | || | | ' \ / _| |
|___/ \_,_| \__| |_||_| |_||_| \__,_| |_| \__| \_,_| |_||_| \__, |
|___/
`
fmt.Printf(banner)
cmd.Execute()
}
18 changes: 17 additions & 1 deletion cmd/invoice.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
package cmd

import (
"github.com/SlashGordon/buchhaltung/pdf"
"github.com/SlashGordon/buchhaltung/types"
"github.com/SlashGordon/buchhaltung/utils"
"github.com/spf13/cobra"
)

func init() {

var (
configPath string
inputPath string
outputPath string
)

startCmd := &cobra.Command{
Use: "invoice",
Short: "Renames invoices based by given config",
Long: "Renames invoices based by given config",
Run: func(cmd *cobra.Command, args []string) {

pdf.InitLicense()
config := types.BillRenameItemList{}
err := config.Unmarshal(configPath)
if err != nil {
utils.Logger.Error(err)
}
err = config.Rename(inputPath, outputPath)
if err != nil {
utils.Logger.Error(err)
}
},
}
configFlag := startCmd.PersistentFlags()
configFlag.StringVarP(&configPath, "config", "c", "", "path to config file")
configFlag.StringVarP(&inputPath, "input", "i", "", "path to pdf directory")
configFlag.StringVarP(&outputPath, "output", "o", "", "path to output directory")
cobra.MarkFlagRequired(configFlag, "config")

RootCmd.AddCommand(startCmd)
Expand Down
25 changes: 0 additions & 25 deletions config/config.go

This file was deleted.

13 changes: 0 additions & 13 deletions config/config_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions config/types.go

This file was deleted.

7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ module github.com/SlashGordon/buchhaltung
go 1.14

require (
github.com/boombuler/barcode v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
github.com/unidoc/unipdf/v3 v3.7.1
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/wcharczuk/go-chart v2.0.1+incompatible
golang.org/x/image v0.0.0-20200609002522-3f4726a040e8 // indirect
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/boombuler/barcode v1.0.0 h1:s1TvRnXwL2xJRaccrdcBQMZxq6X7DvsMogtmJeHDdrc=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down Expand Up @@ -55,6 +56,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -196,12 +198,17 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho=
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand All @@ -216,7 +223,11 @@ github.com/unidoc/unipdf/v3 v3.7.1 h1:EqukFgmxlj8OJv32XJOxY7DMbEekj8jdPPy7KEREZh
github.com/unidoc/unipdf/v3 v3.7.1/go.mod h1:EtgWv92oOYhCV700my0YVG9Io3/em3sGYeEgUVlVqUo=
github.com/unidoc/unitype v0.0.0-20200426000514-43fb032b9ce6 h1:wKQZP0/WXDQ6kqniHSpdXol+895jojF+Sk4XORxxi3A=
github.com/unidoc/unitype v0.0.0-20200426000514-43fb032b9ce6/go.mod h1:mafyug7zYmDOusqa7G0dJV45qp4b6TDAN+pHN7ZUIBU=
github.com/unidoc/unitype v0.2.0 h1:N+ZKjwz8UDU0qa1IYzstDLffvQEctFo+bo6b6ZqW+9M=
github.com/unidoc/unitype v0.2.0/go.mod h1:mafyug7zYmDOusqa7G0dJV45qp4b6TDAN+pHN7ZUIBU=
github.com/wcharczuk/go-chart v1.1.0 h1:aCP+Wgzvw0AqhA7RJpfQpvRUY7IUPGEqqNXS6aXTTCI=
github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLVLBCWz1STcD3doU0A=
github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand All @@ -243,6 +254,8 @@ golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 h1:2fktqPPvDiVEEVT/vSTeoUP
golang.org/x/image v0.0.0-20191214001246-9130b4cfad52/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200609002522-3f4726a040e8 h1:c33/sRasKxMl6r30uyDkOgyIlZKMSQE/SSI/eDtrmBY=
golang.org/x/image v0.0.0-20200609002522-3f4726a040e8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -354,6 +367,8 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
Loading

0 comments on commit 7ca729b

Please sign in to comment.