fortnox-api 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +9 -1104
  4. data/.travis.yml +22 -2
  5. data/Gemfile +3 -1
  6. data/Guardfile +4 -2
  7. data/README.md +2 -2
  8. data/Rakefile +3 -1
  9. data/bin/console +17 -3
  10. data/fortnox-api.gemspec +32 -27
  11. data/lib/fortnox/api.rb +17 -16
  12. data/lib/fortnox/api/circular_queue.rb +13 -7
  13. data/lib/fortnox/api/mappers.rb +29 -25
  14. data/lib/fortnox/api/mappers/article.rb +7 -6
  15. data/lib/fortnox/api/mappers/base.rb +18 -16
  16. data/lib/fortnox/api/mappers/base/from_json.rb +37 -30
  17. data/lib/fortnox/api/mappers/base/to_json.rb +39 -37
  18. data/lib/fortnox/api/mappers/customer.rb +7 -7
  19. data/lib/fortnox/api/mappers/default_delivery_types.rb +4 -2
  20. data/lib/fortnox/api/mappers/default_templates.rb +5 -4
  21. data/lib/fortnox/api/mappers/edi_information.rb +5 -4
  22. data/lib/fortnox/api/mappers/email_information.rb +5 -4
  23. data/lib/fortnox/api/mappers/invoice.rb +10 -8
  24. data/lib/fortnox/api/mappers/invoice_row.rb +12 -7
  25. data/lib/fortnox/api/mappers/order.rb +10 -7
  26. data/lib/fortnox/api/mappers/order_row.rb +13 -6
  27. data/lib/fortnox/api/mappers/project.rb +6 -4
  28. data/lib/fortnox/api/mappers/terms_of_payments.rb +17 -0
  29. data/lib/fortnox/api/mappers/unit.rb +17 -0
  30. data/lib/fortnox/api/models.rb +9 -5
  31. data/lib/fortnox/api/models/article.rb +68 -67
  32. data/lib/fortnox/api/models/base.rb +52 -36
  33. data/lib/fortnox/api/models/customer.rb +95 -94
  34. data/lib/fortnox/api/models/document.rb +186 -0
  35. data/lib/fortnox/api/models/invoice.rb +44 -44
  36. data/lib/fortnox/api/models/label.rb +5 -3
  37. data/lib/fortnox/api/models/order.rb +8 -8
  38. data/lib/fortnox/api/models/project.rb +10 -8
  39. data/lib/fortnox/api/models/terms_of_payments.rb +28 -0
  40. data/lib/fortnox/api/models/unit.rb +24 -0
  41. data/lib/fortnox/api/repositories.rb +9 -5
  42. data/lib/fortnox/api/repositories/article.rb +6 -4
  43. data/lib/fortnox/api/repositories/base.rb +49 -46
  44. data/lib/fortnox/api/repositories/base/loaders.rb +32 -36
  45. data/lib/fortnox/api/repositories/base/savers.rb +23 -21
  46. data/lib/fortnox/api/repositories/customer.rb +6 -4
  47. data/lib/fortnox/api/repositories/invoice.rb +6 -4
  48. data/lib/fortnox/api/repositories/order.rb +6 -4
  49. data/lib/fortnox/api/repositories/project.rb +6 -4
  50. data/lib/fortnox/api/repositories/terms_of_payments.rb +17 -0
  51. data/lib/fortnox/api/repositories/unit.rb +17 -0
  52. data/lib/fortnox/api/request_handling.rb +12 -12
  53. data/lib/fortnox/api/types.rb +62 -11
  54. data/lib/fortnox/api/types/default_delivery_types.rb +5 -3
  55. data/lib/fortnox/api/types/default_templates.rb +3 -1
  56. data/lib/fortnox/api/types/defaulted.rb +2 -2
  57. data/lib/fortnox/api/types/document_row.rb +41 -42
  58. data/lib/fortnox/api/types/edi_information.rb +10 -8
  59. data/lib/fortnox/api/types/email_information.rb +10 -8
  60. data/lib/fortnox/api/types/enums.rb +60 -47
  61. data/lib/fortnox/api/types/invoice_row.rb +8 -8
  62. data/lib/fortnox/api/types/model.rb +14 -10
  63. data/lib/fortnox/api/types/nullable.rb +7 -7
  64. data/lib/fortnox/api/types/order_row.rb +5 -5
  65. data/lib/fortnox/api/types/required.rb +5 -5
  66. data/lib/fortnox/api/types/sized.rb +14 -6
  67. data/lib/fortnox/api/version.rb +3 -1
  68. data/spec/fortnox/api/mappers/article_spec.rb +3 -1
  69. data/spec/fortnox/api/mappers/base/from_json_spec.rb +15 -13
  70. data/spec/fortnox/api/mappers/base/to_json_spec.rb +4 -3
  71. data/spec/fortnox/api/mappers/base_spec.rb +40 -35
  72. data/spec/fortnox/api/mappers/contexts/json_conversion.rb +12 -11
  73. data/spec/fortnox/api/mappers/customer_spec.rb +3 -1
  74. data/spec/fortnox/api/mappers/default_delivery_types_spec.rb +3 -1
  75. data/spec/fortnox/api/mappers/edi_information_spec.rb +4 -2
  76. data/spec/fortnox/api/mappers/email_information_spec.rb +4 -2
  77. data/spec/fortnox/api/mappers/examples/mapper.rb +17 -9
  78. data/spec/fortnox/api/mappers/invoice_row_spec.rb +8 -3
  79. data/spec/fortnox/api/mappers/invoice_spec.rb +4 -1
  80. data/spec/fortnox/api/mappers/order_row_spec.rb +9 -2
  81. data/spec/fortnox/api/mappers/order_spec.rb +4 -1
  82. data/spec/fortnox/api/mappers/project_spec.rb +3 -1
  83. data/spec/fortnox/api/mappers/terms_of_payments_spec.rb +16 -0
  84. data/spec/fortnox/api/mappers/unit_spec.rb +57 -0
  85. data/spec/fortnox/api/models/article_spec.rb +2 -0
  86. data/spec/fortnox/api/models/base_spec.rb +46 -38
  87. data/spec/fortnox/api/models/customer_spec.rb +2 -0
  88. data/spec/fortnox/api/models/examples/document_base.rb +5 -3
  89. data/spec/fortnox/api/models/examples/model.rb +12 -9
  90. data/spec/fortnox/api/models/invoice_spec.rb +2 -0
  91. data/spec/fortnox/api/models/order_spec.rb +2 -0
  92. data/spec/fortnox/api/models/project_spec.rb +2 -0
  93. data/spec/fortnox/api/models/terms_of_payments_spec.rb +9 -0
  94. data/spec/fortnox/api/models/unit_spec.rb +31 -0
  95. data/spec/fortnox/api/repositories/article_spec.rb +7 -5
  96. data/spec/fortnox/api/repositories/base_spec.rb +121 -100
  97. data/spec/fortnox/api/repositories/customer_spec.rb +7 -5
  98. data/spec/fortnox/api/repositories/examples/all.rb +5 -4
  99. data/spec/fortnox/api/repositories/examples/find.rb +50 -41
  100. data/spec/fortnox/api/repositories/examples/only.rb +14 -13
  101. data/spec/fortnox/api/repositories/examples/save.rb +23 -29
  102. data/spec/fortnox/api/repositories/examples/save_with_nested_model.rb +11 -11
  103. data/spec/fortnox/api/repositories/examples/save_with_specially_named_attribute.rb +11 -10
  104. data/spec/fortnox/api/repositories/examples/search.rb +15 -15
  105. data/spec/fortnox/api/repositories/invoice_spec.rb +8 -6
  106. data/spec/fortnox/api/repositories/order_spec.rb +8 -6
  107. data/spec/fortnox/api/repositories/project_spec.rb +7 -5
  108. data/spec/fortnox/api/repositories/terms_of_payments_spec.rb +30 -0
  109. data/spec/fortnox/api/repositories/unit_spec.rb +34 -0
  110. data/spec/fortnox/api/types/account_number_spec.rb +12 -9
  111. data/spec/fortnox/api/types/default_delivery_types_spec.rb +6 -4
  112. data/spec/fortnox/api/types/edi_information_spec.rb +9 -7
  113. data/spec/fortnox/api/types/email_information_spec.rb +8 -6
  114. data/spec/fortnox/api/types/email_spec.rb +27 -14
  115. data/spec/fortnox/api/types/enums_spec.rb +3 -1
  116. data/spec/fortnox/api/types/examples/document_row.rb +10 -8
  117. data/spec/fortnox/api/types/examples/enum.rb +29 -22
  118. data/spec/fortnox/api/types/examples/types.rb +8 -4
  119. data/spec/fortnox/api/types/housework_types_spec.rb +68 -0
  120. data/spec/fortnox/api/types/invoice_row_spec.rb +3 -1
  121. data/spec/fortnox/api/types/model_spec.rb +12 -9
  122. data/spec/fortnox/api/types/nullable_spec.rb +8 -6
  123. data/spec/fortnox/api/types/order_row_spec.rb +4 -2
  124. data/spec/fortnox/api/types/required_spec.rb +4 -2
  125. data/spec/fortnox/api/types/sized_spec.rb +18 -16
  126. data/spec/fortnox/api_spec.rb +45 -43
  127. data/spec/spec_helper.rb +9 -6
  128. data/spec/support/helpers.rb +3 -1
  129. data/spec/support/helpers/configuration_helper.rb +2 -0
  130. data/spec/support/helpers/dummy_class_helper.rb +7 -8
  131. data/spec/support/helpers/repository_helper.rb +2 -0
  132. data/spec/support/helpers/when_performing_helper.rb +3 -1
  133. data/spec/support/matchers.rb +2 -0
  134. data/spec/support/matchers/type.rb +3 -1
  135. data/spec/support/matchers/type/attribute_matcher.rb +15 -14
  136. data/spec/support/matchers/type/enum_matcher.rb +9 -7
  137. data/spec/support/matchers/type/have_account_number_matcher.rb +11 -9
  138. data/spec/support/matchers/type/have_country_code_matcher.rb +6 -4
  139. data/spec/support/matchers/type/have_currency_matcher.rb +4 -2
  140. data/spec/support/matchers/type/have_customer_type_matcher.rb +6 -4
  141. data/spec/support/matchers/type/have_default_delivery_type_matcher.rb +4 -2
  142. data/spec/support/matchers/type/have_discount_type_matcher.rb +4 -2
  143. data/spec/support/matchers/type/have_email_matcher.rb +11 -9
  144. data/spec/support/matchers/type/have_housework_type_matcher.rb +9 -0
  145. data/spec/support/matchers/type/have_nullable_date_matcher.rb +29 -29
  146. data/spec/support/matchers/type/have_nullable_matcher.rb +23 -21
  147. data/spec/support/matchers/type/have_nullable_string_matcher.rb +30 -32
  148. data/spec/support/matchers/type/have_sized_float_matcher.rb +4 -2
  149. data/spec/support/matchers/type/have_sized_integer_matcher.rb +4 -2
  150. data/spec/support/matchers/type/have_sized_string_matcher.rb +16 -15
  151. data/spec/support/matchers/type/have_vat_type_matcher.rb +4 -2
  152. data/spec/support/matchers/type/numeric_matcher.rb +25 -23
  153. data/spec/support/matchers/type/require_attribute_matcher.rb +36 -37
  154. data/spec/support/matchers/type/type_matcher.rb +18 -16
  155. data/spec/support/vcr_setup.rb +2 -0
  156. data/spec/vcr_cassettes/orders/{house_work_type_babysitting.yml → housework_type_babysitting.yml} +9 -10
  157. data/spec/vcr_cassettes/orders/{house_work_type_cleaning.yml → housework_type_cleaning.yml} +9 -10
  158. data/spec/vcr_cassettes/orders/{house_work_type_construction.yml → housework_type_construction.yml} +9 -10
  159. data/spec/vcr_cassettes/orders/{house_work_type_cooking.yml → housework_type_cooking.yml} +7 -7
  160. data/spec/vcr_cassettes/orders/{house_work_type_electricity.yml → housework_type_electricity.yml} +9 -10
  161. data/spec/vcr_cassettes/orders/{house_work_type_gardening.yml → housework_type_gardening.yml} +9 -10
  162. data/spec/vcr_cassettes/orders/{house_work_type_glassmetalwork.yml → housework_type_glassmetalwork.yml} +9 -10
  163. data/spec/vcr_cassettes/orders/{house_work_type_grounddrainagework.yml → housework_type_grounddrainagework.yml} +9 -10
  164. data/spec/vcr_cassettes/orders/{house_work_type_hvac.yml → housework_type_hvac.yml} +9 -10
  165. data/spec/vcr_cassettes/orders/{house_work_type_masonry.yml → housework_type_masonry.yml} +9 -10
  166. data/spec/vcr_cassettes/orders/{house_work_type_othercare.yml → housework_type_othercare.yml} +9 -10
  167. data/spec/vcr_cassettes/orders/{house_work_type_othercosts.yml → housework_type_othercosts.yml} +9 -10
  168. data/spec/vcr_cassettes/orders/{house_work_type_paintingwallpapering.yml → housework_type_paintingwallpapering.yml} +9 -10
  169. data/spec/vcr_cassettes/orders/{house_work_type_snowplowing.yml → housework_type_snowplowing.yml} +9 -10
  170. data/spec/vcr_cassettes/orders/{house_work_type_textileclothing.yml → housework_type_textileclothing.yml} +9 -10
  171. data/spec/vcr_cassettes/orders/{house_work_type_tutoring.yml → housework_type_tutoring.yml} +7 -7
  172. data/spec/vcr_cassettes/termsofpayments/all.yml +51 -0
  173. data/spec/vcr_cassettes/termsofpayments/find_failure.yml +45 -0
  174. data/spec/vcr_cassettes/termsofpayments/find_id_1.yml +46 -0
  175. data/spec/vcr_cassettes/termsofpayments/find_new.yml +46 -0
  176. data/spec/vcr_cassettes/termsofpayments/save_new.yml +45 -0
  177. data/spec/vcr_cassettes/termsofpayments/save_old.yml +46 -0
  178. data/spec/vcr_cassettes/units/all.yml +48 -0
  179. data/spec/vcr_cassettes/units/find_failure.yml +45 -0
  180. data/spec/vcr_cassettes/units/find_id_1.yml +46 -0
  181. data/spec/vcr_cassettes/units/find_new.yml +48 -0
  182. data/spec/vcr_cassettes/units/save_new.yml +47 -0
  183. data/spec/vcr_cassettes/units/save_old.yml +48 -0
  184. data/spec/vcr_cassettes/units/save_with_specially_named_attribute.yml +47 -0
  185. metadata +127 -88
  186. data/docs/account.rb +0 -59
  187. data/docs/extraction_script.js +0 -23
  188. data/docs/generation_script.rb +0 -43
  189. data/docs/json/account.json +0 -77
  190. data/lib/fortnox/api/models/document_base.rb +0 -189
  191. data/spec/fortnox/api/types/house_work_types_spec.rb +0 -64
  192. data/spec/support/matchers/type/have_house_work_type_matcher.rb +0 -7
