/*
** Verwaltung von Artikeln in einer Liste
**
** Copyright (C) 1996 by Stefan Scherer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for non-commerical use and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation.  This software is provided "as is" without
** express or implied warranty.
*/

#ifndef ARTIKEL_H
#define ARTIKEL_H

#define MAX_ART_LEN 100


/* jeder Artikel enthält folgende Daten */

struct Article
  {
    double Betrag;		/* der Betrag ohne Mehrwertsteuer */
    double Menge;		/* (Default-)Stückzahl dieses Artikels */
    char Bezeichnung[MAX_ART_LEN + 1];	/* die Artikel-Bezeichnung */
#ifdef EXTASY_MODEN
    char Farbe[MAX_ART_LEN + 1];	/* die Farbe-Bezeichnung */
    char Size[MAX_ART_LEN + 1];	/* die Size-Bezeichnung */
    char Material[MAX_ART_LEN + 1];	/* das Material */
#endif
    char Artikelnummer[MAX_ART_LEN + 1];	/* "" = keine Nummer, sonst */
    				/* Artikelnummer als String */
    UBYTE Preistabelle;		/* 1 = 15%, alles andere = 7% */

    char Datum[12];		/* Datum letzte Änderung */
    double EKBetrag;		/* der Betrag ohne Mehrwertsteuer */
    double EKVersand;		/* zusätzlicher Versand beim Einkauf */
    double VGLBetrag;		/* Vergleichsbetrag anderer Anbieter */
    char Lieferfirma[MAX_ART_LEN + 1];	/* Name der Lieferfirma */
    char Notiz[MAX_ART_LEN + 1];	/* zusätzliche Notiz */
    char Kategorie[MAX_ART_LEN + 1];	/* welche Art von Artikel ist es */
  };


/* manche Programm-Module benötigen nur geringere Informationen über
** den Artikel. Hier die abgespeckte Version.
*/

struct MinArticle
  {
    double Betrag;			/* der Betrag ohne Mehrwertsteuer */
    double Menge;			/* die Stückzahl dieses Artikels */
    char Bezeichnung[MAX_ART_LEN + 1];	/* die Artikel-Bezeichnung */
#ifdef EXTASY_MODEN
    char Farbe[MAX_ART_LEN + 1];	/* die Farbe-Bezeichnung */
    char Size[MAX_ART_LEN + 1];		/* die Size-Bezeichnung */
    char Material[MAX_ART_LEN + 1];	/* das Material */
#endif
    char Artikelnummer[MAX_ART_LEN + 1];	/* "" = keine Nummer, sonst */
					/* Artikelnummer als String */
    UBYTE Preistabelle;			/* 1 = 15%, alles andere = 7% */
  };


/* o-functions */

int ConstructArticle (void);
void DestructArticle (void);

int A_AddItem (struct Article *item);
int A_DelItem (void);
int A_ChangeItem (struct Article *item);
int A_SetCurrentNumber (UWORD number);
int A_SetCurrentArticle (struct Article *article);

int A_LoadArticles (void);
int A_SaveArticles (void);

BOOL A_ComparePattern (UWORD number, struct Article *art);

/* v-functions */

int A_GetArticleCount (void);
int A_GetCurrentNumber (void);
int A_GetCurrentItemCat (void);
int A_GetCurrentItem (struct Article *item);
int A_GetItem (UWORD num, struct Article *item);
BOOL A_GetStatus (void);

int A_AddCategory (STRPTR category);
int A_DelCategory (void);
int A_ChangeCategory (STRPTR category);
int A_GetCategory (UWORD num, STRPTR category);
int A_GetCategoryCount (void);
int A_SetCurrentCategory (UWORD number);
int A_GetCurrentCategoryNumber (void);

/* 3.3.96, ss: zum Korrigieren der Menge */
int A_LoadAddArticle (struct MinArticle *);
int A_SaveSubArticle (struct MinArticle *);

STRPTR A_GetErrorMsg (void);

/* alle Fehler der Funktionen */

enum
  {
    ERR_ART_OK,			/* kein Fehler */
    ERR_ART_NOPOOL,		/* kein Memory-Pool vorhanden */
    ERR_ART_NOMEM,		/* nicht genügend Speicher vorhanden */
    ERR_ART_LISTEMPTY,		/* Liste ist leer */
    ERR_ART_NOITEM,		/* Eintrag ist nicht in der Liste vorhanden */
    ERR_ART_FILENOTFOUND,	/* File nicht gefunden */
    ERR_ART_CANTCREATEFILE,	/* File konnte nicht erzeugt werden */
    ERR_ART_SAVE,		/* Fehler beim speichern */
  };

#endif /* ARTIKEL_H */
