magelex 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/bin/magelex +1 -1
- data/bin/magelex_debug +45 -12
- data/lib/magelex/lexware_account.rb +1 -0
- data/lib/magelex/lexware_bill.rb +0 -1
- data/lib/magelex/lexware_csv.rb +2 -1
- data/lib/magelex/magento_csv.rb +1 -1
- data/lib/magelex/version.rb +1 -1
- data/lib/magelex.rb +1 -0
- 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: cbda5aa522eef5b3da7f41ad1efc32e85a451e80
|
4
|
+
data.tar.gz: b097cd63d2734096b785f85b7db06a11eefd8cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62481373f646ddde8da7e4e830c0b10a581e2214c7a6c7f52d11072d23443552e1327273356e5996c1e4d7c30ff3021c1ea029722afb52d085c880219d202abd
|
7
|
+
data.tar.gz: 023cbd9161e35894893e266c0487483c3f3e02608b72ddfafb6435b249da8562eb4cf17644690b3fc61ae336670ddc5ca5229e872dd3c91487ce5e096bc83c5e
|
data/README.md
CHANGED
@@ -57,6 +57,10 @@ Swiss orders require some special attention, so steps are undertaken to adjust t
|
|
57
57
|
|
58
58
|
Finally the `LexwareBill`s that conform to the rules (`LexwareBill#check`) can be exported to be imported to Lexware (`Magelex::LexwareCSV`).
|
59
59
|
|
60
|
+
## TODO
|
61
|
+
|
62
|
+
Quite something
|
63
|
+
|
60
64
|
## Changes
|
61
65
|
|
62
66
|
- 0.1.4:
|
data/bin/magelex
CHANGED
@@ -14,7 +14,7 @@ optparse = OptionParser.new do |opts|
|
|
14
14
|
" data to be imported to open positions in lexware."
|
15
15
|
opts.separator ""
|
16
16
|
|
17
|
-
opts.on('-o', '--out-dir DIR', 'Directory to write output files to.') do |o|
|
17
|
+
opts.on('-o', '--out-dir DIR', 'Directory to write output files to, otherwise concats to STDOUT. If "auto", outputs to source dir.') do |o|
|
18
18
|
options[:out_dir] = o
|
19
19
|
end
|
20
20
|
opts.on('-l', '--log-file FILE', 'File to log to (default: STDERR).') do |o|
|
data/bin/magelex_debug
CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
require 'optparse'
|
7
7
|
require 'terminal-table'
|
8
8
|
|
9
|
-
options = {}
|
9
|
+
options = {table: true, filter_checked: false, filter_complete: false, lexware: true}
|
10
10
|
|
11
11
|
optparse = OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: #{$PROGRAM_NAME} DIR_OR_FILE"
|
@@ -14,12 +14,29 @@ optparse = OptionParser.new do |opts|
|
|
14
14
|
opts.separator "Debug magelex im- and export"
|
15
15
|
opts.separator ""
|
16
16
|
|
17
|
+
opts.separator "Filtering options"
|
18
|
+
opts.separator ""
|
19
|
+
opts.on('-b', '--bad', 'Show only bills that do not pass check') do |o|
|
20
|
+
options[:filter_checked] = o
|
21
|
+
end
|
22
|
+
opts.on('-c', '--[no-]complete', 'Show only bills that are complete') do |o|
|
23
|
+
options[:filter_complete] = o
|
24
|
+
end
|
25
|
+
opts.on('-n', '--ordernumber ORDERNUMBER', 'Show only bill with given ORDERNUMBER') do |o|
|
26
|
+
options[:filter_ordernumber] = o
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.separator "Output options"
|
30
|
+
opts.separator ""
|
17
31
|
opts.on('-v', '--verbose', 'Run verbosely') do |o|
|
18
32
|
options[:verbose] = o
|
19
33
|
end
|
20
|
-
opts.on('-
|
21
|
-
options[:
|
34
|
+
opts.on('-t', '--[no-]table', 'Show table of bills') do |o|
|
35
|
+
options[:table] = o
|
22
36
|
end
|
37
|
+
opts.on('-l', '--[no-]lexware', 'Show lexware output') do |o|
|
38
|
+
options[:lexware] = o
|
39
|
+
end
|
23
40
|
opts.on_tail('--version', 'Show version and exit.') do
|
24
41
|
puts "Magelex #{Magelex::VERSION}"
|
25
42
|
exit 0
|
@@ -49,25 +66,41 @@ def main options
|
|
49
66
|
# Import/Read file.
|
50
67
|
bills = Magelex::MagentoCSV.read ARGV[0]
|
51
68
|
Magelex::BillModifier.process bills
|
69
|
+
|
70
|
+
if options[:filter_complete]
|
71
|
+
bills.reject!{|b| !b.complete?}
|
72
|
+
end
|
73
|
+
if options[:filter_checked]
|
74
|
+
bills.reject!{|b| b.check}
|
75
|
+
end
|
76
|
+
if options[:filter_ordernumber]
|
77
|
+
bills.reject!{|b| b.order_nr.to_s != options[:filter_ordernumber].to_s}
|
78
|
+
end
|
79
|
+
|
52
80
|
bill_rows = bills.map do |bill|
|
53
81
|
[
|
54
82
|
bill.order_nr,
|
55
|
-
bill.
|
83
|
+
bill.country_code,
|
56
84
|
bill.total,
|
57
85
|
"%.3f" %bill.total_0, "%.3f" % bill.total_7, "%.3f" % bill.total_19,
|
58
86
|
"%.3f" % bill.tax_7, "%.3f" % bill.tax_19,
|
59
|
-
"%.3f" % bill.shipping_cost, "%.3f" % bill.check_diff, bill.check ? "Y" : "N"
|
87
|
+
"%.3f" % bill.shipping_cost, "%.3f" % (bill.discount_7 + bill.discount_19), "%.3f" % bill.check_diff, bill.check ? "Y" : "N"
|
60
88
|
]
|
61
89
|
end
|
62
90
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
91
|
+
if options[:table]
|
92
|
+
t = Terminal::Table.new(headings: ["nr", "Co","total_b",
|
93
|
+
"total0", "total7", "total19",
|
94
|
+
"tax7", "tax19",
|
95
|
+
"ship", "discount", "diff", "C"],
|
96
|
+
rows: bill_rows)
|
97
|
+
puts t
|
98
|
+
end
|
99
|
+
|
100
|
+
if options[:lexware]
|
101
|
+
puts Magelex::LexwareCSV::render bills
|
102
|
+
end
|
68
103
|
|
69
|
-
puts t
|
70
|
-
puts Magelex::LexwareCSV::render bills
|
71
104
|
Magelex.logger.info("Finished")
|
72
105
|
end
|
73
106
|
|
data/lib/magelex/lexware_bill.rb
CHANGED
data/lib/magelex/lexware_csv.rb
CHANGED
@@ -11,6 +11,7 @@ module Magelex
|
|
11
11
|
rows = []
|
12
12
|
rows << [bill.date.strftime("%d.%m.%Y"),
|
13
13
|
bill.order_nr,
|
14
|
+
# Replace , by dash
|
14
15
|
bill.customer_name,
|
15
16
|
bill.total.round(2),
|
16
17
|
Magelex::AccountNumber.for_customer(bill),
|
@@ -45,7 +46,7 @@ module Magelex
|
|
45
46
|
|
46
47
|
def self.to_rows bill
|
47
48
|
# split-booking needed?
|
48
|
-
if [:total_0, :total_7, :total_19].map{|t| bill.send(t)}.count{|i| i > 0} > 1
|
49
|
+
if [:total_0, :total_7, :total_19, :incorrect_tax, :discount_7, :discount_19].map{|t| bill.send(t)}.count{|i| i > 0} > 1
|
49
50
|
to_split_rows bill
|
50
51
|
else
|
51
52
|
to_single_row bill
|
data/lib/magelex/magento_csv.rb
CHANGED
@@ -39,7 +39,7 @@ module Magelex
|
|
39
39
|
bill.status = row['Order Status']
|
40
40
|
|
41
41
|
bill.shipping_cost = row['Order Shipping']
|
42
|
-
if bill.shipping_cost
|
42
|
+
if (12.59..12.61).include? bill.shipping_cost
|
43
43
|
Magelex::logger.info "Correcting shipping cost of #{bill.order_nr} (12.6 -> 15 / 1.19 €)"
|
44
44
|
bill.shipping_cost = 15 / 1.19
|
45
45
|
elsif bill.shipping_cost == 4.15
|
data/lib/magelex/version.rb
CHANGED
data/lib/magelex.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magelex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Wolfsteller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|