shoplex 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 20c7941e19b65f85d1302da25487fbfcea4b97bd4ab155e2f7653016f17bb706
4
+ data.tar.gz: 101b225c841f95759f39448a22e6db2f49202d935e2e0c0dbe89b85cb6dfedf3
5
+ SHA512:
6
+ metadata.gz: aa8521384cf880d9604114d072d9e10aec63d270da3f4411b627b48dff4fc09065d8bee630958af5b5cc030a6cccd8c4b88289a5dcda21cbd1e8a0f72a9650b8
7
+ data.tar.gz: d147a8c5c0684f92d57d1e0fae3e548583636456e78f0cc8d460969a313f8f713180525138a8dc665263b1e53ef010ad954080b989e164fabb0a5ec6050ade35
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.3.0] - 2023-03-02
4
+
5
+ - Add invoice sanity check
6
+
7
+ ## [0.1.0] - 2023-03-02
8
+
9
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at felix.wolfsteller@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ ruby "3.2.1" # for CI to work, needs to match .github/workflows/ruby.yml
4
+
5
+ source "https://rubygems.org"
6
+
7
+ # Specify your gem's dependencies in shoplex.gemspec
8
+ gemspec
9
+
10
+ # Test and Gem maintenance
11
+
12
+ gem "rake", "~> 13.0"
13
+ gem "minitest", "~> 5.0"
14
+ gem "minitest-reporters", "~> 1.6"
15
+
16
+ # Webui
17
+
18
+ gem "sinatra", "~> 3.0"
19
+ gem "haml", "~> 6.1"
20
+ gem "puma", "~> 6.1"
21
+
22
+ gem "rerun", "~> 0.14.0"
23
+
24
+ gem "guard", "~> 2.18"
25
+
26
+ gem "guard-minitest", "~> 2.4"
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Shoplex
2
+
3
+ Shoplex takes Shopware online shop order and invoice data and converts it in a format that Lexware can read to model open positions.
4
+
5
+ It superseedes the [magelex (version online is outdated)](github.com/raw-living-germany/magelex), since the change from Monstergento to Shopliftware.
6
+
7
+ It supports the management of cash flow in Lexware.
8
+
9
+ The solution is specific for one customers needs. If you need a similar (or better) solution, contact us!
10
+
11
+ It is hacked in pretty vanilla (and as of writing, recent) Ruby 3.2.1+ and comes
12
+ with a sinatra (old school, single fileish) web interface.
13
+
14
+ ## Installation
15
+
16
+ Install it yourself as:
17
+
18
+ $ gem install shoplex
19
+
20
+ Instructions to run the web-ui are below.
21
+
22
+ ## Assumptions
23
+
24
+ Customer accounts are hard coded.
25
+
26
+ ## Usage
27
+
28
+ $ none yet
29
+
30
+ ## Documentation of process
31
+
32
+
33
+
34
+ ## Open questions and/or answers
35
+
36
+ **How to deal with credits/Gutschriften**
37
+
38
+ *We don't know yet*
39
+
40
+ **Does EU-ity depend on shipping or billing address**
41
+
42
+ *We don't know yet*
43
+
44
+ **Some invoices have 0 amount and/or a gutschrift - where do they come from?**
45
+
46
+ *We don't know yet*
47
+
48
+ **Where is the tax of the shipping costs?**
49
+
50
+ The **invoiceAmount is inclusive the invoiceShipping**.
51
+ Taxes of the shipping is not included in the individual tax columns but calculated via percentage (anteilsmäßig).
52
+
53
+ **Which invoices or orders to take into account?**
54
+
55
+ Take **all invoices** (irrespective of orderStatus and paymentStatus)
56
+
57
+ **Does Lexware needs gross or net numbers?**
58
+
59
+ Lexware takes **gross** numbers
60
+
61
+ **Do we need to book the discount?**
62
+
63
+ No.
64
+
65
+ ## Other
66
+
67
+ To experiment with that code, run `bin/console` for an interactive prompt.
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/raw-living-germany/shoplex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/shoplex/blob/master/CODE_OF_CONDUCT.md).
72
+
73
+ ### License
74
+
75
+ The included [pico css](https://github.com/picocss/pico) file is [MIT](https://github.com/picocss/pico/blob/08da409d0758dd1807783a938e4e202445f30033/LICENSE.md)
76
+ licensed.
77
+ Rest is [AGPLv3+](LICENSE), Copyright 2023 Felix wolfsteller.
78
+
79
+ ## Code of Conduct
80
+
81
+ Everyone interacting in the Shoplex project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/raw-living-germany/shoplex/blob/master/CODE_OF_CONDUCT.md).
82
+
83
+ # Web-UI for Shoplex
84
+
85
+ (single file sinatra app)
86
+
87
+ ## Start and usage instructions
88
+
89
+ `bundle exec exe/shoplex-web`
90
+
91
+ ### Development
92
+
93
+ Execute
94
+
95
+ ```bash
96
+ bundle exec rerun --pattern "**/*" --ignore="test/*" exe/shoplex-web
97
+ ```
98
+
99
+ for automatic server reloads in development.
100
+
101
+ ## Deployment
102
+
103
+ As a service you can take the template in [webui/shoplex.service], link it (e.g.
104
+ `ln -s /home/rawbotz/shoplex/webui/shoplex.service /etc/systemd/system/shoplex.service`) and
105
+ start it (`service shoplex restart`)
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ ## config.ru (run with rackup)
2
+ load './exe/shoplex-web'
3
+
4
+ run Sinatra::Application
data/exe/shoplex ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'shoplex'
4
+
5
+ puts Shoplex::process(ARGF.read).csv_out
6
+
7
+ exit 0
data/exe/shoplex-web ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sinatra'
4
+ require 'haml'
5
+
6
+ require 'shoplex'
7
+
8
+ set :root, File.dirname(__FILE__)
9
+ set :public_folder, Proc.new { File.join(root, "..", "webui") }
10
+ set :static, true
11
+
12
+ get '/' do
13
+ content_type "text/html"
14
+ @open_file_upload_dialog = true
15
+ haml :index
16
+ end
17
+
18
+ post '/' do
19
+ unless params[:file] &&
20
+ (tmpfile = params[:file][:tempfile]) &&
21
+ (name = params[:file][:filename])
22
+ @open_file_upload_dialog = true
23
+ @error = "No file selected"
24
+ return haml(:index)
25
+ end
26
+ @open_file_upload_dialog = false
27
+ tmpfile_content = tmpfile.read
28
+ @result = Shoplex::process tmpfile_content
29
+ haml :index
30
+ end
31
+
32
+ # Sinatra & Ruby Magic
33
+ __END__
34
+
35
+ @@layout
36
+ !!! 5
37
+ %html{:"data-theme" => "dark"}
38
+ %head
39
+ %meta{:charset => "utf-8"}
40
+ %title Shoplex WEB
41
+ %meta{:name => "viewport", :content => "width=device-width, initial-scale=1"}
42
+ :css
43
+ :root {
44
+ --primary: #8e24aa;
45
+ }
46
+ %link{:rel => "stylesheet", :href => "/assets/pico.min.css"}
47
+ :css
48
+ /* Purple Dark scheme (Forced) */
49
+ [data-theme="dark"] {
50
+ --primary: #8e24aa;
51
+ --primary-hover: #9c27b0;
52
+ --primary-focus: rgba(142, 36, 170, 0.25);
53
+ --primary-inverse: #FFF;
54
+ }
55
+ /* Purple (Common styles) */
56
+ :root {
57
+ --form-element-active-border-color: var(--primary);
58
+ --form-element-focus-color: var(--primary-focus);
59
+ --switch-color: var(--primary-inverse);
60
+ --switch-checked-background-color: var(--primary);
61
+ }
62
+ h1 {
63
+ --typography-spacing-vertical: 1rem;
64
+ }
65
+ %body
66
+ %main.container
67
+ != yield
68
+
69
+ @@index
70
+ %h1 Shoplex
71
+ %em(style="color: red")=@error
72
+ %details(open=@open_file_upload_dialog)
73
+ %summary File Upload
74
+ %form{action: "/", method: "post", enctype: "multipart/form-data"}
75
+ .grid
76
+ %div
77
+ %input{type: "file", name: "file"}
78
+ %div
79
+ %input{type: "submit", value: "Upload"}
80
+ %details
81
+ %summary Text Upload
82
+ %form{action: "/", method: "post", enctype: "multipart/form-data"}
83
+ %textarea{name: 'textarea', placeholder: "copy your text here"}
84
+ %input{type: "submit", value: "Upload"}
85
+ %hr
86
+ - if @result
87
+ %h2 Result
88
+ %h3 Errors and invoices to look out for
89
+ %div(style="color: red")
90
+ #{@result.errors.count} errors here
91
+ #{@result.errors.inspect}
92
+ %h3 Lexware file
93
+ %a{role: 'button', href:"data:attachment/csv;charset=utf-8,#{URI.encode_www_form_component @result.csv_out}", target: '_blank', download: 'filename.csv'}
94
+ Download file
95
+ %pre
96
+ = @result.csv_out
@@ -0,0 +1,29 @@
1
+ class Shoplex::AccountNumber
2
+ def self.sending_gross(lastname:)
3
+ char = lastname.encode(Encoding::UTF_8).strip.upcase[/[a-zA-ZÖÄÜ]/].chars.first
4
+ char.gsub!(/[ÖÜÄ]/, 'Ä' => 'A', 'Ö' => 'O', 'Ü' => 'U')
5
+
6
+ if char !~ /[A-Z]/
7
+ raise ArgumentError, "Don't know account number for #{lastname} (does not start with a 'good' letter A-Z)"
8
+ end
9
+
10
+ ordinal = char.ord - "A".ord
11
+
12
+ 10_000 + ordinal * 100
13
+ end
14
+
15
+
16
+ # 8120 is e.g. Swiss and taxfree - book manually
17
+ # 8125 would be EU with tax-ID-Nr. §4 - book manually
18
+ def self.receiving_tax00(german:)
19
+ 8120
20
+ end
21
+
22
+ def self.receiving_tax07(german:)
23
+ german ? 8300 : 8310
24
+ end
25
+
26
+ def self.receiving_tax19(german:)
27
+ german ? 8400 : 8315
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ class Shoplex::Booking
2
+ attr_reader :booking_lines, :date, :reference
3
+
4
+ def initialize(date:, reference:)
5
+ @booking_lines = []
6
+ @date = date
7
+ @reference = reference
8
+ end
9
+
10
+ def line(type:)
11
+ @booking_lines.select{_1.type == type}.first
12
+ end
13
+
14
+ def lines
15
+ @booking_lines.dup.freeze
16
+ end
17
+
18
+ def add_line(booking_line)
19
+ booking_line.booking = self
20
+ @booking_lines << booking_line
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Shoplex
2
+ BookingLine = Struct.new(:sending_account, :receiving_account, :gross_amount,
3
+ :reference,
4
+ :type,
5
+ :booking,
6
+ keyword_init:true) do
7
+ def initialize(...)
8
+ super(...)
9
+ raise BookingLine::Types::UnsupportedType.new("BookingLine Type #{type.inspect} not supported") if !BookingLine::Types::contains?(type)
10
+ end
11
+ end
12
+
13
+ module BookingLine::Types
14
+ class UnsupportedType < StandardError ; end
15
+
16
+ GROSS = :gross
17
+ TAX00 = :tax00
18
+ TAX07 = :tax07
19
+ TAX19 = :tax19
20
+
21
+ def self.contains? type
22
+ [GROSS, TAX00, TAX07, TAX19].include? type
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,42 @@
1
+ module Shoplex
2
+ class InvoiceBookingConverter
3
+ def self.convert(invoice:)
4
+ booking = Booking.new(date: invoice.order_time, reference: invoice.invoice_number)
5
+
6
+ add_gross_booking_line(invoice:, booking:)
7
+ [
8
+ [:tax00, AccountNumber::method(:receiving_tax00), :tax00_amount],
9
+ [:tax07, AccountNumber::method(:receiving_tax07), :tax07_amount],
10
+ [:tax19, AccountNumber::method(:receiving_tax19), :tax19_amount],
11
+ ].each do |type, account_number_method, invoice_amount_accessor|
12
+ add_tax_booking_line(invoice:, booking:, type:, account_number_method:, invoice_amount_accessor:)
13
+ end
14
+
15
+ booking
16
+ end
17
+
18
+ def self.create_reference invoice:
19
+ "#{invoice.invoice_number} #{invoice.order_number} #{invoice.firstname} #{invoice.lastname}"
20
+ end
21
+
22
+ def self.add_gross_booking_line(invoice:, booking:)
23
+ booking.add_line Shoplex::BookingLine.new(sending_account: Shoplex::AccountNumber::sending_gross(lastname: invoice.lastname),
24
+ receiving_account: 0,
25
+ gross_amount: invoice.invoice_amount,
26
+ reference: create_reference(invoice:),
27
+ type: BookingLine::Types::GROSS)
28
+ end
29
+
30
+ def self.add_tax_booking_line(invoice:, booking:, type:, account_number_method:, invoice_amount_accessor:)
31
+ return if invoice.send(invoice_amount_accessor).to_f == 0.0
32
+
33
+ line = Shoplex::BookingLine.new(
34
+ sending_account: 0,
35
+ receiving_account: account_number_method.(german: invoice.german?),
36
+ gross_amount: invoice.send(invoice_amount_accessor),
37
+ reference: create_reference(invoice:),
38
+ type:)
39
+ booking.add_line line
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ module Shoplex
2
+ class LexwareCSV
3
+ def self.create_from(bookings:)
4
+ CSV.generate do |csv|
5
+ bookings.each do |booking|
6
+ booking.booking_lines.each do |line|
7
+ csv << [
8
+ booking.date.strftime("%d.%m.%Y"),
9
+ booking.reference,
10
+ line.reference,
11
+ "%.2f" % line.gross_amount.to_f,
12
+ line.sending_account,
13
+ line.receiving_account,
14
+ 'EUR'
15
+ ]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module Shoplex
2
+ class Result
3
+ attr_accessor :invoices
4
+ attr_reader :errors
5
+ attr_accessor :csv_out
6
+
7
+ def initialize
8
+ @invoices = []
9
+ @errors = {}
10
+ end
11
+
12
+ def mark_error(maker:, error:, obj:)
13
+ @errors[maker] ||= {}
14
+ @errors[maker][error] ||= []
15
+
16
+ @errors[maker][error] << obj
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Shoplex
2
+ class SanityCheck
3
+ class GrossDoesNotMatchNet < StandardError ; end
4
+ def self.check!(invoice:)
5
+ net_tax_sum = (invoice.invoice_amount_net + invoice.tax07_amount + invoice.tax19_amount).round(2)
6
+ if invoice.invoice_amount != net_tax_sum
7
+ raise GrossDoesNotMatchNet.new(
8
+ "Gross amount #{invoice.invoice_amount} does not equal net + tax sums "\
9
+ "(#{invoice.invoice_amount_net} "\
10
+ "+ #{invoice.tax07_amount} "\
11
+ "+ #{invoice.tax19_amount} == #{net_tax_sum})")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module Shoplex
2
+ class ShippingSplitter
3
+ def self.apply!(invoice:)
4
+ return if invoice.shipping_net.to_i == 0 || invoice.shipping_gross.to_i == 0
5
+
6
+ #https://www.wolframalpha.com/input?i=solve+a+%2B+b+%3D+1+AND+g+-+n+%3D+0.07+*+a+*+n+%2B+0.19+*+b+*+n+for+a
7
+
8
+
9
+ ratio_07 = (119 / 12.0) - (25 * invoice.shipping_gross) / (3 * invoice.shipping_net)
10
+ ratio_19 = 1.0 - ratio_07
11
+
12
+ shipping_cost_19part = invoice.shipping_net * ratio_19
13
+ shipping_cost_07part = invoice.shipping_net * ratio_07
14
+
15
+ invoice.tax19_amount = invoice.tax19_amount.to_f + shipping_cost_19part * 0.19
16
+ invoice.tax07_amount = invoice.tax07_amount.to_f + shipping_cost_07part * 0.07
17
+
18
+ invoice.tax19_amount = invoice.tax19_amount.round(2)
19
+ invoice.tax07_amount = invoice.tax07_amount.round(2)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,55 @@
1
+ require 'csv'
2
+
3
+ module Shoplex
4
+ class ShopwareCSVParser
5
+ def self.parse csv_file_content
6
+ result = Shoplex::Result.new
7
+
8
+ CSV.parse(csv_file_content, headers: true, col_sep: ';', converters:
9
+ :date_time, encoding: Encoding::ISO_8859_1) do |row|
10
+ if row['invoiceNumber']
11
+ begin
12
+ convert_tax_numbers!(row:)
13
+ convert_shipping_and_amount__numbers!(row:)
14
+ result.invoices << create_invoice_from(row:)
15
+ rescue => e
16
+ result.mark_error(maker: self, error: :creation_failed, obj: [e, row])
17
+ STDERR.puts e
18
+ STDERR.puts e.backtrace
19
+ end
20
+ else
21
+ result.mark_error(maker: self, error: :no_invoice_number, obj: row)
22
+ end
23
+ end
24
+
25
+ return result
26
+ end
27
+
28
+ def self.convert_tax_numbers!(row:)
29
+ row["taxRateSums_7"] = row["taxRateSums_7"].to_f
30
+ row["taxRateSums_19"] = row["taxRateSums_19"].to_f
31
+ end
32
+
33
+ def self.convert_shipping_and_amount__numbers!(row:)
34
+ row["invoiceShipping"] = row["invoiceShipping"].to_s.gsub(",",".").to_f
35
+ row["invoiceShippingNet"] = row["invoiceShippingNet"].to_s.gsub(",",".").to_f
36
+ row["invoiceAmount"] = row["invoiceAmount"].to_s.gsub(",",".").to_f
37
+ row["invoiceAmountNet"] = row["invoiceAmountNet"].to_s.gsub(",",".").to_f
38
+ end
39
+
40
+ def self.create_invoice_from(row:)
41
+ ShopwareInvoice.new(invoice_number: row["invoiceNumber"],
42
+ order_number: row['orderNumber'],
43
+ order_time: row['orderTime'],
44
+ tax00_amount: row['taxRateSums_0'],
45
+ tax07_amount: row['taxRateSums_7'],
46
+ tax19_amount: row['taxRateSums_19'],
47
+ invoice_amount: row['invoiceAmount'],
48
+ invoice_amount_net: row['invoiceAmountNet'],
49
+ shipping_gross: row['invoiceShipping'],
50
+ shipping_net: row['invoiceShippingNet'],
51
+ country: row['billingCountry'],
52
+ lastname: row['billingLastName'],)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,37 @@
1
+ module Shoplex
2
+ ShopwareInvoice = Struct.new(:invoice_number,
3
+ :order_number,
4
+ :firstname, :lastname,
5
+ :country,
6
+ :order_time,
7
+ :invoice_amount, :invoice_amount_net,
8
+ :tax00_amount,
9
+ :tax07_amount,
10
+ :tax19_amount,
11
+ :shipping_gross, :shipping_net,
12
+ keyword_init: true) do
13
+
14
+ # provide defaults (floats for the numbers)
15
+ def initialize(invoice_number: nil,
16
+ order_number: nil,
17
+ firstname: nil, lastname: nil,
18
+ country: nil,
19
+ order_time: nil,
20
+ invoice_amount: 0.0, invoice_amount_net: 0.0,
21
+ tax00_amount: 0.0,
22
+ tax07_amount: 0.0,
23
+ tax19_amount: 0.0,
24
+ shipping_gross: 0.0, shipping_net: 0.0
25
+ )
26
+ super
27
+ end
28
+
29
+ def german?
30
+ country == "Deutschland"
31
+ end
32
+
33
+ def swiss?
34
+ county == "Schweiz"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shoplex
4
+ VERSION = "0.3.0"
5
+ end