1+ {% comment %}
2+ User base currency (EUR, USD, etc.)
3+ {% endcomment %}
4+ {% assign base = trmnl .plugin_settings .custom_fields_values .base_currency | upcase %}
5+
6+ {% comment %}
7+ Currency symbol mapping
8+ {% endcomment %}
9+
10+ {% if base == "USD" %}
11+ {% assign currency_symbol = "$" %}
12+ {% elsif base == "EUR" %}
13+ {% assign currency_symbol = "€" %}
14+ {% elsif base == "GBP" %}
15+ {% assign currency_symbol = "£" %}
16+ {% elsif base == "JPY" or base == "CNY" %}
17+ {% assign currency_symbol = "¥" %}
18+ {% elsif base == "UAH" %}
19+ {% assign currency_symbol = "₴" %}
20+ {% elsif base == "INR" %}
21+ {% assign currency_symbol = "₹" %}
22+ {% elsif base == "ILS" %}
23+ {% assign currency_symbol = "₪" %}
24+ {% elsif base == "KRW" %}
25+ {% assign currency_symbol = "₩" %}
26+ {% elsif base == "VND" %}
27+ {% assign currency_symbol = "₫" %}
28+ {% elsif base == "PHP" %}
29+ {% assign currency_symbol = "₱" %}
30+ {% elsif base == "RUB" %}
31+ {% assign currency_symbol = "₽" %}
32+ {% else %}
33+ {% assign currency_symbol = "" %}
34+ {% endif %}
35+
36+ {% comment %}
37+ Fetch rates
38+ {% endcomment %}
39+ {% assign forex = IDX_0 %}
40+ {% assign metals = IDX_1 %}
41+ {% assign crypto = IDX_2 %}
42+ {% assign stocks = IDX_3 %}
43+
44+ {% comment %}
45+ Initialize totals
46+ {% endcomment %}
47+ {% assign total_fiat = 0 %}
48+ {% assign total_metal = 0 %}
49+ {% assign total_crypto = 0 %}
50+ {% assign total_stock = 0 %}
51+
52+ {% comment %}
53+ Process fiat assets
54+ {% endcomment %}
55+ {% assign fiat_assets_string = trmnl .plugin_settings .custom_fields_values .fiat_assets %}
56+ {% assign fiat_assets = fiat_assets_string | split: ',' %}
57+
58+ {% for asset in fiat_assets %}
59+ {% assign asset_parts = asset | split: '=' %}
60+ {% if asset_parts .size == 2 %}
61+ {% assign symbol = asset_parts [0] | strip %}
62+ {% assign qty = asset_parts [1] | strip | times: 1 %}
63+
64+ {% if forex .rates [symbol] %}
65+ {% assign rate = 1 | divided_by: forex .rates [symbol] %}
66+ {% assign asset_value = qty | times: rate %}
67+ {% assign total_fiat = total_fiat | plus: asset_value %}
68+ {% endif %}
69+ {% endif %}
70+ {% endfor %}
71+
72+ {% comment %}
73+ Process metal assets
74+ {% endcomment %}
75+ {% assign metal_assets_string = trmnl .plugin_settings .custom_fields_values .metal_assets %}
76+ {% assign metal_assets = metal_assets_string | split: ',' %}
77+
78+ {% for asset in metal_assets %}
79+ {% assign asset_parts = asset | split: '=' %}
80+ {% if asset_parts .size == 2 %}
81+ {% assign symbol = asset_parts [0] | strip %}
82+ {% assign qty = asset_parts [1] | strip | times: 1 %}
83+
84+ {% if metals .rates [symbol] %}
85+ {% assign rate = 1 | divided_by: metals .rates [symbol] %}
86+ {% assign asset_value = qty | times: rate %}
87+ {% assign total_metal = total_metal | plus: asset_value %}
88+ {% endif %}
89+ {% endif %}
90+ {% endfor %}
91+
92+ {% comment %}
93+ Process crypto assets
94+ {% endcomment %}
95+ {% assign crypto_assets_string = trmnl .plugin_settings .custom_fields_values .crypto_assets %}
96+ {% assign crypto_assets = crypto_assets_string | split: ',' %}
97+
98+ {% for asset in crypto_assets %}
99+ {% assign asset_parts = asset | split: '=' %}
100+ {% if asset_parts .size == 2 %}
101+ {% assign symbol = asset_parts [0] | strip %}
102+ {% assign qty = asset_parts [1] | strip | times: 1 %}
103+
104+ {% if crypto .rates [symbol] %}
105+ {% assign rate = 1 | divided_by: crypto .rates [symbol] %}
106+ {% assign asset_value = qty | times: rate %}
107+ {% assign total_crypto = total_crypto | plus: asset_value %}
108+ {% endif %}
109+ {% endif %}
110+ {% endfor %}
111+
112+ {% comment %}
113+ Process stock assets
114+ {% endcomment %}
115+ {% assign stock_assets_string = trmnl .plugin_settings .custom_fields_values .stock_assets %}
116+ {% assign stock_assets = stock_assets_string | split: ',' %}
117+
118+ {% for asset in stock_assets %}
119+ {% assign asset_parts = asset | split: '=' %}
120+ {% if asset_parts .size == 2 %}
121+ {% assign symbol = asset_parts [0] | strip %}
122+ {% assign qty = asset_parts [1] | strip | times: 1 %}
123+
124+ {% if stocks .rates [symbol] %}
125+ {% assign rate = 1 | divided_by: stocks .rates [symbol] %}
126+ {% assign asset_value = qty | times: rate %}
127+ {% assign total_stock = total_stock | plus: asset_value %}
128+ {% endif %}
129+ {% endif %}
130+ {% endfor %}
131+
132+ {% assign grand_total = total_fiat | plus: total_metal | plus: total_crypto | plus: total_stock %}
133+
134+ <div class =" layout layout--col gap--space-between" >
135+
136+ <div class =" grid" >
137+ <div class =" item" >
138+ <div class =" meta" ></div >
139+ <div class =" content" >
140+ <span class =" value md:value--xxlarge lg:value--xxxlarge value--tnums" data-value-format =" true" >
141+ {{ grand_total | round: 2 | number_to_currency: currency_symbol }}
142+ </span >
143+ <span class =" label" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-wallet" ><path stroke =" none" d =" M0 0h24v24H0z" fill =" none" /><path d =" M17 8v-3a1 1 0 0 0 -1 -1h-10a2 2 0 0 0 0 4h12a1 1 0 0 1 1 1v3m0 4v3a1 1 0 0 1 -1 1h-12a2 2 0 0 1 -2 -2v-12" /><path d =" M20 12v4h-4a2 2 0 0 1 0 -4h4" /></svg >{{ base }}</span >
144+ </div >
145+ </div >
146+ </div >
147+
148+ <div class =" divider" ></div >
149+
150+ <div class =" grid grid--cols-2" >
151+
152+ <div class =" item" >
153+ <div class =" meta" ></div >
154+ <div class =" content" >
155+ <span class =" value md:value--large lg:value--xlarge value--tnums" data-value-format =" true" >
156+ {{ total_fiat | round: 2 | number_to_currency: currency_symbol }}
157+ </span >
158+ <span class =" label" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-cash" ><path stroke =" none" d =" M0 0h24v24H0z" fill =" none" /><path d =" M7 15h-3a1 1 0 0 1 -1 -1v-8a1 1 0 0 1 1 -1h12a1 1 0 0 1 1 1v3" /><path d =" M7 9m0 1a1 1 0 0 1 1 -1h12a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-12a1 1 0 0 1 -1 -1z" /><path d =" M12 14a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" /></svg >Fiat</span >
159+ </div >
160+ </div >
161+
162+ <div class =" item" >
163+ <div class =" meta" ></div >
164+ <div class =" content" >
165+ <span class =" value md:value--large lg:value--xlarge value--tnums" data-value-format =" true" >
166+ {{ total_metal | round: 2 | number_to_currency: currency_symbol }}
167+ </span >
168+ <span class =" label" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-medal" ><path stroke =" none" d =" M0 0h24v24H0z" fill =" none" /><path d =" M12 4v3m-4 -3v6m8 -6v6" /><path d =" M12 18.5l-3 1.5l.5 -3.5l-2 -2l3 -.5l1.5 -3l1.5 3l3 .5l-2 2l.5 3.5z" /></svg >Metals</span >
169+ </div >
170+ </div >
171+
172+ <div class =" item" >
173+ <div class =" meta" ></div >
174+ <div class =" content" >
175+ <span class =" value md:value--large lg:value--xlarge value--tnums" data-value-format =" true" >
176+ {{ total_crypto | round: 2 | number_to_currency: currency_symbol }}
177+ </span >
178+ <span class =" label" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-coin-bitcoin" ><path stroke =" none" d =" M0 0h24v24H0z" fill =" none" /><path d =" M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /><path d =" M9 8h4.09c1.055 0 1.91 .895 1.91 2s-.855 2 -1.91 2c1.055 0 1.91 .895 1.91 2s-.855 2 -1.91 2h-4.09" /><path d =" M10 12h4" /><path d =" M10 7v10v-9" /><path d =" M13 7v1" /><path d =" M13 16v1" /></svg >Crypto</span >
179+ </div >
180+ </div >
181+
182+ <div class =" item" >
183+ <div class =" meta" ></div >
184+ <div class =" content" >
185+ <span class =" value md:value--large lg:value--xlarge value--tnums" data-value-format =" true" >
186+ {{ total_stock | round: 2 | number_to_currency: currency_symbol }}
187+ </span >
188+ <span class =" label" ><svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" class =" icon icon-tabler icons-tabler-outline icon-tabler-chart-line" ><path stroke =" none" d =" M0 0h24v24H0z" fill =" none" /><path d =" M4 19l16 0" /><path d =" M4 15l4 -6l4 2l4 -5l4 4" /></svg >Stocks</span >
189+ </div >
190+ </div >
191+
192+ </div >
193+ </div >
0 commit comments