Loading ...
Sorry, an error occurred while loading the content.
 

Calculation clip doing crazy calculations

Expand Messages
  • swisscatdk
    Dear all I thought I had posted this yesterday but it doesn t appear in the list. Someone helped me with this clip about a year ago. For some year it doesn t
    Message 1 of 4 , Nov 4, 2008
      Dear all
      I thought I had posted this yesterday but it doesn't appear in the
      list.
      Someone helped me with this clip about a year ago. For some year it
      doesn't work properly any more. I am using NoteTab Pro (same problem
      occurs with NoteTab Light as well).
      Basically it concerns a calculation for payments by Paypal for
      tickets under the following conditions:
      - If the calculated Paypal fee is under 4 SFr then the Paypal fee
      should be set to 4 SFr. Otherwise it should be the genuine 5% (which
      Paypal takes off me in Switzerland as their fee).
      - The price of ticket can be anything from about 33 SFr upwards.

      The problems which occur are:
      1) As soon as the price of tickets + postage hit 200 SFr, the Paypal
      fee is incorrectly calculated as 4 Fr. 200 SFr seems to be a "magic
      number"
      2) When the Paypal fee is *under* 4 SFr, it sometimes doesn't change
      this to 4 SFr.
      3) For no reason which I can see, it sometimes seems to use the
      values from the previous order, resulting in 400+ SFr for a 35 SFr
      ticket.
      4) If postage is entered as 1 SFr this then results in a message
      depending on whether "Late" is set to 1 (=too late to send) or 0 (=
      customer wants to pick the tickets up in person). This part works
      fine.

      Below are the most important clip lines. If anyone has time to play
      around with them and test them with, say, ticket value of 35 SFr, 140
      SFr. and 201 SFr and get it to work correctly in all cases, I would
      be most grateful, because I am at my wits end.

      ^!Set %Tix%=^?[Tickets value only=1]
      ^!Set %Postage%=^?[&Postage=8.40|6.00|1.00]
      ^!Set %Late%=^?[&Too late to send=1.00|0.00]
      ^!Set %Paypal%=^$Calc((^%Tix%+^%Postage%)*0.05;2)$
      ^!If "^%Paypal%" < "4.00" Next ELSE Skip_1
      ^!Set %Paypal%=^$Calc(4*1)$
      ;following calculates Paypal fee
      Paypal fee corrected: CHF ^%Paypal%

      ---------------------------

      ^!Continue [Question]
      Tickets* CHF ^%Tix%
      Postage* CHF ^%Postage%
      Paypal Fee* CHF ^%Paypal%
      ;following calculates final sum in SFr
      Total* CHF ^$Calc(^%Tix%+^%Postage%+^%Paypal%)$
      ;following calculates final sum in Euro
      ^!Set %Total_SFr%=^$Calc(^%Tix%+^%Postage%+^%Paypal%)$

      Euro* ^$Calc((^%Total_SFr%)/1.41;2)$ EUR
      ---------------------------

      ^!If "^%Paypal%" > "4.00" Next ELSE Skip_2
      ^!InsertText ^P The corrected Paypal fee is ^%Paypal% SFr.^P^P

      ^!If "^%Postage%" = "1.00" Next ELSE Skip_8
      ^!If "^%Late%" = "1.00" Next ELSE Skip_2
      ^!InsertText ^PIt is too late to send the tickets, so we have only
      calculated 1 SFr for the printing of the tickets and no postage.
      ^!InsertText ^pIf payment has been received, your tickets will be
      deposited at the ticket office where you can collect them there from
      doors-open time.^P^P

      ^!If "^%Postage%" = "1.00" Next ELSE Skip_3
      ^!If "^%Late%" <> "1.00" Next ELSE Skip_2
      ^!InsertText ^PYou have selected to pick up your tickets in person (1
      SFr for printing the tickets).
      ^!InsertText ^pIf payment has been received, your tickets will be
      deposited at the ticket office where you can collect them there from
      doors-open time.^P^P

      Please pay the sum in Euros to the correct Paypal address as given
      below.

      Paypal account: xxxxx
      Total sum: Euro* ^$Calc((^%Total_SFr%)/1.41;2)$ EUR

      ^!If "^%Postage%" <> "1.00" Next ELSE Skip_2
      ^!InsertText ^P^P As soon as your payment is received, your tickets
      will be sent with the next post.

      best wishes
      xxx
    • ebbtidalflats
      Swiss X, I don t ordinarily reply to such confused requests. But the bad math came through clearly. Most of your problems come from the middle of the three
      Message 2 of 4 , Nov 10, 2008
        Swiss X,

        I don't ordinarily reply to such confused requests. But the bad math
        came through clearly.

        Most of your problems come from the middle of the three lines I offer
        a replacement for. But the remainder of your code needs some heavy
        gardening as well. I'll leave that up to you.


        In your code, replace the 3 lines of paypal calculation:


        ^!Set %Paypal%=^$Calc((^%Tix%+^%Postage%)*0.05);2)$
        ^!If "^%Paypal%" < "4.00" Next ELSE Skip_1
        ^!Set %Paypal%=^$Calc(4*1)$


        with:


        ^!Set %paypal%=^$Calc(max(4.00;(^%Tix%+^%Postage%)*0.05);2)$


        Not that you need it above, but if you're going to assign the product
        of two constants to a variable, why not just assign the product as a
        constant?

        ^!Set %paypal%=4
        instead of
        ^!Set %Paypal%=^$Calc(4*1)$


        Eb

        PS, outside of Switzerland, when someone signs their mail with 'X',
        they usually have to provide a witness to the signature.
      • helvetica_switzerland
        Hi ebbtidalflats ... The xxx was meant as three kisses for any help, not a sign of anonymity. Sorry it was misunderstood. I am still struggling with this
        Message 3 of 4 , Jan 21, 2010
          Hi ebbtidalflats
          After a year and a bit more (well, time passes quickly) I only just noticed the last line of your reply:

          > PS, outside of Switzerland, when someone signs their mail with 'X',
          > they usually have to provide a witness to the signature.

          The xxx was meant as three kisses for any help, not a sign of
          anonymity. Sorry it was misunderstood.

          I am still struggling with this blasted clip, it seems to have a life of its own, sometimes it works, sometimes it doesn't. I do wish someone would write a Paypal Wizard for Thunderbird. I have been using the one for Outlook but I don't like Outlook.

          Thanks for your help in 2008.
        • ebbtidalflats
          ... Though I had no idea what your XXX variable stood for at the time, I m sure I was just making a joke. Eb
          Message 4 of 4 , Jan 24, 2010
            --- In notetab@yahoogroups.com, "helvetica_switzerland" <z7dane@...> wrote:
            >
            > Hi ebbtidalflats
            > After a year and a bit more (well, time passes quickly) I only just noticed the last line of your reply:
            >
            > > PS, outside of Switzerland, when someone signs their mail with 'X',
            > > they usually have to provide a witness to the signature.
            >
            > The xxx was meant as three kisses for any help, not a sign of
            > anonymity. Sorry it was misunderstood.


            Though I had no idea what your XXX 'variable' stood for at the time, I'm sure I was just making a joke.



            Eb
          Your message has been successfully submitted and would be delivered to recipients shortly.