SUM the values within an ARRAY

Discuss here how to configure hoteldruid and better use its features.

Moderator: marco

Post Reply
dnaisbi
Posts: 1
Joined: Wed Jun 26, 2019 7:12 pm

SUM the values within an ARRAY

Post by dnaisbi »

Hello,
The subject really says it all, I need to learn how to sum the values in an array. For example the Array
sum([r]
[price_tot_p]
[/r]
will list the price of each reservation, but I need to know how to add them together.

The info here has been very helpful, but adding information on how to do equations within Arrays would be great:
http://www.hoteldruid.com/wiki/doku.php?id=document&rev=1523619495

I will be purchasing the hosting for multiple motels if I can get everything running well, I just want to make sure it will work well before the purchase.

It would also be VERY helpful if there was a place where everyone could post documents that they have made so others could use them if needed and everyone could also look at the documents to see how the different formulas were created.
marco
Posts: 1332
Joined: Tue Jul 05, 2005 6:00 pm
Location: Roma, Italia

Re: SUM the values within an ARRAY

Post by marco »

Hello,
I don't think you need an array to sum values of all reservations, just create a custom variable and add a condition to put it = 0 at the beginning of each reservations repetition and another condition to put it equal the sum of itself and the value you want to calculate. After the first repetition of reservations (you can also put [r][null_value][/r] at the beginning of the document) the variable will have the sum of all reservations.

Arrays are for special cases, for example when you want a repetition that doesn't match the reservations, like a repetition of days or % of taxes.

Regards,
Marco
Problems installing, configuring, upgrading?
Try the easiest way to use HotelDruid:
https://www.digitaldruid.net/hosted/index.php
Post Reply