Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem bei der Berechnung

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
rehman
Smarty n00b


Joined: 16 May 2019
Posts: 1

PostPosted: Thu May 16, 2019 10:27 am    Post subject: Problem bei der Berechnung Reply with quote

Ich habe Problem bei der Berechnung wegen Komma und Punkt.

bei einem Variable (Gesamtsumme) möchte ich 23,50 Euro addieren.

z.B 1000+23,50 = 1.023,50 das muss Ergebnis und format sein. Da Smarty kein Komma akzeptiert. schreibe ich 23.50.

Beispiel:
{assign var = "amount" value =$variable|replace:',':'.'}
{math equation = "x+y" x=$amount y=23.50 format="%.2f"}

als Ergebnis addiert der Variable 1000+23.500 statt 23,50 und gib 24.500 Euro
Es muss so sein 1.000+23,50= 1.023,50
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 18, 2019 11:17 am    Post subject: Reply with quote

Either do your calculation before calling Smarty, or don't pass pre-formatted values to Smarty.
Preferable both. Totals calculation is part of business logic of your app and should be done in app, not in template, and formatting should be done in the template, not in the app.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP