HI guys, I'm just about to build a small, simple expenses application. Basically I'd like to keep track of how much money I'll make by selling some stuff, and therefore I have to input the income and have a total of it, the expenses (fee, refunds) and total it and then the effective total (income - expenses), so pretty simple stuff. I'd like to store everything in the database as I'd like to have a record of everything (income per item, total income, total expenses and effective total), but I'm not sure where the calculations should occur (database or on the fly in the application). So for example: say I sell a camera, I'd like to store the price paid and the item on the database. But where do I calculate the total income, expenses and effective total? The thing is so far I've only stored and retrieved stuff from the EF database, not sure what I have to do to make calculations and store the values back in the database.
In terms of data visualization, I'd like to have a good summary of everything, so again I'd like to be able to see what I sold, for how much and keep track of income, expenses and effective total.

Needless to say, if somebody have any suggestions, or think that the way I want to implement the application is wrong, please do let me know. Once we establish the way to proceed I'll think about the classes needed
thanks

Recommended Answers

All 3 Replies

I thought I might start looking at the class as well. This is the way I'm thinking to proceed.
I will have two options - perhaps with radio buttons - to start with:
a)Sale
b)Expense
For a) I will display the name of the item and the price it was sold for. For b) instead I will display the name of the item and the refund/fee paid by me. So I'm thinking that perhaps only one class is necessary:

public class Item
    {
        public int ItemID { get; set; }
        public string Name { get; set; }
        public double Price { get; set; }
        public double Expense { get; set; }
    }

How does it sound to you guys?

But where do I calculate the total income, expenses and effective total?

Just use LINQ to Entity. There is no need to store totals, unless your database gets so huge it would take too long to calculate.

Am not sure I'd choose Price and Expense. To me it makes more sense to seperate an item from it's transactions. Something like:

public class Item 
{
    public int ID { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Transaction> { get; set; }
}

public class Category 
{
    public int ID { get; set; }
    public string Name { get; set; }
}

public class Transaction 
{
    public int ID { get; set; }
    public Item Item { get; set; }
    public DateTime DateTime { get; set; }
    public Category Category { get; set; }
    public string Description { get; set; }
}

That way you can have a flow like this:

1 Buy a camera for 100 (add item and transaction)
2 Repair for 15 (add transaction)
3 Sell for 200 (add transaction)
4 Refund 25 for broken battery (add transaction)

If you want a report by category (bought, sold, refund, repair) then you can. Same with totals over a period.

Sounds like a good idea. 2 questions though:
1) in the class Transaction, shouldn't public Item Item { get; set; } and public Category Category { get; set; } be virtual?
2)Are Item and Category classes in a many-to-may relationship?
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.