@@ -1,11 +1,12 @@
1
- require "fortnox/api/types"
2
- require "fortnox/api/models/base"
1
+ # frozen_string_literal: true
2
+
3
+ require 'fortnox/api/types'
4
+ require 'fortnox/api/models/base'
3
5
 
4
6
  module Fortnox
5
7
  module API
6
8
  module Model
7
9
  class Customer < Fortnox::API::Model::Base
8
-
9
10
  UNIQUE_ID = :customer_number
10
11
  STUB = { name: '' }.freeze
11
12
 
@@ -26,183 +27,183 @@ module Fortnox
26
27
  # :hire
27
28
  # )
28
29
 
29
- #Url Direct URL to the record
30
- attribute :url, Types::Nullable::String.with( read_only: true )
30
+ # Url Direct URL to the record
31
+ attribute :url, Types::Nullable::String.is(:read_only)
31
32
 
32
- #Address1 First address of the customer. 1024 characters
33
- attribute :address1, Types::Sized::String[ 1024 ]
33
+ # Address1 First address of the customer. 1024 characters
34
+ attribute :address1, Types::Sized::String[1024]
34
35
 
35
- #Address2 Second address of the customer. 1024 characters
36
- attribute :address2, Types::Sized::String[ 1024 ]
36
+ # Address2 Second address of the customer. 1024 characters
37
+ attribute :address2, Types::Sized::String[1024]
37
38
 
38
- #City City of the customer. 1024 characters
39
- attribute :city, Types::Sized::String[ 1024 ]
39
+ # City City of the customer. 1024 characters
40
+ attribute :city, Types::Sized::String[1024]
40
41
 
41
- #Country Country of the customer. Read-only.
42
- attribute :country, Types::Nullable::String.with( read_only: true )
42
+ # Country Country of the customer. Read-only.
43
+ attribute :country, Types::Nullable::String.is(:read_only)
43
44
 
44
- #Comments Comments. 1024 characters.
45
- attribute :comments, Types::Sized::String[ 1024 ]
45
+ # Comments Comments. 1024 characters.
46
+ attribute :comments, Types::Sized::String[1024]
46
47
 
47
- #Currency Currency of the customer, 3 letters
48
+ # Currency Currency of the customer, 3 letters
48
49
  attribute :currency, Types::Currency
49
50
 
50
- #CostCenter Cost center of the customer, Cost center in Fortnox
51
+ # CostCenter Cost center of the customer, Cost center in Fortnox
51
52
  attribute :cost_center, Types::Nullable::String
52
53
 
53
- #CountryCode Country code of the customer, 2 letters
54
+ # CountryCode Country code of the customer, 2 letters
54
55
  attribute :country_code, Types::CountryCode
