 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Help navigating SQL Server 2008 database?</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/</link>
	<description></description>
	<lastBuildDate>Sun, 19 May 2013 03:14:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: palloquin</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-81005</link>
		<dc:creator>palloquin</dc:creator>
		<pubDate>Tue, 31 Aug 2010 11:32:31 +0000</pubDate>
		<guid isPermaLink="false">#comment-81005</guid>
		<description><![CDATA[Hey guys...

This one will take me a while. The client has chosen to not have a procedure that helps in suggesting, but will to it all by hand, since they expect it will be not that often that real difficult problems arise...

I will try to built this in my spare time though... It sounds like an interesting problem that should be solvable, My basic idea: If I can solve it manually, all I need to do is analyse what I do, and explain that to the stupid computer ;)

The &#039;basic&#039; code by  Kccrosser is a great start, and recursion is the only viable option here I suppose...

Thank you, and I&#039;ll return here when I&#039;ve had time to complete this (or need help ;) )]]></description>
		<content:encoded><![CDATA[<p>Hey guys&#8230;</p>
<p>This one will take me a while. The client has chosen to not have a procedure that helps in suggesting, but will to it all by hand, since they expect it will be not that often that real difficult problems arise&#8230;</p>
<p>I will try to built this in my spare time though&#8230; It sounds like an interesting problem that should be solvable, My basic idea: If I can solve it manually, all I need to do is analyse what I do, and explain that to the stupid computer <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The &#8216;basic&#8217; code by  Kccrosser is a great start, and recursion is the only viable option here I suppose&#8230;</p>
<p>Thank you, and I&#8217;ll return here when I&#8217;ve had time to complete this (or need help <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kccrosser</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80857</link>
		<dc:creator>kccrosser</dc:creator>
		<pubDate>Thu, 26 Aug 2010 18:48:45 +0000</pubDate>
		<guid isPermaLink="false">#comment-80857</guid>
		<description><![CDATA[Hi Palloquin,
Yes, as I noted above, if there were no credit invoices, you could have the algorithm stop whenever it exceeds the sum of the evaluated invoices.  That will significantly reduce the number of evaluations.  (More like order N^2 instead of N-factorial.)
There are a couple of reasons I suggested processing oldest invoice first:
1.  Usually there are additional fees associated with late/overdue invoices.  If you start clearing invoices on a LIFO basis, customers might get cranky when you charge them fees on older invoices.
2.  Customers tend to pay invoices in time received order - chances are that a payment was for the earliest outstanding billings rather than the latest.  Good cash flow management usually means you don&#039;t pay your bills any earlier than is required to avoid paying late fees.

I thought about also rolling up all the credit invoices first and &quot;adding&quot; that amount to the payment, then only evaluating the invoices with amounts due (so you can stop evaluating when the sum of the invoices exceeds the payment+credit amount), but that will fail if one or more of the credit amounts was NOT taken into account in the payment.

A more complex algorithm may be best, like (all comparisons are done in oldest-first order):
1.  Try to apply the payment to a single invoice - this requires only N comparisons.
2.  If there are any outstanding credit invoices, add the sum of the outstanding credit invoices to the payment and try to apply the payment to a single invoice - another N comparisons.
3.  If there are multiple credit invoices outstanding, try
For i = 1 to num_credit_invoices
   credit_sum = sum(credit_invoice1..credit_invoicei)
   payment_sum = payment + credit_sum
   run recursive algorithm on amount due invoices - stopping the recursion whenever the sum of the invoices exceeds the payment_sum  (order N^2 evaluations)
4.  Run the full recursive algorithm on the first X (10-12?) invoices.
5.  Give up (or do a partial payment).]]></description>
		<content:encoded><![CDATA[<p>Hi Palloquin,<br />
Yes, as I noted above, if there were no credit invoices, you could have the algorithm stop whenever it exceeds the sum of the evaluated invoices.  That will significantly reduce the number of evaluations.  (More like order N^2 instead of N-factorial.)<br />
There are a couple of reasons I suggested processing oldest invoice first:<br />
1.  Usually there are additional fees associated with late/overdue invoices.  If you start clearing invoices on a LIFO basis, customers might get cranky when you charge them fees on older invoices.<br />
2.  Customers tend to pay invoices in time received order &#8211; chances are that a payment was for the earliest outstanding billings rather than the latest.  Good cash flow management usually means you don&#8217;t pay your bills any earlier than is required to avoid paying late fees.</p>
<p>I thought about also rolling up all the credit invoices first and &#8220;adding&#8221; that amount to the payment, then only evaluating the invoices with amounts due (so you can stop evaluating when the sum of the invoices exceeds the payment+credit amount), but that will fail if one or more of the credit amounts was NOT taken into account in the payment.</p>
<p>A more complex algorithm may be best, like (all comparisons are done in oldest-first order):<br />
1.  Try to apply the payment to a single invoice &#8211; this requires only N comparisons.<br />
2.  If there are any outstanding credit invoices, add the sum of the outstanding credit invoices to the payment and try to apply the payment to a single invoice &#8211; another N comparisons.<br />
3.  If there are multiple credit invoices outstanding, try<br />
For i = 1 to num_credit_invoices<br />
   credit_sum = sum(credit_invoice1..credit_invoicei)<br />
   payment_sum = payment + credit_sum<br />
   run recursive algorithm on amount due invoices &#8211; stopping the recursion whenever the sum of the invoices exceeds the payment_sum  (order N^2 evaluations)<br />
4.  Run the full recursive algorithm on the first X (10-12?) invoices.<br />
5.  Give up (or do a partial payment).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80803</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Wed, 25 Aug 2010 23:25:35 +0000</pubDate>
		<guid isPermaLink="false">#comment-80803</guid>
		<description><![CDATA[If business rules allow it, I think the partial payment would be the best option (using some prioritisation criteria, which is usually the invoice date).  If not, you might want to think of way to let the client specify the invoices he/she is paying.]]></description>
		<content:encoded><![CDATA[<p>If business rules allow it, I think the partial payment would be the best option (using some prioritisation criteria, which is usually the invoice date).  If not, you might want to think of way to let the client specify the invoices he/she is paying.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: palloquin</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80799</link>
		<dc:creator>palloquin</dc:creator>
		<pubDate>Wed, 25 Aug 2010 21:45:17 +0000</pubDate>
		<guid isPermaLink="false">#comment-80799</guid>
		<description><![CDATA[Reading your solution, without having tried it yet, I&#039;m thinking  about how the process could be speeded up. some of our clients might have 20, 30 or even more open invoices...

Here&#039;s my first notion. What if I do a pre-check on all the available invoices. should there not be any negative ones (no credit invoices, which will be the case most of the time), I could perhaps choose to order the invoices from high to low and stop recursion as soon as I would exceed the total of the payment... 

The might be some other tricks to speed things up be using some kind of prediction.... let me sleep on it ;)]]></description>
		<content:encoded><![CDATA[<p>Reading your solution, without having tried it yet, I&#8217;m thinking  about how the process could be speeded up. some of our clients might have 20, 30 or even more open invoices&#8230;</p>
<p>Here&#8217;s my first notion. What if I do a pre-check on all the available invoices. should there not be any negative ones (no credit invoices, which will be the case most of the time), I could perhaps choose to order the invoices from high to low and stop recursion as soon as I would exceed the total of the payment&#8230; </p>
<p>The might be some other tricks to speed things up be using some kind of prediction&#8230;. let me sleep on it <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: palloquin</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80798</link>
		<dc:creator>palloquin</dc:creator>
		<pubDate>Wed, 25 Aug 2010 21:36:44 +0000</pubDate>
		<guid isPermaLink="false">#comment-80798</guid>
		<description><![CDATA[Hey Kccrosser,

Wow... that is some answer, and some code for me to try and comprehend! It&#039;s close to midnight here, will spend tomorrow trying to get this to work for me.

Thank you so much!]]></description>
		<content:encoded><![CDATA[<p>Hey Kccrosser,</p>
<p>Wow&#8230; that is some answer, and some code for me to try and comprehend! It&#8217;s close to midnight here, will spend tomorrow trying to get this to work for me.</p>
<p>Thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: palloquin</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80771</link>
		<dc:creator>palloquin</dc:creator>
		<pubDate>Wed, 25 Aug 2010 13:59:31 +0000</pubDate>
		<guid isPermaLink="false">#comment-80771</guid>
		<description><![CDATA[Hey Carlos, 

Thanks for your input!

I agree with you that this is not a desired *first* way to do things. But, when all automatic fail-save options fail, I need to let someone book the invoices manually, and I would like to make this manual booking easier by being able to suggest possible combinations that will match up to the desired amount. 
Obviously, I will only be searching through invoices that have passed the &#039;do they belong to this client&#039; check. 

Usually, our invoices will not be neatly rounded to $50 amounts (that would make matching them by hand very doable), but they will be amounts like $79.32 and $182.14 etc...

I&#039;m curious to hear if there are any mathematical or programming algorithms that would be able to help me solve this...]]></description>
		<content:encoded><![CDATA[<p>Hey Carlos, </p>
<p>Thanks for your input!</p>
<p>I agree with you that this is not a desired *first* way to do things. But, when all automatic fail-save options fail, I need to let someone book the invoices manually, and I would like to make this manual booking easier by being able to suggest possible combinations that will match up to the desired amount.<br />
Obviously, I will only be searching through invoices that have passed the &#8216;do they belong to this client&#8217; check. </p>
<p>Usually, our invoices will not be neatly rounded to $50 amounts (that would make matching them by hand very doable), but they will be amounts like $79.32 and $182.14 etc&#8230;</p>
<p>I&#8217;m curious to hear if there are any mathematical or programming algorithms that would be able to help me solve this&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-numbers-that-add-up-to-another-number/#comment-80766</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Wed, 25 Aug 2010 13:40:54 +0000</pubDate>
		<guid isPermaLink="false">#comment-80766</guid>
		<description><![CDATA[I don&#039;t think you are going to find an efficient way to do that, and I don&#039;t think you should rely on such a method if you find it.

Say you have 5 invoices:  1) $100, 2) $100, 3) $50, 4)$50, 5) $150

If you want to apply a $200 payment, are you going to apply it to invoices 1 and 2, or 1 and 3 and 4, or 3 and 5, or 4 and 5, etc ?

I think some policy should be defined, so you don&#039;t have to guess what invoices you have to apply the payment to.]]></description>
		<content:encoded><![CDATA[<p>I don&#8217;t think you are going to find an efficient way to do that, and I don&#8217;t think you should rely on such a method if you find it.</p>
<p>Say you have 5 invoices:  1) $100, 2) $100, 3) $50, 4)$50, 5) $150</p>
<p>If you want to apply a $200 payment, are you going to apply it to invoices 1 and 2, or 1 and 3 and 4, or 3 and 5, or 4 and 5, etc ?</p>
<p>I think some policy should be defined, so you don&#8217;t have to guess what invoices you have to apply the payment to.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.014 seconds using memcached
Object Caching 364/367 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 01:11:22 -->