/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*  CHECK.H                            Alan C. Partis                        */
/*                                     Copyright (C) AP MicroSystems, 1991   */
/*                                                                           */
/*  Description:   General header file for the CHKBK program.  Contains      */
/*       Check class definition as well as                                   */
/*       global constant definitions, function prototypes, and global data   */
/*       structures.  Also contains definitions for screens text messages.   */
/*                                                                           */
/*  Date      Initials  Comments                                             */
/*  -----------------------------------------------------------------------  */
/*  05-10-91  ACP       initial creation                                     */
/*  05-26-91  ACP       added Check class definition                         */
/*  07-20-91  ACP       updated for "auto" dating                            */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef  _CHECK_H
#define  _CHECK_H

#include <apms.h>
#include <fstream.h>
#include <stdlib.h>

//
// field sizes
//
#define  SZ_DATE        10             //'mm-dd-yy' ',' and '\0'
#define  SZ_DESC        40
#define  SZ_MAX_FIELD   80             // maximum field size - for input


//
// type definitions
//
typedef  struct    {
    int       number;
    _Date     date;
    char      desc[SZ_DESC];
    float     check;
    float     deposit;
    float     balance;
    byte      cleared;
} XACT;



class    Check     {

         //
         // private by default
         //
              word      record;        // unique record identifier
              int       number;        // check number (optional)
              _Date     date;          // date of transaction
              char      desc[SZ_DESC]; // description of transaction
              float     check;         // amount of withdrawal
              float     deposit;       // amount of deposit (this transaction)
              float     balance;       // balance up to and including this check
              byte      cleared;       // 1 if transaction cleared - 0 otherwise
              Check     *prev;         // previous check in database
              Check     *next;         // next check in database

         //
         // public member functions
         //
         public:
                        Check() { cleared = 0;
                                  prev = (Check *)NULL;
                                  next = (Check *)NULL;
                                }

              void      Add(int   Number,
                            char  *Desc,
                            float Check,
                            float Deposit,
                            Check *Prev);

inline        float     Balance() {return(balance);}
inline        void      Clear() {cleared ^= 1;}  // toggle (xor) cleared flag
              void      Edit(int   Number, 
                             _Date *Date,
                             char  *Desc, 
                             float Check,
                             float Deposit);
inline        void      Fix() {balance = prev->Balance() + deposit - check;}
inline        void      NewNext(Check *Next) {next = Next;}
inline        void      NewPrev(Check *Prev) {prev = Prev;}
inline        void      NewRecord(word Record) {record = Record;}
inline        Check     *Next() {return(next);}
inline        Check     *Prev() {return(prev);}
              void      Read(istream& fp, Check *Prev);
              void      Remove();
              void      WhoCheck(XACT *xact);
inline        byte      WhoCleared() {return (cleared);}
inline        word      WhoRecord() {return (record);}
              void      Write(ostream& fp);

         //
         // overloading operators
         //
              void operator>> (ostream& fp);
              void operator<< (istream& fp);

};

#endif


  Copyright © Thundernet Development Group Inc., 2003.
All rights reserved.