Ask the application who has paid, who has not and who paid the wrong amount.
An agentic application can answer this because it reads the customer, agreement, invoice and payment records itself, applies your billing rules to every account and returns a reviewable list with the reason each account appears. The arithmetic stays in ordinary software. The agent handles the untidy part: matching payments, explaining short amounts and separating what is settled from what needs a decision.