fortnox-api 0.5.2 → 0.6.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 +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +9 -1104
- data/.travis.yml +22 -2
- data/Gemfile +3 -1
- data/Guardfile +4 -2
- data/README.md +2 -2
- data/Rakefile +3 -1
- data/bin/console +17 -3
- data/fortnox-api.gemspec +32 -27
- data/lib/fortnox/api.rb +17 -16
- data/lib/fortnox/api/circular_queue.rb +13 -7
- data/lib/fortnox/api/mappers.rb +29 -25
- data/lib/fortnox/api/mappers/article.rb +7 -6
- data/lib/fortnox/api/mappers/base.rb +18 -16
- data/lib/fortnox/api/mappers/base/from_json.rb +37 -30
- data/lib/fortnox/api/mappers/base/to_json.rb +39 -37
- data/lib/fortnox/api/mappers/customer.rb +7 -7
- data/lib/fortnox/api/mappers/default_delivery_types.rb +4 -2
- data/lib/fortnox/api/mappers/default_templates.rb +5 -4
- data/lib/fortnox/api/mappers/edi_information.rb +5 -4
- data/lib/fortnox/api/mappers/email_information.rb +5 -4
- data/lib/fortnox/api/mappers/invoice.rb +10 -8
- data/lib/fortnox/api/mappers/invoice_row.rb +12 -7
- data/lib/fortnox/api/mappers/order.rb +10 -7
- data/lib/fortnox/api/mappers/order_row.rb +13 -6
- data/lib/fortnox/api/mappers/project.rb +6 -4
- data/lib/fortnox/api/mappers/terms_of_payments.rb +17 -0
- data/lib/fortnox/api/mappers/unit.rb +17 -0
- data/lib/fortnox/api/models.rb +9 -5
- data/lib/fortnox/api/models/article.rb +68 -67
- data/lib/fortnox/api/models/base.rb +52 -36
- data/lib/fortnox/api/models/customer.rb +95 -94
- data/lib/fortnox/api/models/document.rb +186 -0
- data/lib/fortnox/api/models/invoice.rb +44 -44
- data/lib/fortnox/api/models/label.rb +5 -3
- data/lib/fortnox/api/models/order.rb +8 -8
- data/lib/fortnox/api/models/project.rb +10 -8
- data/lib/fortnox/api/models/terms_of_payments.rb +28 -0
- data/lib/fortnox/api/models/unit.rb +24 -0
- data/lib/fortnox/api/repositories.rb +9 -5
- data/lib/fortnox/api/repositories/article.rb +6 -4
- data/lib/fortnox/api/repositories/base.rb +49 -46
- data/lib/fortnox/api/repositories/base/loaders.rb +32 -36
- data/lib/fortnox/api/repositories/base/savers.rb +23 -21
- data/lib/fortnox/api/repositories/customer.rb +6 -4
- data/lib/fortnox/api/repositories/invoice.rb +6 -4
- data/lib/fortnox/api/repositories/order.rb +6 -4
- data/lib/fortnox/api/repositories/project.rb +6 -4
- data/lib/fortnox/api/repositories/terms_of_payments.rb +17 -0
- data/lib/fortnox/api/repositories/unit.rb +17 -0
- data/lib/fortnox/api/request_handling.rb +12 -12
- data/lib/fortnox/api/types.rb +62 -11
- data/lib/fortnox/api/types/default_delivery_types.rb +5 -3
- data/lib/fortnox/api/types/default_templates.rb +3 -1
- data/lib/fortnox/api/types/defaulted.rb +2 -2
- data/lib/fortnox/api/types/document_row.rb +41 -42
- data/lib/fortnox/api/types/edi_information.rb +10 -8
- data/lib/fortnox/api/types/email_information.rb +10 -8
- data/lib/fortnox/api/types/enums.rb +60 -47
- data/lib/fortnox/api/types/invoice_row.rb +8 -8
- data/lib/fortnox/api/types/model.rb +14 -10
- data/lib/fortnox/api/types/nullable.rb +7 -7
- data/lib/fortnox/api/types/order_row.rb +5 -5
- data/lib/fortnox/api/types/required.rb +5 -5
- data/lib/fortnox/api/types/sized.rb +14 -6
- data/lib/fortnox/api/version.rb +3 -1
- data/spec/fortnox/api/mappers/article_spec.rb +3 -1
- data/spec/fortnox/api/mappers/base/from_json_spec.rb +15 -13
- data/spec/fortnox/api/mappers/base/to_json_spec.rb +4 -3
- data/spec/fortnox/api/mappers/base_spec.rb +40 -35
- data/spec/fortnox/api/mappers/contexts/json_conversion.rb +12 -11
- data/spec/fortnox/api/mappers/customer_spec.rb +3 -1
- data/spec/fortnox/api/mappers/default_delivery_types_spec.rb +3 -1
- data/spec/fortnox/api/mappers/edi_information_spec.rb +4 -2
- data/spec/fortnox/api/mappers/email_information_spec.rb +4 -2
- data/spec/fortnox/api/mappers/examples/mapper.rb +17 -9
- data/spec/fortnox/api/mappers/invoice_row_spec.rb +8 -3
- data/spec/fortnox/api/mappers/invoice_spec.rb +4 -1
- data/spec/fortnox/api/mappers/order_row_spec.rb +9 -2
- data/spec/fortnox/api/mappers/order_spec.rb +4 -1
- data/spec/fortnox/api/mappers/project_spec.rb +3 -1
- data/spec/fortnox/api/mappers/terms_of_payments_spec.rb +16 -0
- data/spec/fortnox/api/mappers/unit_spec.rb +57 -0
- data/spec/fortnox/api/models/article_spec.rb +2 -0
- data/spec/fortnox/api/models/base_spec.rb +46 -38
- data/spec/fortnox/api/models/customer_spec.rb +2 -0
- data/spec/fortnox/api/models/examples/document_base.rb +5 -3
- data/spec/fortnox/api/models/examples/model.rb +12 -9
- data/spec/fortnox/api/models/invoice_spec.rb +2 -0
- data/spec/fortnox/api/models/order_spec.rb +2 -0
- data/spec/fortnox/api/models/project_spec.rb +2 -0
- data/spec/fortnox/api/models/terms_of_payments_spec.rb +9 -0
- data/spec/fortnox/api/models/unit_spec.rb +31 -0
- data/spec/fortnox/api/repositories/article_spec.rb +7 -5
- data/spec/fortnox/api/repositories/base_spec.rb +121 -100
- data/spec/fortnox/api/repositories/customer_spec.rb +7 -5
- data/spec/fortnox/api/repositories/examples/all.rb +5 -4
- data/spec/fortnox/api/repositories/examples/find.rb +50 -41
- data/spec/fortnox/api/repositories/examples/only.rb +14 -13
- data/spec/fortnox/api/repositories/examples/save.rb +23 -29
- data/spec/fortnox/api/repositories/examples/save_with_nested_model.rb +11 -11
- data/spec/fortnox/api/repositories/examples/save_with_specially_named_attribute.rb +11 -10
- data/spec/fortnox/api/repositories/examples/search.rb +15 -15
- data/spec/fortnox/api/repositories/invoice_spec.rb +8 -6
- data/spec/fortnox/api/repositories/order_spec.rb +8 -6
- data/spec/fortnox/api/repositories/project_spec.rb +7 -5
- data/spec/fortnox/api/repositories/terms_of_payments_spec.rb +30 -0
- data/spec/fortnox/api/repositories/unit_spec.rb +34 -0
- data/spec/fortnox/api/types/account_number_spec.rb +12 -9
- data/spec/fortnox/api/types/default_delivery_types_spec.rb +6 -4
- data/spec/fortnox/api/types/edi_information_spec.rb +9 -7
- data/spec/fortnox/api/types/email_information_spec.rb +8 -6
- data/spec/fortnox/api/types/email_spec.rb +27 -14
- data/spec/fortnox/api/types/enums_spec.rb +3 -1
- data/spec/fortnox/api/types/examples/document_row.rb +10 -8
- data/spec/fortnox/api/types/examples/enum.rb +29 -22
- data/spec/fortnox/api/types/examples/types.rb +8 -4
- data/spec/fortnox/api/types/housework_types_spec.rb +68 -0
- data/spec/fortnox/api/types/invoice_row_spec.rb +3 -1
- data/spec/fortnox/api/types/model_spec.rb +12 -9
- data/spec/fortnox/api/types/nullable_spec.rb +8 -6
- data/spec/fortnox/api/types/order_row_spec.rb +4 -2
- data/spec/fortnox/api/types/required_spec.rb +4 -2
- data/spec/fortnox/api/types/sized_spec.rb +18 -16
- data/spec/fortnox/api_spec.rb +45 -43
- data/spec/spec_helper.rb +9 -6
- data/spec/support/helpers.rb +3 -1
- data/spec/support/helpers/configuration_helper.rb +2 -0
- data/spec/support/helpers/dummy_class_helper.rb +7 -8
- data/spec/support/helpers/repository_helper.rb +2 -0
- data/spec/support/helpers/when_performing_helper.rb +3 -1
- data/spec/support/matchers.rb +2 -0
- data/spec/support/matchers/type.rb +3 -1
- data/spec/support/matchers/type/attribute_matcher.rb +15 -14
- data/spec/support/matchers/type/enum_matcher.rb +9 -7
- data/spec/support/matchers/type/have_account_number_matcher.rb +11 -9
- data/spec/support/matchers/type/have_country_code_matcher.rb +6 -4
- data/spec/support/matchers/type/have_currency_matcher.rb +4 -2
- data/spec/support/matchers/type/have_customer_type_matcher.rb +6 -4
- data/spec/support/matchers/type/have_default_delivery_type_matcher.rb +4 -2
- data/spec/support/matchers/type/have_discount_type_matcher.rb +4 -2
- data/spec/support/matchers/type/have_email_matcher.rb +11 -9
- data/spec/support/matchers/type/have_housework_type_matcher.rb +9 -0
- data/spec/support/matchers/type/have_nullable_date_matcher.rb +29 -29
- data/spec/support/matchers/type/have_nullable_matcher.rb +23 -21
- data/spec/support/matchers/type/have_nullable_string_matcher.rb +30 -32
- data/spec/support/matchers/type/have_sized_float_matcher.rb +4 -2
- data/spec/support/matchers/type/have_sized_integer_matcher.rb +4 -2
- data/spec/support/matchers/type/have_sized_string_matcher.rb +16 -15
- data/spec/support/matchers/type/have_vat_type_matcher.rb +4 -2
- data/spec/support/matchers/type/numeric_matcher.rb +25 -23
- data/spec/support/matchers/type/require_attribute_matcher.rb +36 -37
- data/spec/support/matchers/type/type_matcher.rb +18 -16
- data/spec/support/vcr_setup.rb +2 -0
- data/spec/vcr_cassettes/orders/{house_work_type_babysitting.yml → housework_type_babysitting.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_cleaning.yml → housework_type_cleaning.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_construction.yml → housework_type_construction.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_cooking.yml → housework_type_cooking.yml} +7 -7
- data/spec/vcr_cassettes/orders/{house_work_type_electricity.yml → housework_type_electricity.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_gardening.yml → housework_type_gardening.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_glassmetalwork.yml → housework_type_glassmetalwork.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_grounddrainagework.yml → housework_type_grounddrainagework.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_hvac.yml → housework_type_hvac.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_masonry.yml → housework_type_masonry.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_othercare.yml → housework_type_othercare.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_othercosts.yml → housework_type_othercosts.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_paintingwallpapering.yml → housework_type_paintingwallpapering.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_snowplowing.yml → housework_type_snowplowing.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_textileclothing.yml → housework_type_textileclothing.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_tutoring.yml → housework_type_tutoring.yml} +7 -7
- data/spec/vcr_cassettes/termsofpayments/all.yml +51 -0
- data/spec/vcr_cassettes/termsofpayments/find_failure.yml +45 -0
- data/spec/vcr_cassettes/termsofpayments/find_id_1.yml +46 -0
- data/spec/vcr_cassettes/termsofpayments/find_new.yml +46 -0
- data/spec/vcr_cassettes/termsofpayments/save_new.yml +45 -0
- data/spec/vcr_cassettes/termsofpayments/save_old.yml +46 -0
- data/spec/vcr_cassettes/units/all.yml +48 -0
- data/spec/vcr_cassettes/units/find_failure.yml +45 -0
- data/spec/vcr_cassettes/units/find_id_1.yml +46 -0
- data/spec/vcr_cassettes/units/find_new.yml +48 -0
- data/spec/vcr_cassettes/units/save_new.yml +47 -0
- data/spec/vcr_cassettes/units/save_old.yml +48 -0
- data/spec/vcr_cassettes/units/save_with_specially_named_attribute.yml +47 -0
- metadata +127 -88
- data/docs/account.rb +0 -59
- data/docs/extraction_script.js +0 -23
- data/docs/generation_script.rb +0 -43
- data/docs/json/account.json +0 -77
- data/lib/fortnox/api/models/document_base.rb +0 -189
- data/spec/fortnox/api/types/house_work_types_spec.rb +0 -64
- data/spec/support/matchers/type/have_house_work_type_matcher.rb +0 -7
data/docs/account.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require "fortnox/api/models/base"
|
2
|
-
|
3
|
-
module Fortnox
|
4
|
-
module API
|
5
|
-
module Entities
|
6
|
-
module Account
|
7
|
-
class Entity < Fortnox::API::Model::Base
|
8
|
-
|
9
|
-
# Direct URL to the record
|
10
|
-
attribute :url, String
|
11
|
-
|
12
|
-
# If the account is actve
|
13
|
-
attribute :acitve, Boolean
|
14
|
-
|
15
|
-
# Opening balance of the account
|
16
|
-
attribute :balancebroughtforward, Float
|
17
|
-
|
18
|
-
# Closing balance of the account
|
19
|
-
attribute :balancecarriedforward, Float
|
20
|
-
|
21
|
-
# Code of the proposed cost center. The code must be of an existing cost center.
|
22
|
-
attribute :costcenter, String
|
23
|
-
|
24
|
-
# Cost center settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
|
25
|
-
attribute :costcentersettings, String
|
26
|
-
|
27
|
-
# Account description
|
28
|
-
attribute :description, String
|
29
|
-
|
30
|
-
# Account number
|
31
|
-
attribute :number, Integer
|
32
|
-
|
33
|
-
# Number of the proposed project. The number must be of an existing project.
|
34
|
-
attribute :project, Integer
|
35
|
-
|
36
|
-
# Project settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
|
37
|
-
attribute :projectsettings, String
|
38
|
-
|
39
|
-
# SRU code
|
40
|
-
attribute :sru, String
|
41
|
-
|
42
|
-
# Proposed transaction information
|
43
|
-
attribute :transactioninformation, String
|
44
|
-
|
45
|
-
# Transaction information settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
|
46
|
-
attribute :transactioninformationsettings, String
|
47
|
-
|
48
|
-
# VAT code
|
49
|
-
attribute :vatcode, String
|
50
|
-
|
51
|
-
# Id of the financial year.
|
52
|
-
attribute :year, Integer
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
data/docs/extraction_script.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
o = {};
|
2
|
-
|
3
|
-
$('table.target tr').each(function(index, row){
|
4
|
-
|
5
|
-
first_column = $('td', row).first();
|
6
|
-
name = first_column.text().toLowerCase();
|
7
|
-
|
8
|
-
last_column = $('td', row).last().text();
|
9
|
-
|
10
|
-
parts = last_column.split(/\n|,/);
|
11
|
-
parts = parts.map( function( el ){ return el.trim(); });
|
12
|
-
|
13
|
-
type = parts.shift();
|
14
|
-
description = parts.pop();
|
15
|
-
validations = parts.length > 0 ? parts.join(', ') : null;
|
16
|
-
o[ name ] = {
|
17
|
-
"type": type,
|
18
|
-
"validations": validations,
|
19
|
-
"description": description
|
20
|
-
}
|
21
|
-
});
|
22
|
-
|
23
|
-
JSON.stringify(o);
|
data/docs/generation_script.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
filename = 'account.json'
|
4
|
-
modelname = filename.split('.').first.capitalize
|
5
|
-
|
6
|
-
json = File.read( 'json/account.json' )
|
7
|
-
hash = JSON.parse( json )
|
8
|
-
|
9
|
-
header = <<-RB
|
10
|
-
require "fortnox/api/models/base"
|
11
|
-
|
12
|
-
module Fortnox
|
13
|
-
module API
|
14
|
-
module Entities
|
15
|
-
module {{ model_name }}
|
16
|
-
class Entity < Fortnox::API::Model::Base
|
17
|
-
|
18
|
-
RB
|
19
|
-
|
20
|
-
footer = <<-RB
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
RB
|
28
|
-
|
29
|
-
attribute = <<-RB
|
30
|
-
# {{ description }}
|
31
|
-
attribute :{{ name }}, {{ type }}
|
32
|
-
|
33
|
-
RB
|
34
|
-
|
35
|
-
generated_class = header.gsub( '{{ model_name }}', modelname )
|
36
|
-
|
37
|
-
hash.each do |name, attributes|
|
38
|
-
generated_class << attribute.gsub( '{{ description }}', attributes.fetch( 'description' ) ).gsub( '{{ name }}', name ).gsub( '{{ type }}', attributes.fetch( 'type' ).capitalize )
|
39
|
-
end
|
40
|
-
|
41
|
-
generated_class << footer
|
42
|
-
|
43
|
-
File.write( "#{ modelname.downcase }.rb", generated_class )
|
data/docs/json/account.json
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"url": {
|
3
|
-
"type": "string",
|
4
|
-
"validations": "read-only",
|
5
|
-
"description": "Direct URL to the record"
|
6
|
-
},
|
7
|
-
"acitve": {
|
8
|
-
"type": "boolean",
|
9
|
-
"validations": null,
|
10
|
-
"description": "If the account is actve"
|
11
|
-
},
|
12
|
-
"balancebroughtforward": {
|
13
|
-
"type": "float",
|
14
|
-
"validations": null,
|
15
|
-
"description": "Opening balance of the account"
|
16
|
-
},
|
17
|
-
"balancecarriedforward": {
|
18
|
-
"type": "float",
|
19
|
-
"validations": "read-only",
|
20
|
-
"description": "Closing balance of the account"
|
21
|
-
},
|
22
|
-
"costcenter": {
|
23
|
-
"type": "string",
|
24
|
-
"validations": null,
|
25
|
-
"description": "Code of the proposed cost center. The code must be of an existing cost center."
|
26
|
-
},
|
27
|
-
"costcentersettings": {
|
28
|
-
"type": "string",
|
29
|
-
"validations": null,
|
30
|
-
"description": "Cost center settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED"
|
31
|
-
},
|
32
|
-
"description": {
|
33
|
-
"type": "string",
|
34
|
-
"validations": "200 characters, required",
|
35
|
-
"description": "Account description"
|
36
|
-
},
|
37
|
-
"number": {
|
38
|
-
"type": "integer",
|
39
|
-
"validations": "4 digits, sortable, required",
|
40
|
-
"description": "Account number"
|
41
|
-
},
|
42
|
-
"project": {
|
43
|
-
"type": "integer",
|
44
|
-
"validations": null,
|
45
|
-
"description": "Number of the proposed project. The number must be of an existing project."
|
46
|
-
},
|
47
|
-
"projectsettings": {
|
48
|
-
"type": "string",
|
49
|
-
"validations": null,
|
50
|
-
"description": "Project settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED"
|
51
|
-
},
|
52
|
-
"sru": {
|
53
|
-
"type": "string",
|
54
|
-
"validations": "4 or 5 digits, searchable",
|
55
|
-
"description": "SRU code"
|
56
|
-
},
|
57
|
-
"transactioninformation": {
|
58
|
-
"type": "string",
|
59
|
-
"validations": "100 characters",
|
60
|
-
"description": "Proposed transaction information"
|
61
|
-
},
|
62
|
-
"transactioninformationsettings": {
|
63
|
-
"type": "string",
|
64
|
-
"validations": null,
|
65
|
-
"description": "Transaction information settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED"
|
66
|
-
},
|
67
|
-
"vatcode": {
|
68
|
-
"type": "string",
|
69
|
-
"validations": null,
|
70
|
-
"description": "VAT code"
|
71
|
-
},
|
72
|
-
"year": {
|
73
|
-
"type": "integer",
|
74
|
-
"validations": "read-only",
|
75
|
-
"description": "Id of the financial year."
|
76
|
-
}
|
77
|
-
}
|
@@ -1,189 +0,0 @@
|
|
1
|
-
require "fortnox/api/types"
|
2
|
-
require "fortnox/api/models/label"
|
3
|
-
|
4
|
-
module Fortnox
|
5
|
-
module API
|
6
|
-
module Model
|
7
|
-
module DocumentBase
|
8
|
-
# Method length is ignored due to readability.
|
9
|
-
# rubocop:disable Metrics/MethodLength
|
10
|
-
def self.ify( base )
|
11
|
-
base.class_eval do
|
12
|
-
|
13
|
-
# Url Direct url to the record.
|
14
|
-
base.attribute :url, Types::Nullable::String.with( read_only: true )
|
15
|
-
|
16
|
-
# AdministrationFee The document administration fee.
|
17
|
-
base.attribute :administration_fee, Types::Nullable::Float
|
18
|
-
|
19
|
-
# AdministrationFeeVAT VAT of the document administration fee.
|
20
|
-
base.attribute :administration_fee_vat, Types::Nullable::Float.with( read_only: true )
|
21
|
-
|
22
|
-
# Address1 Document address 1. 1024 characters
|
23
|
-
base.attribute :address1, Types::Sized::String[ 1024 ]
|
24
|
-
|
25
|
-
# Address2 Document address 2. 1024 characters
|
26
|
-
base.attribute :address2, Types::Sized::String[ 1024 ]
|
27
|
-
|
28
|
-
# BasisTaxReduction Basis of tax reduction.
|
29
|
-
base.attribute :basis_tax_reduction, Types::Nullable::Float.with( read_only: true )
|
30
|
-
|
31
|
-
# Cancelled If the document is cancelled.
|
32
|
-
base.attribute :cancelled, Types::Nullable::Boolean.with( read_only: true )
|
33
|
-
|
34
|
-
# City City for the document address.
|
35
|
-
base.attribute :city, Types::Sized::String[ 1024 ]
|
36
|
-
|
37
|
-
# Comments Comments of the document
|
38
|
-
base.attribute :comments, Types::Sized::String[ 1024 ]
|
39
|
-
|
40
|
-
# ContributionPercent Document contribution in percent.
|
41
|
-
base.attribute :contribution_percent, Types::Nullable::Float.with( read_only: true )
|
42
|
-
|
43
|
-
# ContributionValue Document contribution in amount.
|
44
|
-
base.attribute :contribution_value, Types::Nullable::Float.with( read_only: true )
|
45
|
-
|
46
|
-
# Country Country for the document address.
|
47
|
-
base.attribute :country, Types::CountryCode
|
48
|
-
|
49
|
-
# CostCenter Code of the cost center.
|
50
|
-
base.attribute :cost_center, Types::Nullable::String
|
51
|
-
|
52
|
-
# Currency Code of the currency.
|
53
|
-
base.attribute :currency, Types::Currency
|
54
|
-
|
55
|
-
# CurrencyRate Currency rate used for the document
|
56
|
-
base.attribute :currency_rate, Types::Nullable::Float
|
57
|
-
|
58
|
-
# CurrencyUnit Currency unit used for the document
|
59
|
-
base.attribute :currency_unit, Types::Nullable::Float
|
60
|
-
|
61
|
-
# CustomerName Name of the customer. 1024 characters
|
62
|
-
base.attribute :customer_name, Types::Sized::String[ 1024 ]
|
63
|
-
|
64
|
-
# CustomerNumber Customer number of the customer. Required
|
65
|
-
base.attribute :customer_number, Types::Required::String
|
66
|
-
|
67
|
-
# DeliveryAddress1 Document delivery address 1.
|
68
|
-
base.attribute :delivery_address1, Types::Sized::String[ 1024 ]
|
69
|
-
|
70
|
-
# DeliveryAddress2 Document delivery address 2.
|
71
|
-
base.attribute :delivery_address2, Types::Sized::String[ 1024 ]
|
72
|
-
|
73
|
-
# DeliveryCity City for the document delivery address.
|
74
|
-
base.attribute :delivery_city, Types::Sized::String[ 1024 ]
|
75
|
-
|
76
|
-
# DeliveryCountry Country for the document delivery address.
|
77
|
-
base.attribute :delivery_country, Types::CountryCode
|
78
|
-
|
79
|
-
# DeliveryDate Date of delivery.
|
80
|
-
base.attribute :delivery_date, Types::Nullable::Date
|
81
|
-
|
82
|
-
# DeliveryName Name of the recipient of the delivery
|
83
|
-
base.attribute :delivery_name, Types::Sized::String[ 1024 ]
|
84
|
-
|
85
|
-
# DeliveryZipCode ZipCode for the document delivery address.
|
86
|
-
base.attribute :delivery_zip_code, Types::Sized::String[ 1024 ]
|
87
|
-
|
88
|
-
# DocumentNumber The document number.
|
89
|
-
base.attribute :document_number, Types::Nullable::Integer
|
90
|
-
|
91
|
-
# EmailInformation Separete EmailInformation object
|
92
|
-
base.attribute :email_information, Types::EmailInformation
|
93
|
-
|
94
|
-
# ExternalInvoiceReference1 External document reference 1. 80 characters
|
95
|
-
base.attribute :external_invoice_reference1, Types::Sized::String[ 80 ]
|
96
|
-
|
97
|
-
# ExternalInvoiceReference2 External document reference 2. 80 characters
|
98
|
-
base.attribute :external_invoice_reference2, Types::Sized::String[ 80 ]
|
99
|
-
|
100
|
-
# Freight Freight cost of the document. 12 digits (incl. decimals)
|
101
|
-
base.attribute :freight, Types::Sized::Float[ 0.0, 99_999_999_999.9 ]
|
102
|
-
|
103
|
-
# FreightVAT VAT of the freight cost.
|
104
|
-
base.attribute :freight_vat, Types::Nullable::Float.with( read_only: true )
|
105
|
-
|
106
|
-
# Gross Gross value of the document
|
107
|
-
base.attribute :gross, Types::Nullable::Float.with( read_only: true )
|
108
|
-
|
109
|
-
# HouseWork If there is any row of the document marked “house work”.
|
110
|
-
base.attribute :house_work, Types::Nullable::Boolean.with( read_only: true )
|
111
|
-
|
112
|
-
base.attribute :labels, Types::Strict::Array.member( Label )
|
113
|
-
|
114
|
-
# Net Net amount
|
115
|
-
base.attribute :net, Types::Nullable::Float.with( read_only: true )
|
116
|
-
|
117
|
-
# NotCompleted If the document is set as not completed.
|
118
|
-
base.attribute :not_completed, Types::Nullable::Boolean
|
119
|
-
|
120
|
-
# OfferReference Reference to the offer, if one exists.
|
121
|
-
base.attribute :offer_reference, Types::Nullable::Integer.with( read_only: true )
|
122
|
-
|
123
|
-
# OrganisationNumber Organisation number of the customer for the
|
124
|
-
# document.
|
125
|
-
base.attribute :organisation_number, Types::Nullable::String.with( read_only: true )
|
126
|
-
|
127
|
-
# OurReference Our reference. 50 characters
|
128
|
-
base.attribute :our_reference, Types::Sized::String[ 50 ]
|
129
|
-
|
130
|
-
# Phone1 Phone number 1 of the customer for the document. 1024 characters
|
131
|
-
base.attribute :phone1, Types::Sized::String[ 1024 ]
|
132
|
-
|
133
|
-
# Phone2 Phone number 2 of the customer for the document. 1024 characters
|
134
|
-
base.attribute :phone2, Types::Sized::String[ 1024 ]
|
135
|
-
|
136
|
-
# PriceList Code of the price list.
|
137
|
-
base.attribute :price_list, Types::Nullable::String
|
138
|
-
|
139
|
-
# PrintTemplate Print template of the document.
|
140
|
-
base.attribute :print_template, Types::Nullable::String
|
141
|
-
|
142
|
-
# Project Code of the project.
|
143
|
-
base.attribute :project, Types::Nullable::String
|
144
|
-
|
145
|
-
# Remarks Remarks of the document. 1024 characters
|
146
|
-
base.attribute :remarks, Types::Sized::String[ 1024 ]
|
147
|
-
|
148
|
-
# RoundOff Round off amount for the document.
|
149
|
-
base.attribute :round_off, Types::Nullable::Float.with( read_only: true )
|
150
|
-
|
151
|
-
# Sent If the document is printed or sent in any way.
|
152
|
-
base.attribute :sent, Types::Nullable::Boolean.with( read_only: true )
|
153
|
-
|
154
|
-
# TaxReduction The amount of tax reduction.
|
155
|
-
base.attribute :tax_reduction, Types::Nullable::Integer.with( read_only: true )
|
156
|
-
|
157
|
-
# TermsOfDelivery Code of the terms of delivery.
|
158
|
-
base.attribute :terms_of_delivery, Types::Nullable::String
|
159
|
-
|
160
|
-
# TermsOfPayment Code of the terms of payment.
|
161
|
-
base.attribute :terms_of_payment, Types::Nullable::String
|
162
|
-
|
163
|
-
# Total The total amount of the document.
|
164
|
-
base.attribute :total, Types::Nullable::Float.with( read_only: true )
|
165
|
-
|
166
|
-
# TotalVAT The total VAT amount of the document.
|
167
|
-
base.attribute :total_vat, Types::Nullable::Float.with( read_only: true )
|
168
|
-
|
169
|
-
# VATIncluded If the price of the document is including VAT.
|
170
|
-
base.attribute :vat_included, Types::Nullable::Boolean
|
171
|
-
|
172
|
-
# WayOfDelivery Code of the way of delivery.
|
173
|
-
base.attribute :way_of_delivery, Types::Nullable::String
|
174
|
-
|
175
|
-
# YourOrderNumber Your order number. 30 characters
|
176
|
-
base.attribute :your_order_number, Types::Sized::String[ 30 ]
|
177
|
-
|
178
|
-
# YourReference Your reference. 50 characters
|
179
|
-
base.attribute :your_reference, Types::Sized::String[ 50 ]
|
180
|
-
|
181
|
-
# ZipCode Zip code of the document. 1024 characters
|
182
|
-
base.attribute :zip_code, Types::Sized::String[ 1024 ]
|
183
|
-
end
|
184
|
-
end
|
185
|
-
# rubocop:enable Metrics/MethodLength
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fortnox/api'
|
3
|
-
require 'fortnox/api/types'
|
4
|
-
require 'fortnox/api/repositories/order'
|
5
|
-
require 'fortnox/api/models/order'
|
6
|
-
require 'fortnox/api/types/order_row'
|
7
|
-
|
8
|
-
# rubocop:disable RSpec/DescribeClass
|
9
|
-
describe 'HouseWorkTypes', integration: true do
|
10
|
-
include Helpers::Configuration
|
11
|
-
|
12
|
-
before{ set_api_test_configuration }
|
13
|
-
|
14
|
-
let(:repository){ Fortnox::API::Repository::Order.new }
|
15
|
-
let(:valid_model) do
|
16
|
-
Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [order_row])
|
17
|
-
end
|
18
|
-
let(:order_row){ Fortnox::API::Types::OrderRow.new(ordered_quantity: 1,
|
19
|
-
article_number: '0000',
|
20
|
-
house_work_type: house_work_type)}
|
21
|
-
|
22
|
-
shared_examples_for 'house work type' do |type, legacy: false|
|
23
|
-
subject do
|
24
|
-
-> do
|
25
|
-
VCR.use_cassette( "orders/house_work_type_#{ type.downcase }" ) do
|
26
|
-
repository.save(valid_model)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:error_message){ 'Skattereduktion för en av de valda husarbetestyperna har upphört.' }
|
32
|
-
let(:house_work_type){ Fortnox::API::Types::HouseWorkTypes[type] }
|
33
|
-
|
34
|
-
context "when creating an OrderRow with house_work_type set to #{ type }" do
|
35
|
-
if legacy
|
36
|
-
it 'raises an error' do
|
37
|
-
is_expected.to raise_error(Fortnox::API::RemoteServerError, error_message)
|
38
|
-
end
|
39
|
-
else
|
40
|
-
it{ is_expected.not_to raise_error }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it_behaves_like 'house work type', 'CONSTRUCTION'
|
46
|
-
it_behaves_like 'house work type', 'ELECTRICITY'
|
47
|
-
it_behaves_like 'house work type', 'GLASSMETALWORK'
|
48
|
-
it_behaves_like 'house work type', 'GROUNDDRAINAGEWORK'
|
49
|
-
it_behaves_like 'house work type', 'MASONRY'
|
50
|
-
it_behaves_like 'house work type', 'PAINTINGWALLPAPERING'
|
51
|
-
it_behaves_like 'house work type', 'HVAC'
|
52
|
-
it_behaves_like 'house work type', 'CLEANING'
|
53
|
-
it_behaves_like 'house work type', 'TEXTILECLOTHING'
|
54
|
-
it_behaves_like 'house work type', 'CLEANING'
|
55
|
-
it_behaves_like 'house work type', 'SNOWPLOWING'
|
56
|
-
it_behaves_like 'house work type', 'GARDENING'
|
57
|
-
it_behaves_like 'house work type', 'BABYSITTING'
|
58
|
-
it_behaves_like 'house work type', 'OTHERCARE'
|
59
|
-
it_behaves_like 'house work type', 'OTHERCOSTS'
|
60
|
-
|
61
|
-
it_behaves_like 'house work type', 'COOKING', legacy: true
|
62
|
-
it_behaves_like 'house work type', 'TUTORING', legacy: true
|
63
|
-
end
|
64
|
-
# rubocop:enable RSpec/DescribeClass
|