Creating a Finance App with Model-Driven Apps from Scratch – Part 2

<- Part 1

In the first part of this series, we created the basic app, and the tables and forms for portfolio and movements. In movements, we can select buy, sell, or adjust, but we should also be able to select what we are buying or selling. So in this post, we’re going to create the table Assets and add a lookup in movements to this table.

The table assets will have an asset type, which could be a tradable stock or a non-tradable asset. We won’t add currency because Dataverse already has support for currencies. We also won’t add options or bonds to keep the app simple. The reason for having a distinction between tradable and non-tradable is because in the future, we’ll automate price updates, but we can only do that with tradable assets.

We’ll also have a ticker, which is a symbol that identifies a stock. While there is a default format for tickers in Model-Driven Apps, I’m not going to use it. The first reason is that it creates a link to a webpage with stock info, but on my end, the link was broken. Also, I want more granularity when identifying stocks. Particularly, I want the user to select the exchange. That will be helpful when using APIs to update prices. Sometimes the same ticker may refer to different companies depending on the country, like ‘SIBN,’ which is a medical company in the NASDAQ and an energy company in the MOEX.

Finally, we’re going to add the price of the asset.

Assets table

Let’s open our solution and add a new table:

Because it’s just a single table, we can directly use ‘Table (Advanced properties)’.

I’ll leave the primary column tab with the default value (Name).

I’ll add a choice column for Asset type with stocks and nontraded assets. For the type, I’ll select ‘Yes’ sync and add a ‘New choice’:

Values are Stock and Nontraded.

I’ll add another choice for the Exchange:

Values are US equity, LSE UK, XETRA Germany, AIX Kazakhstan

Then the Price, in (currency):

Automatically, 4 fields will be created:

Currency represents the currency of the transaction. Exchange rate is a non-editable field that retrieves the exchange rate (provided by the currency entity). Price Base refers to the price in our base currency, while Price indicates the price in the foreign currency.

Finally, we’ll add a Ticker (Text) and Description (Text).

Next, we’ll edit the Main form:

The ‘Active assets’ view:

And we’ll add it to the app:

And finally, we have:

Now it would be easier for the user if we hide Exchange when it’s a non-tradable stock. We can do that with Business Rules:

It will open a UI where we need to create a condition. (make sure to select Apply, or the changes will not be saved.)

And what happen when this condition is true:

And we’ll set the visibility to false:

The same for when is false:

We can name the rule, save it, and activate it.

And we can create another business rule to make Price and Currency non-editable when it’s a stock (since we’re going to automate the price update).

It looks cool 🎯:

Movements table

Now we can add a relationship in the Movements table with Assets creating a new column of type lookup.

And add it to the form and the view:

We can hide this field in certain Movements when it’s not necessary, like in Deposits and Withdrawals, using Business Rules.


That’s all for today. In the next posts, we’ll explore how to automate price updates using Power Automate and a public API.

Part 3 ->


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *