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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3265c8e33e2ad6890d52621525e0c1bd5dd413be
4
- data.tar.gz: 155eeb146e499ce591d689fc234800ccacc0667d
3
+ metadata.gz: cbda5aa522eef5b3da7f41ad1efc32e85a451e80
4
+ data.tar.gz: b097cd63d2734096b785f85b7db06a11eefd8cbe
5
5
  SHA512:
6
- metadata.gz: 3c15c967d7f20bdf9eedaf4f4cf333dbccfcd3c0fa7486a06b10a73fc78c52ef8f61cccb8757aa93cd8135fdf83314ae9c6eb65be44387d9705251149b4fe35c
7
- data.tar.gz: b9263bc21038c81c2d33e69b9410a62a8df4db0a9324491e34e70db3c087456c93dc8e66fa04af3a44cf99079cb0d642f2498c388cd712fbb35c4c9a9b4e18bf
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('-s', '--skip-db', 'Do not update dates from mysql database.') do |o|
21
- options[:skipdb] = o
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.swiss? ? 'Y' : 'N',
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
- t = Terminal::Table.new(headings: ["nr", "S?","total_b",
64
- "total0", "total7", "total19",
65
- "tax7", "tax19",
66
- "ship", "diff", "C"],
67
- rows: bill_rows)
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
 
@@ -28,6 +28,7 @@ module Magelex
28
28
  elsif tax_kind == :discount_19
29
29
  return for_discount_19 bill
30
30
  else
31
+ # its not a tax kind anymore, its a posten type
31
32
  raise "unknown tax_kind (#{tax_kind})"
32
33
  end
33
34
  end
@@ -101,7 +101,6 @@ module Magelex
101
101
  def self.floor2 value
102
102
  (value * 100).to_i / 100.0
103
103
  end
104
- end
105
104
 
106
105
  def complete?
107
106
  @status == "complete"
@@ -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
@@ -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 == 12.6
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
@@ -1,3 +1,3 @@
1
1
  module Magelex
2
- VERSION = "0.1.4".freeze
2
+ VERSION = "0.1.5".freeze
3
3
  end
data/lib/magelex.rb CHANGED
@@ -71,6 +71,7 @@ module Magelex
71
71
  exit 3
72
72
  end
73
73
  Magelex.logger.info("Writing to #{out_file}")
74
+ # TODO want STDOUT
74
75
  Magelex::LexwareCSV.write out_file, bills_export
75
76
  end
76
77
  end
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
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-01 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2