lewt 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +22 -0
  3. data/README.md +238 -0
  4. data/bin/lewt +10 -0
  5. data/lib/config/customers.yml +33 -0
  6. data/lib/config/enterprise.yml +54 -0
  7. data/lib/config/settings.yml +10 -0
  8. data/lib/config/templates/invoice.html.liquid +63 -0
  9. data/lib/config/templates/invoice.text.liquid +40 -0
  10. data/lib/config/templates/meta.html.liquid +0 -0
  11. data/lib/config/templates/meta.text.liquid +1 -0
  12. data/lib/config/templates/metastat.html.liquid +2 -0
  13. data/lib/config/templates/metastat.text.liquid +8 -0
  14. data/lib/config/templates/report.html.liquid +29 -0
  15. data/lib/config/templates/report.text.liquid +15 -0
  16. data/lib/config/templates/style.css +461 -0
  17. data/lib/extension.rb +158 -0
  18. data/lib/extensions/calendar-timekeeping/apple_extractor.rb +63 -0
  19. data/lib/extensions/calendar-timekeeping/calendar-timekeeping.rb +65 -0
  20. data/lib/extensions/calendar-timekeeping/extractor.rb +62 -0
  21. data/lib/extensions/calendar-timekeeping/gcal_extractor.rb +61 -0
  22. data/lib/extensions/calendar-timekeeping/ical_extractor.rb +52 -0
  23. data/lib/extensions/liquid-renderer.rb +106 -0
  24. data/lib/extensions/metastat/metamath.rb +108 -0
  25. data/lib/extensions/metastat/metastat.rb +161 -0
  26. data/lib/extensions/simple-expenses.rb +112 -0
  27. data/lib/extensions/simple-invoices.rb +93 -0
  28. data/lib/extensions/simple-milestones.rb +102 -0
  29. data/lib/extensions/simple-reports.rb +81 -0
  30. data/lib/extensions/store.rb +81 -0
  31. data/lib/lewt.rb +233 -0
  32. data/lib/lewt_book.rb +29 -0
  33. data/lib/lewt_ledger.rb +149 -0
  34. data/lib/lewtopts.rb +170 -0
  35. data/tests/LEWT Schedule.ics +614 -0
  36. data/tests/expenses.csv +1 -0
  37. data/tests/milestones.csv +1 -0
  38. data/tests/run_tests.rb +14 -0
  39. data/tests/tc_Billing.rb +29 -0
  40. data/tests/tc_CalExt.rb +44 -0
  41. data/tests/tc_Lewt.rb +37 -0
  42. data/tests/tc_LewtExtension.rb +31 -0
  43. data/tests/tc_LewtLedger.rb +38 -0
  44. data/tests/tc_LewtOpts.rb +26 -0
  45. metadata +158 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b3e642248afd3ef3d87a72ad3ea77fe7233bd00
