31
Views
4
Comments
Solved
The best design pattern for creating a receipt
Question

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?

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

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

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