...
When reducing the deficit from the BorrowerAccount, beware that if any existing invoice is active the InvoiceItems needs to be reduce. That is explained in this page ->[Insert_InvoicePage] https://bricknode.atlassian.net/wiki/spaces/KB/pages/3872489508/Invoice+Items#Changing-the-Invoice-Items. Otherwise, the invoice will not be able to be paid since it can’t find any deficit on the account.
...