I got a Product and a collection of Payers. The Payers can pay for the product in three different ways, either but manually set the percentage, by Payers income or by the value of the Payers respective holdings.How the product is paid is determined by an enum on the Product.
In my persistence layer i got three classes, Product, Payer, and ProductManuallyPaid which is a many-to-many class between Product and Payer if the Product is paid by manually, specifying the percentage each Payer will have to pay.
How should i map this to the view? I would like to have a new many-to-many class (which would consist of a reference to the Payer, a reference to the Product and the exact amount that payer should pay)?
I guess the calculation should be done in the Service Layer, but should the Service layer return a ViewModel/DTO version of the Product/Payer with a new many-to-many class attached, or should this be handled afterward? if it should be handled afterward, should the entity contain a list of that new Many-to-many class, but be ignored in the persistence layer?