Skip to content

Conversation

@einhverfr
Copy link
Member

@einhverfr einhverfr commented Jun 12, 2025

This branch and (initially draft) Pull Request fixes Overpayments issues and allows overpayments to be posted on the master branch (tests forthcoming while in draft mode).

Please note that while I intend to backport this, I have also fixed two fundamentally broken uses of the translation API (which lead to untranslated strings in 1.12. I have left several other bad calls which will be a separate bug fix for master after this gets merged.

@ehuelsmann ehuelsmann requested a review from Copilot June 12, 2025 06:13

This comment was marked as outdated.

einhverfr added 13 commits June 14, 2025 20:29
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.
@ehuelsmann ehuelsmann requested a review from Copilot June 14, 2025 18:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses issues with overpayments processing by fixing broken translation API calls and modifying how overpayments are applied and displayed. The key changes include:

  • Adding a new helper method (script) in Payment.pm to select transaction scripts based on invoice status.
  • Refactoring and simplifying the overpayment logic in the payment processing script, including renaming variables and adjusting conditions.
  • Updating the UI template to accommodate new hidden fields and revised default values.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
old/lib/LedgerSMB/DBObject/Payment.pm Added a new method (script) with inline documentation for determining the script.
lib/LedgerSMB/Scripts/payment.pm Refactored overpayment logic, improved handling of invoice processing, and updated variable usage.
UI/payments/use_overpayment2.html Updated the form inputs by adding a hidden field for entity name and adjusting default values.
Comments suppressed due to low confidence (1)

lib/LedgerSMB/Scripts/payment.pm:1690

  • [nitpick] The input field 'checkbox_$count' is being used to skip processing; consider renaming it (e.g., to 'ignore_checkbox_$count') to clarify its purpose.
if ($Payment->{"checkbox_$count"} or not $Payment->{"entity_id_$count"})

options = vc_list
default_values = [ request.new_entity_id ]
default_blank = 1
default_values = []
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default_values to an empty list instead of [ request.new_entity_id ] may affect the pre-selected value; please confirm that this change is intentional.

Suggested change
default_values = []
default_values = [selected_value]

Copilot uses AI. Check for mistakes.
name => $name,
name => $vcname,
vc_discount_accno => $vc_info[$ref]->{discount}};
$n_name = $vcname if $vc_info[$ref]->{id} == $Payment->{new_entity_id};
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Ensure that $n_name is assigned a meaningful default value in cases where no vendor/customer id matches $Payment->{new_entity_id} to prevent potential issues later in the processing.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants