Hi,
As i am creating reactive inventory management application, I want to change the value of database dynamically. Suppose the stock of a medicine is 15 and the customer buys 5, then the value of stock should change from 15 to 10.
I am not getting exact logic for that. Could you please share any similar oml file?
Hi Pooja,
For this type of requirement you need to use BPT process to achieve this.
Thanks
CV sharma
Why you need a BPT process for this? To update data in the database it is not a prerequisite to use BPT.
Hello there pooja,
Hope you're doing well.
So it seems that you have this value (stock) stored as an attribute in the database.
By the time that a customer buys 5 items of a medicine, you will need to call a Server Action in order to fetch that medicine record (using an Aggregate) and you should update the stock attribute with the correct value.
You should update this record (in the stock attribute) by calling Update<Entity> action. So inside the Server Action, you will need to call this action to update the value for the new available stock. You just need do update the specific record of that medicine with the correct value for the new stock.
Hope that this helps you!
Kind regards,
Rui Barradas
Hello Pooja.
A dynamic update would mean "for each order created, update my table".
The normal way is, call an action to update, based on how much you placed on the order.
-You have product id and quantity.
-You search inventory by productid, edit that record to minus quantity, and do an update.
I made this example where you update stock. If the number is positive, you add stock. If negative, you remove stock.
what if there are two enitites?
I assume that your stock entity will also use Productid somewhere so the main logic is still valid. If you want this fitted to your project, you have to show your datamodel.
I have attached the oml file.
Have you studied relational databases? In the Reactive course there are chapters on modeling data that you should watch.
The way you did it, when you edit the client your stock will be affected again by the same request. You can't just save quantities on the Customer table. You need an Order entity.How about starting from scratch?
You can use the sum of customer's purchase item to calculate the item quantity.
You can substract the sum of purchase quantity of customer's entity from item quantity of stock entity, and use create and update action of stock entity.
Hope this will help.
Regards,
Komal
Thank you.
I have one doubt that how to calculate sum of purchase quantity of customer's entity .
Go to the customer's aggregate and click on drop arrow on purchase quantity and select sum and it will create the sum of purchase quantity sum, please fins screenshot below,
if you still have questions then we can connect,
I want to calculate the sum of Purchase Quantity MedicineNamewise.
You can group by on Medicine name column and use sum functionality on purchase quantity column,
If your problem has solved then please marked this post as solved,
Thanks,