[ic] total item-list for numeric field other than price

Mike Heins mikeh@minivend.com
Thu, 7 Dec 2000 17:46:24 -0500

Quoting Greg (greg@valuemedia.com):
> Hi all,
> I am setting up to export a "purchase order" transaction to Quickbooks.  On
> the invoice export that Mike built you can use [total-cost] or [sub-total]
> in the AMOUNT field for quickbooks.  On the purchase order, I need to use
> the total of the item list from a different field (named "cost" in my
> database), so that my total cost for the items is entered into the purchase
> order rather than the total sales price.  I can easily get the individual
> costs into the export using [item-field cost], but can someone tell me how
> to get the sum of these [item-field cost] 's in the [item-list] into a
> variable or somesuch?

At the top of etc/trans_quickbooks:

[perl tables="products"]
	my $total = 0;
	foreach my $item (@$Items) {
	    my $cost = tag_data('products', 'cost', $item->{code});
	    $total += $cost * $item->{quantity};
	$Scratch->{total_cost} = $total;

Now you can access it with [scratch total_cost].

Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

I don't buy from direct telephone or email marketers.  This makes it
hard for me to find a phone company. ;>