tecashregisterbase.h

00001 /****************************************************************************
00002 ** $Id: tecashregisterbase.h,v 1.15 2006/06/21 05:35:58 red75 Exp $
00003 **
00004 ** Trade equipment common portable library project
00005 **
00006 ** Copyright (C) 1999-2006 Leader InfoTech.  All rights reserved.
00007 **
00008 ** This file is part of the Library of the Ananas
00009 ** automation accounting system.
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 as published by the Free Software
00013 ** Foundation and appearing in the file LICENSE.GPL included in the
00014 ** packaging of this file.
00015 **
00016 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00017 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018 **
00019 ** See http://www.leaderit.ru/ or email sales@leaderit.ru
00020 **
00021 ** Contact org@leaderit.ru if any conditions of this licensing are
00022 ** not clear to you.
00023 **
00024 **********************************************************************/
00025 
00026 /*
00027    Abstract cash register interface object
00028    (c) V.Grazdankin, 1999-2005
00029 */
00030 #include <tebase.h> // Damn, We should place that 'include' before 'define TECASHREG...', see templexports.h
00031 #ifndef TECASHREGISTERBASE_H
00032 #define TECASHREGISTERBASE_H
00033 #include <qdict.h>
00034 #include <qstring.h>
00035 #include <qvariant.h>
00036 #include <qsqldatabase.h>
00037 #include <qvaluelist.h>
00038 //#include <vector>
00039 
00040 //using std::vector;
00041 
00042 //#ifdef Q_OS_UNIX
00043 //enum par_code   { COM_NONE, COM_EVEN, COM_ODD, COM_ZERO, COM_ONE };
00044 //void serial_setparams(int port, int speed, int bits, enum par_code parity, int stopbits);
00045 //#endif
00046 
00047 //
00048 /*
00049 typedef struct {
00050    int     KL;          // # control line
00051    int     NBue;        // # bue
00052    int     NCBue;       // # bue in check
00053    int     Dep;         // # departament
00054    char    AskCode[20]; // asking barcode
00055    char    Code[20];    // finding barcode
00056    char    Name[200];   // full name
00057    char    PName[20];   // printable name
00058    double  Price;       // price
00059    double  Quantity;    // quantity
00060    double  Sum;         // summa
00061    double  Discount;    // discount
00062 } Bue_Item;
00063 */
00064 
00065 
00066 typedef struct {
00067    char Cmd;
00068    unsigned long NM;
00069    unsigned int Addr;
00070    char Len;
00071    char data[16];
00072    char CS;
00073 } Socket_Rec;
00074 
00075 //
00076 typedef struct {
00077    int nbue;
00078    char code[20];
00079    char name[60];
00080 } bue_lst;
00081 
00082 /*
00083 class CCMConnection : public QObject
00084 {
00085 Q_OBJECT
00086 
00087 public:
00088 
00089 };
00090 */
00091 
00092 class CCM_CheckItem : public QObject
00093 {
00094 Q_OBJECT
00095 
00096 public:
00097     CCM_CheckItem();
00098     ~CCM_CheckItem();
00099 
00100 private:
00101     int     KL;          // # control line
00102     int     NBue;        // # bue
00103     int     NCBue;       // # bue in check
00104     int     Dep;         // # departament
00105     char    AskCode[20]; // asking barcode
00106     char    Code[20];    // finding barcode
00107     char    Name[200];   // full name
00108     char    PName[20];   // printable name
00109     double  Price;       // price
00110     double  Quantity;    // quantity
00111     double  Sum;         // summa
00112     double  Discount;    // discount
00113 };
00114 
00115 struct LIB_EXPORT PurchaseInfo
00116 {
00117         PurchaseInfo()
00118         {
00119                 clear();
00120         }
00121 
00122         PurchaseInfo(const PurchaseInfo & in) :
00123                 m_name(in.m_name),m_dep(in.m_dep),m_price(in.m_price),m_quantity(in.m_quantity),
00124                 m_qdec(in.m_qdec),m_taxes(in.m_taxes),m_dDiscount(in.m_dDiscount),
00125                 m_isDiscountInPercent(in.m_isDiscountInPercent), m_iOperation(in.m_iOperation),
00126                 m_sUnit(in.m_sUnit), m_sComment(in.m_sComment), m_isEmpty(in.m_isEmpty)
00127         {
00128         }
00129 
00130         PurchaseInfo(const QString &name, int dep, double price, double quantity, int qdec):
00131                 m_name(name),m_dep(dep),m_price(price),m_quantity(quantity),m_qdec(qdec),m_isEmpty(false)
00132         {
00133         }
00134 
00135         void clear()
00136         {
00137                 m_isEmpty=true;
00138                 m_name="";
00139                 m_dep=0;
00140                 m_price=0;
00141                 m_quantity=0;
00142                 m_qdec=3;
00143                 m_taxes.clear();
00144                 m_dDiscount=0;
00145                 m_isDiscountInPercent=false;
00146                 m_iOperation=-1;
00147                 m_sUnit="";
00148                 m_sComment="";
00149         }
00150 
00151         bool isEmpty()
00152         {
00153                 return m_isEmpty;
00154         }
00155 
00156         QString m_name;
00157         int m_dep;
00158         double m_price;
00159         double m_quantity;
00160         int m_qdec;
00161         QValueList<int> m_taxes;
00162         double m_dDiscount;
00163         bool m_isDiscountInPercent;
00164         int m_iOperation;
00165         QString m_sUnit,m_sComment;
00166         bool m_isEmpty;
00167         bool operator < (const PurchaseInfo & in) const
00168         {
00169                 return m_name<in.m_name;
00170         }
00171         bool operator == (const PurchaseInfo & in) const
00172         {
00173                 return (m_name==in.m_name) && (m_dep==in.m_dep) && (m_price==in.m_price) && (m_quantity==in.m_quantity);
00174         }
00175 };
00176 
00177 /*
00178 Class for database connection and work.
00179 */
00180 /*
00181 class CCM_Database : public QObject
00182 {
00183 public:
00184     CCM_Database();
00185     ~CCM_Database();
00186 private:
00187     QSqlDatabase *db;
00188 };
00189 */
00190 //---------------------------------------------------------------------------
00191 class KKM_IO : public QObject
00192 {
00193 Q_OBJECT
00194 
00195 public:
00196     unsigned long MachineNumber;
00197     int Channal;
00198     KKM_IO(int Chan, unsigned long nm);
00199     ~KKM_IO();
00200 
00201 private:
00202 
00203 };
00204 //---------------------------------------------------------------------------
00205 
00206 #define     EVENT_NONE      0
00207 #define     EVENT_CLOSECHECK    1
00208 #define     EVENT_ASKBARCODE    2
00209 #define     EVENT_RESETCHECK    3
00210 #define     EVENT_MANUALSALE    4
00211 #define     EVENT_CONFIRMBUE    5
00212 #define     EVENT_PRINT_ZERO_CHECK 11
00213 #define     EVENT_REQUEST_ZREPORT 12
00214 
00215 #define     EVENT_POWEROFF      100
00216 #define     EVENT_POWERON       101
00217 #define     EVENT_BUSY      102
00218 #define     EVENT_READY     103
00219 #define     EVENT_DRIVER_ACTIVATED 104
00220 #define     EVENT_DRIVER_ACTIVATION_FAILED 105
00221 #define     EVENT_CRITICAL_FAIL 106
00222 #define         EVENT_CONFIRMATION 107
00223 #define     EVENT_UNKNOWN 128
00224 
00225 // -- error codes for new check-related functions
00226 #define CRERROR_OK 0
00227 #define CRERROR_NOTSUPPORTED 1
00228 #define CRERROR_DEVICEERROR 2
00229 #define CRERROR_INVALIDCALL 3
00230 #define CRERROR_FATALDEVICEERROR 4
00231 
00232 enum CROperations
00233 {
00234         CRO_SELL=0x0,
00235         CRO_BUY=0x1,
00236         CRO_SELLRET=0x2,
00237         CRO_BUYRET=0x3,
00238         CRO_SELLSTORNO=0x4,
00239         CRO_BUYSTORNO=0x5,
00240         CRO_CASHIN=0x6,
00241         CRO_CASHOUT=0x7,
00242         CRO_DISCOUNT=0x8,
00243         CRO_DISCOUNTPERCENT=0x9,
00244         CRO_OPMASK=0xF
00245         //CRO_SIMPLEMODE=0x8,
00246         //CRO_MODEMASK=0x8,
00247         //CRO_CASHLESS=0x10,
00248         //CRO_PAYMENTMASK=0x10
00249 };
00250 
00251 //template class LIB_EXPORT QDict <QVariant>;
00252 //template class LIB_EXPORT std::vector <PurchaseInfo>;
00253 //template class LIB_EXPORT std::allocator <PurchaseInfo>;
00254 #include <templexports.h>
00255 
00256 struct LIB_EXPORT CheckInfo
00257 {
00258         QValueList<int> m_vTaxes;
00259         QMap<int,double> m_mPayment;
00260         int m_DefaultOperation;
00261         int m_CheckOperation;
00262 };
00263 
00264 enum PassType
00265 {
00266         PTOperator=0,
00267         PTAdmin=1,
00268         PTFiscal=2
00269 };
00270 
00271 class LIB_EXPORT TECashRegisterBase : public TEBase
00272 {
00273 Q_OBJECT
00274 
00275 public:
00276 
00277 //  enum eventCode {
00278 //  EVENT_NONE, EVENT_CLOSECHECK, EVENT_ASKBARCODE,
00279 //  EVENT_RESETCHECK, EVENT_MANUALSALE, EVENT_CONFIRMBUE
00280 //  };
00281 
00282     enum Mode { MOD_OFF, MOD_ONLINE, MOD_CHECKONLINE };
00283 
00284     TECashRegisterBase(int pn, unsigned long nm);
00285     ~TECashRegisterBase();
00286 
00287     static int EANControl(Q_ULLONG code);
00288 
00289     virtual Q_ULONG readROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00290     virtual Q_ULONG readRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00291     virtual Q_ULONG readIRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00292     virtual Q_ULONG readEROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00293     virtual Q_ULONG writeRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00294     virtual Q_ULONG writeIRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00295     virtual Q_ULONG writeEROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
00296 
00297     virtual Q_ULONG readMachineNumber();
00298     virtual int readSoftwareVersion();
00299         virtual int softwareVersion(){return vSoftwareVersion;};
00300     virtual Q_ULONG netNumber();
00301     virtual void setNetNumber( Q_ULONG nn );
00302     virtual Q_ULONG readNetNumber();
00303     virtual void writeNetNumber( Q_ULONG nn );
00304     virtual int readCashSum();
00305     virtual double cashSum() {return vCashSum;};
00306     virtual void setCashSum(double cashSum){vCashSum=cashSum;};
00307     virtual void setPollPausing(bool bPollPausing){m_bPollPausing=bPollPausing;};
00308     virtual bool pollPausing(){return m_bPollPausing;} // pause polling after particular events
00309         virtual bool pollPaused() const {return m_bPollPaused;} // unconditionally pause polling
00310         virtual void setPollPaused(bool pollPaused){m_bPollPaused=pollPaused;}
00311     virtual double buySum(){return vSum;}; // Sum of buyed/returned position
00312     virtual void setBuySum(double sum){vSum=sum;};
00313     virtual double quantity(){return vQuantity;}; 
00314     virtual void setQuantity(double quantity){vQuantity=quantity;};
00315     virtual double price(){return vPrice;};
00316     virtual void setPrice(double price){vPrice=price;};
00317     virtual QString productDesc() {return vProdDesc;};
00318     virtual void setProductDesc(const QString & prodDesc){vProdDesc=prodDesc;};
00319     virtual int precision(){return vQDec;};
00320     virtual void setPrecision(int dec){vQDec=dec;};
00321     virtual int checkNum(){return m_iChkNum;};
00322     virtual void setCheckNum(int iChkNum){m_iChkNum=iChkNum;};
00323     virtual int prodNum(){return m_iProdNum;};
00324     virtual void setProdNum(int iProdNum){m_iProdNum=iProdNum;};
00325     virtual int prodCount(){return m_iProdCnt;};
00326     virtual void setProdCount(int iProdCnt){m_iProdCnt=iProdCnt;};
00327     virtual int section(){return m_iSection;};
00328     virtual void setSection(int iSection){m_iSection=iSection;};
00329     virtual enum Mode currentMode(){return vMode;};
00330     virtual void setReturnFlag(bool bReturnFlag){m_bReturnFlag=bReturnFlag;}
00331     virtual bool returnFlag(){return m_bReturnFlag;}
00332         
00333         void setCheckHeader(const QString & sCheckHeader){m_sCheckHeader=sCheckHeader;}
00334         QString checkHeader() const {return m_sCheckHeader;}
00335 
00336         // this function puts driver in wait for user action state and returns
00337         // When user enters specified command sequense, driver prints check filled with previous call to bueAdd
00338         virtual bool printCheck(bool returnFlag)=0; // returns true on ok, false on error
00339         virtual bool cancelPrint()=0;
00340         virtual bool openCheck()=0;
00341 
00342 // ----------------- New check related functions. ------------------------
00343         virtual bool isCheckOpened();
00344         virtual bool onlinePrintMode();
00345         virtual void setOnlinePrintMode(bool bOnlinePM);
00346         virtual bool isOnlinePrintModeSupported();
00347 
00348         virtual int openCheck(int eDocumentType, int & iReserved);
00349         virtual int beginAdd(int iReserved);
00350         virtual int addTax(int iTax);
00351         virtual int setDiscount(double dDiscount); // absolute value of a discount
00352         virtual int setDiscountPercent(double dDiscProcent);
00353         virtual int setItemSection(int iSection);
00354         virtual int setOperation(int eOperationType);
00355         virtual int setUnit(const QString & sUnit);
00356         virtual int setComment(const QString & sComment);
00357         virtual int setItem(const QString & sName, double dPrice, double dQuantity);
00358         virtual int endAdd(int iReserved);
00359         virtual int cancelAdd(int iReserved);
00360         virtual int setPayment(double dSum, int iType=0); 
00361         virtual int addCheckTax(int iTax); 
00362         virtual int cancelCheck(int iReserved);
00363         virtual int closeCheck(double & dChange, int iReserved);
00364   virtual int curDocumentNumber(int & iDocnum);
00365         
00366         virtual int printItemOut(const PurchaseInfo &);
00367     virtual int payment(double dSum); // 

Generated on Sun Jul 2 23:38:22 2006 for Trade equipment common library. by  doxygen 1.4.7