55
56
 
56
- #CustomerNumber Customer number. 1024 characters
57
- attribute :customer_number, Types::Sized::String[ 1024 ]
57
+ # CustomerNumber Customer number. 1024 characters
58
+ attribute :customer_number, Types::Sized::String[1024]
58
59
 
59
- #DefaultDeliveryTypes The properties for this object is listed in the table for Default Delivery Types”.
60
+ # DefaultDeliveryTypes The properties for this object is listed in the table for "Default Delivery Types".
60
61
  attribute :default_delivery_types, Types::DefaultDeliveryTypes
61
62
 
62
- #The properties for this object is listed in the table for Default Templates”.
63
+ # The properties for this object is listed in the table for "Default Templates".
63
64
  attribute :default_templates, Types::DefaultTemplates
64
65
 
65
- #DeliveryAddress1 First delivery address of the customer. 1024 characters
66
- attribute :delivery_address1, Types::Sized::String[ 1024 ]
66
+ # DeliveryAddress1 First delivery address of the customer. 1024 characters
67
+ attribute :delivery_address1, Types::Sized::String[1024]
67
68
 
68
- #DeliveryAddress2 Second delivery address of the customer. 1024 characters
69
- attribute :delivery_address2, Types::Sized::String[ 1024 ]
69
+ # DeliveryAddress2 Second delivery address of the customer. 1024 characters
70
+ attribute :delivery_address2, Types::Sized::String[1024]
70
71
 
71
- #DeliveryCity Delivery city of the customer. 1024 characters
72
- attribute :delivery_city, Types::Sized::String[ 1024 ]
72
+ # DeliveryCity Delivery city of the customer. 1024 characters
73
+ attribute :delivery_city, Types::Sized::String[1024]
73
74
 
