Correct the models against what a real server actually sends

Every one of these was wrong in a way the mock tests could not see, because
the mocks were written from the same upstream source the models were.

- `SystemLog.created_at`/`updated_at` are integer timestamps, not the date
  strings the OpenAPI spec declares.
- `frequency_id` arrives as a numeric string on recurring invoices and
  expenses, so both now decode through `int_or_numeric_string`.
- `Location.country_id`, `PurchaseOrder.status_id` and `Webhook.format` are
  omitted when empty. The server runs `ConvertEmptyStringsToNull`, so an
  unset `String` sent as `""` becomes NULL and then fails a non-null column
  or an `integer` rule — which meant a create from a `Default` model could
  not succeed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 21:55:46 -04:00
co-authored by Claude Opus 5
parent 0002d32197
commit bd2d34cae9
8 changed files with 41 additions and 17 deletions
+7 -6
View File
@@ -584,23 +584,24 @@ fn company_keeps_settings_untyped_and_preserves_toggles() {
assert_eq!(round_tripped["settings"]["timezone_id"], "15");
}
/// System logs are the one resource whose timestamps are date strings
/// rather than integers.
/// The spec says system-log timestamps are date strings; a real server sends
/// integers, as it does everywhere else.
#[test]
fn system_log_timestamps_are_strings() {
fn system_log_timestamps_are_integers() {
let log: SystemLog = serde_json::from_value(json!({
"id": "sl1",
"event_id": 30,
"category_id": 1,
"type_id": 300,
"log": {"message": "gateway declined"},
"created_at": "2026-10-01 12:00:00",
"updated_at": "2026-10-01 12:00:00",
"created_at": 1792869488,
"updated_at": 1792869489,
}))
.unwrap();
assert_eq!(log.event_id, 30);
assert_eq!(log.created_at, "2026-10-01 12:00:00");
assert_eq!(log.created_at, 1792869488);
assert_eq!(log.updated_at, 1792869489);
assert_eq!(log.log["message"], "gateway declined");
}