4
+ data.tar.gz: 2f1cdbcdc9f6bb46c0a6a6e6af37ead5a75e9c29
5
+ SHA512:
6
+ metadata.gz: 832a00f6f7ae4d399cb02131bf6efff644674ce013aec8cbc434afa35e0494a7e1c9cb218ad218d9a126e1c36b3f7978d12748c6193e6c9f0ecc8b11190a1556
7
+ data.tar.gz: ef329864a9f15c557976cecd041fd148f0ceaf226dc5eb7de82403e0ac3dbe24b44f021a50ceaaedc5279dc404ddb6ad97a7495b00a5b7f34ac1103d4a1b1854
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Jason Wijegooneratne
4
+
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # LEWT v0.5.12
2
+
3
+ LEWT is a command line program & library written in Ruby that can help you invoice customers, manage expenses, generate reports and much more. It is designed to encourage lazy accounting, to get more out of it, and to be extended with minimal friction.
4
+
5
+ **Features**
6
+
7
+ - Can operate in a terminal or as a drop in library for your Ruby programs.
8
+ - Simple & concise architecture. Less than 1300 lines of ruby code including the bundled core extensions and tests.
9
+ - A nifty extension system that plays well with Ruby Gems.
10
+
11
+ ## Installation
12
+
13
+ LEWT requires you have [Ruby](https://www.ruby-lang.org/en/) & [Ruby Gems](https://rubygems.org) installed on your machine. Once you have that sorted:
14
+
15
+ ```
16
+ gem install lewt
17
+ ```
18
+
19
+ then test with:
20
+
21
+ ```
22
+ # output lewt's version number
23
+ lewt --version
24
+ ```
25
+
26
+ LEWT ships with some dummy data and config so you can jump straight into the quick start guide.
27
+
28
+ ## Quick Start
29
+
30
+ The LEWT program is based around a procedure I call *extract, process, render* [EPR]. Data is extracted from some source(s) and transformed into a general ledger data structure, this is then passed to the specified processor(s) which may use it to perform calculations, the processed data is then finally passed onto a renderer for outputting in a useful format. All EPR operations are handled by LEWT Extensions, thus a basic LEWT command only involves you specify which extensions to use for the EPR procedure:
31
+
32
+ ```
33
+ # -e = extractor, -p = processor, -o = renderer. Outputs an invoice for target customer Wayne Corp [alias: WCorp] since 1 sep 2014
34
+ lewt -x calendar -p invoice -o liquid -t WCorp -s 01-09-2014
35
+
36
+ ...
37
+
38
+ # sample text output
39
+ *******
40
+ Dear Bruce Wayne,
41
+
42
+ You have recived a new invoice from Jason Wijegooneratne
43
+
44
+ *******
45
+
46
+ Date Created: 17/09/14
47
+ ID: 12-4d7d2c79
48
+
49
+ INVOICED TO:
50
+ Wayne Corp,
51
+ 2 Wayne Street
52
+ 90210, Gotham,
53
+ Cartoon Land,
54
+ abn: 45 443 23 123.
55
+
56
+
57
+ INVOICED FROM:
58
+ Your Trading Name,
59
+ 13 Your Street,
60
+ 0, O-state,
61
+ O-stralia,
62
+ abn 45 443 23 123.
63
+
64
+ ITEMS:
65
+ --
66
+ 03/09/14 7:00pm >>> 04/09/14 5:45am
67
+ $150 * 10.75 hrs = $1612.5
68
+ Hacking on the bat mobile in secrecy.
69
+ --
70
+ 10/09/14 7:00pm >>> 11/09/14 3:00am
71
+ $150 * 8.0 hrs = $1200.0
72
+ Hacking on the bat mobile in secrecy.
73
+
74
+
75
+ ---------------------------
76
+ SUB-TOTAL: 2812.5
77
+ TAX [gst]: 281.25
78
+ ---------------------------
79
+ TOTAL: 3093.75
80
+
81
+ *******
82
+
83
+ ```
84
+
85
+ You can also extract from multiple sources at once:
86
+
87
+ ```
88
+ # extract time sheet data, expenses, and milestone data for all customers since begining of year and mash it up into a report.
89
+ lewt -x expenses,calendar,milestones -s 01-01-2014 -p report -o liquid
90
+
91
+ ...
92
+
93
+ # sample text output
94
+ *******
95
+
96
+ Date Created: 17/09/14
97
+ Included:
98
+ ACME
99
+ Wayne Corp
100
+
101
+ Revenue: 63737.5
102
+ Expenses: -740.0
103
+ Tax-Levees:
104
+ income tax[0.0]: 0.0
105
+ income tax[0.19]: 3609.81
106
+ income tax[0.325]: 12020.86
107
+ GST[0.1]: 6373.75
108
+
109
+ Bottom Line: 40993.08
110
+ -----------------------------------
111
+ Hours Worked: 311.0
112
+ *******
113
+
114
+ ```
115
+
116
+ LEWT's default liquid template rendering extension supports multiple output formats, it can even use WebKit to render a PDF from one of your templates complete with CSS stylesheets support!
117
+
118
+ ```
119
+ # output an invoice for specified customer as text, save a pdf simultaneously.
120
+ lewt -x expenses,calendar -p invoice -o liquid -t WCorp -s 01-09-2014 --method pdf,text --save-path wcorp-invoice.pdf
121
+
122
+ # create separate pdf invoices for all customers using some naming templates
123
+ lewt -x expenses,calendar -p invoice -o liquid --method pdf -s 01-09-2014 --save-path "#date #alias.pdf"
124
+
125
+ ...
126
+
127
+ # sample output. files will be written to FS.
128
+ 20XX-MM-DD ACME.pdf
129
+ 20XX-MM-DD WCorp.pdf
130
+ ```
131
+
132
+ LEWT does not use a database, persisting data is done on a file system:
133
+
134
+ ```
135
+ # Persist some processed data in YAML format using the store extension
136
+ lewt -t ACME -p invoice -o store >> invoice.yml
137
+
138
+ # reuse it and output it in plain text
139
+ cat invoice.yml | lewt pipe render -p invoice -m text
140
+ ```
141
+
142
+ LEWT can even help you generate basic statistics on the fly and supports embedded [metatags](https://github.com/jdwije/LEWT/wiki/Metatags) in your extraction sources:
143
+
144
+ ```
145
+ # output a frequency table of hash tags #good-day, #bad-day by customer. use
146
+ # store for output as liquid template is dodgy.
147
+ lewt -x calendar -p metastat --tags good-day,bad-day -s 01-01-2014 -o store
148
+
149
+ ...
150
+
151
+ # sample YAML output
152
+ ---
153
+ - frequency_table:
154
+ ACME:
155
+ bad_day: 10
156
+ good_day: 5
157
+ Wayne Corp:
158
+ good_day: 5
159
+ bad_day: 4
160
+ ```
161
+
162
+ For a list of options available run:
163
+
164
+ ```
165
+ lewt --help
166
+ ```
167
+
168
+ You can perform all of the above using LEWT as a library in your projects as well.
169
+
170
+ ```
171
+ require "LEWT"
172
+
173
+
174
+ options = {
175
+ :extract => 'calendar',
176
+ :process => 'invoice',
177
+ :render => 'liquid',
178
+ :target => 'ACME',
179
+ :dump_output => false
180
+ }
181
+
182
+ # returns a hash containing the invoice data for further use
183
+ lewt_invoice = LEWT::Lewt.new( options ).run
184
+
185
+ ```
186
+
187
+ ## LEWT Extensions
188
+
189
+ LEWT by itself is basically just an extension system, all the EPR operations are performed by extensions making LEWT very customisable. Being a beta version of this software, I have shipped LEWT with some basic extension which I find useful in my day to day contracting operations but I'm hoping others will replace them with better versions in time :) these *core extensions* as I will call them for now are:
190
+
191
+ 1. Calendar Timekeeping: Extract Time sheet data from iCal, OSX Calendar, and Google Calender sources and transform it for further processing.
192
+ 2. Simple Invoices: Process extract data as an invoice.
193
+ 3. Simple Reports: Process extract data as a report.
194
+ 4. Liquid Renderer: Liquid template rendering with support for text, html, and PDF tempting.
195
+ 5. Simple Expenses: Manage expenses with in simple CSV file and extract it into LEWT.
196
+ 6. Simple Milestones: Manage milestone payments in a CSV file and extract it into LEWT.
197
+ 7. Store: Persist lewt data as YAML formatted files. Re-use this data later.
198
+ 8. Metastat: Generate simple statistics from your data sources using embedded metatags.
199
+
200
+ Conceptually, there are 3 different kinds of extensions: **Extractors, Processors, and Renderers**, however for now they all inherit from the same **LEWT::Extension** base class. This class provides some convenience methods for the extensions as well as a means for them to register themselves within LEWT.
201
+
202
+ It's pretty easy to get started creating your own extension for LEWT, see the [Authoring LEWT Extensions](https://github.com/jdwije/LEWT/wiki/3-Creating-Extensions-for-LEWT) for more information.
203
+
204
+
205
+ ## Configuration
206
+
207
+ LEWT (and it's extensions) want config. They want it in the form of flat YAML files which can be stored in your ```/config``` directory, see [Installation & Setup](https://github.com/jdwije/LEWT/wiki/2-Installation-&-Setup) for more on this. LEWT's default config directory is ```path/to/lewt/lib/config/``` but you can change this if you like.
208
+
209
+ ## Want to learn more?
210
+
211
+ Checkout the [WIKI](https://github.com/jdwije/LEWT/wiki) section for a bunch of tutorials on setting LEWT up and getting started writing extensions.
212
+
213
+ Finally go browse through the source code, there is only ~1300 lines of ruby including comments with which I have tried to be liberal.
214
+
215
+
216
+ ## Disclaimer
217
+
218
+ LEWT is very much beta-ware. I only just started using it myself in my contracting operations, however it's making thing's easier for me so I thought I'd release it as is - when you find those bugs I would love to hear about them!
219
+
220
+ ## License
221
+
222
+ LEWT is distributed under the terms and conditions of the MIT license, see LICENSE.md for more information.
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
data/bin/lewt ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This is the command line tool wrapper for LEWT. RubyGEMS makes this available at $PATH.
4
+
5
+ require 'lewt'
6
+
7
+ lewt = LEWT::Lewt.new
8
+
9
+ # invoke the logic loop
10
+ lewt.run
@@ -0,0 +1,33 @@
1
+ ---
2
+ -
3
+ name: ACME
4
+ business_number: 45 443 23 123
5
+ address:
6
+ lines: 2 ACME Rd
7
+ city : Old Skool
8
+ state : Digidom
9
+ postal : 90210
10
+ country: Cartoon Land
11
+ contact:
12
+ name:
13
+ first: Wiley
14
+ last: Coyote
15
+ email: wiley@acme.com
16
+ alias: AC
17
+ rate: 100
18
+ -
19
+ name: Wayne Corp
20
+ business_number: 45 443 23 123
21
+ address:
22
+ lines: 2 Wayne Street
23
+ city : Gotham City
24
+ state : Gotham
25
+ postal : 90210
26
+ country: Cartoon Land
27
+ contact:
28
+ name:
29
+ first: Bruce
30
+ last: Wayne
31
+ email: bruce@waynecorp.com
32
+ alias: WCorp
33
+ rate: 150
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: Your Trading Name
3
+ business_number: 123456
4
+ address:
5
+ lines: 13 Your Street
6
+ city : O-town
7
+ state : O-state
8
+ postal : 0000
9
+ country: O-stralia
10
+ contact:
11
+ name: Your Name
12
+ email: your@email.com
13
+ alias: YTN
14
+ rate: 50
15
+ invoice-tax: 0.10
16
+ tax_levees:
17
+ -
18
+ applies_to: income
19
+ name: income tax
20
+ lower_threshold: 0
21
+ upper_threshold: 18000
22
+ rate: 0.00
23
+ -
24
+ applies_to: income
25
+ name: income tax
26
+ lower_threshold: 18001
27
+ upper_threshold: 37000
28
+ rate: 0.19
29
+ -
30
+ applies_to: income
31
+ name: income tax
32
+ lower_threshold: 37001
33
+ upper_threshold: 80000
34
+ flatrate: 3572
35
+ rate: 0.325
36
+ -
37
+ applies_to: income
38
+ name: income tax
39
+ lower_threshold: 80001
40
+ upper_threshold: 180000
41
+ flatrate: 17547
42
+ rate: 0.37
43
+ -
44
+ applies_to: income
45
+ name: income tax
46
+ lower_threshold: 180000
47
+ upper_threshold: ~
48
+ flatrate: 54547
49
+ rate: 0.45
50
+ -
51
+ applies_to: revenue
52
+ name: GST
53
+ rate: 0.10
54
+
@@ -0,0 +1,10 @@
1
+ ---
2
+ ical_filepath: tests/LEWT Schedule.ics
3
+ osxcal_path: /path/to/osxcalender/dir/
4
+ gmail_username: you@google.com
5
+ gmail_password: your_secret
6
+ gmail_app_name: some-goggle-hash-code
7
+ expenses_filepath: tests/expenses.csv
8
+ milestones_filepath: tests/milestones.csv
9
+ store_path: /path/to/store/dir/
10
+ invoice_id_counter: 12
@@ -0,0 +1,63 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" type="text/css" href="style.css" />
4
+ </head>
5
+ <body>
6
+ <hr />
7
+
8
+ <p>
9
+ <b>Date Created:</b> {{ date_created }} <br />
10
+ <b>ID:</b> {{ id }} <br />
11
+ </p>
12
+
13
+ <h3>INVOICED TO:</h3>
14
+ <address>
15
+ {{ billed_to.name }},<br />
16
+ {{ billed_to.address.lines }},<br />
17
+ {{ billed_to.address.postal }}, {{ billed_to.address.state }},<br />
18
+ {{ billed_to.address.country }},<br />
19
+ abn: {{ billed_to.business_number }}.
20
+ </address>
21
+
22
+ <h3>INVOICED FROM:</h3>
23
+ <address>
24
+ {{ billed_from.name }},<br />
25
+ {{ billed_from.address.lines }},<br />
26
+ {{ billed_from.address.postal }}, {{ billed_from.address.state }},<br />
27
+ {{ billed_from.address.country }},<br />
28
+ abn: {{ billed_from.business_number }}.
29
+ </address>
30
+
31
+ <h2>ITEMS:</h2>
32
+ <ul class="unstyled invoice-items">
33
+ {% for item in items %}
34
+ <li>
35
+ <table>
36
+ <tr>
37
+ <td><strong>Start:</strong> {{ item.start }}</td>
38
+ <td><strong>End:</strong> {{ item.end }}</td>
39
+ <td><strong>Rate:</strong> ${{ item.rate }}</td>
40
+ <td><strong>Duration:</strong> {{ item.duration }}</td>
41
+ <td><strong>Total:</strong> ${{ item.total }}</td>
42
+ </tr>
43
+ <tr class="invoice-item-description">
44
+ <td colspan="5">
45
+ {{ item.description }}
46
+ </td>
47
+ <tr>
48
+ </table>
49
+ </li>
50
+ {% endfor %}
51
+ </ul>
52
+
53
+ <p>
54
+ <b>SUB-TOTAL:</b> {{ sub-total }}<br />
55
+ <b>TAX [gst]:</b> {{ tax }}
56
+ </p>
57
+
58
+ <h3>TOTAL: <span>{{ total }}</span></h3>
59
+
60
+ <hr />
61
+ </body>
62
+ </html>
63
+
@@ -0,0 +1,40 @@
1
+ Dear {{ billed_to.contact.name.first }} {{ billed_to.contact.name.last }},
2
+
3
+ You have recived a new invoice from Jason Wijegooneratne
4
+
5
+ *******
6
+
7
+ Date Created: {{ date_created }}
8
+ ID: {{ id }}
9
+
10
+ INVOICED TO:
11
+ {{ billed_to.name }},
12
+ {{ billed_to.address.lines }}
13
+ {{ billed_to.address.postal }}, {{ billed_to.address.state }},
14
+ {{ billed_to.address.country }},
15
+ abn: {{ billed_to.business_number }}.
16
+
17
+
18
+ INVOICED FROM:
19
+ {{ billed_from.name }},
20
+ {{ billed_from.address.lines }},
21
+ {{ billed_from.address.postal }}, {{ billed_from.address.state }},
22
+ {{ billed_from.address.country }},
23
+ abn {{ billed_to.business_number }}.
24
+
25
+ ITEMS:
26
+ {% for item in items %}--
27
+ {{ item.start }} >>> {{ item.end }}
28
+ ${{ item.rate }} * {{ item.duration }} hrs = ${{ item.total }}
29
+ {{ item.description }}
30
+ {% endfor %}
31
+
32
+ ---------------------------
33
+ SUB-TOTAL: {{ sub-total }}
34
+ TAX [gst]: {{ tax }}
35
+ ---------------------------
36
+ TOTAL: {{ total }}
37
+
38
+ *******
39
+
40
+
File without changes
@@ -0,0 +1 @@
1
+ Meta Log not yet fully implemented.
@@ -0,0 +1,2 @@
1
+ Meta Stat not yet fully implemented. Output with store instead i.e. -o store
2
+ ----------------------------------------------------------------------------
@@ -0,0 +1,8 @@
1
+ Meta Stat not yet fully implemented. Output with store instead i.e. -o store
2
+ ----------------------------------------------------------------------------
3
+
4
+ {% for f in frequency_table %}
5
+ {% for tag in f %}
6
+ {{ tag }}
7
+ {% endfor %}
8
+ {% endfor %}
@@ -0,0 +1,29 @@
1
+ <hr />
2
+ <img id="logo" src="/Users/JWIJESWWW/Documents/lewtstash/templates/logo.jpg" />
3
+
4
+ <p><b>Date Created:</b> {{ date_created }}</p>
5
+
6
+ Included:
7
+ <ul>
8
+ {% for target in included_customers %}
9
+ <li>{{ target.name }}</li>
10
+ {% endfor %}
11
+ </ul>
12
+
13
+ <p><b>Revenue:</b> {{ revenue }}</p>
14
+ <p><b>Expenses:</b> {{ expenses }}</p>
15
+
16
+ Tax-Levees:
17
+ <ul>
18
+ {% for tax in taxes %}
19
+ <li>{{ tax.name }}[{{ tax.rate }}]: {{ tax.amount }}</li>
20
+ {% endfor %}
21
+ </ul>
22
+
23
+ <p><b>Bottom Line:</b> {{ bottom_line }}</p>
24
+
25
+ <hr />
26
+
27
+ <p><b>Hours Worked:</b> {{ hours }}</p>
28
+
29
+ <hr />
@@ -0,0 +1,15 @@
1
+ *******
2
+
3
+ Date Created: {{ date_created }}
4
+ Included:
5
+ {% for target in included_customers %} {{ target.name }}
6
+ {% endfor %}
7
+ Revenue: {{ revenue }}
8
+ Expenses: {{ expenses }}
9
+ Tax-Levees:
10
+ {% for tax in taxes %} {{ tax.name }}[{{ tax.rate }}]: {{ tax.amount }}
11
+ {% endfor %}
12
+ Bottom Line: {{ bottom_line }}
13
+ -----------------------------------
14
+ Hours Worked: {{ hours }}
15
+ *******