Conversation
Updated the Application model to incorporate subscription costs in total cost and balance due calculations. Refactored the PaymentsController and ActiveAdmin views to utilize the new total_cost method, ensuring consistent handling of subscription scenarios across the application. Added tests to verify correct computation of total costs when subscriptions are selected.
Implemented new test cases for the `subscription_cost` method in the Application model to ensure accurate cost calculations based on subscription selection. The tests cover scenarios for unselected subscriptions, selected subscriptions with configured costs, and cases with missing settings. This enhances the overall test coverage for application cost calculations.
Updated the `total_cost` method in the PaymentsController to handle potential errors when computing the total cost for applications. Added logging for exceptions to aid in debugging, ensuring that the method returns a default value of 0.0 in case of errors. This enhancement improves the robustness of payment calculations.
Enhance application cost calculations to include subscription fees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how the total application cost is calculated throughout the codebase by introducing a new
subscription_costmethod and updating thetotal_costcalculation to include the subscription fee when applicable. The changes ensure that all relevant controllers, admin views, and models consistently use the new logic, and adds comprehensive tests for these behaviors.Key changes include:
Application Model Logic
subscription_costmethod toApplication, which returns the current subscription cost if the user has selected a subscription, or zero otherwise. Thetotal_costmethod now includes this subscription cost in its calculation.balance_due_with_batchmethod to also include the subscription cost when computing the total.Controller and Admin Usage
ApplicationsController,PaymentsController, andapp/admin/applications.rbto use the newtotal_costandsubscription_costmethods from the model, ensuring consistency and reducing code duplication.Testing
application_spec.rbto cover the newsubscription_costlogic, the updatedtotal_costcalculation, and balance computations that include subscription fees.