Formatter formatCurrency not working

Hello everyone,

I have encountered an issue with the formatCurrency expression in my app, and I’m seeking assistance to resolve it. I suspect that the problem arose after I performed a plugin upgrade yesterday.

The error message I am receiving in Chrome’s console is as follows:

Formatter formatCurrency in expression [importe.formatCurrency('$', ',', '.', 2)] doesn't exist for type string

What’s perplexing to me is that “importe” is not a string; it is, in fact, a numeric value. Moreover, the formatter appears to be functioning correctly in the sum row, as indicated by the green highlight. However, the rows marked in red are the ones where the issue is occurring.

Below is the code for my table:

                        <table class="table table-sm table-hover border-secondary">
                            <thead>
                                <tr>
                                    <th>Fecha</th>
                                    <th>Proveedor</th>
                                    <th>Tipo</th>
                                    <th>PV - Comprobante</th>
                                    <th>Rubro</th>
                                    <th>Descripcion</th>
                                    <th>Importe</th>
                                    <th>Saldo</th>
                                </tr>
                            </thead>
                            <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="queryComprobantes.data.querySIAC.data" id="tableRepeatSIAC">
                                <tr dmx-on:click="modalAgregarGasto.show();modalAgregarGasto.detailGastoApagar.select(comprobante)">
                                    <td dmx-text="fecha.formatDate('dd/MM/yyyy')"></td>
                                    <td dmx-text="proveedor"></td>
                                    <td dmx-text="tipo"></td>
                                    <td dmx-text="pv+' - '+numero"></td>
                                    <td dmx-bs-tooltip="rubro" class="text-center"><i class="fas fa-info-circle"></i></td>
                                    <td dmx-bs-tooltip="descripcion" class="text-center"><i class="fas fa-info-circle"></i></td>
                                    <td dmx-text="importe.formatCurrency('$', ',', '.', 2)"></td>
                                    <td dmx-text="saldo.formatCurrency('$', ',', '.', 2)"></td>
                                </tr>
                            </tbody>
                            <tbody class="table-secondary">
                                <tr>
                                    <th scope="row" colspan="6" class="text-end">Totales</th>
                                    <td dmx-text="queryComprobantes.data.querySIAC.data.sum(`importe`).formatCurrency('$', ',', '.', 2)"></td>
                                    <td dmx-text="queryComprobantes.data.querySIAC.data.sum(`saldo`).formatCurrency('$', ',', '.', 2)"></td>
                                </tr>
                            </tbody>
                        </table>

You have to convert to number first.

[importe.toNumber().formatCurrency('$', ',', '.', 2)]

It worked, but why did it work correctly before, and now it’s not working? Did some update cause it to fail?

It is a decimal I suppose, so it is considered as a string and needs the .toNumber() formatter before the formatCurrency formatter

Now, about the sum it is automatically doing it and doesn’t need toNumber() before formatCurrency()

Still I can’t understand why is not working now when it did worked before…

I don’t know…
Maybe you remember of normal numbers my friend. Decimals in wappler are always appear as strings and you can check that if you see a serveraction output in your network tab.
Allthought you can perform calculations with them

Maybe it’s related to updating my server’s MySQL version to MySQL 8. This is interesting behavior that may be related to Wappler’s ORM. Prior to the update, DECIMAL values were being retrieved as numbers. However, post-update, these same DECIMAL values are now being returned as strings, encapsulated in quotation marks ("").

Has anyone else experienced this? I’ve looked into MySQL 8’s documentation and couldn’t find any setting that might have caused this change in behavior directly. It leads me to suspect that this could be an interaction between MySQL 8 and Wappler’s ORM.

Not sure, it’s always been you have to convert to number first. Here is a thread from almost five years ago (February 2019) with the same problem.

1 Like

Javascript can be fun when it comes to numbers. Try storing 17.99 and then display it. I think it will return something like 17.9899999999989 or something like that!

1 Like