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

          tyson Tyson Phillips (Inactive) created issue -
          tyson Tyson Phillips (Inactive) made changes -
          Field Original Value New Value
          Rank Ranked higher
          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).
          cody Cody Phillips (Inactive) made changes -
          Rank Ranked higher
          cody Cody Phillips (Inactive) made changes -
          Link This issue relates to CORE-1092 [ CORE-1092 ]
          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.
          cody Cody Phillips (Inactive) made changes -
          Rank Ranked higher
          admin Paul Phillips made changes -
          Fix Version/s 3.5.0 [ 10401 ]
          Fix Version/s 3.4.3 [ 10613 ]
          cody Cody Phillips (Inactive) made changes -
          Rank Ranked higher
          cody Cody Phillips (Inactive) made changes -
          Rank Ranked lower
          admin Paul Phillips made changes -
          Rank Ranked higher
          admin Paul Phillips made changes -
          Fix Version/s Short Term [ 10800 ]
          admin Paul Phillips made changes -
          Rank Ranked higher
          jonathan Jonathan Reissmueller made changes -
          Assignee Tyson Phillips [ tyson ] Jonathan Reissmueller [ jonathan ]
          Automated transition triggered when Jonathan Reissmueller created a branch in Stash -
          Status Open [ 1 ] In Progress [ 3 ]
          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.
          Automated transition triggered when Jonathan Reissmueller created pull request #287 in Stash -
          Status In Progress [ 3 ] In Review [ 5 ]
          Resolution Fixed [ 1 ]
          jonathan Jonathan Reissmueller made changes -
          Sprint 4.1.0 Sprint 4 [ 38 ]
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked lower
          jonathan Jonathan Reissmueller made changes -
          Fix Version/s 4.1.0 [ 11007 ]
          Fix Version/s Short Term [ 10800 ]
          tyson Tyson Phillips (Inactive) made changes -
          Sprint 4.1.0 Sprint 4 [ 38 ] 4.1.0 Sprint 4, 4.1.0 Sprint 5 [ 38, 42 ]
          tyson Tyson Phillips (Inactive) made changes -
          Rank Ranked higher
          Automated transition triggered when Tyson Phillips (Inactive) merged pull request #287 in Stash -
          Status In Review [ 5 ] Closed [ 6 ]

            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