How to aggregate payment records (Amount) and then update an Outstanding Balance value in another form

How to aggregate payment records (Amount) and then update an Outstanding Balance value in another form

As the title suggests, I am struggling to both aggregate a form (Form A) that collects payments made against specific invoices (the matching value between the two forms or reference field is the PO#) and then updating a field on Form B that reflects the outstanding balance (or Total minus Sum of Form A payments). Any assistance would be GREATLY appreciated. Thank you.

In theory, the outcome should be as follows. Form A captures payments made against invoices. Form B is updated when Form A has an applicable payment submitted and updates the Outstanding Balance field/value in Form B. Form B is used to track the invoice itself and includes the total for the invoice, any deposits, and the outstanding balance owed. Form A only tracks payments made by customers.