Customer balance system

Posted on 2007-10-08
Last Modified: 2013-12-13
Hi EE Community,

I don't know to realize a customer balance system. I have a system, where all bills are entered. I wan't now to create a customer balance in a table. Should all values positive or i.e. bills negative? How would you realize it?

Kind regards
Question by:HMoellendorf
    1 Comment
    LVL 34

    Accepted Solution

    You have two options here.

    1) Simply maintain a list of all transactions on the customer account. The customer balance is then the sum of all the transactions at any point in time.

    2) To apply the balances to a running total for a customer. You only have one total to worry about and it is always current.

    There are disadvantages to either method. My preference is to store all transactions and sum up the value to a point in time. This may be CPU intensive, but it means you have a transaction history (eats space!!!!) and you can reproduce statements.

    I suppose that at a minimum you want something like

         transId INT auto_increment,
         transCustCode VARCHAR(20) NOT NULL,
         transDate DATE NOT NULL,
         transReason VARCHAR(50) NOT NULL,
         transAmount double(10,2) NOT NULL DEFAULT '0.00',
         PRIMARY KEY( transId )

    then something like

    SELECT SUM(transAmount) FROM tblCustTrans WHERE transCustCode = '......'


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now