Hi, it's all or nothing, and it goes by the application transaction, not the payment. So whatever was applied in one posting comes off together, discounts and currency gains included.
Easier fix is upstream. If they apply invoices one at a time from the ledger entries instead of ticking twenty at once, each one is its own transaction and you can unapply just that one later. For the old ones already applied together there's nothing, unapply and reapply.
Custom code for this I'd avoid, too easy to break the ledger.
Glad to help - follow up if anything is unclear.
â–º If this solved it, marking it verified helps others too.
Regards,
Grigorios Mavrogeorgis
Business Central Consultant & AL Developer
Work: Gmsoft Limited
Blog: insidebusinesscentral
LinkedIn: linkedin.com/in/gregorymavrogeorgis