fix: change DolibarrOrderDto.dateCommande to String
Dolibarr GET /orders/{id} returns date fields as ISO strings, not
Unix timestamps, causing Jackson Long deserialization to fail.
String handles both: sends epoch string in POST body (Dolibarr accepts
it); ignores the date_commande string in GET via @JsonIgnoreProperties.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c5d36bf051
commit
b55805665b
|
|
@ -1,6 +1,5 @@
|
|||
package com.teterialosjuanjos.tfg.sync_service.integration.dolibarr.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -20,8 +19,11 @@ public record DolibarrOrderDto(
|
|||
String ref,
|
||||
/** Thirdparty (customer) internal ID */
|
||||
Integer socid,
|
||||
/** Order date as UNIX timestamp. POST requires "date"; GET response uses "date_commande". */
|
||||
@JsonProperty("date") @JsonAlias("date_commande") Long dateCommande,
|
||||
/**
|
||||
* Order date. POST requires field name "date" with UNIX timestamp as String.
|
||||
* GET response returns "date_commande" as date string — ignored via @JsonIgnoreProperties.
|
||||
*/
|
||||
@JsonProperty("date") String dateCommande,
|
||||
/** 0 = draft, 1 = validated, 2 = shipped, 3 = canceled */
|
||||
Integer statut,
|
||||
@JsonProperty("note_public") String notePublic,
|
||||
|
|
|
|||
|
|
@ -117,8 +117,9 @@ public class OrderSyncService {
|
|||
DolibarrThirdpartyDto customer = resolveCustomer(psOrder);
|
||||
|
||||
// 2. Build order in Dolibarr
|
||||
long dateEpoch = LocalDateTime.parse(psOrder.dateAdd(), PS_DATE_FORMAT)
|
||||
.toEpochSecond(ZoneOffset.UTC);
|
||||
String dateEpoch = String.valueOf(
|
||||
LocalDateTime.parse(psOrder.dateAdd(), PS_DATE_FORMAT)
|
||||
.toEpochSecond(ZoneOffset.UTC));
|
||||
|
||||
DolibarrOrderDto orderDto = DolibarrOrderDto.builder()
|
||||
.socid(customer.id())
|
||||
|
|
|
|||
Loading…
Reference in New Issue