amazon_purchases_ledger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/amazon_purchases_ledger-0.1.0.gem +0 -0
- data/amazon_purchases_ledger.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/amazon_purchases_ledger +5 -0
- data/lib/amazon_purchases_ledger.rb +24 -0
- data/lib/amazon_purchases_ledger/item.rb +51 -0
- data/lib/amazon_purchases_ledger/item/factory.rb +15 -0
- data/lib/amazon_purchases_ledger/merge_service.rb +55 -0
- data/lib/amazon_purchases_ledger/order.rb +68 -0
- data/lib/amazon_purchases_ledger/order/factory.rb +21 -0
- data/lib/amazon_purchases_ledger/shipment.rb +30 -0
- data/lib/amazon_purchases_ledger/shipment/factory.rb +16 -0
- data/lib/amazon_purchases_ledger/version.rb +3 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d6f6be1f97de2fbd0aa0628bd485bb0212b3e1b5
|
4
|
+
data.tar.gz: 2a232cab20c11bbc73451cc70db4ccf96d2175c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ea309277784ad1037eee6671202e22e3a79a54616080a4605a2259d8b3ae15d10aec7848f435e405858b8e64b1cf761f166f78a38b6dc284d34f73499fc2ced
|
7
|
+
data.tar.gz: 84becc66b0829aae3424d21f00f780396c75ce552e5f5fa508d44f859f248e2e2389d1bc613cb6a54c8bba90d1c7c6539e996ea25e7758c692baa07d3f28492f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
amazon_purchases_ledger (0.0.1)
|
5
|
+
thor (~> 0.20)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.0)
|
11
|
+
coderay (1.1.2)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
flog (4.6.2)
|
14
|
+
path_expander (~> 1.0)
|
15
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
16
|
+
sexp_processor (~> 4.8)
|
17
|
+
method_source (0.9.0)
|
18
|
+
parser (2.5.0.4)
|
19
|
+
ast (~> 2.4.0)
|
20
|
+
path_expander (1.0.2)
|
21
|
+
pry (0.11.3)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.9.0)
|
24
|
+
rake (10.5.0)
|
25
|
+
rspec (3.7.0)
|
26
|
+
rspec-core (~> 3.7.0)
|
27
|
+
rspec-expectations (~> 3.7.0)
|
28
|
+
rspec-mocks (~> 3.7.0)
|
29
|
+
rspec-core (3.7.1)
|
30
|
+
rspec-support (~> 3.7.0)
|
31
|
+
rspec-expectations (3.7.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.7.0)
|
34
|
+
rspec-mocks (3.7.0)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.7.0)
|
37
|
+
rspec-support (3.7.1)
|
38
|
+
ruby_parser (3.11.0)
|
39
|
+
sexp_processor (~> 4.9)
|
40
|
+
sexp_processor (4.10.1)
|
41
|
+
thor (0.20.0)
|
42
|
+
zombie_scout (0.0.6)
|
43
|
+
flog (~> 4.2)
|
44
|
+
parser (~> 2.1)
|
45
|
+
thor (~> 0.18)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
amazon_purchases_ledger!
|
52
|
+
bundler (~> 1.16)
|
53
|
+
pry (~> 0.11)
|
54
|
+
rake (~> 10.0)
|
55
|
+
rspec (~> 3.0)
|
56
|
+
zombie_scout (~> 0.0.5)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 John Randall
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Amazon Purchases Ledger
|
2
|
+
|
3
|
+
This gem takes order and item CSVs downloaded from your Amazon account as input, and parses those into a transactions CSV which is created in your home folder.
|
4
|
+
|
5
|
+
This output file is suitable for importing into a financial ledger system, such as Bankivity or Quicken. It contains fields for for transaction date, transaction amount, source account, and a memo.
|
6
|
+
|
7
|
+
The memo field in the output file contains details for each order, including the items and shipment details. Having these details included in each transaction row can helps with categorizing transactions for tax or budgeting purposes.
|
8
|
+
|
9
|
+
To create the orders and items CSVs needed as input, see https://www.amazon.com/gp/help/customer/display.html
|
10
|
+
|
11
|
+
|
12
|
+
## TODO:
|
13
|
+
|
14
|
+
[ ] Create a scraper that automatically downloads the source CSVs. See https://github.com/kyamaguchi/amazon_auth
|
15
|
+
|
16
|
+
|
17
|
+
## Similar projects
|
18
|
+
|
19
|
+
* Amazon Order - Does similar things scraping he Amazon DOM rather than using CSVs. See https://github.com/kyamaguchi/amazon_order
|
20
|
+
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'amazon_purchases_ledger'
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
$ bundle
|
33
|
+
|
34
|
+
Or install it yourself as:
|
35
|
+
|
36
|
+
$ gem install amazon_purchases_ledger
|
37
|
+
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
After installing, bundle should be available at the command line via
|
42
|
+
|
43
|
+
$ amazon_purchases_ledger
|
44
|
+
|
45
|
+
Pass in the filepaths to an Amazon orders csv and an Amazon items csv, and the gem will create a ```transactions.csv``` in the user's home folder:
|
46
|
+
|
47
|
+
$ amazon_purchases_ledger [orders csv filepath] [items csv filepath]
|
48
|
+
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
53
|
+
|
54
|
+
To install this gem onto your local machine, run `bundle exec rake install`. 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).
|
55
|
+
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/johntrandall/amazon_purchases_ledger.
|
60
|
+
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "amazon_purchases_ledger/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'amazon_purchases_ledger'
|
8
|
+
spec.version = AmazonPurchasesLedger::VERSION
|
9
|
+
spec.authors = ['John Randall']
|
10
|
+
spec.email = ['john@johnrandall.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Combine and Amazon orders csv and items csv into a csv suitable for importing into a financial ledger.}
|
13
|
+
spec.description = %q{Takes and Amazon orders csv and items csv as input. Generates and output csv suitable for importing into a financial program.}
|
14
|
+
spec.homepage = 'https://github.com/johntrandall/amazon_purchases_ledger'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib", 'lib/**']
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "pry", "~> 0.11"
|
37
|
+
spec.add_development_dependency 'zombie_scout', '~> 0.0.5'
|
38
|
+
spec.add_dependency 'thor', '~> 0.20'
|
39
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "amazon_purchases_ledger"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "amazon_purchases_ledger/version"
|
2
|
+
require "amazon_purchases_ledger/merge_service"
|
3
|
+
require "amazon_purchases_ledger/order"
|
4
|
+
require "amazon_purchases_ledger/order/factory"
|
5
|
+
require "amazon_purchases_ledger/shipment"
|
6
|
+
require "amazon_purchases_ledger/shipment/factory"
|
7
|
+
require "amazon_purchases_ledger/item"
|
8
|
+
require "amazon_purchases_ledger/item/factory"
|
9
|
+
|
10
|
+
require 'thor'
|
11
|
+
|
12
|
+
module AmazonPurchasesLedger
|
13
|
+
# Your code goes here...
|
14
|
+
class CLI < Thor
|
15
|
+
|
16
|
+
desc 'merge [orders.csv] [items.csv]', 'render transactions CSV at user\'s home_dir'
|
17
|
+
|
18
|
+
def merge(csv_path_1, csv_path_2)
|
19
|
+
AmazonPurchasesLedger::MergeService.new(csv_path_1, csv_path_2).perform
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module AmazonPurchasesLedger
|
2
|
+
class Item
|
3
|
+
def initialize(items_csv_row:)
|
4
|
+
@items_csv_row = items_csv_row
|
5
|
+
end
|
6
|
+
|
7
|
+
def output_text
|
8
|
+
[
|
9
|
+
'* ',
|
10
|
+
item_cost, ' for ',
|
11
|
+
item_quantity_string, item_title, ', ',
|
12
|
+
'Seller: ', item_seller
|
13
|
+
].join
|
14
|
+
end
|
15
|
+
|
16
|
+
def item_quantity_string
|
17
|
+
"#{@items_csv_row[:quantity]}x " if @items_csv_row[:quantity]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def item_seller
|
22
|
+
@items_csv_row[:seller]
|
23
|
+
end
|
24
|
+
|
25
|
+
def item_title
|
26
|
+
truncate(@items_csv_row[:title], 40)
|
27
|
+
end
|
28
|
+
|
29
|
+
def item_cost
|
30
|
+
@items_csv_row[:item_total]
|
31
|
+
end
|
32
|
+
|
33
|
+
def truncate(content, max)
|
34
|
+
if content.length > max
|
35
|
+
truncated = ""
|
36
|
+
collector = ""
|
37
|
+
content = content.split(" ")
|
38
|
+
content.each do |word|
|
39
|
+
word = word + " "
|
40
|
+
collector << word
|
41
|
+
truncated << word if collector.length < max
|
42
|
+
end
|
43
|
+
truncated = truncated.strip.chomp(",").concat("...")
|
44
|
+
else
|
45
|
+
truncated = content
|
46
|
+
end
|
47
|
+
return truncated
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AmazonPurchasesLedger
|
2
|
+
class Item
|
3
|
+
class Factory
|
4
|
+
def initialize(items_csv:, carrier_tracking:)
|
5
|
+
@items_csv = items_csv
|
6
|
+
@carrier_tracking = carrier_tracking
|
7
|
+
end
|
8
|
+
|
9
|
+
def items
|
10
|
+
items_csv_rows = @items_csv.select { |row| row[:carrier_name__tracking_number] == @carrier_tracking }
|
11
|
+
items_csv_rows.map { |items_csv_row| Item.new(items_csv_row: items_csv_row) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module AmazonPurchasesLedger
|
4
|
+
class MergeService
|
5
|
+
|
6
|
+
def initialize(csv_path_1, csv_path_2)
|
7
|
+
@csv_path_1 = csv_path_1
|
8
|
+
@csv_path_2 = csv_path_2
|
9
|
+
@csvs = [CSV.table(@csv_path_1, headers: true), CSV.table(@csv_path_2, headers: true)]
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: Fix filepath (strings are not paths). Also, make this cross platform.
|
13
|
+
def perform
|
14
|
+
CSV.open("#{Dir.home}/Desktop/amazon_transactions_#{timestamp}.csv", "wb") do |csv|
|
15
|
+
csv << output_header_row
|
16
|
+
orders.each do |order|
|
17
|
+
csv << order.output_row
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def orders
|
23
|
+
AmazonPurchasesLedger::Order::Factory.new(orders_csv: orders_csv,
|
24
|
+
items_csv: items_csv)
|
25
|
+
.orders
|
26
|
+
end
|
27
|
+
|
28
|
+
def orders_csv
|
29
|
+
csvs_with_header(:total_charged)
|
30
|
+
end
|
31
|
+
|
32
|
+
def items_csv
|
33
|
+
csvs_with_header(:title)
|
34
|
+
end
|
35
|
+
|
36
|
+
def output_header_row
|
37
|
+
AmazonPurchasesLedger::Order::OUTPUT_HEADER_ROW
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def timestamp
|
42
|
+
Time.now.strftime('%Y-%m-%d_%H-%M-%S')
|
43
|
+
end
|
44
|
+
|
45
|
+
class InvalidInputCsvs < StandardError;
|
46
|
+
end
|
47
|
+
|
48
|
+
def csvs_with_header(header)
|
49
|
+
csvs = @csvs.select { |csv| csv.headers.include?(header) }
|
50
|
+
raise InvalidInputCsvs unless csvs.count == 1
|
51
|
+
csvs.first
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module AmazonPurchasesLedger
|
2
|
+
class Order
|
3
|
+
attr_reader :order_id
|
4
|
+
|
5
|
+
def initialize(order_id:, orders_csv:, items_csv:)
|
6
|
+
@order_id = order_id
|
7
|
+
@orders_csv = orders_csv
|
8
|
+
@items_csv = items_csv
|
9
|
+
end
|
10
|
+
|
11
|
+
def complete?
|
12
|
+
amount != nil
|
13
|
+
end
|
14
|
+
|
15
|
+
OUTPUT_HEADER_ROW = [
|
16
|
+
:order_date,
|
17
|
+
:payment_account,
|
18
|
+
:amount,
|
19
|
+
:memo
|
20
|
+
]
|
21
|
+
|
22
|
+
def output_row
|
23
|
+
return nil if shipments.any? { |shipment| shipment.total_charged.nil? }
|
24
|
+
[
|
25
|
+
order_date,
|
26
|
+
payment_account,
|
27
|
+
amount,
|
28
|
+
memo
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def memo
|
33
|
+
shipments.map(&:output_text).join("\n")
|
34
|
+
end
|
35
|
+
|
36
|
+
def shipments
|
37
|
+
AmazonPurchasesLedger::Shipment::Factory.new(order_id: @order_id,
|
38
|
+
orders_csv: @orders_csv,
|
39
|
+
items_csv: @items_csv)
|
40
|
+
.shipments
|
41
|
+
end
|
42
|
+
|
43
|
+
def items
|
44
|
+
shipments.flat_map(&:items)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def shipment_rows
|
49
|
+
@orders_csv.select { |row| row[:order_id] == @order_id }
|
50
|
+
end
|
51
|
+
|
52
|
+
def order_date
|
53
|
+
shipment_rows.first[:order_date]
|
54
|
+
end
|
55
|
+
|
56
|
+
def payment_account
|
57
|
+
shipment_rows.first[:payment_instrument_type]
|
58
|
+
end
|
59
|
+
|
60
|
+
def amount
|
61
|
+
return nil if shipments.any? { |shipment| shipment.total_charged.nil? }
|
62
|
+
shipments.map { |shipment| shipment.total_charged }
|
63
|
+
.sum.to_f.to_s.prepend('$')
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AmazonPurchasesLedger
|
2
|
+
class Order
|
3
|
+
class Factory
|
4
|
+
def initialize(orders_csv:, items_csv:)
|
5
|
+
@orders_csv = orders_csv
|
6
|
+
@items_csv = items_csv
|
7
|
+
end
|
8
|
+
|
9
|
+
def orders
|
10
|
+
order_ids.map do |order_id|
|
11
|
+
Order.new(order_id: order_id, orders_csv: @orders_csv, items_csv: @items_csv)
|
12
|
+
end.select(&:complete?)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def order_ids
|
17
|
+
@orders_csv[:order_id]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'bigdecimal'
|
2
|
+
require 'bigdecimal/util'
|
3
|
+
|
4
|
+
module AmazonPurchasesLedger
|
5
|
+
class Shipment
|
6
|
+
def initialize(items_csv:, order_csv_row:)
|
7
|
+
@items_csv = items_csv
|
8
|
+
@order_csv_row = order_csv_row
|
9
|
+
end
|
10
|
+
|
11
|
+
def output_text
|
12
|
+
[
|
13
|
+
"Shipment: #{@order_csv_row[:carrier_name__tracking_number]}",
|
14
|
+
items.map { |item| item.output_text },
|
15
|
+
'----------------------'
|
16
|
+
].join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def total_charged
|
20
|
+
return nil unless @order_csv_row[:total_charged]
|
21
|
+
@order_csv_row[:total_charged].gsub('$', '').to_d
|
22
|
+
end
|
23
|
+
|
24
|
+
def items
|
25
|
+
AmazonPurchasesLedger::Item::Factory.new(carrier_tracking: @order_csv_row[:carrier_name__tracking_number],
|
26
|
+
items_csv: @items_csv)
|
27
|
+
.items
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module AmazonPurchasesLedger
|
2
|
+
class Shipment
|
3
|
+
class Factory
|
4
|
+
def initialize(orders_csv:, items_csv:, order_id:)
|
5
|
+
@orders_csv = orders_csv
|
6
|
+
@items_csv = items_csv
|
7
|
+
@order_id = order_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def shipments
|
11
|
+
order_csv_rows = @orders_csv.select { |row| row[:order_id] == @order_id }
|
12
|
+
order_csv_rows.map { |order_csv_row| Shipment.new(items_csv: @items_csv, order_csv_row: order_csv_row) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amazon_purchases_ledger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Randall
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: zombie_scout
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.5
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.20'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.20'
|
97
|
+
description: Takes and Amazon orders csv and items csv as input. Generates and output
|
98
|
+
csv suitable for importing into a financial program.
|
99
|
+
email:
|
100
|
+
- john@johnrandall.com
|
101
|
+
executables:
|
102
|
+
- amazon_purchases_ledger
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- amazon_purchases_ledger-0.1.0.gem
|
115
|
+
- amazon_purchases_ledger.gemspec
|
116
|
+
- bin/console
|
117
|
+
- bin/setup
|
118
|
+
- exe/amazon_purchases_ledger
|
119
|
+
- lib/amazon_purchases_ledger.rb
|
120
|
+
- lib/amazon_purchases_ledger/item.rb
|
121
|
+
- lib/amazon_purchases_ledger/item/factory.rb
|
122
|
+
- lib/amazon_purchases_ledger/merge_service.rb
|
123
|
+
- lib/amazon_purchases_ledger/order.rb
|
124
|
+
- lib/amazon_purchases_ledger/order/factory.rb
|
125
|
+
- lib/amazon_purchases_ledger/shipment.rb
|
126
|
+
- lib/amazon_purchases_ledger/shipment/factory.rb
|
127
|
+
- lib/amazon_purchases_ledger/version.rb
|
128
|
+
homepage: https://github.com/johntrandall/amazon_purchases_ledger
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
- lib/**
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.6.13
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Combine and Amazon orders csv and items csv into a csv suitable for importing
|
153
|
+
into a financial ledger.
|
154
|
+
test_files: []
|