shoplex 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shoplex.rb ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "shoplex/version"
4
+ require_relative "shoplex/account_number"
5
+ require_relative "shoplex/booking"
6
+ require_relative "shoplex/booking_line"
7
+ require_relative "shoplex/invoice_booking_converter"
8
+ require_relative "shoplex/lexware_csv"
9
+ require_relative "shoplex/result"
10
+ require_relative "shoplex/sanity_check"
11
+ require_relative "shoplex/shipping_splitter"
12
+ require_relative "shoplex/shopware_csv_parser"
13
+ require_relative "shoplex/shopware_invoice"
14
+
15
+ module Shoplex
16
+ class Error < StandardError; end
17
+
18
+ def self.process file_content
19
+ result = Shoplex::ShopwareCSVParser.parse(file_content)
20
+ bookings = result.invoices.map do |invoice|
21
+ begin
22
+ Shoplex::ShippingSplitter::apply!(invoice:)
23
+ Shoplex::SanityCheck::check!(invoice:)
24
+ Shoplex::InvoiceBookingConverter.convert(invoice:)
25
+ rescue => e
26
+ result.mark_error(maker: self, error: :unknown, obj: [e, invoice])
27
+ STDERR.puts e
28
+ STDERR.puts e.backtrace
29
+ end
30
+ end.compact
31
+
32
+ result.csv_out = Shoplex::LexwareCSV.create_from(bookings:)
33
+ return result
34
+ end
35
+ end
data/shoplex.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/shoplex/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "shoplex"
7
+ spec.version = Shoplex::VERSION
8
+ spec.authors = ["Felix Wolfsteller"]
9
+ spec.email = ["felix.wolfsteller@gmail.com"]
10
+
11
+ spec.summary = "shopware csv invoice export to lexware csv import"
12
+ spec.description = "Converts a file exported from shopware 5 invoice data into booking lines for lexware accounting software"
13
+ spec.homepage = "https://github.com/rawliving-germany/shoplex"
14
+ spec.required_ruby_version = ">= 3.2.0"
15
+
16
+ #spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end