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

Deal with non-WorldPay payments when updating balance #256

Merged
merged 1 commit into from
Sep 6, 2018

Conversation

irisfaraway
Copy link
Member

https://eaflood.atlassian.net/browse/WC-377

The finance_details.update_balance method previously just used payments with the correct world_pay_payment_status. However, payments by other means will never have this value. This commit changes the method to always count non-Worldpay payments when calculating the balance, while still only using WorldPay payments which have been authorised.

https://eaflood.atlassian.net/browse/WC-377

The `finance_details.update_balance` method previously just used payments with the correct `world_pay_payment_status`. However, payments by other means will never have this value. This commit changes the method to always count non-Worldpay payments when calculating the balance, while still only using WorldPay payments which have been authorised.
@irisfaraway irisfaraway self-assigned this Sep 4, 2018
irisfaraway added a commit to DEFRA/waste-carriers-back-office that referenced this pull request Sep 4, 2018
This test doesn't pass yet because of a bug in the engine which means it will always ignore non-Worldpay payments for the balance. Awaiting this fix: DEFRA/waste-carriers-engine#256
@irisfaraway irisfaraway merged commit f33eaaf into master Sep 6, 2018
@irisfaraway irisfaraway deleted the fix/update-balance-non-worldpay branch September 6, 2018 08:42
irisfaraway added a commit to DEFRA/waste-carriers-back-office that referenced this pull request Sep 6, 2018
* Finance users can record electronic bank transfer payment

https://eaflood.atlassian.net/browse/WC-377

A user with the finance or finance_admin role should be able to record when a bank transfer payment has been received. Recording the receipt of the payment should also update the balance.

This PR should lay the groundwork for recording payments of other types.

* Set up form objects for payments

Create a new PaymentForm and a TransferPaymentForm which inherits from it.

The form creates a new payment with attributes from the params and adds it to the transient_object (if valid).

* Set up TransferPaymentFormsController

We can now send requests to submit the form with the params. We also add the current user's email to the params so we can include that in the payment details.

There's also a rudimentary view, although this is missing fields – however, it's enough to pass the tests for now.

Also tweaked one of the existing tests so that it doesn't fail if the date in the factory is changed.

* Standardise field name

Let's use updated_by_user from the start, rather than flipping over from current_user_email.

* Get order_key from order

We'll be doing more with the order once DEFRA/waste-carriers-engine#255 is merged in.

* Add all fields to form

Add the necessary fields to the bank transfer form, plus microcopy.

* Validate the form

These validations are taken from the existing form in waste-carriers-frontend.

* Refactor PaymentForm to use new engine method

The WasteCarriersEngine now has a new Payment.new_from_non_worldpay method to create payments, so we can strip that out from the form. However, we do need to do a little more prep before we pass that data to the new method.

* Fix post-merge issue with authorising forms

After merging in the new role-based authorisation changes, the payment form broke as we hadn't yet added any authorisation.

We will be adding some authorisation for this form - however, just in case we have forms which don't, we should still fix this issue. This change means that we don't attempt to check authorisation if no auth method is passed in to the AdminFormController from the child form controllers.

* Move payment form into partial

This is in preparation for when we have multiple types of payment to enter.

* Only allow finance users to enter a bank transfer payment

All other users who try to access this page should be redirected to an error.

* Link from transient reg page to payment

Soon there will be an intermediary page where users can select the type of payment to log, but for the purposes of joining up the journey, let's link directly for now.

* Convert amount from pounds to pence

We ask users to enter this value in pounds (120.50) but it is stored in the DB in pence (12050), so we need to convert it before saving.

* Balance should update after payment is entered

This test doesn't pass yet because of a bug in the engine which means it will always ignore non-Worldpay payments for the balance. Awaiting this fix: DEFRA/waste-carriers-engine#256
@irisfaraway irisfaraway added the bug Something isn't working label Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants