Skip to content

Commit

Permalink
Temporary fix for ledger_account.allowed_document_types should be an …
Browse files Browse the repository at this point in the history
…array
  • Loading branch information
arwinvdv committed Jan 23, 2024
1 parent 1ec8c41 commit 1329e92
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Picqer/Financials/Moneybird/Entities/LedgerAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,23 @@ class LedgerAccount extends Model
* @var string
*/
protected $namespace = 'ledger_account';

/**
* Dirty fix for allowed_document_types, which is an object because of JSON_FORCE_OBJECT but should be an array.
* TODO: make a generic solution for this.
*
* @return string
*/
public function jsonWithNamespace()
{
$json = parent::jsonWithNamespace();
$array = json_decode($json, true);

// Make sure allowed_document_types is always an array and not an object
if (isset($array['ledger_account']['allowed_document_types']) && is_object($array['ledger_account']['allowed_document_types'])) {
$array['ledger_account']['allowed_document_types'] = (array) $array['ledger_account']['allowed_document_types'];
}
return json_encode($array);
}

}

0 comments on commit 1329e92

Please sign in to comment.