Fix TypeError by handling NoneType in set_print_format_fields #41503
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.
##Details
This pull request fixes a TypeError in the set_print_format_fields method of the Journal Entry doctype. The error occurs when attempting to add a float to a NoneType. The changes ensure that NoneType values are handled properly by using the flt function with a default value.
##Problem
When running the Payment Reconciliation process, a TypeError is thrown due to an attempt to add a NoneType to a float. This occurs when either debit_in_account_currency or credit_in_account_currency is None.
##Solution
The solution involves updating the set_print_format_fields method to use the flt function with a default value of 0.0, ensuring that NoneType values are converted to 0.0.
##Changes Made
Modified the set_print_format_fields method in journal_entry.py to handle NoneType values properly.
Updated the calculation logic to use flt(d.debit_in_account_currency, 0.0) + flt(d.credit_in_account_currency, 0.0).