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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7616a9760dec5aa02b7295ec094013aaffe962f98c402f613636a039f3d1891c
4
- data.tar.gz: 6d8665d732a8f5125ad02991d2f9daf6277cef5cb9e9ce7123da32680f60a9f3
3
+ metadata.gz: 6a383d4f26222585f14be0a06145f63bb4584f8033e2eae2f91dc22cc513c085
4
+ data.tar.gz: 71fe26b84df2f8bb30ddcd990b39742606827b507164d42f8b05594b069f8ad6
5
5
  SHA512:
6
- metadata.gz: 734e2f06e8e55583e789b9830092bcf6d53ee0d3b8511693cac15edab25a3658fd126d91ba18bcc8ebe33b823659a20494b16389c02adff0799b3faf8cf7a9bd
7
- data.tar.gz: bf07508b1a70cbfabbba0fc9611866f2a87c3cb8fff564acfc9dbae3fca66d70fafbc2a1b8e1f5e594950800bb850fb5f592fdd38e4a61233d2f6568b8276411
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.rc11...HEAD
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
@@ -24,23 +24,7 @@ module Fortnox
24
24
  end
25
25
  end
26
26
 
27
- after_serialise do |data|
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fortnox
4
- VERSION = '1.0.0.rc11'
4
+ VERSION = '1.0.0.rc12'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortnox-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc11
4
+ version: 1.0.0.rc12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Schubert Erlandsson