package Ġio . ple o . ant ae us . core . services Ċ Ċ import Ġio . ple o . ant ae us . models . Invoice Ċ import Ġio . ple o . ant ae us . models . Invoice Charge Status Ċ import Ġio . ple o . ant ae us . models . Transaction Status Ċ Ċ fun ĠInvoice Charge Limiter Ġ( un paid In voices Ġ: ĠList < Invoice >, Ġinvoice Charge Results Ġ: ĠList < Invoice Charge Status >, Ġcharge Attempts Ġ: ĠInt ) Ġ: ĠList < Invoice >{ ĊĊĠĠĠ Ġvar Ġinvoice El igible For Retry Ġ= Ġinvoice Charge Results ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Ġ{ Ġit . transaction Status Ġ== ĠTransaction Status . Failed Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. groupBy Ġ{ Ġit Ġ-> Ġit . invoice Id Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Ġ{ Ġit Ġ-> Ġit . value . count () Ġ<= Ġcharge Attempts Ġ- Ġ 1 } ĊĊĠĠĠ Ġreturn Ġun paid In voices . filter Ġ{ Ġit Ġ-> Ġinvoice El igible For Retry . containsKey ( it . id ) Ġ} Ċ }