I have written an accounting program in C# which keeps tabs on the costs
of a small block of shared flats. The leases are all different in that
Flat x pays 12.5% of the shared electricity costs and 7.5% of the
gardening costs while Flat y pays 5% of the shared electricity costs and
12.5% of the gardening costs. As a consequence there appears to be
nothing on the market I can use. The complete matrix of costs has 17
categories of payment x 8 flats = 136 percentages.
What I do is when an invoice comes in it is entered on the ledger and
written to an Access table
If it is a split account the program calculates the payment for each flat
and writes it to a second Access table with each entry identified by the
FlatID.
It works well and allows me to keep leaseholders up to date with
expenditure and also allows me to ensure the bank statement agrees with
what the program thinks it should be.
The classes for both the whole invoice and the split amounts are identical
so I use one class called JAccountEntry. However, they have to be written
to 2 separate Access tables so I have ended up with 2 static updater
classes with identical functions, the only difference being the table
name. All the functions in the updater classes are static.
I could have just one updater and set the table name before I call it but
it's almost inevitable I will forget or get it wrong somewhere in the
program and that will really mess up the data.
I tried one main updater class with 2 minimal updaters based on that with
the intention of just having a different table name in each but you can't
inherit from static classes.
The objective is to call one updater in some situations and the other in
other situations and have it automatically set the correct table name and
then call the correct function in the base class e.g.
JSplitUpdater.UpdateRecord(accountEntry) sets the appropriate table name
and calls the base UpdateRecord function.
JInvoiceUpdater.UpdateRecord(accountEntry) sets the appropriate table name
and calls the base UpdateRecord function.
Any ideas on a way to deign this so that calling the correct updater sets
the table name then calls the correct function in the base class?
--
Jeff Gaines Wiltshire UK
Tell me what you need, and I'll tell you how to get along without it.
|