I’m working on an invoice log of sorts. Our invoice tables are header information and line item information.
On our invoices, we have an extra freight amount that usually shows up. Most customers are fine with it being in the totals section of the invoice, thus in the header table. But there is one customer who prefers it as a line item, thus in the line item table.
I have been able to add these two together to report the amount in one column of my invoice log, using the following formulae:
line item "door del": if {invoice_line.item_desc}='Door Delivery Charges' then invoice_line.unit_price}
Total: {invoice_hdr.freight}+Sum ({@door del}, {invoice_hdr.invoice_no})
And that's working just fine. But, now I am trying to get a grand total of this column down at the bottom. I would have thought that
Sum ({invoice_hdr.freight}) + Sum ({@door del})
would do the trick, but it is way inflated. Because of the join of the header with the lines, the freight field is showing up for every line in the result set. So when it sums up the whole thing, each freight amount is multiplied by the number of items on the invoice and then added together.
How can I get this grand total to be right?
On our invoices, we have an extra freight amount that usually shows up. Most customers are fine with it being in the totals section of the invoice, thus in the header table. But there is one customer who prefers it as a line item, thus in the line item table.
I have been able to add these two together to report the amount in one column of my invoice log, using the following formulae:
line item "door del": if {invoice_line.item_desc}='Door Delivery Charges' then invoice_line.unit_price}
Total: {invoice_hdr.freight}+Sum ({@door del}, {invoice_hdr.invoice_no})
And that's working just fine. But, now I am trying to get a grand total of this column down at the bottom. I would have thought that
Sum ({invoice_hdr.freight}) + Sum ({@door del})
would do the trick, but it is way inflated. Because of the join of the header with the lines, the freight field is showing up for every line in the result set. So when it sums up the whole thing, each freight amount is multiplied by the number of items on the invoice and then added together.
How can I get this grand total to be right?