The room price calculation
We need the calculation of a room price in a number of places. At least the Journal and the Stay have this requirement. We can also foresee a future enhancement of a Web Service returning a price, based on an inquiry or a wizard for manual inquiries.
Although the price is based on three elements—Room Code, Season Code, and Guest No., the Room is the only process that is mandatory and can be assigned as the owner of the process. Rather than implementing the price calculation as a member of the price table, we will implement this as a member of the Room. From a functional perspective, the reason is that we know the room and want to know the price, and not the other way around.
The following code is the function on the Room table. It can be called with the optional members—Season Code and Customer No.-and calls into a method Codeunit with these parameters:
GetPrice(SeasonCode : Code[10];CustomerNo : Code[20]) : Decimal EXIT(RoomCalculatePrice.GetRoomPrice...