11 Replies Latest reply on Jan 18, 2015 5:31 PM by AndrewJudd

    Trying to Zero the VAT!



      Trying to Zero the VAT!


      Hi all, I have a field for VAT on my invoice layout which is set to calculate the VAT based on either a subtotal or a total field (depending on whether there is a discount or not). In the event an object is sold overseas or a Non VAT country I need to zero the field.

      I have tried a button which inserts a calculated result (0). However the zero appears and then the previous calculation reappears when you exit the field. I have also tried script triggers on exit to set field to 0. These don't work either..

      Any ideas?

        • 1. Re: Trying to Zero the VAT!

          Is this a field with an auto-enter calculation? That would fit what you describe anyway.

          I suggest adding a field "NoVAT". Use your button to set it to 1 (this could be the NoVAT field formatted with as a check box.) Then modify your calculation with an If or case function that returns zero or null instead of calculating a VAT from the other fields.

          • 2. Re: Trying to Zero the VAT!

            Thank you, getting close to a solution. Now, 2 strange things happen which would be great to correct.

            1. For some reason when I press the button to calculate VAT i get an "0" in front of the number. I can manually remove but would be nice not to.

            2. The VAT works fine when there is a discount and the VAT calculates from the subtotal field, however if you decide to remove the discount and VAT field still thinks it is there and doesn't revert to the no discount situation.

            I'll attach 3 screenshots which demonstrate. I think I need script triggers?


            • 3. Re: Trying to Zero the VAT!
              /files/ed04532f88/Screen_Shot_2015-01-18_at_20.58.35.png 238x304
              • 4. Re: Trying to Zero the VAT!
                /files/afa3ee3227/Screen_Shot_2015-01-18_at_20.58.43.png 250x304
                • 5. Re: Trying to Zero the VAT!

                  This is my calculation for the green button - INVOICES::Subtotal *.2  & If(IsEmpty (INVOICES::Subtotal) ; ARTWORK::Invoice Total  *.2 )

                  This is the red (clear) button - Clear (Select; INVOICES::Vat)

                  • 6. Re: Trying to Zero the VAT!

                    I would not use scripts to do this calculation. I'd define a calculation button Field.

                    But the main problem that I see is the use of the & operator. This is the concatenation operator that will append the text returned by the expression to the left of & with the text returned to the right of it. This is where you are getting that unnecessary leading zero.

                    You can rewrite this expression as
                    If(IsEmpty (INVOICES::Subtotal) ; ARTWORK::Invoice Total  *.2 ; INVOICES::Subtotal *.2 )

                    I think that reproduces the intent of your original expression, but am not sure how that affects whether or not a VAT is calculated and included as part of the transaction total.

                    • 7. Re: Trying to Zero the VAT!

                      Thank you, that is almost there. However, in the situation you add a discount, have the vat calculate off the new subtotal file, but you then decide to remove the discount and the vat is supposed to re-calculate off the top original invoice total field it still thinks there is a discount there.

                      Attached example (vat should is 20% of Net) but it thinks there is a 10% discount on the artwork still in place.

                      • 8. Re: Trying to Zero the VAT!

                        Do i need a script trigger to refresh the vat field when the - button is pressed? Or something similar?

                        • 9. Re: Trying to Zero the VAT!

                          Which is why I would not do it this way. With a calculation field, modifying the value of a field referenced in the calculation triggers an automatic recalculation and it all happens without any need for a script to calculate the value.

                          If the button performs a script, that script should be able to recalculate the needed value, but which button are you clicking at this point? If you are clicking a button, you shouldn't need the script trigger as well in most cases.

                          • 10. Re: Trying to Zero the VAT!

                            ok thanks, so I have a calculation field now for VAT and a noVAT field as a checkbox pulling values from a valuelist called NoVat which just has custom values of "1".

                            In my vat calculation i need to have something like the below (help!) as VAT needs to be calculated from either the invoice total (net) or a new subtotal field if a discount is applied. Screenshot attached.

                            ARTWORK::Invoice Total *.2   or  Subtotal  *.2  & If(NoVat)=1 ; NoVat)


                            • 11. Re: Trying to Zero the VAT!

                              have also tried this as a calculated value for my novat field -

                              If ( NoVat ; 1 ; Vat = 0).

                              but the VAT field doesn't seem to change.