11 Replies Latest reply on Apr 5, 2016 3:17 PM by ch0c0halic

    If / Case Function

    Takahide

      Hi, I am creating discount options but I cannot figure out how to apply the sales tax of 4.5% at the discounted service total.

       

      EX:     service fee $100

                discount 10%

                sales tax should be $100 X 10% X 4.5% = $4.05  

      ------> but always the sales tax comes out as $4.50 which is calculated as $100 X 4.5%.

      Capture.PNG

       

      If ( Payment = "credit"; Service total + Sales Tax + Product Total + Sales Tax Product  + Tip -

       

         Case (

       

            Promotion="10%"; Truncate (Service total * .1 ; 0) ;

       

            Promotion="20% C"; Truncate (Service total * .2 ; 0) ;

       

            Promotion="20% S"; Truncate (Service total * .2 ; 0) ;

       

            0

       

         )

       

      )

       

      Please help! Thank you very much.

        • 1. Re: If / Case Function
          jonmyrah

          Assuming "Sales Tax" is a calculated field, what formula do you have in there? It looks like it is Service Total * 0.045, but it should be ( Service Total - Promotion ) * 0.045.

          • 2. Re: If / Case Function
            siplus

            (100 - (100 * 0.1)) * 0.045 = 4.05

             

            where 100 = service fee,

            0.1 = discount


            Not sure that this is what you meant, though.

            • 3. Re: If / Case Function
              Takahide

              Hi,

               

              the problem is that I created the radio button for promotion

              Capture.PNG

              • 4. Re: If / Case Function
                jonmyrah

                There is no problem with "Promotion" using a radio button set, just keep in mind that the data is being stored as text based on your value list. Give this a try for your "Sales Tax" formula:

                 

                If ( Promotion = "No Discount" ;

                     Service total * 0.0045 ;

                     ( Service total * ( GetAsNumber ( Left ( Promotion ; 2 ) ) / 100 ) ) * 0.0045

                     )

                • 5. Re: If / Case Function
                  Takahide

                  Hi,

                   

                  I applied the formula but not working.

                  -----> No discount, Tax is correct

                  noDiscount.PNG

                  -----> 10% Discount, Tax shows only $0.25? It supposed to be $2.25.

                  10%.PNG

                  • 6. Re: If / Case Function
                    jonmyrah

                    Sorry about that... the formula I gave you was calculating tax on the amount of the discount (the 10%) not the discounted total (the 90%).

                     

                    Change that portion to:

                     

                        ( Service total * ( 1 - ( GetAsNumber ( Left ( Promotion ; 2 ) ) / 100 ) ) ) * 0.0045

                    • 7. Re: If / Case Function
                      Takahide

                      Hi, I am getting so close!!!!

                      Sales Tax is $2.23 but it supposed to be $2.25.

                       

                      10%.PNG

                      • 8. Re: If / Case Function
                        jonmyrah

                        $55.00 - 10% = $49.50

                        4.5% of $49.50 = $2.2275 ... rounded = $2.23

                         

                        Where did you get $2.25 from?

                        • 9. Re: If / Case Function
                          JesseH

                          Your Grand Total amount math is also wrong:

                          10% discount of $55.00 is $49.50 plus $2.23 = $51.73, not $52.23

                           

                          BTW, 4.5% of $49.50 is $2.23

                          • 10. Re: If / Case Function
                            Takahide

                            it rounded up. $50

                            • 11. Re: If / Case Function
                              ch0c0halic

                              Takahide,

                               

                              According to the image the Amount is not getting the discount. I think you haven't applied the discount correctly.

                               

                              The Amount starts as $55.00

                              Then you apply a 10% discount so the amount shown at the bottom should now be $49.50

                              Tax is calculated on the discounted amount. At a tax rate of 4.5% that is $2.2455 but should be rounded to $2.25 since it is over $.005.

                              adding amount plus tax is $49.90 + $2.25 = $52.15

                               

                              So I'd make the calculation match the requirements. If you make it a custom function it would look like this:

                              I've mixed in using either the decimal or percent of a value so you can see the difference. But, I suggest you make both use the same format.

                               

                              Pass in amount = 55, discount = .1, and tax_rate = 4.5 (if you pass in .045 then remove the "* 100" from the tax calculation)

                               

                              CF:

                              new_total (amount ; discount_percent ; tax_rate )

                               

                              Calculation:

                              Let ( [

                              new_amount = amount * ( 1 - discount_percent ) ;

                              tax = new_amount * ( tax_rate * 100 ) ;

                              final_amount = tax + new_amount

                              ] ;

                              final_amount

                              )

                               

                              Note that since Tax Rates change this should NOT be a calculation field. Make it an AutoEnter calculation, possibly using a custom function.