spree-kashflow 0.1.1 → 0.1.2

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: b2346845707634b7353b64e8d2a982136ead6009e47f7b1ea5b94d1e905b5455
4
- data.tar.gz: 2a238745c13d9cd5a6cf0fde8e2854b2a7bc9c12c3ad35df25e396ea0d8a7159
3
+ metadata.gz: d20212552f51bc299bb20645fc8f5dbca833b2bdb63a1678d752b29a15f00a17
4
+ data.tar.gz: fb65959bc02ff1ac1b1eb7b38257ca03b9fba95386efb49b40baf91378b7c0bb
5
5
  SHA512:
6
- metadata.gz: ff74935654982f15a9094b50b36a26d1507705b33955444df4d9490c7511d51008c6c01cd92c42ff036475f5eb7d5ad475e820aa3ddee699fe9c35d895681956
7
- data.tar.gz: ecca24ec4c22aef839778a214b0a62e206588836810cb012ac762151e08ef9aed538a5e0c5b8c5a8c90ca21151658003b644691437ac19e4a8244d68a8b46438
6
+ metadata.gz: a257c8a10a8576b39a5b58613568cc1faf751f3fa28caa505df9d190404be40d12e0e52272a48c3f2f141cc7e2b0c540b59bf32bb2501d7c2dd60b01b31ecf9b
7
+ data.tar.gz: 19f304c825178155659864ba3b064507ade831b27632d385befd8d27a60f84ccd74471b0eef8ce94cea0f1bd1391ce900fc034af404377e578d87e292527a276
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - **Fix: every order sync still failed against a live KashFlow account**, now on
6
+ the invoice rather than the customer. KashFlow types every date field in the
7
+ WSDL as `s:dateTime`, and its .NET `XmlSerializer` rejected the whole envelope
8
+ with `The string '2026-08-18 10:53:48 UTC' is not a valid AllXsd value` —
9
+ no invoice created, and the fault naming only a character offset. Gyoku
10
+ type-switches with `Module#===`, so `ActiveSupport::TimeWithZone` (a
11
+ delegator, not a `Time` subclass) fell through to `to_s`; plain `Time` did
12
+ too, and `Date` emitted an xsd `date` rather than a `dateTime`. Since
13
+ `Time.current` and Active Record datetime attributes all return
14
+ `TimeWithZone`, this was the default path, affecting `InvoiceDate`, `DueDate`
15
+ and `PayDate` on orders and `InvoiceDate` / `DueDate` on refunds.
16
+ `Client#call` now normalises every temporal value in an outgoing message to
17
+ UTC xsd `dateTime`, so the wire format is owned by the one class that touches
18
+ the wire and any date field added later is correct by default.
19
+ - Assert the *serialised* SOAP body for temporal values. The suite doubled the
20
+ client and asserted the payload Hash, where a `TimeWithZone` looks correct
21
+ right up until it reaches the wire — which is why 0.1.1 shipped with this
22
+ defect behind a green build.
23
+
3
24
  ## 0.1.1
4
25
 
5
26
  - **Fix: every order sync failed against a live KashFlow account.** The customer
@@ -182,7 +182,8 @@ module Spree
182
182
  #
183
183
  def call(operation, message = {})
184
184
  credentials = {"UserName" => @username, "Password" => @password}
185
- response = savon_client.call(operation, message: credentials.merge(message))
185
+ body = coerce_temporal(credentials.merge(message))
186
+ response = savon_client.call(operation, message: body)
186
187
  body = response.body
187
188
  assert_status!(body)
188
189
  body
@@ -195,6 +196,48 @@ module Spree
195
196
  raise TransportError, e.message
196
197
  end
197
198
 
199
+ ##
200
+ # Rewrites every temporal value in an outgoing message to xsd `dateTime`.
201
+ #
202
+ # KashFlow types every date field in the WSDL as `s:dateTime`, and its
203
+ # .NET `XmlSerializer` rejects the *entire* envelope with a
204
+ # `FormatException` ("is not a valid AllXsd value") when one of them is
205
+ # not valid xsd — the invoice is never created, and the fault names only
206
+ # a character offset, not the field.
207
+ #
208
+ # Gyoku cannot be relied on to do this. It type-switches with
209
+ # `case/when`, i.e. `Module#===`, so:
210
+ # - `ActiveSupport::TimeWithZone` is a *delegator*, not a `Time`
211
+ # subclass, and misses the branch entirely -> `to_s`
212
+ # ("2026-08-18 10:53:48 UTC").
213
+ # - plain `Time` is likewise emitted via `to_s` by Gyoku 1.4.
214
+ # - `Date` serialises as `2026-08-18`, an xsd `date`, not the `dateTime`
215
+ # the schema asks for.
216
+ #
217
+ # `Time.current` and every Active Record datetime attribute return
218
+ # `TimeWithZone`, so the broken path was the default one, which is why
219
+ # every caller was affected. Normalising here rather than at each call
220
+ # site keeps the wire format owned by the one class that touches the
221
+ # wire, and means a date field added to any future payload is correct
222
+ # without the author having to know this.
223
+ #
224
+ # Values are converted to UTC first so the instant is preserved and the
225
+ # emitted form is unambiguous (`...Z`) regardless of the app's zone.
226
+ #
227
+ # @param value [Object] any message value; Hashes and Arrays are walked
228
+ # @return [Object] the value with temporals replaced by xsd strings
229
+ #
230
+ def coerce_temporal(value)
231
+ case value
232
+ when Hash then value.transform_values { |element| coerce_temporal(element) }
233
+ when Array then value.map { |element| coerce_temporal(element) }
234
+ when ActiveSupport::TimeWithZone, Time then value.utc.xmlschema
235
+ when DateTime then value.to_time.utc.xmlschema
236
+ when Date then value.to_time(:utc).xmlschema
237
+ else value
238
+ end
239
+ end
240
+
198
241
  ##
199
242
  # KashFlow reports business-level rejections *in band*: the SOAP call
200
243
  # succeeds at HTTP 200 with an empty result element and a `Status` /
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Spree
4
4
  module Kashflow
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree-kashflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aypex