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

Mwst. 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
masterxx
Smarty n00b


Joined: 17 Dec 2012
Posts: 3

PostPosted: Mon Dec 17, 2012 12:49 am    Post subject: Mwst. Berechnung Reply with quote

Hi,

Ich benutze Smarty zum ersten mal.

Folgendes Problem:
Ich will im Template die Mwst. berechnen das mache ich z.B so:
{($article->price->price*0.19)|string_format:"%.2f"|replace:".":","}

Das klappt auch bei den meisten ganz gut
21,01 * 0.19 = 3,99

aber unter umständen kappt es nicht:
Richtig wäre: 12,61 * 0.19 = 2,39 raus kommt aber 2,40

Kann es sein das string_format rundet ? wenn ja wie kriege ich das raus?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Dec 17, 2012 5:16 pm    Post subject: Reply with quote

Mehrwertsteuerbeträge sind kaufmännisch zu runden. 2,40 ist also der richtige Betrag.
Back to top
View user's profile Send private message
masterxx
Smarty n00b


Joined: 17 Dec 2012
Posts: 3

PostPosted: Mon Dec 17, 2012 5:34 pm    Post subject: Reply with quote

U.Tews wrote:
Mehrwertsteuerbeträge sind kaufmännisch zu runden. 2,40 ist also der richtige Betrag.


Das ist mir schon klar. also rundet string_format doch!

So müsste es sein !

15.00 € Brutto = 12.61 € Netto und 2.39 € Mwst.

Gibt es eine Möglichkeit ohne Rundung zu Formatieren dann lasse ich mir einfach 3 Stellen ausgeben und schneide den rest weg von rechts dann ist es richtig.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Dec 17, 2012 6:37 pm    Post subject: Reply with quote

Der string_format Modifier ruft die PHP Funktion sprintf() die immer rundet.

Du müsstest dann also nach 2 Nachkommastellen abschneiden.
Back to top
View user's profile Send private message
masterxx
Smarty n00b


Joined: 17 Dec 2012
Posts: 3

PostPosted: Tue Dec 18, 2012 1:11 pm    Post subject: Reply with quote

U.Tews wrote:
Der string_format Modifier ruft die PHP Funktion sprintf() die immer rundet.

Du müsstest dann also nach 2 Nachkommastellen abschneiden.



und wie mache ich das im Template ?

Erledigt ich mache es jetzt so:

{($article->price->price*0.19)|substr:0:((($article->price->price*0.19)|strlen) - 2)|replace:".":","}
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Dec 18, 2012 8:00 pm    Post subject: Reply with quote

Das jedesmal im Template zu programmieren ist nicht im Sinne des Erfinders.

Ich würde dafür ein Benutzer Modifier Plugin für die Mwst Berechnung und Formatierung kreieren.

Siehe http://www.smarty.net/docs/en/plugins.modifiers.tpl
Back to top
View user's profile Send private message
Shorty88
Smarty n00b


Joined: 04 Jan 2013
Posts: 3

PostPosted: Fri Jan 04, 2013 1:27 pm    Post subject: Reply with quote

U.Tews wrote:
Das jedesmal im Template zu programmieren ist nicht im Sinne des Erfinders.

Ich würde dafür ein Benutzer Modifier Plugin für die Mwst Berechnung und Formatierung kreieren.

Siehe http://www.allnet-flat-angebote.de/

Denke auch dass es nicht im Sinne des Erfinders ist. Würde es auch so machen
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