PhilipOfOrange
Programmer
I am writing a tax report, based on invoices. The lead table (from which all links originate) is the “invoice item” table and it is linked into the “invoice” table that contains the information about the invoice as a whole (customer number, ship to, method of payment, etc.). The tables keep track of up to five different sales taxes (such as federal, state, county, city or a special jurisdiction). The report must display the taxable sales for each type of tax and the tax collected.
Only the “invoice item” table can provide the amount of the sales for a given tax type because it depends on what was sold as to whether or not it was taxable. Taxes overlap, so the sale of an item may not be taxed at all or it may have one or more taxes applied to it. Taxes are rounded up at the invoice level (at the time the invoice was corrected) for each of the accumulated taxes on the items according to tax laws, which to my knowledge, are universal in requiring the round up on any fraction cent regardless of how small the fraction may be. This means that the taxes collected will be slightly more than the tax rate times the taxable sales. Taxing authorities want to know the taxable sales and the tax collected. Consequently, only the “invoice” table can provide the amount of the tax collected.
Now here is the problem, when Crystal steps through the item table, summing up the sales, it also sums up the tax collected in the linked invoice table. If there are three items on the invoice, it will correctly report the taxable sales but it will triple the amount of the tax collected. How do I prevent this, without recalculating the figures in the invoice table, which I prefer not to do as a defense against integrity issues, like missing records.
Only the “invoice item” table can provide the amount of the sales for a given tax type because it depends on what was sold as to whether or not it was taxable. Taxes overlap, so the sale of an item may not be taxed at all or it may have one or more taxes applied to it. Taxes are rounded up at the invoice level (at the time the invoice was corrected) for each of the accumulated taxes on the items according to tax laws, which to my knowledge, are universal in requiring the round up on any fraction cent regardless of how small the fraction may be. This means that the taxes collected will be slightly more than the tax rate times the taxable sales. Taxing authorities want to know the taxable sales and the tax collected. Consequently, only the “invoice” table can provide the amount of the tax collected.
Now here is the problem, when Crystal steps through the item table, summing up the sales, it also sums up the tax collected in the linked invoice table. If there are three items on the invoice, it will correctly report the taxable sales but it will triple the amount of the tax collected. How do I prevent this, without recalculating the figures in the invoice table, which I prefer not to do as a defense against integrity issues, like missing records.