Hello Devs! ??

Considering that I have the following Entities and that I want to create a receipt that contains the amounts spent on room service and the cost of hosting, what would be the best design pattern that I could use for data modelling? How could I store this receipt in the DataBase and then send it to the customer via email?

Hi,

When you say to save a receipt, do you mean to save a Binary document, or to save only the receipt information?

If it is the binary, it works as if it were an image, you create an entity on the side, with the name Receipt (for example), and keep the binary there, in Booking you have a reference to the entity of the receipt.


When it comes to sending by email, you can build the email yourself, you have to configure the email in the Service Center, and then just create an action, for example a button or a timer, which calls the action of the email.

  • Send an Email From a Web Application
  • Reactive Web:
    • It seems that you are trying to implement those solutions within the same service studio application. You need to create a new Traditional application to have access to the email functionality and consume it in your Reactive app. If you are creating a module within the same application as your Reactive app, you won't have the Traditional web option.
  • Mobile:
    • You need to do this in server side , you must have an eSpace in OutSystems server where you have your entities , You can create a function there to send an email and use it in your mobile espace.

      Doing this you can use default OutSystems functionality to send email, else you need to find some Cordova plugin to send email directly from mobile.

    • Demo Forge Component: How-to: Send emails from a Mobile App


About Storing image/file in entity or structure:

  • You use the Binary data type to do so. What I'd like to add, is that in case you want to store them in the database, it is good practice to have a separate Entity that contains just an Id and the Binary data (and optionally the file name or the like). The reason for this is that databases store binary content in a specific way, which may interfere (as in "slow down") with normal database stuff like searching and indexing.

  • So say you want to store the image/file of a receipt, and you already have a Booking Entity, create a separate BookingReceipt Entity that stores the image/file, and uses a "Booking Id" as its identifier (so you have a 1:1 relationship).


Cheers

Hi Miguel! Thanks for your reply.


Regarding your question at the beginning of your answer, I intent to save the receipt as PDF file and to send it by email.

However, I guess you already answered my question on your explanation.

Let me see if I understood. I will save the file in a new Entity which has a 1 to 1 relationship with the Booking Entity. Considering that I still need to fetch the specific data in order to build the receipt, let's suppose I want to show this information (the data fetched) on the screen before creating a receipt file and then to use the check-out button to generate and save this information as PDF. What is the best manner to fetch the data? Do I need to create another Entity, Structure or something like that?  Do you know some documentation or post that could help me with this procedure?

Now, regarding sending an email as soon as the check-out is done and the receipt file is stored, I didn't know that is only possible using Traditional Web, once I'm developing in Reactive.


I appreciate your help and the links mentioned above.


Thanks for now.

Solution

So to get the data, you just have to use an aggregate, filtering by the booking ID you want.

Have you taken any of these courses? 

Because there you have exercises that explain these simple things.


Nothing like that, you can have this logic also in reactive, and I explain in my previous comment how you can do it in Reactive. As soon as you press the button to check out customers, you can automatically generate the action to create the receipt and send it to customers.


Send Email Reactive Web:

  • It seems that you are trying to implement those solutions within the same service studio application. You need to create a new Traditional application to have access to the email functionality and consume it in your Reactive app. If you are creating a module within the same application as your Reactive app, you won't have the Traditional web option.


Cheers,

Miguel

Solution

Yeap, I have taken both courses and got the Traditional Web Certification so far. I thought that there could be a more suitable way to do this using something different. But I see that doing that with Aggregates is easier.

Miguel Verdasca thanks for your support, you helped me a lot.