Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-1597

Recording credit for invoice may fail due to amount precision

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.2
    • Fix Version/s: 4.1.0-b1
    • Component/s: None
    • Labels:
      None

      Description

      It's possible that a credit can exist for an amount less than the precision displayed for that currency in the interface. e.g. $10.009

      Attempting to record a payment by using the credit to pay an invoice may then fail. In the admin interface, this error is encountered:
      "One or more Amount to Pay values could not be applied to the specified invoice. Ensure that the Amount to Pay does not exceed the Amount Due on the invoice, that the invoice is open, and the sum of the Amount to Pay values do not exceed the Payment or Credit Amount."

      e.g.
      Attempt to pay an invoice totaling $10.01 with a credit of $10.009
      $10.009 < $10.01, so the amount is not enough to pay the invoice. However, I think the credit amount may need to be rounded to cover the payment. $total may need to be rounded in Transactions::validateApplyAmounts

        Issue Links

          Activity

          Hide
          cody Cody Phillips (Inactive) added a comment - - edited

          If rounding, the rounding must observe the decimal precision of the currency itself, not some arbitrary value (like 2, for example).

          Show
          cody Cody Phillips (Inactive) added a comment - - edited If rounding, the rounding must observe the decimal precision of the currency itself, not some arbitrary value (like 2, for example).
          Hide
          cody Cody Phillips (Inactive) added a comment -

          I'm thinking CORE-1092 might be blocking this. Without looking at the currency in question to observe the proper number of decimal places required we can't round accurately.

          Show
          cody Cody Phillips (Inactive) added a comment - I'm thinking CORE-1092 might be blocking this. Without looking at the currency in question to observe the proper number of decimal places required we can't round accurately.
          Hide
          jonathan Jonathan Reissmueller added a comment -

          Okay so the the problem seems to stem for this line (767 on my current dev branch):

          'amount' => $this->CurrencyFormat->cast($credit_amount, $currency_code)
          

          This rounds the apply amount to 2 decimal places, and as far as I can tell there is no good reason for it since that is a mismatch from the database and it is not based on the currency at all.

          Show
          jonathan Jonathan Reissmueller added a comment - Okay so the the problem seems to stem for this line (767 on my current dev branch): 'amount' => $ this ->CurrencyFormat-> cast ($credit_amount, $currency_code) This rounds the apply amount to 2 decimal places, and as far as I can tell there is no good reason for it since that is a mismatch from the database and it is not based on the currency at all.

            People

            • Assignee:
              jonathan Jonathan Reissmueller
              Reporter:
              tyson Tyson Phillips (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/Jul/17

                Agile