#ifndef GETPAYED_PRJ_H
#define GETPAYED_PRJ_H
/*
**  $VER: getpayed_prj.h 1.0 (5.6.97)
**
**  Structures and constants for GetPayed's project library.
**
**  ©1997 TigerSoft
*/

/*                        *
***************************
***** Work day related ****
***************************
*                         */

/*
** NewDay structure
*/

struct NewDay {

    BYTE    Date; /* Date work was done (day_of_month number - 1 = 1st day of month) */
    BYTE    even; /* Unused for now - keep it NUL */
    WORD    allong; /* Longword allign, unused for now - keep it NUL */
    FLOAT   Start; /* Start time of work | */
    FLOAT   Stop; /* End time of work    |-> time values */
    FLOAT   Pause; /* Pause duration     | */
    STRPTR  Comment; /* Ptr on comment string */
};

/* Maximum length of a "HH:MM" time string incl. nul termination */
#define GPPRJ_HHMM_MAXLEN   6



/*                  *
*********************
***** Error codes ***
*********************
*                   */

#define GPPRJ_ERR_OK        0       /* All went well */
#define GPPRJ_ERR_INVALID   1       /* Data was invalid (e.g. NewData was invalid) */
#define GPPRJ_ERR_BADDATE   2       /* NewData.Date is invalid */
#define GPPRJ_ERR_BADSTART  3       /* NewData.Start is invalid */
#define GPPRJ_ERR_BADSTOP   4       /* NewData.Stop is invalid */
#define GPPRJ_ERR_BADPAUSE  5       /* NewData.Pause is invalid */
#define GPPRJ_ERR_BADTIME   6       /* Pause is longer than worktime or work stoped
                                       before it started. */

/*                            *
*******************************
***** GetPayed project tags ***
*******************************
*                             */

#define GPPRJ_ProjectFile   TAG_USER + 1
#define GPPRJ_ProjectPath   TAG_USER + 2
#define GPPRJ_ReportFile    TAG_USER + 3
#define GPPRJ_ReportPath    TAG_USER + 4
#define GPPRJ_RuleFile      TAG_USER + 5
#define GPPRJ_RulePath      TAG_USER + 6
#define GPPRJ_Modified      TAG_USER + 7
#define GPPRJ_PrefsFile     TAG_USER + 8
#define GPPRJ_PrefsPath     TAG_USER + 9
/*
********************************
***** Payment report related ***
********************************
*                              */

/*
** All report entries begin with this structure
*/

struct RepNode {
    UBYTE   Type; /* The type of entry following RepNode */
    BYTE    pad; /* Unused - keep it NUL */
    UWORD   Size; /* Size of entire structure (including RepNode) */
};

/* RepNode Types */
#define GPREP_TYPE_DATA     0   /* A data entry (calculation result
                                   from a rule) */
#define GPREP_TYPE_TEXT     1   /* A line of simple text */
#define GPREP_TYPE_SPACE    2   /* An empty line */
#define GPREP_TYPE_TOTAL    3   /* A sum of payment since last _HEADER
                                   line */
#define GPREP_TYPE_HEADER   4   /* This marks the beginning of a new
                                   payment calculation */

/*
** GPREP_TYPE_DATA report entry
*/

struct Rep_Data {
    struct RepNode  Rep;

    STRPTR  Name; /* Name of the payment rule that created this entry */
    FLOAT   Duration; /* The total time this rule has »been active«
                         (a long Time value - hour count is not limited to 24 hours) */
    LONG    Rate; /* The payment rate for the above duration
                     (actually range*100 : If actual rate is £9 per hour
                      you would have Rep_Data.Rate = 9*100 = 900 */
};

/*
** GPREP_TYPE_TEXT report entry
*/

struct Rep_Text {
    struct RepNode  Rep;

    STRPTR  Text; /* The text to display in report */
};

/*
** GPREP_TYPE_SPACE report entry
*/

struct Rep_Space {
    struct RepNode  Rep;
};

/*
** GPREP_TYPE_TOTAL report entry
*/

struct Rep_Total {
    struct RepNode  Rep;

    LONG    Total; /* The total payment for this sub report (payment since
                      last GPREP_TYPE_HEADER entry).
                      This number is actually payment*100 : If actual
                      payment is £150.5 then
                      Rep_Total.Total = 150.5*100 = 15050 */
};

/*
** GPREP_TYPE_HEADER
*/

struct Rep_Header {
    struct RepNode  Rep;

    BYTE    RangeUnit; /* Unit for the calculation range given below.
                          This is one of the GPREP_CALCUNIT_xxx constants */
    BYTE    pad; /* unused - keep it NUL */
    WORD    From; /* Start of calculation range (measured in RangeUnits) */
    WORD    To; /* End of calculation range (measured in RangeUnits) */
    LONG    Year; /* The year the calculation range is in */
};

/* RangeUnits */
#define GPREP_CALCUNIT_WEEKS    0   /* Range is given as week numbers. Be
                                       aware that week 0 is the last week of
                                       the previous year, and that week 53 is
                                       the first week of the next year. */
#define GPREP_CALCUNIT_MONTHS   1   /* Range is given as month numbers.
                                       January = 0, December = 11 */
#define GPREP_CALCUNITS         2   /* Number of calculation unit types */
/*
** Position codes for gpAddRepEntry()
*/

#define GPPRJ_REPORTENTRY_BOTTOM    -1L /* Add entry at bottom of report */
#define GPPRJ_REPORTENTRY_TOP       0 /* Add entry at top of report
                                         (line numbers goes from 0 and up) */


#endif /* GETPAYED_PRJ_H */
