Fee revamp - #17
Open
badal8381 wants to merge 19 commits into
Open
Conversation
…tize payload fields - Remove custom GrayQuest API Log DocType and api_client module - Use Frappe built-in Integration Request for API call logging - Add log_request and make_request methods to GrayQuestSettings - Strip whitespace from all email fields in API payloads - Route customer_mobile through _clean_mobile_number in all payment flows - Use response.ok instead of hardcoded status code checks
…in webhook handlers
Mark is_emi_payment on emi.form.submitted, unmark on emi.rejected and emi.backout. Remove payment plan discount on form submission instead of at payment URL generation time.
fix: set is_emi_payment on form submission and remove discount
- Skip handle_response for EMI payments on success page - Detect EMI when payment_term (udf_3) is missing or "EMI" - Show "EMI Form Submitted" message with redirect to fee page - Remove unnecessary Admin login from handle_response - Fees not marked as paid for EMI (webhooks handle disbursement)
- Removed fetching of program name and sequence from student details. - Added retrieval of program abbreviation for student class ID assignment. - Implemented error logging for missing program abbreviation. - Enhanced EMI payment handling to use db_set for setting payment status.
- Consolidated class ID retrieval into a dedicated function for better readability and maintainability. - Updated student details functions to utilize the new class ID retrieval method. - Removed redundant code related to program name and sequence fetching.
…uest payload When a student is promoted but has outstanding fees from the previous class, the class_id was incorrectly derived from the student's current program. Now fetches the program from the Fees document for accurate class_id mapping.
…g against None doctype - Success page now only redirects, payment processing is handled by webhook - Add None check for doctype in add_webhook_log to prevent TypeError
When no valid mobile number is available, send empty string to GrayQuest instead of the hardcoded 9999999999 placeholder.
- Accept split_payments_emi in _build_fee_headers for separate EMI splits - _apply_payment_prefixes uses pg_headers for _PG and emi_headers for _EMI - Add isinstance guard for split_payments_emi type safety - Backward compatible: falls back to pg_headers when emi splits not provided
- Updated the webhook to remove payment plan discount for "emi.process.completed" and "emi.disbursed" events, in addition to "emi.form.submitted". This ensures discounts are removed appropriately as the EMI process progresses.
Refactor/dual mode fee headers
Partially reverts the parent-doc move made in 1fad43b. Marking is_emi_payment on the Fees parent leaves no way to express "this installment is under EMI", so funding installment 1 blocked payment of installment 2 permanently. Note that emi.process.completed means the process finished, so latching the flag there is what made the block permanent. - read the originating installment from udf_3 and record it on GrayQuest EMI Status - set/clear the blocking flag on the matching Payment Schedule row; only in-flight events block, every terminal event releases - clear the parent flag on emi.rejected / emi.backout - pass payment_term into handle_emi_payment so duplicate emi.disbursed webhooks resolve to the same installment instead of the next unpaid one The Payment Schedule custom field is owned by edu_quality's module customisations, not this app's fixtures, so the hooks.py fixtures filter stays as it is.
fix: track EMI state per installment on Payment Schedule
set_term_emi_flag cleared the flag on every terminal event, including the Process Completed rows that trail a disbursal - five of them on the fee that prompted this. That erased the record of which installment EMI funded, written when the payment is authorised. Clearing only ever serves to release an installment someone still has to pay, so it is now skipped once the installment has no outstanding left. A rejection or backout on an unpaid installment still releases the payment portal exactly as before.
emi.disbursed fell outside EMI_IN_FLIGHT_EVENTS, so the flag was cleared on arrival and set again a moment later once the installment settled. The intermediate write served nothing: from the moment GrayQuest hands over the money, collecting the installment from the parent again is the worse error, so the flag is now set on the disbursal itself and stays set even if the settlement that follows fails. A rejection or backout also no longer clears the fee level flag once EMI has funded an installment. Money moved, and Fees.is_emi_payment drives both the EMI details tab and the payment plan discount gating - clearing it on a later application's backout misreads the fee and can re-apply a discount to an amount EMI already funded in full.
Fix/gq emi funded term flag
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.
No description provided.