magelex 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/bin/magelex +101 -0
- data/lib/magelex/lexware_account.rb +40 -0
- data/lib/magelex/lexware_bill.rb +75 -0
- data/lib/magelex/lexware_csv.rb +43 -0
- data/lib/magelex/magento_csv.rb +69 -0
- data/lib/magelex/magento_mysql.rb +27 -0
- data/lib/magelex/tax_guess.rb +16 -0
- data/lib/magelex/version.rb +3 -0
- data/lib/magelex.rb +18 -0
- data/magelex.conf.example +6 -0
- data/magelex.gemspec +26 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d3dcd100c3a4c73c1e885c3e512704d4e21d1ba
|
4
|
+
data.tar.gz: da8ac0c3a739e5a8c05c361a52bd9260f4619c32
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19cf4f8f959f1ee4c13cdb19c0ea37f456314a75050d442a3ee148458fa78213912302c54aedb4c44170259af13e69a507d734b805db81d6e006e17b84d559bb
|
7
|
+
data.tar.gz: e0113ad7243563e6dc4e55a67e7f8ebe682498a0f1339dcc466ae17a89410a8666e642b744f049ec12c5085e933c4230676fffcce1c5958050f4fad69ec65db2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at felix.wolfsteller@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Magelex
|
2
|
+
|
3
|
+
*This README reflects (more or less) the current development state, for documentation of a given version, see the README shipped with that gem (or respective tag on github).*
|
4
|
+
|
5
|
+
Magelex takes Magento data and presents it in a format that Lexware can read.
|
6
|
+
|
7
|
+
Aim is to manage the cash flow in Lexware.
|
8
|
+
|
9
|
+
The solution is specific for one customers needs. If you need a similar solution (or have a better one!) contact me!
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Install it yourself as:
|
14
|
+
|
15
|
+
$ gem install magelex
|
16
|
+
|
17
|
+
## Assumptions
|
18
|
+
|
19
|
+
Customer accounts are hard coded. Database access necessary for date corrections.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Call `magelex --help` to get a basic idea:
|
24
|
+
|
25
|
+
Usage: magelex DIR_OR_FILE
|
26
|
+
|
27
|
+
Imports order data from magento csv export, exports this data to be imported to open positions in lexware.
|
28
|
+
|
29
|
+
-o, --out-dir DIR Directory to write output files to.
|
30
|
+
-l, --log-file FILE File to log to (default: STDERR).
|
31
|
+
-v, --verbose Run verbosely
|
32
|
+
-s, --skip-db Do not update dates from mysql database.
|
33
|
+
-h, --help Show this help and exit.
|
34
|
+
--version Show version and exit.
|
35
|
+
|
36
|
+
|
37
|
+
By default, `magelex` will log to `STDERR`, put you can pass the path to a log file.
|
38
|
+
|
39
|
+
It consumes a single file (given as argument, as in `magelex magento_orders.csv`). `magelex` will create a file with same filename in the path `lexware` (can be changed with the `--out-dir` switch).
|
40
|
+
|
41
|
+
### Configuration
|
42
|
+
|
43
|
+
Configure magento MySQL database access in `magelex.conf` . An example configuration comes shipped with the gem (`magelex.conf.example`).
|
44
|
+
|
45
|
+
If no database queries should be done, invoke with `--skip-db`.
|
46
|
+
|
47
|
+
### Use the command line interface
|
48
|
+
|
49
|
+
Call `magelex --help` to get a basic idea.
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `rake spec` to run the tests. You can also run `bundle console` for an interactive prompt that will allow you to experiment. Run `bundle exec magelex` to use the gem in this directory, ignoring other installed copies of this gem.
|
54
|
+
|
55
|
+
Generally, I prefer to work and develop in `bundle exec`-mode.
|
56
|
+
|
57
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fwolfst/magelex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
62
|
+
|
63
|
+
That said, just get in contact.
|
data/Rakefile
ADDED
data/bin/magelex
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "magelex"
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
program_name = File.basename __FILE__
|
9
|
+
options = {out_dir: 'lexware'}
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: #{program_name} DIR_OR_FILE"
|
12
|
+
opts.separator ""
|
13
|
+
opts.separator "Imports order data from magento csv export, exports this"\
|
14
|
+
" data to be imported to open positions in lexware."
|
15
|
+
opts.separator ""
|
16
|
+
|
17
|
+
opts.on('-o', '--out-dir DIR', 'Directory to write output files to.') do |o|
|
18
|
+
options[:out_dir] = o
|
19
|
+
end
|
20
|
+
opts.on('-l', '--log-file FILE', 'File to log to (default: STDERR).') do |o|
|
21
|
+
options[:log_file] = o
|
22
|
+
end
|
23
|
+
opts.on('-v', '--verbose', 'Run verbosely') do |o|
|
24
|
+
options[:verbose] = o
|
25
|
+
end
|
26
|
+
opts.on('-s', '--skip-db', 'Do not update dates from mysql database.') do |o|
|
27
|
+
options[:skipdb] = o
|
28
|
+
end
|
29
|
+
opts.on_tail('--version', 'Show version and exit.') do
|
30
|
+
puts "Magelex #{Magelex::VERSION}"
|
31
|
+
exit 0
|
32
|
+
end
|
33
|
+
opts.on('-h', '--help', 'Show this help and exit.') do
|
34
|
+
puts opts
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
end.parse!
|
38
|
+
|
39
|
+
if ARGV.length != 1
|
40
|
+
STDERR.puts "Need an argument (directory or file)"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
Magelex.logger = Logger.new(options[:log_file] ? options[:log_file] : STDERR)
|
45
|
+
|
46
|
+
Magelex.logger.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
|
47
|
+
Magelex.logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
48
|
+
Magelex.logger.formatter = proc { |severity, datetime, progname, msg|
|
49
|
+
"#{severity} - #{datetime} - #{msg}\n"
|
50
|
+
}
|
51
|
+
|
52
|
+
def main options
|
53
|
+
Magelex.logger.info("Started")
|
54
|
+
|
55
|
+
# Import/Read file.
|
56
|
+
bills_export = []
|
57
|
+
bills = Magelex::MagentoCSV.read ARGV[0]
|
58
|
+
bills.each do |bill|
|
59
|
+
if !bill.complete?
|
60
|
+
Magelex.logger.info("Skip order #{bill.order_nr} (incomplete: #{bill.status})")
|
61
|
+
else # complete!
|
62
|
+
bill.consume_shipping_cost
|
63
|
+
bill.swissify
|
64
|
+
if !bill.check
|
65
|
+
Magelex.logger.info("Skip order #{bill.order_nr} "\
|
66
|
+
"(totals do not match #{bill.total} != "\
|
67
|
+
"(0: #{bill.total_0} + 7: #{bill.total_7} "\
|
68
|
+
"+ 19: #{bill.total_19})")
|
69
|
+
else
|
70
|
+
Magelex.logger.debug("Handle #{bill.order_nr}")
|
71
|
+
bills_export << bill
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Fix dates via database.
|
77
|
+
if !options[:skipdb]
|
78
|
+
begin
|
79
|
+
Magelex.logger.info("Fetching dates from magento mysql.")
|
80
|
+
Magelex::MagentoMYSQL.update_dates YAML.load_file('magelex.conf'), bills_export
|
81
|
+
rescue => e
|
82
|
+
Magelex.logger.error("Could not connect to MySQL database, exiting.")
|
83
|
+
Magelex.logger.error(e.inspect)
|
84
|
+
exit 2
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Export/Write to file
|
89
|
+
Dir.mkdir options[:out_dir] rescue {}
|
90
|
+
outdir = Pathname.new(options[:out_dir]).realpath
|
91
|
+
outfile = outdir.join(File::basename ARGV[0])
|
92
|
+
if File.exist?(outfile)
|
93
|
+
Magelex.logger.error("Output file #{outfile} exists already, exiting.")
|
94
|
+
exit 3
|
95
|
+
end
|
96
|
+
Magelex.logger.info("Writing to #{outfile}")
|
97
|
+
Magelex::LexwareCSV.write outfile, bills_export
|
98
|
+
Magelex.logger.info("Finished")
|
99
|
+
end
|
100
|
+
|
101
|
+
main options
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Magelex
|
2
|
+
module AccountNumber
|
3
|
+
def self.for_customer bill
|
4
|
+
first_letter = bill.customer_lastname[0].upcase
|
5
|
+
first_letter.gsub!(/[ÖÜÄ]/, 'Ä' => 'A', 'Ö' => 'O', 'Ü' => 'U')
|
6
|
+
|
7
|
+
return 12300 if first_letter == "Y"
|
8
|
+
return 12300 if first_letter == "Z"
|
9
|
+
|
10
|
+
# A is 0
|
11
|
+
ord = first_letter.ord - "A".ord# + 1
|
12
|
+
10000 + ord * 100
|
13
|
+
end
|
14
|
+
|
15
|
+
# get tax for :total_0, :total_7 or :total_19
|
16
|
+
def self.for(bill, tax_kind)
|
17
|
+
if tax_kind == :total_0
|
18
|
+
return for_0 bill
|
19
|
+
elsif tax_kind == :total_7
|
20
|
+
return for_7 bill
|
21
|
+
elsif tax_kind == :total_19
|
22
|
+
return for_19 bill
|
23
|
+
else
|
24
|
+
raise "unknown tax_kind"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.for_7 bill
|
29
|
+
bill.in_eu? ? '8310' : '8300'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.for_19 bill
|
33
|
+
bill.in_eu? ? '8315' : '8400'
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.for_0 bill
|
37
|
+
'8120'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'magelex'
|
2
|
+
|
3
|
+
module Magelex
|
4
|
+
class LexwareBill
|
5
|
+
@@EU_CODES = ['BE','BG','CZ','DK','EE','EL','ES','FR',
|
6
|
+
'IE','IT','CY','LV','LT','LU','HU','MT',
|
7
|
+
'NL','AT','PL','PT','RO','SI','SK','FI','SE','UK']
|
8
|
+
|
9
|
+
attr_accessor :order_nr, :customer_name, :country_code,
|
10
|
+
:date, :status, :shipping_cost, :total, :total_0, :total_7, :total_19
|
11
|
+
|
12
|
+
def initialize values={}
|
13
|
+
@total_0, @total_7, @total_19, @total = 0, 0, 0, 0
|
14
|
+
@customer_name = values.delete(:customer_name) || ""
|
15
|
+
@order_nr = values.delete(:order_nr) || nil
|
16
|
+
@date = values.delete(:date) || nil
|
17
|
+
@total = values.delete(:total) || 0
|
18
|
+
@total_0 = values.delete(:total_0) || 0
|
19
|
+
@total_7 = values.delete(:total_7) || 0
|
20
|
+
@total_19 = values.delete(:total_19) || 0
|
21
|
+
@status = values.delete(:status) || nil
|
22
|
+
@shipping_cost = values.delete(:shipping_cost) || nil
|
23
|
+
@country_code = values.delete(:country_code) || nil
|
24
|
+
if !values.empty?
|
25
|
+
raise "Unknown values for bill: #{values.inspect}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def swiss?
|
30
|
+
@country_code == 'CH'
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_item amount, tax, name
|
34
|
+
case TaxGuess.guess(amount, tax)
|
35
|
+
when :tax0
|
36
|
+
@total_0 += amount
|
37
|
+
when :tax7
|
38
|
+
@total_7 += amount
|
39
|
+
when :tax19
|
40
|
+
@total_19 += amount
|
41
|
+
else
|
42
|
+
raise 'Unknown Tax class'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def customer_lastname
|
47
|
+
@customer_name.split[-1]
|
48
|
+
end
|
49
|
+
|
50
|
+
def in_eu?
|
51
|
+
@@EU_CODES.include? @country_code
|
52
|
+
end
|
53
|
+
|
54
|
+
def check
|
55
|
+
@total.round(2) == (@total_0 + @total_7 + @total_19).round(2)
|
56
|
+
end
|
57
|
+
|
58
|
+
def consume_shipping_cost
|
59
|
+
@total_19 += @shipping_cost * 1.19
|
60
|
+
@shipping_cost = 0
|
61
|
+
end
|
62
|
+
|
63
|
+
def complete?
|
64
|
+
@status == "complete"
|
65
|
+
end
|
66
|
+
|
67
|
+
def swissify
|
68
|
+
return if !swiss?
|
69
|
+
@total_0 += @total_19
|
70
|
+
@total_19 = 0
|
71
|
+
@total_0 += @total_7
|
72
|
+
@total_7 = 0
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Magelex
|
2
|
+
module LexwareCSV
|
3
|
+
def self.write file, bills
|
4
|
+
File.open(file, 'w') do |f|
|
5
|
+
f.write render(bills).gsub("\n", "\r\n").encode(
|
6
|
+
'windows-1252', invalid: :replace, undef: :replace)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.to_rows bill
|
11
|
+
# main
|
12
|
+
rows = []
|
13
|
+
rows << [bill.date.strftime("%d.%m.%Y"),
|
14
|
+
bill.order_nr,
|
15
|
+
bill.customer_name,
|
16
|
+
bill.total.round(2),
|
17
|
+
Magelex::AccountNumber.for_customer(bill),
|
18
|
+
0]
|
19
|
+
# subs
|
20
|
+
[:total_0, :total_7, :total_19].each do |part|
|
21
|
+
if (amount = bill.send(part)) != 0
|
22
|
+
rows << [
|
23
|
+
bill.date.strftime("%d.%m.%Y"),
|
24
|
+
bill.order_nr,
|
25
|
+
bill.customer_name,
|
26
|
+
amount.round(2),
|
27
|
+
0,
|
28
|
+
Magelex::AccountNumber.for(bill, part),
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rows
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.render bills
|
36
|
+
CSV.generate(encoding: 'utf-8') do |csv|
|
37
|
+
bills.each do |b|
|
38
|
+
to_rows(b).each { |r| csv << r }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Magelex
|
4
|
+
module MagentoCSV
|
5
|
+
MONEY_FIELDS = ['Order Shipping', 'Order Grand Total',
|
6
|
+
'Item Total', 'Item Tax']
|
7
|
+
|
8
|
+
CSV::Converters[:german_money_amount] = lambda do |value, info|
|
9
|
+
if MONEY_FIELDS.include? info[:header]
|
10
|
+
value.gsub(',', '.').to_f
|
11
|
+
else
|
12
|
+
value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
CSV::Converters[:order_date] = lambda do |value, info|
|
17
|
+
if info[:header] == 'Order Date'
|
18
|
+
Date.strptime(value[0..10], "%d.%m.%Y")
|
19
|
+
else
|
20
|
+
value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Reads file and returns lexware_bills
|
25
|
+
def self.read filename
|
26
|
+
self.parse(File.read filename)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Creates a bill with basic information from csv line
|
30
|
+
def self.init_bill row
|
31
|
+
bill = Magelex::LexwareBill.new
|
32
|
+
|
33
|
+
# TODO: defining a attribute|colum- map would be nicer
|
34
|
+
bill.order_nr = row['Order Number']
|
35
|
+
bill.customer_name = row['Billing Name']
|
36
|
+
bill.country_code = row['Shipping Country']
|
37
|
+
bill.date = row['Order Date']
|
38
|
+
|
39
|
+
bill.status = row['Order Status']
|
40
|
+
|
41
|
+
bill.shipping_cost = row['Order Shipping']
|
42
|
+
bill.total = row['Order Grand Total']
|
43
|
+
bill
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.parse string
|
47
|
+
bills = []
|
48
|
+
current_bill = Magelex::LexwareBill.new
|
49
|
+
|
50
|
+
CSV::parse(string, :headers => :first_row,
|
51
|
+
converters: [:all, :german_money_amount, :order_date]) do |row|
|
52
|
+
# Multiple rows (with same order_nr) define one order
|
53
|
+
# One order will be mapped to one bill
|
54
|
+
if current_bill.order_nr != row['Order Number']
|
55
|
+
current_bill = init_bill row
|
56
|
+
end
|
57
|
+
|
58
|
+
current_bill.add_item(row['Item Total'],
|
59
|
+
row['Item Tax'],
|
60
|
+
row['Item Name'])
|
61
|
+
|
62
|
+
if !bills.include? (current_bill)
|
63
|
+
bills << current_bill
|
64
|
+
end
|
65
|
+
end
|
66
|
+
bills
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
|
3
|
+
module Magelex
|
4
|
+
module MagentoMYSQL
|
5
|
+
def self.update_dates mysqlconf, bills
|
6
|
+
@client = Mysql2::Client.new(:host => mysqlconf[:host],
|
7
|
+
:port => mysqlconf[:port],
|
8
|
+
:database => mysqlconf[:database],
|
9
|
+
:username => mysqlconf[:username],
|
10
|
+
:password => mysqlconf[:password])
|
11
|
+
|
12
|
+
in_statement = bills.map{|b| "'#{b.order_id}'"}.join(',')
|
13
|
+
query = "SELECT increment_id, created_at, updated_at, "\
|
14
|
+
"invoice_status_id FROM sales_flat_invoice "\
|
15
|
+
"WHERE increment_id IN (#{in_statement});"
|
16
|
+
|
17
|
+
# Build up index TODO rubyfy
|
18
|
+
bill_idx = {}
|
19
|
+
bills.each {|b| bill_idx[b.order_id] = b}
|
20
|
+
results = @client.query(query)
|
21
|
+
|
22
|
+
results.each do |row|
|
23
|
+
bill_idx[row['increment_id']].date = row['created_at']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Magelex
|
2
|
+
module TaxGuess
|
3
|
+
def self.guess(total, tax_amount)
|
4
|
+
if tax_amount == 0
|
5
|
+
:tax0
|
6
|
+
elsif (total - total/1.06) <= tax_amount && (total - total/1.08) >= tax_amount
|
7
|
+
:tax7
|
8
|
+
elsif (total - total/1.18) <= tax_amount && (total - total/1.20) >= tax_amount
|
9
|
+
:tax19
|
10
|
+
else
|
11
|
+
raise "TaxGuess: Cannot guess tax of "\
|
12
|
+
"#{total}/#{tax_amount} (#{total - total/tax_amount})"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/magelex.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'magelex/version'
|
2
|
+
require 'magelex/magento_csv'
|
3
|
+
require 'magelex/lexware_bill'
|
4
|
+
require 'magelex/lexware_csv'
|
5
|
+
require 'magelex/tax_guess'
|
6
|
+
require 'magelex/lexware_account'
|
7
|
+
require 'magelex/magento_mysql'
|
8
|
+
|
9
|
+
require 'logger'
|
10
|
+
|
11
|
+
module Magelex
|
12
|
+
def self.logger
|
13
|
+
@logger ||= Logger.new
|
14
|
+
end
|
15
|
+
def self.logger= logger
|
16
|
+
@logger = logger
|
17
|
+
end
|
18
|
+
end
|
data/magelex.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'magelex/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "magelex"
|
8
|
+
spec.version = Magelex::VERSION
|
9
|
+
spec.authors = ["Felix Wolfsteller"]
|
10
|
+
spec.email = ["felix.wolfsteller@gmail.com"]
|
11
|
+
spec.licenses = ['GPL-3.0']
|
12
|
+
|
13
|
+
spec.summary = %q{Bridge for data from Magento shop to Lexware financial software.}
|
14
|
+
spec.homepage = "https://github.com/fwolfst/magelex"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'mysql2', '~> 0.4'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magelex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felix Wolfsteller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mysql2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- felix.wolfsteller@gmail.com
|
72
|
+
executables:
|
73
|
+
- magelex
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/magelex
|
84
|
+
- lib/magelex.rb
|
85
|
+
- lib/magelex/lexware_account.rb
|
86
|
+
- lib/magelex/lexware_bill.rb
|
87
|
+
- lib/magelex/lexware_csv.rb
|
88
|
+
- lib/magelex/magento_csv.rb
|
89
|
+
- lib/magelex/magento_mysql.rb
|
90
|
+
- lib/magelex/tax_guess.rb
|
91
|
+
- lib/magelex/version.rb
|
92
|
+
- magelex.conf.example
|
93
|
+
- magelex.gemspec
|
94
|
+
homepage: https://github.com/fwolfst/magelex
|
95
|
+
licenses:
|
96
|
+
- GPL-3.0
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.5.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Bridge for data from Magento shop to Lexware financial software.
|
118
|
+
test_files: []
|