exact 0.1.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
+ SHA1:
3
+ metadata.gz: 84a6a669af80d51b9c64b1d652fa8bca6be89077
4
+ data.tar.gz: 865b3306405fa1653a9f126d60c154e25d2bae4e
5
+ SHA512:
6
+ metadata.gz: 50a72ed9a2ee05b800298b61cdd2e92c13ffc493be3c2c6e63b1826454fd828945ea0ec4e18a152bab7dc7d12827de88f2c2ea271c2bbb64fec26dacc64d61c1
7
+ data.tar.gz: 645119abfc84882c18914d9b7f33516dd5d6b45496878614c8b98c4d99cae0e501d55ff07d8ce53d449d3abcfe500ede42f84331bc20d56caba6a057aa15fbf6
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
11
+ .rubocop*.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exact.gemspec
4
+ gemspec
5
+
6
+ gem 'ruby_odata', github: 'zzk/ruby_odata', branch: 'oauth2'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 zzk
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,41 @@
1
+ # Exact
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/exact`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'exact'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install exact
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zzk/exact. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'exact'
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exact.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exact/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'exact'
8
+ spec.version = Exact::VERSION
9
+ spec.authors = ['zzk']
10
+ spec.email = ['zzk@chickenkiller.org']
11
+
12
+ spec.summary = 'Exact API handler'
13
+ spec.description = 'Exact API handler'
14
+ spec.homepage = 'https://github.com/zzk/exact'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'virtus', '~> 1.0.3'
31
+ spec.add_dependency 'ruby_odata', '~> 0.1.6'
32
+ spec.add_dependency 'activesupport', '~> 4.2.3'
33
+ spec.add_dependency 'activemodel', '~> 4.2.3'
34
+
35
+ spec.add_development_dependency 'bundler', '~> 1.10'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'rspec', '~> 3.3.0'
38
+ spec.add_development_dependency 'pry', '~> 0.10.1'
39
+ spec.add_development_dependency 'factory_girl', '~> 4.5.0'
40
+ spec.add_development_dependency 'vcr', '~> 2.9.3'
41
+ end
@@ -0,0 +1,22 @@
1
+ require 'ruby_odata'
2
+
3
+ module Exact
4
+ class Client
5
+ attr_reader :exact_url, :exact_client
6
+ attr_accessor :access_token, :division, :service, :endpoint
7
+
8
+ def initialize(access_token:, division:, service:, endpoint:)
9
+ @access_token = access_token
10
+ @division = division
11
+ @service = service
12
+ @endpoint = endpoint
13
+ @exact_url = "#{Exact.configuration.exact_url}/#{division}/#{service}"
14
+ @exact_client = OData::Service.new(@exact_url, access_token: access_token, namespace: 'Exactonline')
15
+ @exact_client.send(endpoint)
16
+ end
17
+
18
+ def method_missing(mthd, *args, &block)
19
+ exact_client.send(mthd, *args, &block) if exact_client.respond_to? mthd.to_s
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ module Exact
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure
7
+ self.configuration ||= Configuration.new
8
+ yield(configuration) if block_given?
9
+ end
10
+
11
+ class Configuration
12
+ attr_accessor :exact_url
13
+
14
+ def initialize
15
+ @exact_url = 'https://start.exactonline.nl/api/v1'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class AccountMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class BankAccountMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,17 @@
1
+ module Exact
2
+ class BaseMapping
3
+ def self.convert(exact_object, object = nil)
4
+ hsh = exact_object.instance_variables.each_with_object({}) { |var, hash| hash[var.to_s.delete('@').to_sym] = exact_object.instance_variable_get(var) }.except!(:__metadata)
5
+ if object.present?
6
+ hsh.each do |k, v|
7
+ object.send("#{k}=", v)
8
+ end
9
+ object
10
+ else
11
+ name = to_s.demodulize
12
+ name.slice!('Mapping')
13
+ Exact.const_get(name).new(hsh) unless object.present?
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class CostCenterMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class CostUnitMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class ItemMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class ProjectMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class SalesInvoiceLineMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Exact
2
+ class SalesInvoiceMapping < BaseMapping
3
+ end
4
+ end
@@ -0,0 +1,142 @@
1
+ module Exact
2
+ class Account < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'crm'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :Accountant, String
10
+ attribute :AccountManager, String
11
+ attribute :AccountManagerFullName, String
12
+ attribute :AccountManagerHID, String
13
+ attribute :ActivitySector, String
14
+ attribute :ActivitySubSector, String
15
+ attribute :AddressLine1, String
16
+ attribute :AddressLine2, String
17
+ attribute :AddressLine3, String
18
+ attribute :Blocked, String
19
+ attribute :BRIN, String
20
+ attribute :BusinessType, String
21
+ attribute :CanDropShip, String
22
+ attribute :ChamberOfCommerce, String
23
+ attribute :City, String
24
+ attribute :Classification, String
25
+ attribute :Classification1, String
26
+ attribute :Classification2, String
27
+ attribute :Classification3, String
28
+ attribute :Classification4, String
29
+ attribute :Classification5, String
30
+ attribute :Classification6, String
31
+ attribute :Classification7, String
32
+ attribute :Classification8, String
33
+ attribute :ClassificationDescription, String
34
+ attribute :Code, String
35
+ attribute :CodeAtSupplier, String
36
+ attribute :CompanySize, String
37
+ attribute :ConsolidationScenario, String
38
+ attribute :ControlledDate, DateTime
39
+ attribute :Costcenter, String
40
+ attribute :CostcenterDescription, String
41
+ attribute :CostPaid, String
42
+ attribute :Country, String
43
+ attribute :CountryName, String
44
+ attribute :Created, DateTime
45
+ attribute :Creator, String
46
+ attribute :CreatorFullName, String
47
+ attribute :CreditLinePurchase, String
48
+ attribute :CreditLineSales, String
49
+ attribute :Currency, String
50
+ attribute :CustomerSince, DateTime
51
+ attribute :DiscountPurchase, String
52
+ attribute :DiscountSales, String
53
+ attribute :Division, String
54
+ attribute :Document, String
55
+ attribute :DunsNumber, String
56
+ attribute :Email, String
57
+ attribute :EndDate, DateTime
58
+ attribute :Fax, String
59
+ attribute :GLAccountPurchase, String
60
+ attribute :GLAccountSales, String
61
+ attribute :GLAP, String
62
+ attribute :GLAR, String
63
+ attribute :ID, String
64
+ attribute :IntraStatArea, String
65
+ attribute :IntraStatDeliveryTerm, String
66
+ attribute :IntraStatSystem, String
67
+ attribute :IntraStatTransactionA, String
68
+ attribute :IntraStatTransactionB, String
69
+ attribute :IntraStatTransportMethod, String
70
+ attribute :InvoiceAccount, String
71
+ attribute :InvoiceAccountCode, String
72
+ attribute :InvoiceAccountName, String
73
+ attribute :InvoiceAttachmentType, String
74
+ attribute :InvoicingMethod, String
75
+ attribute :IsAccountant, String
76
+ attribute :IsAgency, String
77
+ attribute :IsBank, String
78
+ attribute :IsCompetitor, String
79
+ attribute :IsMailing, String
80
+ attribute :IsMember, String
81
+ attribute :IsPilot, String
82
+ attribute :IsPurchase, String
83
+ attribute :IsReseller, String
84
+ attribute :IsSales, String
85
+ attribute :IsSupplier, String
86
+ attribute :Language, String
87
+ attribute :LanguageDescription, String
88
+ attribute :Latitude, String
89
+ attribute :LeadSource, String
90
+ attribute :LogoFileName, String
91
+ attribute :LogoThumbnailUrl, String
92
+ attribute :LogoUrl, String
93
+ attribute :Logo, String
94
+ attribute :Longitude, String
95
+ attribute :MainContact, String
96
+ attribute :Modified, DateTime
97
+ attribute :Modifier, String
98
+ attribute :ModifierFullName, String
99
+ attribute :Name, String
100
+ attribute :Parent, String
101
+ attribute :PaymentConditionPurchase, String
102
+ attribute :PaymentConditionPurchaseDescription, String
103
+ attribute :PaymentConditionSales, String
104
+ attribute :PaymentConditionSalesDescription, String
105
+ attribute :Phone, String
106
+ attribute :PhoneExtension, String
107
+ attribute :Postcode, String
108
+ attribute :PriceList, String
109
+ attribute :PurchaseCurrency, String
110
+ attribute :PurchaseCurrencyDescription, String
111
+ attribute :PurchaseLeadDays, String
112
+ attribute :PurchaseVATCode, String
113
+ attribute :PurchaseVATCodeDescription, String
114
+ attribute :Remarks, String
115
+ attribute :RecepientOfCommissions, String
116
+ attribute :Reseller, String
117
+ attribute :ResellerCode, String
118
+ attribute :ResellerName, String
119
+ attribute :SalesCurrency, String
120
+ attribute :SalesCurrencyDescription, String
121
+ attribute :SalesVATCode, String
122
+ attribute :SalesVATCodeDescription, String
123
+ attribute :SearchCode, String
124
+ attribute :SecurityLevel, String
125
+ attribute :SeparateInvPerProject, String
126
+ attribute :SeparateInvPerSubscription, String
127
+ attribute :ShippingLeadDays, String
128
+ attribute :ShippingMethod, String
129
+ attribute :StartDate, DateTime
130
+ attribute :State, String
131
+ attribute :StateName, String
132
+ attribute :Status, String, default: 'C'
133
+ attribute :StatusSince, DateTime
134
+ attribute :SalesTaxSchedule, String
135
+ attribute :SalesTaxScheduleCode, String
136
+ attribute :SalesTaxScheduleDescription, String
137
+ attribute :Type, String
138
+ attribute :VATLiability, String
139
+ attribute :VATNumber, String
140
+ attribute :Website, String
141
+ end
142
+ end
@@ -0,0 +1,32 @@
1
+ module Exact
2
+ class BankAccount < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'crm'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :Account, String
10
+ attribute :AccountName, String
11
+ attribute :Bank, String
12
+ attribute :BankAccount, String
13
+ attribute :BankAccountHolderName, String
14
+ attribute :BankDescription, String
15
+ attribute :BankName, String
16
+ attribute :BICCode, String
17
+ attribute :Created, DateTime
18
+ attribute :Creator, String
19
+ attribute :CreatorFullName, String
20
+ attribute :Description, String
21
+ attribute :Division, String
22
+ attribute :Format, String
23
+ attribute :IBAN, String
24
+ attribute :ID, String
25
+ attribute :Main, Boolean
26
+ attribute :Modified, DateTime
27
+ attribute :Modifier, String
28
+ attribute :ModifierFullName, String
29
+ attribute :Type, String
30
+ attribute :TypeDescription, String
31
+ end
32
+ end
@@ -0,0 +1,137 @@
1
+ require 'virtus'
2
+ require 'active_model'
3
+
4
+ module Exact
5
+ class Base
6
+ attr_accessor :client
7
+
8
+ def guid
9
+ send(self.class.exact_guid_attribute)
10
+ end
11
+
12
+ def self.exact_guid_attribute
13
+ Object.const_get("#{name}::EXACT_GUID")
14
+ end
15
+
16
+ def exact_guid_attribute
17
+ self.class.exact_guid_attribute
18
+ end
19
+
20
+ def self.exact_service
21
+ Object.const_get("#{self}::EXACT_SERVICE")
22
+ end
23
+
24
+ def exact_service
25
+ self.class.exact_service
26
+ end
27
+
28
+ def self.exact_endpoint
29
+ to_s.demodulize.pluralize.camelize
30
+ end
31
+
32
+ def exact_endpoint
33
+ self.class.exact_endpoint
34
+ end
35
+
36
+ def self.create_client(access_token:, division:)
37
+ Exact::Client.new(access_token: access_token, division: division, service: exact_service, endpoint: exact_endpoint)
38
+ end
39
+
40
+ def setup_client(access_token: nil, division: nil, reload: false)
41
+ return @client if @client.present? && !reload
42
+ return @client = self.class.create_client(access_token: access_token, division: division) if @client.nil? || reload
43
+ self
44
+ end
45
+
46
+ def self.all(client:)
47
+ client.send(to_s.demodulize.pluralize)
48
+ result = client.execute
49
+ result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
50
+ end
51
+
52
+ def self.create(attributes: {}, client:)
53
+ exact_obj = Exactonline.const_get(to_s.demodulize).new(attributes)
54
+ client.send("AddTo#{to_s.demodulize.pluralize}", exact_obj)
55
+ result = client.save_changes
56
+ result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
57
+ result.first
58
+ end
59
+
60
+ def self.find(id:, client:)
61
+ client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{id}'")
62
+ result = client.execute
63
+ result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
64
+ result.first
65
+ end
66
+
67
+ def self.find_by(field:, value:, guid: false, client:)
68
+ query = "#{field.capitalize} eq "
69
+ query << 'guid' if guid
70
+ query << "'#{value}'"
71
+ client.send(exact_endpoint).filter(query)
72
+ result = client.execute
73
+ result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
74
+ result.first
75
+ end
76
+
77
+ def self.update(id:, attributes: {}, client:)
78
+ client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{id}'")
79
+ result = client.execute
80
+ return false unless result.any?
81
+ exact_obj = result.first
82
+ attributes.each do |attribute, value|
83
+ exact_obj.send("#{attribute}=", value) if exact_obj.respond_to? attribute
84
+ end
85
+ client.update_object(exact_obj)
86
+ client.save_changes
87
+ true
88
+ end
89
+
90
+ def update(client:)
91
+ client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{guid}'")
92
+ result = client.execute
93
+ return false unless result.any?
94
+ exact_obj = result.first
95
+ attributes.each do |attribute, value|
96
+ exact_obj.send("#{attribute}=", value) if exact_obj.respond_to? attribute
97
+ end
98
+ client.update_object(exact_obj)
99
+ client.save_changes
100
+ true
101
+ end
102
+
103
+ def save(client:)
104
+ if guid.present?
105
+ update(client: client)
106
+ else
107
+ result = self.class.create(attributes: attributes, client: client) unless guid.present?
108
+ self.attributes = result.attributes
109
+ self
110
+ end
111
+ end
112
+
113
+ def self.destroy(id: nil, client:)
114
+ client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{id}'")
115
+ result = client.execute
116
+ return false unless result.any?
117
+ client.delete_object(result.first)
118
+ client.save_changes
119
+ true
120
+ rescue OData::ServiceError => e
121
+ errors.add(:base, e.message)
122
+ false
123
+ end
124
+
125
+ def destroy(client:)
126
+ client.send(self.class.exact_endpoint).filter("#{self.class.exact_guid_attribute} eq guid'#{guid}'")
127
+ result = client.execute
128
+ return false unless result.any?
129
+ client.delete_object(result.first)
130
+ client.save_changes
131
+ true
132
+ rescue OData::ServiceError => e
133
+ errors.add(:base, e.message)
134
+ false
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,21 @@
1
+ module Exact
2
+ class CostCenter < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'hrm'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :Active, Boolean
10
+ attribute :Code, String
11
+ attribute :Created, DateTime
12
+ attribute :Creator, String # guid
13
+ attribute :CreatorFullName, String
14
+ attribute :Description, String
15
+ attribute :Division, Integer # HID/division
16
+ attribute :ID, String # guid
17
+ attribute :Modified, DateTime
18
+ attribute :Modifier, String # guid/user
19
+ attribute :ModifierFullName, String
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module Exact
2
+ class CostUnit < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'hrm'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :Code, String
10
+ attribute :Created, DateTime
11
+ attribute :Creator, String
12
+ attribute :CreatorFullName, String
13
+ attribute :Description, String
14
+ attribute :Division, Integer
15
+ attribute :ID, String
16
+ attribute :Modified, DateTime
17
+ attribute :Modifier, String
18
+ attribute :ModifierFullName, String
19
+ end
20
+ end
@@ -0,0 +1,95 @@
1
+ module Exact
2
+ class Item < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'logistics'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :IsSerialNumberItem, String
10
+ attribute :IsBatchNumberItem, String
11
+ attribute :Class_01, String
12
+ attribute :Class_02, String
13
+ attribute :Class_03, String
14
+ attribute :Class_04, String
15
+ attribute :Class_05, String
16
+ attribute :Code, String
17
+ attribute :CopyRemarks, String
18
+ attribute :CostPriceCurrency, String
19
+ attribute :CostPriceNew, String
20
+ attribute :CostPriceStandard, String
21
+ attribute :Created, DateTime
22
+ attribute :CreatorFullName, String
23
+ attribute :Creator, String
24
+ attribute :Description, String
25
+ attribute :Division, String
26
+ attribute :EndDate, DateTime
27
+ attribute :ExtraDescription, String
28
+ attribute :FreeBoolField_01, String
29
+ attribute :FreeBoolField_02, String
30
+ attribute :FreeBoolField_03, String
31
+ attribute :FreeBoolField_04, String
32
+ attribute :FreeBoolField_05, String
33
+ attribute :FreeDateField_01, DateTime
34
+ attribute :FreeDateField_02, DateTime
35
+ attribute :FreeDateField_03, DateTime
36
+ attribute :FreeDateField_04, DateTime
37
+ attribute :FreeDateField_05, DateTime
38
+ attribute :FreeNumberField_01, String
39
+ attribute :FreeNumberField_02, String
40
+ attribute :FreeNumberField_03, String
41
+ attribute :FreeNumberField_04, String
42
+ attribute :FreeNumberField_05, String
43
+ attribute :FreeNumberField_06, String
44
+ attribute :FreeNumberField_07, String
45
+ attribute :FreeNumberField_08, String
46
+ attribute :FreeTextField_01, String
47
+ attribute :FreeTextField_02, String
48
+ attribute :FreeTextField_03, String
49
+ attribute :FreeTextField_04, String
50
+ attribute :FreeTextField_05, String
51
+ attribute :FreeTextField_06, String
52
+ attribute :FreeTextField_07, String
53
+ attribute :FreeTextField_08, String
54
+ attribute :FreeTextField_09, String
55
+ attribute :FreeTextField_10, String
56
+ attribute :GLCostsCode, String
57
+ attribute :GLCostsDescription, String
58
+ attribute :GLCosts, String
59
+ attribute :GLRevenueCode, String
60
+ attribute :GLRevenueDescription, String
61
+ attribute :GLRevenue, String
62
+ attribute :GLStockCode, String
63
+ attribute :GLStockDescription, String
64
+ attribute :GLStock, String
65
+ attribute :ID, String
66
+ attribute :IsBatchItem, String
67
+ attribute :IsFractionAllowedItem, String
68
+ attribute :IsMakeItem, String
69
+ attribute :IsNewContract, String
70
+ attribute :IsOnDemandItem, String
71
+ attribute :IsPackageItem, String
72
+ attribute :IsPurchaseItem, String
73
+ attribute :IsRegistrationCodeItem, String
74
+ attribute :IsSalesItem, String
75
+ attribute :IsSerialItem, String
76
+ attribute :IsStockItem, String
77
+ attribute :IsSubcontractedItem, String
78
+ attribute :IsTime, String
79
+ attribute :IsWebshopItem, String
80
+ attribute :ItemGroupCode, String
81
+ attribute :ItemGroupDescription, String
82
+ attribute :ItemGroup, String
83
+ attribute :Modified, DateTime
84
+ attribute :ModifierFullName, String
85
+ attribute :Modifier, String
86
+ attribute :Notes, String
87
+ attribute :SalesVatCodeDescription, String
88
+ attribute :SalesVatCode, String
89
+ attribute :SearchCode, String
90
+ attribute :SecurityLevel, String
91
+ attribute :StartDate, DateTime
92
+ attribute :Unit, String
93
+ attribute :UnitDescription, String
94
+ end
95
+ end
@@ -0,0 +1,48 @@
1
+ module Exact
2
+ class Project < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'project'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :Account, String
10
+ attribute :AccountCode, String
11
+ attribute :AccountName, String
12
+ attribute :AccountContact, String
13
+ attribute :Classification, String
14
+ attribute :ClassificationDescription, String
15
+ attribute :Code, String
16
+ attribute :CostsAmountFC, String
17
+ attribute :Created, DateTime
18
+ attribute :Creator, String
19
+ attribute :CreatorFullName, String
20
+ attribute :CustomerPOnumber, String
21
+ attribute :Description, String
22
+ attribute :Division, String
23
+ attribute :DivisionName, String
24
+ attribute :EndDate, DateTime
25
+ attribute :FixedPriceItem, String
26
+ attribute :FixedPriceItemDescription, String
27
+ attribute :ID, String
28
+ attribute :Manager, String
29
+ attribute :ManagerFullname, String
30
+ attribute :Modified, DateTime
31
+ attribute :Modifier, String
32
+ attribute :ModifierFullName, String
33
+ attribute :Notes, String
34
+ attribute :SalesTimeQuantity, String
35
+ attribute :StartDate, DateTime
36
+ attribute :TimeQuantityToAlert, String
37
+ attribute :Type, String
38
+ attribute :TypeDescription, String
39
+ attribute :BudgetedAmount, String
40
+ attribute :PrepaidType, String
41
+ attribute :PrepaidTypeDescription, String
42
+ attribute :PrepaidItem, String
43
+ attribute :PrepaidItemDescription, String
44
+ attribute :MarkupPercentage, String
45
+ attribute :BudgetedCosts, String
46
+ attribute :BudgetedRevenue, String
47
+ end
48
+ end
@@ -0,0 +1,58 @@
1
+ module Exact
2
+ class SalesInvoice < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'salesinvoice'
7
+ EXACT_GUID = 'InvoiceID'
8
+
9
+ attribute :AmountFC, String
10
+ attribute :AmountDC, String
11
+ attribute :Created, DateTime
12
+ attribute :Creator, String
13
+ attribute :CreatorFullName, String
14
+ attribute :Currency, String
15
+ attribute :Description, String
16
+ attribute :Division, Integer
17
+ attribute :Document, String
18
+ attribute :DocumentNumber, Integer
19
+ attribute :DocumentSubject, String
20
+ attribute :DueDate, DateTime
21
+ attribute :InvoiceDate, DateTime
22
+ attribute :InvoiceID, String
23
+ attribute :InvoiceTo, String
24
+ attribute :InvoiceToContactPerson, String
25
+ attribute :InvoiceToContactPersonFullName, String
26
+ attribute :InvoiceToName, String
27
+ attribute :InvoiceNumber, Integer
28
+ attribute :Journal, String
29
+ attribute :JournalDescription, String
30
+ attribute :Modified, DateTime
31
+ attribute :Modifier, String
32
+ attribute :ModifierFullName, String
33
+ attribute :OrderDate, DateTime
34
+ attribute :OrderedBy, String
35
+ attribute :OrderedByContactPerson, String
36
+ attribute :OrderedByContactPersonFullName, String
37
+ attribute :OrderedByName, String
38
+ attribute :OrderNumber, Integer
39
+ attribute :PaymentCondition, String
40
+ attribute :PaymentConditionDescription, String
41
+ attribute :PaymentReference, String
42
+ attribute :Remarks, String
43
+ attribute :Salesperson, String
44
+ attribute :SalespersonFullName, String
45
+ attribute :Status, String
46
+ attribute :StatusDescription, String
47
+ attribute :TaxSchedule, String
48
+ attribute :TaxScheduleCode, String
49
+ attribute :TaxScheduleDescription, String
50
+ attribute :Type, Integer
51
+ attribute :TypeDescription, String
52
+ attribute :VATAmountFC, String
53
+ attribute :VATAmountDC, String
54
+ attribute :YourRef, String
55
+ attribute :StarterSalesInvoiceStatus, String
56
+ attribute :StarterSalesInvoiceStatusDescription, String
57
+ end
58
+ end
@@ -0,0 +1,51 @@
1
+ module Exact
2
+ class SalesInvoiceLine < Base
3
+ include ActiveModel::Model
4
+ include Virtus.model
5
+
6
+ EXACT_SERVICE = 'salesinvoice'
7
+ EXACT_GUID = 'ID'
8
+
9
+ attribute :AmountFC, String
10
+ attribute :AmountDC, String
11
+ attribute :CostCenter, String
12
+ attribute :CostCenterDescription, String
13
+ attribute :CostUnit, String
14
+ attribute :CostUnitDescription, String
15
+ attribute :Description, String
16
+ attribute :Discount, String
17
+ attribute :Division, Integer
18
+ attribute :Employee, String
19
+ attribute :EmployeeFullName, String
20
+ attribute :EndTime, DateTime
21
+ attribute :GLAccount, String
22
+ attribute :GLAccountDescription, String
23
+ attribute :ID, String
24
+ attribute :InvoiceID, String
25
+ attribute :Item, String
26
+ attribute :ItemDescription, String
27
+ attribute :ItemCode, String
28
+ attribute :LineNumber, Integer
29
+ attribute :NetPrice, String
30
+ attribute :Notes, String
31
+ attribute :Pricelist, String
32
+ attribute :PricelistDescription, String
33
+ attribute :Project, String
34
+ attribute :ProjectDescription, String
35
+ attribute :Quantity, String
36
+ attribute :StartTime, DateTime
37
+ attribute :Subscription, String
38
+ attribute :SubscriptionDescription, String
39
+ attribute :UnitCode, String
40
+ attribute :UnitDescription, String
41
+ attribute :UnitPrice, String
42
+ attribute :TaxSchedule, String
43
+ attribute :TaxScheduleCode, String
44
+ attribute :TaxScheduleDescription, String
45
+ attribute :VATAmountFC, String
46
+ attribute :VATAmountDC, String
47
+ attribute :VATCode, String
48
+ attribute :VATCodeDescription, String
49
+ attribute :VATPercentage, String
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Exact
2
+ VERSION = '0.1.0'
3
+ end
data/lib/exact.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'exact/version'
2
+ require 'active_support/inflector'
3
+ require 'exact/configuration'
4
+
5
+ module Exact
6
+ autoload :Client, 'exact/client'
7
+
8
+ # Models
9
+ autoload :Account, 'exact/models/account'
10
+ autoload :BankAccount, 'exact/models/bank_account'
11
+ autoload :Base, 'exact/models/base'
12
+ autoload :CostCenter, 'exact/models/cost_center'
13
+ autoload :CostUnit, 'exact/models/cost_unit'
14
+ autoload :Item, 'exact/models/item'
15
+ autoload :Project, 'exact/models/project'
16
+ autoload :SalesInvoice, 'exact/models/sales_invoice'
17
+ autoload :SalesInvoiceLine, 'exact/models/sales_invoice_line'
18
+
19
+ # Mappings
20
+ autoload :AccountMapping, 'exact/mappings/account_mapping'
21
+ autoload :BankAccountMapping, 'exact/mappings/bank_account_mapping'
22
+ autoload :BaseMapping, 'exact/mappings/base_mapping'
23
+ autoload :CostCenterMapping, 'exact/mappings/cost_center_mapping'
24
+ autoload :CostUnitMapping, 'exact/mappings/cost_unit_mapping'
25
+ autoload :ItemMapping, 'exact/mappings/item_mapping'
26
+ autoload :ProjectMapping, 'exact/mappings/project_mapping'
27
+ autoload :SalesInvoiceMapping, 'exact/mappings/sales_invoice_mapping'
28
+ autoload :SalesInvoiceLineMapping, 'exact/mappings/sales_invoice_line_mapping'
29
+
30
+ Error = Class.new(StandardError)
31
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exact
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - zzk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby_odata
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.2.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.2.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.2.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.2.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.3.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.3.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.10.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.10.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: factory_girl
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 4.5.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 4.5.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: vcr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.9.3
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.9.3
153
+ description: Exact API handler
154
+ email:
155
+ - zzk@chickenkiller.org
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".ruby-version"
163
+ - ".travis.yml"
164
+ - CODE_OF_CONDUCT.md
165
+ - Gemfile
166
+ - LICENSE.txt
167
+ - README.md
168
+ - Rakefile
169
+ - bin/console
170
+ - bin/setup
171
+ - exact.gemspec
172
+ - lib/exact.rb
173
+ - lib/exact/client.rb
174
+ - lib/exact/configuration.rb
175
+ - lib/exact/mappings/account_mapping.rb
176
+ - lib/exact/mappings/bank_account_mapping.rb
177
+ - lib/exact/mappings/base_mapping.rb
178
+ - lib/exact/mappings/cost_center_mapping.rb
179
+ - lib/exact/mappings/cost_unit_mapping.rb
180
+ - lib/exact/mappings/item_mapping.rb
181
+ - lib/exact/mappings/project_mapping.rb
182
+ - lib/exact/mappings/sales_invoice_line_mapping.rb
183
+ - lib/exact/mappings/sales_invoice_mapping.rb
184
+ - lib/exact/models/account.rb
185
+ - lib/exact/models/bank_account.rb
186
+ - lib/exact/models/base.rb
187
+ - lib/exact/models/cost_center.rb
188
+ - lib/exact/models/cost_unit.rb
189
+ - lib/exact/models/item.rb
190
+ - lib/exact/models/project.rb
191
+ - lib/exact/models/sales_invoice.rb
192
+ - lib/exact/models/sales_invoice_line.rb
193
+ - lib/exact/version.rb
194
+ homepage: https://github.com/zzk/exact
195
+ licenses:
196
+ - MIT
197
+ metadata:
198
+ allowed_push_host: https://rubygems.org
199
+ post_install_message:
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ requirements: []
214
+ rubyforge_project:
215
+ rubygems_version: 2.4.5
216
+ signing_key:
217
+ specification_version: 4
218
+ summary: Exact API handler
219
+ test_files: []