Hello everybody:
I need helpwith script developing
I have atable that contains data from invoices and payment receipts related.
In othertable I have the checks related witheach receipt.
I need to “create”a new table that apply each check(partially or totally) to one or more invoices, using the aging as the orderingmethod (older check apply to older invoice)
I`m using tables, like following:
Apply table:
IdApply
IdReceipt
IdInvoice
InvoiceDate
AppliedAmount (from receipt toinvoice)
Example:
IdApply | IdReceipt | IdInvoice | InvoiceDate | AppliedAmount |
1 | 1 | 1 | 01/01/2012 | 500 |
2 | 1 | 2 | 01/02/2012 | 400 |
3 | 1 | 3 | 01/03/2012 | 300 |
Tabla de valores:
IdReceipt
IdCheck
CheckDate
CheckAmount
Example:
IdReceipt | IdCheck | CheckDate | CheckAmount |
1 | 1 | 01/04/2012 | 200 |
1 | 2 | 01/05/2012 | 800 |
1 | 3 | 01/06/2012 | 200 |
As Result, I need a table like this:
IdCheck | IdInvoice | AppliedAmount (Check to invoice) |
1 | 1 | 200 |
2 | 1 | 300 |
2 | 2 | 400 |
2 | 3 | 100 |
3 | 3 | 200 |
Really don’t know how to start.
Any I dea?
Thanks!!!