score:2

turn the payment ids into an iterable so you can shove the indexing concept off to the side, and zip up all four iterables at once.

not sure if this is exactly right since i don't have enough of your code to compile it, but something along these lines:

def credittransfer(invoices: list[invoice], salons: list[salon],
                   financialdetails: list[financialdetail]) = {
  val paymentids = stream.from(0).map(paymentid(pmtinfid, _))
  val credittxninforation =
    (invoices, salons, financialdetails, paymentids).zipped
      .map((invoicetosepaconverter.tocredittransactiondetail _).tupled)
}

Related Query