74
- #DeliveryCountry Delivery country of the customer. Read-only.
75
- attribute :delivery_country, Types::Nullable::String.with( read_only: true )
75
+ # DeliveryCountry Delivery country of the customer. Read-only.
76
+ attribute :delivery_country, Types::Nullable::String.is(:read_only)
76
77
 
77
- #DeliveryCountryCode Delivery country code of the customer, 2 letters
78
+ # DeliveryCountryCode Delivery country code of the customer, 2 letters
78
79
  attribute :delivery_country_code, Types::CountryCode
79
80
 
80
- #DeliveryFax Delivery fax number of the customer. 1024 characters
81
- attribute :delivery_fax, Types::Sized::String[ 1024 ]
81
+ # DeliveryFax Delivery fax number of the customer. 1024 characters
82
+ attribute :delivery_fax, Types::Sized::String[1024]
82
83
 
83
- #DeliveryName Delivery name of the customer. 1024 characters
84
- attribute :delivery_name, Types::Sized::String[ 1024 ]
84
+ # DeliveryName Delivery name of the customer. 1024 characters
85
+ attribute :delivery_name, Types::Sized::String[1024]
85
86
 
86
- #DeliveryPhone1 First delivery phone number of the customer. 1024 characters
87
- attribute :delivery_phone1, Types::Sized::String[ 1024 ]
87
+ # DeliveryPhone1 First delivery phone number of the customer. 1024 characters
88
+ attribute :delivery_phone1, Types::Sized::String[1024]
88
89
 
89
- #DeliveryPhone2 Second delivery phone number of the customer. 1024 characters
90
- attribute :delivery_phone2, Types::Sized::String[ 1024 ]
90
+ # DeliveryPhone2 Second delivery phone number of the customer. 1024 characters
91
+ attribute :delivery_phone2, Types::Sized::String[1024]
91
92
 
92
- #DeliveryZipCode Delivery zip code of the customer. 1024 characters.
93
- attribute :delivery_zip_code, Types::Sized::String[ 1024 ]
93
+ # DeliveryZipCode Delivery zip code of the customer. 1024 characters.
94
+ attribute :delivery_zip_code, Types::Sized::String[1024]
94
95
 
95
- #Email Email address of the customer. 1024 characters
96
+ # Email Email address of the customer. 1024 characters
96
97
  attribute :email, Types::Email
97
98
 
98
- #EmailInvoice Invoice email address of the customer. 1024 characters
99
+ # EmailInvoice Invoice email address of the customer. 1024 characters
99
100
  attribute :email_invoice, Types::Email
100
101
 
101
- #EmailInvoiceBCC Invoice BCC email address of the customer. 1024 characters
102
+ # EmailInvoiceBCC Invoice BCC email address of the customer. 1024 characters
102
103
  attribute :email_invoice_bcc, Types::Email
103
104
 
104
- #EmailInvoiceCC Invoice CC email address of the customer. 1024 characters
105
+ # EmailInvoiceCC Invoice CC email address of the customer. 1024 characters
105
106
  attribute :email_invoice_cc, Types::Email
106
107
 
107
- #EmailOffer Offer email address of the customer. 1024 characters
108
+ # EmailOffer Offer email address of the customer. 1024 characters
108
109
  attribute :email_offer, Types::Email
109
110
 
110
- #EmailOfferBCC Offer BCC email address of the customer. 1024 characters
111
+ # EmailOfferBCC Offer BCC email address of the customer. 1024 characters
111
112
  attribute :email_offer_bcc, Types::Email
112
113
 
113
- #EmailOfferCC Offer CC email address of the customer. 1024 characters
114
+ # EmailOfferCC Offer CC email address of the customer. 1024 characters
114
115
  attribute :email_offer_cc, Types::Email
115
116
 
116
- #EmailOrder Order email address of the customer. 1024 characters
117
+ # EmailOrder Order email address of the customer. 1024 characters
117
118
  attribute :email_order, Types::Email
118
119
 
119
- #EmailOrderBCC Order BCC email address of the customer. 1024 characters
120
+ # EmailOrderBCC Order BCC email address of the customer. 1024 characters
120
121
  attribute :email_order_bcc, Types::Email
121
122
 
122
- #EmailOrderCC Order CC email address of the customer. 1024 characters
123
+ # EmailOrderCC Order CC email address of the customer. 1024 characters
123
124
  attribute :email_order_cc, Types::Email
124
125
 
125
- #Fax Fax number of the customer. 1024 characters
126
- attribute :fax, Types::Sized::String[ 1024 ]
126
+ # Fax Fax number of the customer. 1024 characters
127
+ attribute :fax, Types::Sized::String[1024]
127
128
 
128
- #InvoiceAdministrationFee Invoice administration fee of the customer, 12 digits (incl. decimals).
129
+ # InvoiceAdministrationFee Invoice administration fee of the customer, 12 digits (incl. decimals).
129
130
  attribute :invoice_administration_fee,
130
- Types::Sized::Float[ 0.0, 99_999_999_999.9 ]
131
+ Types::Sized::Float[0.0, 99_999_999_999.9]
131
132
 
