fortnox-api 1.0.0.rc11 → 1.0.0.rc12
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/CHANGELOG.md +13 -1
- data/lib/fortnox/resource.rb +21 -17
- data/lib/fortnox/resources/customer.rb +17 -0
- data/lib/fortnox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a383d4f26222585f14be0a06145f63bb4584f8033e2eae2f91dc22cc513c085
|
|
4
|
+
data.tar.gz: 71fe26b84df2f8bb30ddcd990b39742606827b507164d42f8b05594b069f8ad6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c22875f971a82ee3b75168da1395ef21c75bb04ef4e521d550264435c840b5ea786abcde67d8234eded0a06d9ad4028e1926403daf62a3ed8355ae9adfd9634f
|
|
7
|
+
data.tar.gz: '08b942421e226597317d74e1189b3a4aca90fcc5158d8b4f6d27d934a791f2af57f80c9226f406015372286187fd286e43d271fcdb8b2e501380001f55ce43f7'
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,17 @@ and this project adheres to
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [1.0.0.rc12] - 2026-06-26
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- `Fortnox::Customer` no longer sends `OrganisationNumber` when updating a
|
|
16
|
+
customer that has an active e-fakturakoppling
|
|
17
|
+
(`default_delivery_types.invoice == ELECTRONICINVOICE`). Fortnox rejects edits
|
|
18
|
+
to the org/personal number for such customers, and field-level dirty tracking
|
|
19
|
+
meant an unchanged `OrganisationNumber` was always included on update,
|
|
20
|
+
blocking every other update to those customers.
|
|
21
|
+
|
|
11
22
|
## [1.0.0.rc11] - 2026-06-26
|
|
12
23
|
|
|
13
24
|
### Changed
|
|
@@ -270,7 +281,8 @@ for the full list of breaking changes.
|
|
|
270
281
|
For changes prior to the 1.0 rewrite, see the
|
|
271
282
|
[0.x changelog](https://github.com/accodeing/fortnox-api/blob/v0.9.2/CHANGELOG.md).
|
|
272
283
|
|
|
273
|
-
[Unreleased]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.
|
|
284
|
+
[Unreleased]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.rc12...HEAD
|
|
285
|
+
[1.0.0.rc12]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.rc11...v1.0.0.rc12
|
|
274
286
|
[1.0.0.rc11]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.rc10...v1.0.0.rc11
|
|
275
287
|
[1.0.0.rc10]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.rc9...v1.0.0.rc10
|
|
276
288
|
[1.0.0.rc9]: https://github.com/accodeing/fortnox-api/compare/v1.0.0.rc8...v1.0.0.rc9
|
data/lib/fortnox/resource.rb
CHANGED
|
@@ -24,23 +24,7 @@ module Fortnox
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
after_serialise
|
|
28
|
-
if meta.new?
|
|
29
|
-
# Strip nils for new records — rely on Fortnox defaults
|
|
30
|
-
data = data.compact
|
|
31
|
-
elsif __changes__.any?
|
|
32
|
-
# Send only the attributes passed to .update — field-level dirty
|
|
33
|
-
# tracking, not a value diff, so an attribute equal to its stored
|
|
34
|
-
# value is still sent, and an explicit nil reaches Fortnox as a clear.
|
|
35
|
-
changed_api_names = __changes__.keys.filter_map do |model_name|
|
|
36
|
-
self.class.all_attribute_definitions[model_name]&.api_name
|
|
37
|
-
end
|
|
38
|
-
data = data.slice(*changed_api_names)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# TODO: rest-easy should do this wrapping for us.
|
|
42
|
-
{ config.instance_wrapper => data }
|
|
43
|
-
end
|
|
27
|
+
after_serialise { |data| default_after_serialise(data) }
|
|
44
28
|
|
|
45
29
|
class << self
|
|
46
30
|
attr_reader :registered_resources
|
|
@@ -135,5 +119,25 @@ module Fortnox
|
|
|
135
119
|
}
|
|
136
120
|
end
|
|
137
121
|
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
# Shared serialisation tail used by the base after_serialise hook. Exposed
|
|
126
|
+
# as an instance method so subclass hooks can post-process the payload (e.g.
|
|
127
|
+
# drop a field) and still reuse it — rest-easy hooks override, not chain.
|
|
128
|
+
def default_after_serialise(data)
|
|
129
|
+
if meta.new?
|
|
130
|
+
# Strip nils for new records — rely on Fortnox defaults
|
|
131
|
+
data = data.compact
|
|
132
|
+
elsif __changes__.any?
|
|
133
|
+
# Send only the attributes passed to .update — field-level dirty
|
|
134
|
+
# tracking, not a value diff, so an attribute equal to its stored
|
|
135
|
+
# value is still sent, and an explicit nil reaches Fortnox as a clear.
|
|
136
|
+
data = data.slice(*__changes__.keys.filter_map { |name| self.class.all_attribute_definitions[name]&.api_name })
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# TODO: rest-easy should do this wrapping for us.
|
|
140
|
+
{ config.instance_wrapper => data }
|
|
141
|
+
end
|
|
138
142
|
end
|
|
139
143
|
end
|
|
@@ -15,6 +15,15 @@ module Fortnox
|
|
|
15
15
|
validate_electronic_invoice_delivery_type!(default_delivery_types&.invoice)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# Fortnox refuses to edit OrganisationNumber once a customer has an active
|
|
19
|
+
# e-fakturakoppling. Drop it from the update payload in that case so the rest
|
|
20
|
+
# of the customer can still be updated. Field-level dirty tracking means an
|
|
21
|
+
# unchanged OrganisationNumber would otherwise always be sent on update.
|
|
22
|
+
after_serialise do |data|
|
|
23
|
+
data = data.except(organisation_number_api_name) if drop_organisation_number?
|
|
24
|
+
default_after_serialise(data)
|
|
25
|
+
end
|
|
26
|
+
|
|
18
27
|
# Direct URL to the record.
|
|
19
28
|
attr :url <=> '@url', Coercible::String.optional, :read_only
|
|
20
29
|
|
|
@@ -212,6 +221,14 @@ module Fortnox
|
|
|
212
221
|
|
|
213
222
|
private
|
|
214
223
|
|
|
224
|
+
def drop_organisation_number? = !meta.new? && electronic_invoice_active?
|
|
225
|
+
|
|
226
|
+
def electronic_invoice_active?
|
|
227
|
+
default_delivery_types&.invoice == DefaultInvoiceDeliveryTypeValues['ELECTRONICINVOICE']
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def organisation_number_api_name = self.class.all_attribute_definitions[:organisation_number].api_name
|
|
231
|
+
|
|
215
232
|
# ELECTRONICINVOICE is only possible to set in the Fortnox UI.
|
|
216
233
|
# Raise if a consumer tries to set it from this gem.
|
|
217
234
|
def validate_electronic_invoice_delivery_type!(type)
|
data/lib/fortnox/version.rb
CHANGED