Conversation
This mostly changes the way that certain data structures are interacted with, avoiding long calls when shorter refereces are possible. This commit does not yet fix any bugs and behaves identical to the code before this commit. However, it ensures that bugs can be fixed after.
The code is extremely complex for what it does. PLEASE NOTE: this does mess with localization with two strings in warnings in the use overpayment workflow. However not only was this workflow broken but the use of the translation API was also broken and therefore I do not believe this should prevent backporting.
Prior to this, the repeatedly updating the overpayment screen would eventually pass in an array as invoice date, and the amount due would be lost.
This fixes an unexpected blank line in the invoice search workflow.
This involved some further simplifying of the code in areas where there were some past bugs. Not sure exactly what the problem was, but it is now fixed. Now Cucumber tests are needed.
| $Payment->{"amount_$count"}; | ||
| if($invoice_id_amount_to_pay{qq|$Payment->{"invoice_id_$count"}|} | ||
| > $applied_due) { | ||
| $warning .= $locale->text('The amount of the invoice number').qq| $Payment->{"invnumber_$count"} |.$locale->text('is lesser than the amount to be paid').qq|\n|; |
There was a problem hiding this comment.
This use of $locale->text is so fundamentally broken I don't see a problem with introducing a new untranslated string in its place.
| # ojo no me gusta como esta implementado | ||
| ################################################################### | ||
| if($Payment->{"amount_$count"} < 0){ | ||
| $warning .= $locale->text('The amount of the invoice number').qq| $Payment->{"invnumber_$count"} |.$locale->text('is lesser than 0').qq|\n|; |
There was a problem hiding this comment.
Also fundamentally broken.....
| $amount_to_be_used{$ovp_selected_accno} += $Payment->{"amount_$count"}; | ||
|
|
||
| if($Payment->{"amount_$count"} > $applied_due) { | ||
| $warning .= $locale->text('The amount of the invoice number [_1] is less than the amount to be paid.', $Payment->{"invnumber_$count"}); |
There was a problem hiding this comment.
This is the first replacement which is untranslated
| } | ||
|
|
||
| if($Payment->{"amount_$count"} < 0){ | ||
| $warning .= $locale->text('The amount of the invoice number [_1] is less than 0', $Payment->{"invnumber_$count"}); |
There was a problem hiding this comment.
This is the second replacement which is untranslated.
|
@einhverfr are you working on fixing overpayments? If not, could you clean up the branches in this repo (and move them to your namespace)? I've been keeping the branches in the main repo to the bare minimum: all feature branches live in other repositories. Same for fix branches. |
| # we should rename the checkbox to remove_ or ignore_ | ||
| if ($Payment->{"checkbox_$count"} or not $Payment->{"entity_id_$count"}) | ||
| { | ||
| $count++; |
There was a problem hiding this comment.
This manual increase of $count is wrong now that $count is the loop variable
| amount => $Payment->{"amount_$count"} | ||
| } unless ($seen_invoices{$Payment->{"invoice_id_$count"}}++); | ||
| } | ||
| $count++; |
There was a problem hiding this comment.
Manually increasing the loop variable indicates a problem. Why does it need a manual increase here?
| if ($request->{"checkbox_$count"}) | ||
| if ($request->{"checkbox_$count"} or not $request->{"amount_$count"}) | ||
| { | ||
| $count++; |
This fixes all immediately known bugs with using overpayments/prepayments.
Please note -- there are two cases where current translation of strings is broken by this patch. This is because there were two uses of translation which concatenated variables and then concatenated further translated strings. This is fundamentally incorrect and leads to broken translations even without these changes. I am adding comments in line to point these out. If the consensus is better not to backport these, I will revert those lines specifically.