killbill / killbill-admin-ui

Kill Bill Administrative UI engine
https://killbill.io
MIT License
52 stars 60 forks source link

Display the correct amount in payments/invoice payments screen #322

Closed reshmabidikar closed 2 years ago

reshmabidikar commented 2 years ago

The Kaui payments screen and the invoice payment screen display an incorrect amount when the processed amount is different from the actual amount.

These screens use the amount field from the transaction, not the processedAmount field.

For example, when the Retrieve Invoice Payment endpoint returns amount=60 and processedAmount=10, Kaui displays 60 as can be seen from the invoice payment screenshot below:

image

Proposed Fix:

When the processedAmount is different from amount , Kaui should show the processedAmount followed by a (?) symbol. On hovering over the (?) icon, it should display the amount. So, in the example above, it should display $10 (USD) (?) and on hover of the small (?) icon, it should display $60 (USD)

Note that this fix also needs to be applied to the payment screen below.

image
kpbacode commented 2 years ago

On hovering over the (?) icon, it should display the amount.

This is customer requirement to have this effect? Or we can have this listed the same way like other columns?

Note that this fix also needs to be applied to the payment screen below.

Kaui loads partials templates so this is included anywhere where we load payments_table.

When we go to listing of all payments we see capture amount so something has been implemented to show what amount has been captured.

Screenshot 2022-10-11 at 11 10 29 Screenshot 2022-10-11 at 11 18 04 Screenshot 2022-10-11 at 11 19 08

reshmabidikar commented 2 years ago

This is customer requirement to have this effect? Or we can have this listed the same way like other columns?

Could you please elaborate on what you mean by other columns?

When we go to listing of all payments we see capture amount so something has been implemented to show what amount has been captured.

I do not think we need to change anything here, so the payments screen can continue to display the captured amount. @pierre, any thoughts?

kpbacode commented 2 years ago
  1. All columns are listed without ? hover effect, just plain columns with data if there is any and we could implement this the same like other columns.
  2. /accounts/:account_id/payments has not been changed in any way, I just pointed that some info about what amount has been captured is already just not linked to invoice listing.

here is commit for this feature https://github.com/kpbacode/killbill-admin-ui/commits/show-processamount

pierre commented 2 years ago

This is customer requirement to have this effect? Or we can have this listed the same way like other columns?

I don't think we should introduce a new column for that. In 99.9999% of the cases, amount == processed amount. So, in most cases, this new column will take space for not much information. We could have a hover effect for that 0.0001% case, just like in the audit screens?

I do not think we need to change anything here, so the payments screen can continue to display the captured amount. @pierre, any thoughts?

Agreed, auth/capture amounts are a different concept and should be kept as-is.

kpbacode commented 2 years ago

[] Need to figure out how to add transaction with different processed amount. (https://killbill.github.io/slate/index.html?shell#account-trigger-a-payment-authorization-purchase-or-credit) [] Will add this tool tip at the bottom, to don't cover the amount.

Screenshot 2022-10-11 at 14 31 20

pierre commented 2 years ago

Need to figure out how to add transaction with different processed amount.

You mean for testing purposes? If so, you cannot actually. This is returned in corner cases by the payment plugins. You might be able to use the payment test plugin to fake it, but I wouldn't bother.

kpbacode commented 2 years ago

Proposed Fix:

When the processedAmount is different from amount , Kaui should show the processedAmount followed by a (?) symbol. On hovering over the (?) icon, it should display the amount. So, in the example above, it should display $10 (USD) (?) and on hover of the small (?) icon, it should display $60 (USD)

implemented as requested Screenshot 2022-10-12 at 12 42 19

todo: tests

reshmabidikar commented 2 years ago

Did some testing using the payment test plugin. The Retrieve Payment by Id endpoint returns the following data (Different values are returned for amount and processedAmount):

{
  "accountId": "1b5ef030-b380-4d6b-aa35-29c72c7375ff",
  "paymentId": "a70a3127-0ab0-4c6f-897c-faf119acd794",
  "paymentNumber": "2",
  "paymentExternalKey": "a70a3127-0ab0-4c6f-897c-faf119acd794",
  "authAmount": 0,
  "capturedAmount": 0,
  "purchasedAmount": 10,
  "refundedAmount": 0,
  "creditedAmount": 0,
  "currency": "USD",
  "paymentMethodId": "9d24cb12-d95c-4469-9bbe-13c289c7de41",
  "transactions": [
    {
      "transactionId": "d32c1d32-6f01-4180-a813-d06af77e9a9e",
      "transactionExternalKey": "d32c1d32-6f01-4180-a813-d06af77e9a9e",
      "paymentId": "a70a3127-0ab0-4c6f-897c-faf119acd794",
      "paymentExternalKey": "a70a3127-0ab0-4c6f-897c-faf119acd794",
      "transactionType": "PURCHASE",
      "amount": 100,
      "currency": "USD",
      "effectiveDate": "2022-10-27T08:47:01.000Z",
      "processedAmount": 10,
      "processedCurrency": "USD",
      "status": "SUCCESS",
      "gatewayErrorCode": null,
      "gatewayErrorMsg": null,
      "firstPaymentReferenceId": null,
      "secondPaymentReferenceId": null,
      "properties": null,
      "auditLogs": []
    }
  ],
  "paymentAttempts": null,
  "auditLogs": []
}

However, Kaui displays the following screen (No question mark icon and nothing shown on hovering the mouse over the amount field):

image
kpbacode commented 2 years ago

You are using version with this template updated? killbill-admin-ui/app/views/kaui/payments/_payment_table.html.erb

          <% if transaction.amount.present? %>
              <% if transaction.amount != transaction.processed_amount %>
              <%= humanized_money_with_symbol Kaui::Transaction.processed_amount_to_money(transaction) %>
              (<%= transaction.currency %>)
              <a href="#" data-toggle="tooltip" class="kb-tooltip" title="<%= I18n.translate('requested_amount_colon') %> <%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>(<%= transaction.currency %>)">(?)</a>
              <% else%>
              <%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>
              (<%= transaction.currency %>)
              <% end %>
          <% end %>
reshmabidikar commented 2 years ago

Yes, I had the correct code but my killbill-admin-ui-standalone code was not pointing to the local killbill-admin-ui code. On fixing this, it works fine. I see the following payment screen:

image

The invoice payment screen also works as expected.