Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listener: refresh payment rows when CBA is distributed #106

Merged
merged 1 commit into from Nov 5, 2019

Conversation

@pierre
Copy link
Member

pierre commented Nov 4, 2019

In #93, we stopped refreshing payments for INVOICE_CREATION and INVOICE_ADJUSTMENT events.

Payment rows still need to be updated (if they exist) when CBA is distributed, as the balance may change.

This fixes #105.

Testing done

Tested with the following scenario:

  • Account with __EXTERNAL_PAYMENT__ default payment method
  • Monthly subscription started on 2019-10-01: two invoices and two corresponding invoice payments
  • Update the most recent payment from SUCCESS to PAYMENT_FAILURE

State:

[killbill]> select invoice_id, balance, amount_paid, amount_charged, amount_credited from analytics_invoices where account_id = '1cf83538-9117-4386-94da-82c7328ce0b0' order by invoice_number;
+--------------------------------------+---------+-------------+----------------+-----------------+
| invoice_id                           | balance | amount_paid | amount_charged | amount_credited |
+--------------------------------------+---------+-------------+----------------+-----------------+
| 67670acf-4f61-4ab5-9e5f-d9578fad8717 |  0.0000 |     10.0000 |        10.0000 |          0.0000 |
| 290425ac-949b-453a-bb7d-384c5949608c | 10.0000 |      0.0000 |        10.0000 |          0.0000 |
+--------------------------------------+---------+-------------+----------------+-----------------+

[killbill]> select invoice_id, invoice_balance, invoice_amount_paid, invoice_amount_charged, invoice_amount_credited from analytics_payment_purchases where account_id = '1cf83538-9117-4386-94da-82c7328ce0b0' order by invoice_number;
+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
| invoice_id                           | invoice_balance | invoice_amount_paid | invoice_amount_charged | invoice_amount_credited |
+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
| 67670acf-4f61-4ab5-9e5f-d9578fad8717 |          0.0000 |             10.0000 |                10.0000 |                  0.0000 |
| 290425ac-949b-453a-bb7d-384c5949608c |         10.0000 |              0.0000 |                10.0000 |                  0.0000 |
+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
  • Cancel subscription start of term

State:

[killbill]> select invoice_id, balance, amount_paid, amount_charged, amount_credited from analytics_invoices where account_id = '1cf83538-9117-4386-94da-82c7328ce0b0' order by invoice_number;
+--------------------------------------+---------+-------------+----------------+-----------------+
| invoice_id                           | balance | amount_paid | amount_charged | amount_credited |
+--------------------------------------+---------+-------------+----------------+-----------------+
| 67670acf-4f61-4ab5-9e5f-d9578fad8717 |  0.0000 |     10.0000 |        10.0000 |          0.0000 |
| 290425ac-949b-453a-bb7d-384c5949608c |  0.0000 |      0.0000 |        10.0000 |        -10.0000 |
| 70c58d6b-bde6-48cc-b7a6-88dfee843781 |  0.0000 |      0.0000 |       -10.0000 |         10.0000 |
+--------------------------------------+---------+-------------+----------------+-----------------+

[killbill]> select invoice_number, invoice_id, invoice_balance, invoice_amount_paid, invoice_amount_charged, invoice_amount_credited from analytics_payment_purchases where account_id = '1cf83538-9117-4386-94da-82c7328ce0b0' order by invoice_number;
+----------------+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
| invoice_number | invoice_id                           | invoice_balance | invoice_amount_paid | invoice_amount_charged | invoice_amount_credited |
+----------------+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
|             38 | 67670acf-4f61-4ab5-9e5f-d9578fad8717 |          0.0000 |             10.0000 |                10.0000 |                  0.0000 |
|             39 | 290425ac-949b-453a-bb7d-384c5949608c |          0.0000 |              0.0000 |                10.0000 |                -10.0000 |
+----------------+--------------------------------------+-----------------+---------------------+------------------------+-------------------------+
In #93,
we stopped refreshing payments for INVOICE_CREATION and INVOICE_ADJUSTMENT events.

Payment rows still need to be updated (if they exist) when CBA is distributed, as
the balance may change.

This fixes #105.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
@pierre pierre requested a review from sbrossie Nov 4, 2019
@sbrossie sbrossie merged commit 10b3d59 into work-for-release-0.21.x Nov 5, 2019
4 checks passed
4 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: test-h2 Your tests passed on CircleCI!
Details
ci/circleci: test-mysql Your tests passed on CircleCI!
Details
ci/circleci: test-postgresql Your tests passed on CircleCI!
Details
@pierre pierre deleted the fix-for-105 branch Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.