Skip to content

6.6.0

Choose a tag to compare

@guillaume-sainthillier guillaume-sainthillier released this 29 Oct 21:24
· 67 commits to 6.x since this release
Immutable release. Only release title and notes can be modified.
ffae33a

Opt-in consistency checks for statements and transfers (validate()), exact amounts as decimal strings (getAmount(true)), and ParseException messages without account numbers or labels.

Added

  • Statement::validate() and Transfer::validate() check the consistency of a statement or a transfer, which the
    readers do not: they throw a ValidationException (a ParseException) whose getCheck() tells which
    ValidationCheck failed. Opt-in: call them on the statements and transfers you need to trust
    • CFONB 120: the 07 new balance, the 04 operations and their 05 details belong to the account of the 01 old
      balance (desk code, account number, currency; bank code between the two balances only), and the new balance is
      the old balance plus the operations
    • CFONB 240: the 39 total belongs to the account of the 31 header (bank code, counter code, account number,
      currency index), the 34 transactions have its currency index, and the total is the sum of the transactions
    • The amounts are added as integers in minor units, never as floats
  • Exact amounts, as decimal strings: pass true to Balance::getAmount(), Operation::getAmount(),
    Transaction::getTransactionAmount() and Total::getTotalAmount(). getAmount(true) is "-22.79", with the
    number of decimals of the line ("1669565" with 0 decimals), ready for a DECIMAL column or bcmath; the float loses
    cents, (int) (0.29 * 100) being 28. The return type follows the argument for PHPStan and Psalm (float by
    default, string with true). The objects keep the amount as this string and compute the float from it, the same
    float as before. Their constructors take the amount as float|string: a float becomes the decimal string that gives
    it back, 1669.565 staying "1669.565", and a string that is not a decimal throws an InvalidArgumentException
  • ParseException::getRawContent(): the line (or, for an amount, the field) that failed to parse, now kept out of the
    message

Changed

  • The messages of a ParseException no longer hold the line that failed, which holds account numbers and labels and
    ended up in logs and error pages. Code matching the full message must be updated; the beginning of the messages is
    unchanged:
    • Unable to find a parser for the line : + the line is now Unable to find a parser for the line 3: record code "04", 119 characters
    • Regex does not match the line "…" is now Regex does not match the line: the field "amount" at position 91 is invalid
    • Unable to parse amount "…" is now Unable to parse amount: its last character "…" is not a sign character

Deprecated

  • The float returned by getAmount(), getTransactionAmount() and getTotalAmount() without an argument: 7.0 returns
    the exact decimal string only. Pass true to get it now

What's Changed

Full Changelog: 6.5.0...6.6.0