132
- #InvoiceDiscount Invoice discount of the customer, 12 digits (incl. decimals)
133
- attribute :invoice_discount, Types::Sized::Float[ 0.0, 99_999_999_999.9 ]
133
+ # InvoiceDiscount Invoice discount of the customer, 12 digits (incl. decimals)
134
+ attribute :invoice_discount, Types::Sized::Float[0.0, 99_999_999_999.9]
134
135
 
135
- #InvoiceFreight Invoice freight fee of the customer, 12 digits (incl. decimals)
136
- attribute :invoice_freight, Types::Sized::Float[ 0.0, 99_999_999_999.9 ]
136
+ # InvoiceFreight Invoice freight fee of the customer, 12 digits (incl. decimals)
137
+ attribute :invoice_freight, Types::Sized::Float[0.0, 99_999_999_999.9]
137
138
 
138
- #InvoiceRemark Invoice remark of the customer. 1024 characters
139
- attribute :invoice_remark, Types::Sized::String[ 1024 ]
139
+ # InvoiceRemark Invoice remark of the customer. 1024 characters
140
+ attribute :invoice_remark, Types::Sized::String[1024]
140
141
 
141
- #Name Name of the customer, 1024 characters
142
- attribute :name, Types::Sized::String[ 1024 ].with( required: true )
142
+ # Name Name of the customer, 1024 characters
143
+ attribute :name, Types::Sized::String[1024].is(:required)
143
144
 
144
- #OrganisationNumber Organisation number of the customer. 30 characters
145
- attribute :organisation_number, Types::Sized::String[ 30 ]
145
+ # OrganisationNumber Organisation number of the customer. 30 characters
146
+ attribute :organisation_number, Types::Sized::String[30]
146
147
 
147
- #OurReference Our reference of the customer. 50 characters
148
- attribute :our_reference, Types::Sized::String[ 50 ]
148
+ # OurReference Our reference of the customer. 50 characters
149
+ attribute :our_reference, Types::Sized::String[50]
149
150
 
150
- #Phone1 First phone number of the customer. 1024 characters
151
- attribute :phone1, Types::Sized::String[ 1024 ]
151
+ # Phone1 First phone number of the customer. 1024 characters
152
+ attribute :phone1, Types::Sized::String[1024]
152
153
 
153
- #Phone2 Second phone number of the customer. 1024 characters
154
- attribute :phone2, Types::Sized::String[ 1024 ]
154
+ # Phone2 Second phone number of the customer. 1024 characters
155
+ attribute :phone2, Types::Sized::String[1024]
155
156
 
156
- #PriceList Price list of the customer, Price list in Fortnox
157
+ # PriceList Price list of the customer, Price list in Fortnox
157
158
  attribute :price_list, Types::Nullable::String
158
159
 
159
- #Project Project of the customer, Project in Fortnox
160
+ # Project Project of the customer, Project in Fortnox
160
161
  attribute :project, Types::Nullable::String
161
162
 
162
- #SalesAccount Sales account of the customer, 4 digits
163
+ # SalesAccount Sales account of the customer, 4 digits
163
164
  attribute :sales_account, Types::AccountNumber
164
165
 
165
- #ShowPriceVATIncluded Show prices with VAT included or not
166
+ # ShowPriceVATIncluded Show prices with VAT included or not
166
167
  attribute :show_price_vat_included, Types::Nullable::Boolean
167
168
 
168
- #TermsOfDeliveryCode Terms of delivery code of the customer
169
+ # TermsOfDeliveryCode Terms of delivery code of the customer
169
170
  attribute :terms_of_delivery, Types::Nullable::String
170
171
 
171
- #TermsOfPaymentCode Terms of payment code of the customer
172
+ # TermsOfPaymentCode Terms of payment code of the customer
172
173
  attribute :terms_of_payment, Types::Nullable::String
173
174
 
174
- #Type Customer type, PRIVATE / COMPANY
175
+ # Type Customer type, PRIVATE / COMPANY
175
176
  attribute :type, Types::CustomerType
176
177
 
177
- #VATNumber VAT number of the customer
178
+ # VATNumber VAT number of the customer
178
179
  attribute :vat_number, Types::Nullable::String
179
180
 
180
- #VATType VAT type of the customer, SEVAT / SEREVERSEDVAT / EUREVERSEDVAT / EUVAT / EXPORT
181
+ # VATType VAT type of the customer, SEVAT / SEREVERSEDVAT / EUREVERSEDVAT / EUVAT / EXPORT
181
182
  attribute :vat_type, Types::VATType
182
183
 
183
- #VisitAddress Visit address of the customer. 128 characters
184
- attribute :visiting_address, Types::Sized::String[ 128 ]
184
+ # VisitAddress Visit address of the customer. 128 characters
185
+ attribute :visiting_address, Types::Sized::String[128]
185
186
 
