Tax/No Tax on Invoice - InfoPath Dev
in

InfoPath Dev

Tax/No Tax on Invoice

Last post 08-10-2006 02:45 PM by Shiraz Cupala. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-01-2006 11:39 AM

    Tax/No Tax on Invoice

    Hi all,
    I have the need to create an invoice much like the one that is included with the samples that come with Infopath. I am particularly interested in having a checkbox on each line item which allows the end user to turn tax on/off for that particular item. Multiple tax rates are not a requirement.

    Being very new to infopath, the code which I have looked at in the sample seems quite confusing, and a lot of it doesn't make sense to me. I am looking for a way to accomplish the same functionality with as little code as possible, for example using rules to accomplish as much of it as possible. I will have a repeating table with lineitems, some of which will be taxable and some of which will not be. The tax rate will be static, pulled from a field that the user fills in. If the user checks the tax box I need the form to either recalculate everything based on the tax, or have a refresh button which does this.

    I thought there might be a good chance that someone out there who does this a lot may have some tricks that are easier to accomplish this with than the amount of code that is in the sample.

    Regards,
    Ryan
  • 05-01-2006 01:11 PM In reply to

    What I have tried doing at this point is associating a rule with the checkbox on the lineitem, which says if the value of the checkbox field is false, then calculate qty * unit price and set the extended price column value to that value. If it is checked, then what I tell it to do is qty * unit price * (1+taxrate).

    When I first launch the form, and I go and type in a qty and unit price, nothing happens. Then if I click the taxable checkbox, I get an error from Infopath which states "An error occurred in the form's code. The number of calls to the OnAfterChange event for a single update in the data exceeded the maximum limit." And then the incorrect value is filled into extended price.

    I suppose somehow, I've got to tell infopath with an OnAfterChange event somewhere to go and recalculate. Can you somehow tell infopath to reapply rules after a change?
  • 05-01-2006 01:45 PM In reply to

    I found what was causing the previous error. I had created rules on more than one field, so they were all firing at once and stepping on each other. I had put these rules on these other fields when experimenting with different ways to do this, and forgot to remove them. So now at least it gives the right calculation and no error. The issue remains however, as to how to let infopath know to re-apply the rules when something changes. Is there a way to accomplish this?
  • 05-02-2006 12:11 AM In reply to

    Hi rzwahr,

    What you need to do is to create a rule within your "tax box" checkbox for selecting that the item is taxable that then calculates the sales tax in your sales tax amount field based upon the value of the checkbox (either checked or unchecked) - basically a true/false test.

    So when the user selects the "Yes this item is taxable" box, the sales tax is then calcuated. You will need 2 rules within that text box - 1 to test for the condition that the checkbox is selected (checkboxName="yes" & then the action is that sales tax is calcualated) and one condition for when the checkbox is NOT selected (checkbox Name="no" & then the action is that sales tax is ="0").

    That way when the user selects or deselects the item as taxable the sales tax is calucated or not calcuated. It's also important that the "set condition" test within the rule checks for the appropriate value in the checkbox field - the defaults are fine in this case - "Yes" is on (checked) and "no" is off (unchecked).

    Hope that answers your question!
  • 05-02-2006 06:31 AM In reply to

    That does the trick! Thanks for your time and for the advice.

    Ryan
  • 08-10-2006 02:45 PM In reply to

    Glad our forum could help. This is also a good opportunity to point out that the samples that ship in InfoPath 2003 were built before the calculations functionality was added for SP1. Therefore there is a ton of extra code in there that we wouldn't do today. We just didn't have the option back then when we built them and could not take on the task to upgrade them for the SP1.

    The good news is that in InfoPath 2007 all new samples are provided which are simpler, but use no code at all and take advantage of calculations and other declarative business logic.
    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.