Wallos monitor - api custom #497
ziritione85
started this conversation in
Guides and resources
Replies: 5 comments 3 replies
-
The total cost is incorrect because it only adds up the prices without accounting for the duration of the subscription. For instance, my monthly cost is $107.95, and my yearly cost is $1,295.45, but it was showing $224.99 instead. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I agree with your assessment - while this works well as a temporary
solution, there are some inherent limitations when working with the current
API structure. The calculation logic you’ve implemented is solid. I think
your idea of creating a dedicated widget or extension is the way to go.
As a minor enhancement, I consider adding the next payment date alongside
the subscription name in the “NEXT” section, which might provide useful
context at a glance and also add multi currency support.
{{ $currencySymbol := "$" }} <!-- Default currency symbol -->
{{ range .JSON.Array "subscriptions" | first 1 }}
{{ if eq (.Int "currency_id") 1 }}
{{ $currencySymbol = "€" }}
{{ else if eq (.Int "currency_id") 2 }}
{{ $currencySymbol = "£" }}
<!-- Add more currency mappings as needed -->
{{ end }}
{{ end }}
{{ $nextName }} ({{ $nextDate }})
I’ll try to put this all together and update my repo meanwhile a try to
build a Widget.
Thanks!
El El mar, 25 mar 2025 a las 7:07 a. m., Brandon ***@***.***>
escribió:
… I've replaced it with this, but it doesn't account for currency changes.
Our best option is to use get_monthly_cost, but that prevents us from
retrieving ACTIVE or NEXT. The best approach might be to modify it as a
widget (pull request) or extension.
template: |
{{ if eq .Response.StatusCode 200 }}
<div style="display: flex; justify-content: space-between;">
<div style="flex: 1; text-align: center;">
<p>ACTIVE</p>
<p class="color-positive">
{{ len (.JSON.Array "subscriptions") }}
</p>
</div>
<div style="flex: 1; text-align: center;">
<p>MONTHLY</p>
<p class="color-positive">
{{ $total := 0.0 }}
{{ range .JSON.Array "subscriptions" }}
{{ $monthlyCost := .Float "price" }}
{{ $cycle := .Int "cycle" }}
{{ $frequency := .Int "frequency" }}
{{ if eq $cycle 1 }} <!-- Daily cycle -->
{{ $monthlyCost = div (.Float "price") 30 }} <!-- Divide daily cost by 30 days to get monthly equivalent -->
{{ else if eq $cycle 2 }} <!-- Weekly cycle -->
{{ $monthlyCost = div (.Float "price") 4 }} <!-- Divide weekly cost by 4 for monthly equivalent -->
{{ else if eq $cycle 3 }} <!-- Monthly cycle -->
{{ $monthlyCost = div (.Float "price") (.Float "frequency") }} <!-- Divide monthly cost by frequency (months) -->
{{ else if eq $cycle 4 }} <!-- Yearly cycle -->
{{ if lt $frequency 2 }} <!-- If frequency is less than 2 (annual or less frequent) -->
{{ $monthlyCost = div (.Float "price") 12 }} <!-- Divide yearly cost by 12 for monthly cost -->
{{ else }} <!-- Multi-year frequency -->
{{ $monthlyCost = div (.Float "price") (mul $frequency 12) }} <!-- Divide by frequency in years * 12 months -->
{{ end }}
{{ end }}
{{ $total = add $total $monthlyCost }}
{{ end }}
${{ printf "%.2f" $total }} <!-- Format total to 2 decimal places -->
</p>
</div>
<div style="flex: 1; text-align: center;">
<p>NEXT</p>
<p>
{{ $nextDate := "" }}
{{ $nextName := "" }}
{{ range .JSON.Array "subscriptions" }}
{{ if eq $nextDate "" }}
{{ $nextDate = .String "next_payment" }}
{{ $nextName = .String "name" }}
{{ else if lt (.String "next_payment") $nextDate }}
{{ $nextDate = .String "next_payment" }}
{{ $nextName = .String "name" }}
{{ end }}
{{ end }}
{{ $nextName }}
</p>
</div>
</div>
{{ else }}
<div style="text-align: center;" class="color-negative">
Error connecting to Wallos: {{ .Response.StatusCode }}
</div>
{{ end }}
—
Reply to this email directly, view it on GitHub
<#497 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDIIQYNCQY3SANJB52J6RIT2WDXBBAVCNFSM6AAAAABZTFT6MOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRRGA3DKMI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
3 replies
-
Inactive subscriptions may not be taken in account, or as an alternative be
shown as that in a separate way. But this broke the initial nature of this
monitor, a simple glance to see what’s going on in your wallos instance.
The last image is the way to go, also I still think we can at price near
the name of the upcoming subscription, and a link to wallos itself.
El El mar, 25 mar 2025 a las 5:23 p. m., Brandon ***@***.***>
escribió:
… If you end going the widget route, I think expanding on NEXT is a good
idea. Something like this:
image.png (view on web)
<https://github.com/user-attachments/assets/0b363cb2-2090-4959-806e-0ca45255f9d8>
—
Reply to this email directly, view it on GitHub
<#497 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDIIQYJIGJWZY77PMKQX3H32WF7H7AVCNFSM6AAAAABZTFT6MOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRRG43DEOI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
[image: image.png]
implemented the changes that we have been commenting on and also added an
additional table to show next, date and amount. I update the code in my
repo pending its official acceptance. On the other hand, I will start
working on the widget. Thanks for your help!
El mar, 25 mar 2025 a las 17:26, Marcos ***@***.***>) escribió:
… Inactive subscriptions may not be taken in account, or as an alternative
be shown as that in a separate way. But this broke the initial nature of
this monitor, a simple glance to see what’s going on in your wallos
instance.
The last image is the way to go, also I still think we can at price near
the name of the upcoming subscription, and a link to wallos itself.
El El mar, 25 mar 2025 a las 5:23 p. m., Brandon ***@***.***>
escribió:
> If you end going the widget route, I think expanding on NEXT is a good
> idea. Something like this:
>
> image.png (view on web)
> <https://github.com/user-attachments/assets/0b363cb2-2090-4959-806e-0ca45255f9d8>
>
> —
> Reply to this email directly, view it on GitHub
> <#497 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BDIIQYJIGJWZY77PMKQX3H32WF7H7AVCNFSM6AAAAABZTFT6MOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRRG43DEOI>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here's my small contribution. It's a small monitor to display the total active subscriptions, the total cost and the next subscription to be renewed in your Wallos page
Wallos monitor by ziritione85
Beta Was this translation helpful? Give feedback.
All reactions