186
- #VisitCity Visit city of the customer. 128 characters
187
- attribute :visiting_city, Types::Sized::String[ 128 ]
187
+ # VisitCity Visit city of the customer. 128 characters
188
+ attribute :visiting_city, Types::Sized::String[128]
188
189
 
189
- #VisitCountry Visit country of the customer, read-only
190
- attribute :visiting_country, Types::Nullable::String.with( read_only: true )
190
+ # VisitCountry Visit country of the customer, read-only
191
+ attribute :visiting_country, Types::Nullable::String.is(:read_only)
191
192
 
192
- #VisitingCountryCode Code of the visiting country for the customer, 2 letters
193
+ # VisitingCountryCode Code of the visiting country for the customer, 2 letters
193
194
  attribute :visiting_country_code, Types::CountryCode
194
195
 
195
- #VisitZipCode Visit zip code of the customer. 10 characters
196
- attribute :visiting_zip_code, Types::Sized::String[ 10 ]
196
+ # VisitZipCode Visit zip code of the customer. 10 characters
197
+ attribute :visiting_zip_code, Types::Sized::String[10]
197
198
 
198
- #WayOfDeliveryCode Way of delivery code of the customer
199
+ # WayOfDeliveryCode Way of delivery code of the customer
199
200
  attribute :way_of_delivery, Types::Nullable::String
200
201
 
201
- #YourReference Your reference of the customer. 50 characters
202
- attribute :your_reference, Types::Sized::String[ 50 ]
202
+ # YourReference Your reference of the customer. 50 characters
203
+ attribute :your_reference, Types::Sized::String[50]
203
204
 
204
- #ZipCode Zip code of the customer. 10 characters
205
- attribute :zip_code, Types::Sized::String[ 10 ]
205
+ # ZipCode Zip code of the customer. 10 characters
206
+ attribute :zip_code, Types::Sized::String[10]
206
207
  end
207
208
  end
208
209
  end
