ascii_invoicer 2.5.5 → 2.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ascii +26 -2
- data/lib/ascii_invoicer/InvoiceProject.rb +24 -0
- data/lib/ascii_invoicer/mixins.rb +17 -5
- data/lib/ascii_invoicer/version.rb +1 -1
- data/settings/default-settings.yml +1 -0
- data/settings/settings_template.yml +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84258bb06f6de068f343d5ec1ba51150799e703
|
4
|
+
data.tar.gz: 4395599f3222f8febe2ce683e108f591901a9859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd09954c365791aa28dac616ade11804076ee01b63836d9379b43f78307ff2ecea34b8eea751e9c7819f65520f79f6e395e285937822b56a5b7f2ce80bd38f10
|
7
|
+
data.tar.gz: a8eeb5fa5553c2264b6298aa1b4467e4ea1024afe128262e43dc86d78f592cc0f324d1615b1e07ff64e61819df14e288007abe19ff2b5ffbf119d8f5cc88d66d
|
data/bin/ascii
CHANGED
@@ -212,6 +212,30 @@ class Commander < Thor
|
|
212
212
|
end
|
213
213
|
|
214
214
|
|
215
|
+
desc "open NAMES", "Open created documents"
|
216
|
+
method_option :archive,
|
217
|
+
:type=>:numeric, :aliases => "-a", :default => nil,
|
218
|
+
:lazy_default=> Date.today.year, :required => false, :desc => "Open File from archive YEAR"
|
219
|
+
method_option :offer, :type=>:boolean, :aliases => "-o",
|
220
|
+
:default=> false, :lazy_default=> true, :required => false,
|
221
|
+
:desc => "Open the offer, otherwise defaults to invoice"
|
222
|
+
|
223
|
+
def open *names
|
224
|
+
choice = :invoice
|
225
|
+
choice = :offer if options[:offer]
|
226
|
+
|
227
|
+
projects = open_projects names, options
|
228
|
+
projects.each{|p|
|
229
|
+
path = p.output_files[choice]
|
230
|
+
unless File.exists? path
|
231
|
+
$logger.error "File does not exist: #{path}."
|
232
|
+
return false
|
233
|
+
else
|
234
|
+
open_file path
|
235
|
+
end
|
236
|
+
}
|
237
|
+
end
|
238
|
+
|
215
239
|
|
216
240
|
desc "list", "List current Projects"
|
217
241
|
method_option :archive,
|
@@ -411,8 +435,8 @@ class Commander < Thor
|
|
411
435
|
end
|
412
436
|
end
|
413
437
|
|
414
|
-
desc "
|
415
|
-
def
|
438
|
+
desc "unarchive YEAR NAME", "reopen an archived project"
|
439
|
+
def unarchive(year, name)
|
416
440
|
projects = $PLUMBER.open_projects_archive year
|
417
441
|
project = projects.lookup_by_name name
|
418
442
|
if project.count > 1
|
@@ -98,11 +98,13 @@ class InvoiceProject < LuigiProject
|
|
98
98
|
@raw_data = YAML::load(File.open(project_path))
|
99
99
|
rescue SyntaxError => error
|
100
100
|
@logger.warn "SyntaxError in #{project_path}, use \"edit\" to correct it.", :both
|
101
|
+
@logger.info "Check #{@settings.log_file} for details.", :stdo
|
101
102
|
@logger.error error, :file
|
102
103
|
@status = :unparsable
|
103
104
|
return false
|
104
105
|
rescue Psych::SyntaxError => error
|
105
106
|
@logger.warn "SyntaxError in #{project_path}, use \"edit\" to correct it.", :both
|
107
|
+
@logger.info "Check #{@settings.log_file} for details.", :stdo
|
106
108
|
@logger.error error, :file
|
107
109
|
@status = :unparsable
|
108
110
|
return false
|
@@ -272,6 +274,28 @@ class InvoiceProject < LuigiProject
|
|
272
274
|
return false
|
273
275
|
end
|
274
276
|
end
|
277
|
+
|
278
|
+
def output_files
|
279
|
+
output_path = File.expand_path File.join @settings.output_path
|
280
|
+
{
|
281
|
+
:offer => File.join(output_path, export_filename(:offer, 'pdf')),
|
282
|
+
:invoice => File.join(output_path, export_filename(:invoice, 'pdf'))
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
def state_sign choice
|
287
|
+
if validate(choice)
|
288
|
+
if File.exists? output_files[choice]
|
289
|
+
return Paint[?✓,:green, :bright]
|
290
|
+
else
|
291
|
+
return Paint[?✓,:green]
|
292
|
+
end
|
293
|
+
else
|
294
|
+
return Paint[?✗,:red]
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
|
275
299
|
end
|
276
300
|
|
277
301
|
class InvoiceProduct
|
@@ -85,8 +85,8 @@ module AsciiMixins
|
|
85
85
|
project.data[:manager],
|
86
86
|
project.data[:invoice][:number],
|
87
87
|
project.date.strftime("%d.%m.%Y"),
|
88
|
-
project.
|
89
|
-
project.
|
88
|
+
project.state_sign(:offer),
|
89
|
+
project.state_sign(:invoice),
|
90
90
|
project.validate(:payed).print($SETTINGS.currency_symbol),
|
91
91
|
# try these: ☑☒✉☕☀☻
|
92
92
|
]
|
@@ -98,8 +98,8 @@ module AsciiMixins
|
|
98
98
|
projects.each_index do |i|
|
99
99
|
p = projects[i]
|
100
100
|
table.add_row [
|
101
|
-
(i+1).to_s+".",
|
102
|
-
p.name.ljust(35),
|
101
|
+
(i+1).to_s+".",
|
102
|
+
p.name.ljust(35),
|
103
103
|
p.data[:project_path]
|
104
104
|
]
|
105
105
|
end
|
@@ -132,7 +132,7 @@ module AsciiMixins
|
|
132
132
|
puts "...\n\n"
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
def caterers_string project, join = ", "
|
137
137
|
data = project.data
|
138
138
|
data[:hours][:caterers].map{|name, hours| "#{name} (#{hours})" if hours > 0 }.join join if data[:hours][:caterers]
|
@@ -249,6 +249,18 @@ module AsciiMixins
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
+
## hand path to default programm
|
253
|
+
def open_file path
|
254
|
+
unless path.class == String and File.exists? path
|
255
|
+
$logger.error "Cannot open #{path}", :both
|
256
|
+
return false
|
257
|
+
end
|
258
|
+
opener = $SETTINGS.opener
|
259
|
+
$logger.info "Opening #{path} in #{opener}"
|
260
|
+
pid = spawn "#{opener} \"#{path}\""
|
261
|
+
Process.wait pid
|
262
|
+
end
|
263
|
+
|
252
264
|
## hand path to editor
|
253
265
|
def edit_files(paths, editor = $SETTINGS.editor)
|
254
266
|
paths = [paths] if paths.class == String
|
@@ -1,9 +1,10 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
manager_name: "The Unnamed Manager"
|
3
3
|
#verbose: false
|
4
4
|
#editor: "vim -O"
|
5
|
+
#opener: "xdg-open"
|
5
6
|
#colors: false
|
6
|
-
#list_sort:
|
7
|
+
#list_sort: index # index, date, name
|
7
8
|
|
8
9
|
#path: "~" #/where/you/want/to/put/the/dirs
|
9
10
|
#output_path: "."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ascii_invoicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hendrik Sollich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|