N
Nicholas Scarpinato
I have a database which I've built to store invoice data for customer
invoices that could not be applied to the books for various reasons (i.e.,
the account was already closed, the vendor overpaid, etc.), and now I'm
working on an account balancing for this database to tell me which invoices
have been cleared off from this particular holding account (i.e., the closed
account was transferred to another account number, the vendor took their
overpayment back, etc.). The problem is that our invoicing system doesn't
have a 1-to-1 match. Our invoice numbers are built as follows:
1234567-0-ext1-ext2-ext3
where 1234567 is the invoice number, -0 is the invoice line number, and
-ext1-ext2-ext3 are the various optional identifiers. These identifiers
change for almost every invoice line, and a payment on 1234567-0 might not
have the same identifiers as the billing for 1234567-0. The only way I have
of getting any sort of a balancing for these accounts is to trim off the
identifiers and get a sum of the resulting trimmed invoices. What I've been
running into is that when I do this, a sum query will return a sum of zero,
even though there might be a balance on the invoice! If I have the following
list:
1234567-0: $200
1234567-0: -$200
1234567-0: $15,
my Sum query is doing one of two things: it either kicks the invoice out
completely (the query only looks for zero balances), or it returns zero for
the balance on 1234567-0. Neither option is acceptable.
I've also tried splitting my main data table into a table of credits and
debits and running a join on those tables to get only the invoice numbers
which have an exact opposite amount in the opposing table, i.e.:
1234567-0: $-10 <---> 1234567-0: $10
When I do this query, I make sure to include the entire invoice number and
all it's identifiers on each side of the query so I know exactly which
invoice I'm looking at. Then I take those lists (the one for credits and the
one for debits, from that query) and find those invoices on my main data
table and tag those as being cleared off. When I get to the end of all of
this, I run a sum on the records in the main data table that have been tagged
as cleared. The sum SHOULD be zero, but it never is, it's always a couple
thousand dollars off. I know the database is tagging extra records when they
show cleared (sometimes there are duplicate invoices/identifier
combinations), but I don't know how to prevent this, and quite honestly I
don't trust the database's results anyway. (It seems to be tagging way too
many lines as being cleared.) I don't really know how to go about making this
work, and I'm not sure I've explained it well enough to make myself
understood, but if anybody can help me with ideas or suggestions on how this
can be done, I would greatly appreciate the help. My boss needs this
information by close of business tomorrow, lol.
invoices that could not be applied to the books for various reasons (i.e.,
the account was already closed, the vendor overpaid, etc.), and now I'm
working on an account balancing for this database to tell me which invoices
have been cleared off from this particular holding account (i.e., the closed
account was transferred to another account number, the vendor took their
overpayment back, etc.). The problem is that our invoicing system doesn't
have a 1-to-1 match. Our invoice numbers are built as follows:
1234567-0-ext1-ext2-ext3
where 1234567 is the invoice number, -0 is the invoice line number, and
-ext1-ext2-ext3 are the various optional identifiers. These identifiers
change for almost every invoice line, and a payment on 1234567-0 might not
have the same identifiers as the billing for 1234567-0. The only way I have
of getting any sort of a balancing for these accounts is to trim off the
identifiers and get a sum of the resulting trimmed invoices. What I've been
running into is that when I do this, a sum query will return a sum of zero,
even though there might be a balance on the invoice! If I have the following
list:
1234567-0: $200
1234567-0: -$200
1234567-0: $15,
my Sum query is doing one of two things: it either kicks the invoice out
completely (the query only looks for zero balances), or it returns zero for
the balance on 1234567-0. Neither option is acceptable.
I've also tried splitting my main data table into a table of credits and
debits and running a join on those tables to get only the invoice numbers
which have an exact opposite amount in the opposing table, i.e.:
1234567-0: $-10 <---> 1234567-0: $10
When I do this query, I make sure to include the entire invoice number and
all it's identifiers on each side of the query so I know exactly which
invoice I'm looking at. Then I take those lists (the one for credits and the
one for debits, from that query) and find those invoices on my main data
table and tag those as being cleared off. When I get to the end of all of
this, I run a sum on the records in the main data table that have been tagged
as cleared. The sum SHOULD be zero, but it never is, it's always a couple
thousand dollars off. I know the database is tagging extra records when they
show cleared (sometimes there are duplicate invoices/identifier
combinations), but I don't know how to prevent this, and quite honestly I
don't trust the database's results anyway. (It seems to be tagging way too
many lines as being cleared.) I don't really know how to go about making this
work, and I'm not sure I've explained it well enough to make myself
understood, but if anybody can help me with ideas or suggestions on how this
can be done, I would greatly appreciate the help. My boss needs this
information by close of business tomorrow, lol.