using this we can set the flag for the invoice which are paid and calculate the amount based on the receipt.
As shown in the below image once the amount is receipt is created for that invoice we can set Invoice_flag to true so based on this we can show only the open invoice on the condition

Also create a field called remaining_amount in the firebase for each invoices and add if the flag is false and having the remaing_amount values instead of showing the total amount show the remaing_amount values as shown in the below image