@@ -0,0 +1,186 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fortnox/api/types'
4
+ require 'fortnox/api/models/label'
5
+
6
+ module Fortnox
7
+ module API
8
+ module Model
9
+ # This model is the shared attributes for Offer, Order and Invoice, the three "docuemnt models" in Fortnox.
10
+ # In the Fortnox implementation these are so close together that they are saved in the same database table.
11
+ # This is never used standalone, only included in the respective models.
12
+ class Document < Fortnox::API::Model::Base
13
+ # Url Direct url to the record.
14
+ attribute :url, Types::Nullable::String.is(:read_only)
15
+
16
+ # AdministrationFee The document administration fee.
17
+ attribute :administration_fee, Types::Nullable::Float
18
+
19
+ # AdministrationFeeVAT VAT of the document administration fee.
20
+ attribute :administration_fee_vat, Types::Nullable::Float.is(:read_only)
21
+
22
+ # Address1 Document address 1. 1024 characters
23
+ attribute :address1, Types::Sized::String[1024]
24
+
25
+ # Address2 Document address 2. 1024 characters
26
+ attribute :address2, Types::Sized::String[1024]
27
+
28
+ # BasisTaxReduction Basis of tax reduction.
29
+ attribute :basis_tax_reduction, Types::Nullable::Float.is(:read_only)
30
+
31
+ # Cancelled If the document is cancelled.
32
+ attribute :cancelled, Types::Nullable::Boolean.is(:read_only)
33
+
34
+ # City City for the document address.
35
+ attribute :city, Types::Sized::String[1024]
36
+
37
+ # Comments Comments of the document
38
+ attribute :comments, Types::Sized::String[1024]
39
+
40
+ # ContributionPercent Document contribution in percent.
41
+ attribute :contribution_percent, Types::Nullable::Float.is(:read_only)
42
+
43
+ # ContributionValue Document contribution in amount.
44
+ attribute :contribution_value, Types::Nullable::Float.is(:read_only)
45
+
46
+ # Country Country for the document address.
47
+ attribute :country, Types::CountryCode
48
+
49
+ # CostCenter Code of the cost center.
50
+ attribute :cost_center, Types::Nullable::String
51
+
52
+ # Currency Code of the currency.
53
+ attribute :currency, Types::Currency
54
+
55
+ # CurrencyRate Currency rate used for the document
56
+ attribute :currency_rate, Types::Nullable::Float
57
+
58
+ # CurrencyUnit Currency unit used for the document
59
+ attribute :currency_unit, Types::Nullable::Float
60
+
61
+ # CustomerName Name of the customer. 1024 characters
62
+ attribute :customer_name, Types::Sized::String[1024]
63
+
64
+ # CustomerNumber Customer number of the customer. Required
65
+ attribute :customer_number, Types::Required::String
66
+
67
+ # DeliveryAddress1 Document delivery address 1.
68
+ attribute :delivery_address1, Types::Sized::String[1024]
69
+
70
+ # DeliveryAddress2 Document delivery address 2.
71
+ attribute :delivery_address2, Types::Sized::String[1024]
72
+
73
+ # DeliveryCity City for the document delivery address.
74
+ attribute :delivery_city, Types::Sized::String[1024]
75
+
76
+ # DeliveryCountry Country for the document delivery address.
77
+ attribute :delivery_country, Types::CountryCode
78
+
79
+ # DeliveryDate Date of delivery.
80
+ attribute :delivery_date, Types::Nullable::Date
81
+
82
+ # DeliveryName Name of the recipient of the delivery
83
+ attribute :delivery_name, Types::Sized::String[1024]
84
+
85
+ # DeliveryZipCode ZipCode for the document delivery address.
86
+ attribute :delivery_zip_code, Types::Sized::String[1024]
87
+
88
+ # DocumentNumber The document number.
89
+ attribute :document_number, Types::Nullable::Integer
90
+
91
+ # EmailInformation Separete EmailInformation object
92
+ attribute :email_information, Types::EmailInformation
93
+
94
+ # ExternalInvoiceReference1 External document reference 1. 80 characters
95
+ attribute :external_invoice_reference1, Types::Sized::String[80]
96
+
97
+ # ExternalInvoiceReference2 External document reference 2. 80 characters
98
+ attribute :external_invoice_reference2, Types::Sized::String[80]
99
+
100
+ # Freight Freight cost of the document. 12 digits (incl. decimals)
101
+ attribute :freight, Types::Sized::Float[0.0, 99_999_999_999.9]
102
+
103
+ # FreightVAT VAT of the freight cost.
104
+ attribute :freight_vat, Types::Nullable::Float.is(:read_only)
105
+
106
+ # Gross Gross value of the document
107
+ attribute :gross, Types::Nullable::Float.is(:read_only)
108
+
109
+ # HouseWork If there is any row of the document marked "housework".
110
+ attribute :housework, Types::Nullable::Boolean.is(:read_only)
111
+
112
+ attribute :labels, Types::Strict::Array.member(Label)
113
+
114
+ # Net Net amount
115
+ attribute :net, Types::Nullable::Float.is(:read_only)
116
+
117
+ # NotCompleted If the document is set as not completed.
118
+ attribute :not_completed, Types::Nullable::Boolean
119
+
120
+ # OfferReference Reference to the offer, if one exists.
121
+ attribute :offer_reference, Types::Nullable::Integer.is(:read_only)
122
+
123
+ # OrganisationNumber Organisation number of the customer for the
124
+ # document.
125
+ attribute :organisation_number, Types::Nullable::String.is(:read_only)
126
+
127
+ # OurReference Our reference. 50 characters
128
+ attribute :our_reference, Types::Sized::String[50]
129
+
130
+ # Phone1 Phone number 1 of the customer for the document. 1024 characters
131
+ attribute :phone1, Types::Sized::String[1024]
132
+
133
+ # Phone2 Phone number 2 of the customer for the document. 1024 characters
134
+ attribute :phone2, Types::Sized::String[1024]
135
+
136
+ # PriceList Code of the price list.
137
+ attribute :price_list, Types::Nullable::String
138
+
139
+ # PrintTemplate Print template of the document.
140
+ attribute :print_template, Types::Nullable::String
141
+
142
+ # Project Code of the project.
143
+ attribute :project, Types::Nullable::String
144
+
145
+ # Remarks Remarks of the document. 1024 characters
146
+ attribute :remarks, Types::Sized::String[1024]
147
+
148
+ # RoundOff Round off amount for the document.
149
+ attribute :round_off, Types::Nullable::Float.is(:read_only)
150
+
151
+ # Sent If the document is printed or sent in any way.
152
+ attribute :sent, Types::Nullable::Boolean.is(:read_only)
153
+
154
+ # TaxReduction The amount of tax reduction.
155
+ attribute :tax_reduction, Types::Nullable::Integer.is(:read_only)
156
+
157
+ # TermsOfDelivery Code of the terms of delivery.
158
+ attribute :terms_of_delivery, Types::Nullable::String
159
+
160
+ # TermsOfPayment Code of the terms of payment.
161
+ attribute :terms_of_payment, Types::Nullable::String
162
+
163
+ # Total The total amount of the document.
164
+ attribute :total, Types::Nullable::Float.is(:read_only)
165
+
166
+ # TotalVAT The total VAT amount of the document.
167
+ attribute :total_vat, Types::Nullable::Float.is(:read_only)
168
+
169
+ # VATIncluded If the price of the document is including VAT.
170
+ attribute :vat_included, Types::Nullable::Boolean
171
+
172
+ # WayOfDelivery Code of the way of delivery.
173
+ attribute :way_of_delivery, Types::Nullable::String
174
+
175
+ # YourOrderNumber Your order number. 30 characters
176
+ attribute :your_order_number, Types::Sized::String[30]
177
+
178
+ # YourReference Your reference. 50 characters
179
+ attribute :your_reference, Types::Sized::String[50]
180
+
181
+ # ZipCode Zip code of the document. 1024 characters
182
+ attribute :zip_code, Types::Sized::String[1024]
183
+ end
184
+ end
185
+ end
186
+ end