baserider's avatar

Calculate price depending on 2 models

Hi,

i have 2 models (seminars and seminar dates). The price of an seminar depends on data of the 2 models, e.g. there is an early bird price which depends on the start date in the the seminar_date model and the regular price in the seminar model. These 2 criterias i need in order to calculate the correct price. What is a good practice or pattern in order to solve this?

0 likes
2 replies
bobbybouwmann's avatar

I would probably add a method to one of the models to calculate the price. The models are related to each other so you can use the relationship in that method to get all the database, calculate the price and return it.

bobbybouwmann's avatar

You can pass the data to this method, right? Or use the relationship to get the parent object.

Please or to participate in this conversation.