WoollyinWalesIT / jomres

Jomres Core, the online booking engine and portal for Joomla and Wordpress
https://www.jomres.net
GNU General Public License v2.0
40 stars 36 forks source link

Add micromanage tariffs modifications by using jomres API and a script #396

Closed joniale closed 4 years ago

joniale commented 5 years ago

Dear Vince and Jomres Developers, I have already discussed this with you, but i wanted to put this visible to the community. I would like to have a new feature in jomres. This new feature is about adding the option of coding in PHP the modifications of the different tariffs of a property. This could save a lot of time to owners and managers of a property.

I mean, this feature expands the concept of Microtariff management not only with the current visual way of editing the tariffs (point and click many times) to a more automatic batch way of doing the modifications. This is by allowing the users to script the modifications of the tariffs in a script e.g. php. (using the jomres API for tariffs)

Jomres already have an API in php to access the tariffs on the microtariff mode. That is already done. See API here: public_html/jomres/core-plugins/api_feature_tariffs/PUT/tariffs.php //////////////////////////////////////////// a e.g. snip //assume on one day there is a tariff tariffinput[1520121600] : 65 //65 euros is the new price of the tariff for epoch time 1520121600 You can send multiple dates, each one of those integers is the epoch for that particular date, and you can do something like $jrportal_rates->tarifftype_id = 33; //modification for tarifftype_id 33 superior room $jrportal_rates->dates_rates = array( "1520121600" , 65 + 10 ); // See the plus 10 € price modification for that date //////////////////////////////////////////// It is easy in a script to create a loop from one epoch day to other epoch day and change the prices for a range. The owner would be able to modify in one shot all the tariffs very fast by using variables on those date ranges (epochs) and in the prices for each tariff ids. The user would only have to change those variable values once and execute the script!. If you are a manager with many properties and many tariffs that is definitely what you want!

One possible implementation could be to add in the microtariff management page GUI: 1) A button to edit a script file that is created for each property. Initially this is empty. 2) A button to run the script file that will modify the tariffs. At risk of the owner. (the user needs to know that he can run code that modify many prices with one click, if the script is empty then do nothing) 3) Include in the property list of tariffs the information of the tariff ID. That will make easier for the user to create/edit the script, since most of the commands needs the previous knowledge of that ID. 4) One small example documentation would be appreciated.

Again, I think that will be much more useful that the visual way to set the new tariffs. I know that many persons do not know how to code. But once they realize that the code is using always the same functions and understand the behavior it would be much much easier and faster to modify the prices of a property by using the script than going through all the tariffs visually and performing the changes.

What do you think? Would it be possible to have this in the future for jomres? I am looking forward your comments.

joniale commented 5 years ago

Optional: it would be nice if this php tariff API could access to some calculated variables that are useful to calculate dynamic prices. Somethin like the wiseprice plugin does. See http://www.jomres.net/manual/property-managers-guide/49-your-toolbar/settings/property-configuration/253-wiseprice-or-lastminute (execution of cron jobs over these tariff API scripts would be then needed).

The idea is that a cron job executes regularly the tariff API script. This tariff API script will be able to put reduced prices for the next x coming days (last minute prices) as the wiseprice does. The script could have access to the percentage of occupation in the month, week, day, (high season automatic identification). This value can be used to increment or reduce prices dynamically.

This is related to this thread https://github.com/WoollyinWalesIT/jomres/issues/282#issue-317555166

iurirosa commented 4 years ago

This would be a nice feature for many Jomres/Beds24 customers.

We could send daily prices into Micromanage tariffs in Jomres , Jomres could potentially be "treated" as a channel, would be a outstanding feature for Jomres/Beds24 customers.

With this feature it would also be possible to use Pricelabs or RoomPriceGenie.

jomres commented 4 years ago

Howdy,

See https://api.jomres.net/?version=latest#b410a6f9-589c-4405-85c7-61101f0f5f4d

joniale commented 4 years ago

Howdy,

See https://api.jomres.net/?version=latest#b410a6f9-589c-4405-85c7-61101f0f5f4d

Thanks Vince. Nice to see that these are curl commands that can be called from outside jomres. Only downside is that it could be a security problem. However, it makes everything easy to execute. Just one question, On which version of jomres is this API working? Thanks!

jomres commented 4 years ago

It's as secure as your CMS user's account. In a way it's more secure because if you're compromised you just change the api keys.

You'll need the CMF REST API, which I've talked about (links below) because it's a massive task which has already taken months. CMF REST API 0.4> and 9.21.4 (to use that today you'd need the Nightly branch)

https://www.jomres.net/blog/114-channel-management-framework-first-look

https://www.jomres.net/blog/115-channel-management-framework-introduction

https://api.jomres.net/?version=latest#536ee4dd-8b8f-4905-b708-19fc34254cf6

http://www.jomres.net/manual/developers-guide-2/63-jomres-api/394-creating-a-new-property-with-the-cmf-rest-api

http://www.jomres.net/manual/installation-and-upgrading-2/370-installing-updating-to-the-nightly-branch

joniale commented 4 years ago

Great thanks!

joniale commented 4 years ago

Just for your information, many will find this online conversion tool useful with the new REST API. https://incarnate.github.io/curl-to-php/

This will instantly convert curl commands to PHP code! Probably, you will have a PHP script in your server which will calculate the curl commands needed for your tariffs.

jomres commented 4 years ago

Is somebody going to tell them that the API shows it as PHP too?

jomres commented 4 years ago

The API docs page, I mean

joniale commented 4 years ago

OK Thanks for telling me :1st_place_medal: , i did not see the selector on the top. I must be blind, i did not expect that! Good doc Vincent.

image

jomres commented 4 years ago

In line with policy changes mentioned here https://www.jomres.net/blog/116-price-adjustments-2020 I've released a new version of the plugin manager (and made changes on the plugins server) which allow you to install the CMF plugins if you have a valid Jomres license. You won't need a cmf license.

Be aware that for a little while longer the "api feature cmf" will undergo some changes as yet, I'm still figuring some stuff out with respect to work I'm doing with the rentals united thin plugin. Nevertheless, you can install the api feature cmf plugin and the channel management framework plugin, but before you do that :

Install the Nightly, then (and this is super important) remember to go to Tools > Database Integrity Check before installing the cmf plugins.

Then update the plugin manager regardless of whether or not you're prompted to, and then finally the cmf plugins.

I use Postman for testing, it has the added benefit for you guys and girls that you can import endpoints from the https://api.jomres.net documentation and test them against your own development installations.

I've had a torrid week, my development pc crashed on Saturday, then again fatally on Thursday meaning I've had to switch all dev to a slower machine and I'm in the process of catching up. Basically I've lost a bloody week. Don't expect too many responses from me for the next few days while I pull things together again, help each other out if somebody asks and you think you know the answer.

joniale commented 4 years ago

Thanks Vince for posting this. I have renewed my essential subscription today. Lets see if i find time to try the nightly build. If i can´t the following weeks, then i think i will do it ,for sure, with the 9.21.4.

joniale commented 4 years ago

tariffs_modification_update_example.txt

I have written a small php script to test the API. I have renamed to extension .txt This is just a test concept and see what the API does. Maybe, somebody can find the script useful to start. Any collaboration and comments would be appreciated.