Amount Distribution

Taber, Phil prta@lubrizol.com
Wed, 5 Jul 2000 08:55:32 -0400


Two thoughts come to mind on this problem.  1) adjust the payment amount
each time so that your distribution totals = the actual payment. The trick
here is to evenly distribute the difference to all accounts over the number
of payments so that no one account gets all the adjustments.  

2) The second approach would be to allow the distribution amounts to carry a
greater degree of precision.  Say four decimal places.  You could still
report them as 2 decimal point numbers but it would allow more accurate
totaling, etc.  Of course some people might get upset if the numbers
reported do not add up to the total reported.  

Phil Taber
Phone: (440) 943-1200 x 3892
Email: prta@lubrizol.com


	-----Original Message-----
	From:	Terry Pickering
[SMTP:pickering%myself.com@interlockp.lubrizol.com]
	Sent:	Monday, July 03, 2000 5:09 PM
	To:	powerh-l%sphere.swau.edu@interlockp.lubrizol.com
	Subject:	Amount Distribution

	I have a situation where I need to distribute amounts based upon
	percentages of the total. Rounding works for "most of the time". But
there
	are cases where I need to be guaranteed the "sum of the parts"
equals the
	total.

	Here is the situation:

	I have a purchase order record for $3,900.00 (stored internally
390000 in 
	an integer*10 field) in the PO-MST file. It was distributed across 3

	accounts in the PO-DIST file as follows:

	Record 1:	$1,000.00
	Record 2:	$1,204.34
	Record 3:	$1,695.66

	Total:		$3,900.00

	The distributions were originally entered using a QUICK screen and
it was 
	fairly easy to ensure the distributions added up to the total.
	Now comes the fun part - time to pay on this PO. They can make
multiple 
	partial payments and the payments need to be distributed in the same

	percentage ratio as the original distribution. In this case, a
payment of 
	$13.19 is made. The amount to be distributed is
	calculated by finding the percentage of the total for each record,
then 
	multiplying that times the invoice amount.

	Record 1: (1,000.00 / 3,900.00) * 13.19 = 3.38
	Record 2: (1,204.34 / 3,900.00) * 13.19 = 4.07
	Record 3: (1,695.66 / 3,900.00) * 13.19 = 5.73

	Total: 13.18 or .01 short of the total.

	I have tried using rounding on the "percentage" calculation and
sometimes 
	that helps, but not always. I want to insure that all of the
individual 
	records add up to the original amount. The process that does these 
	calculations is in QTP. What I have attempted to do using temporary
fields 
	is to keep a running total of the amounts, then at the sort break to
"add 
	in the difference". This can of course be a negative amount if the
total 
	was higher than the total amount. I've been successful except I
can't seem 
	to figure out when to know what the "last record" is to add in my
fudge 
	factor. I've tried at sort breaks  but at that point either the
record is 
	not available or the counters have been reset.

	Any suggestions would be welcome - except I don't relish the thought
of 
	doing another pass on the data......



	~~~~~~~~~~~~~~~~
	Terry A. Pickering
	Portland, Oregon
	pickering@myself.com
	~~~~~~~~~~~~~~~~
	= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
	Subscribe: "subscribe powerh-l" in message body to
majordomo@lists.swau.edu
	Unsubscribe: "unsubscribe powerh-l" in message to
majordomo@lists.swau.edu
	This list is closed, thus to post to the list, you must be a
subscriber.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.