Общая библиотека для работы с торговым оборудованием.  1.0.0
tecashregisterbase.h
1 /****************************************************************************
2 ** $Id: tecashregisterbase.h,v 1.20 2006/12/01 16:45:51 leader Exp $
3 **
4 ** Trade equipment common portable library project
5 **
6 ** Copyright (C) 1999-2006 Leader InfoTech. All rights reserved.
7 **
8 ** This file is part of the Library of the Ananas
9 ** automation accounting system.
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 as published by the Free Software
13 ** Foundation and appearing in the file LICENSE.GPL included in the
14 ** packaging of this file.
15 **
16 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 **
19 ** See http://www.leaderit.ru/ or email sales@leaderit.ru
20 **
21 ** Contact org@leaderit.ru if any conditions of this licensing are
22 ** not clear to you.
23 **
24 **********************************************************************/
25 
26 /*
27  Abstract cash register interface object
28  (c) V.Grazdankin, 1999-2005
29 */
30 #include <tebase.h> // Damn, We should place that 'include' before 'define TECASHREG...', see templexports.h
31 #ifndef TECASHREGISTERBASE_H
32 #define TECASHREGISTERBASE_H
33 #include <qdict.h>
34 #include <qstring.h>
35 #include <qvariant.h>
36 #include <qsqldatabase.h>
37 #include <qvaluelist.h>
38 //#include <vector>
39 
40 //using std::vector;
41 
42 //#ifdef Q_OS_UNIX
43 //enum par_code { COM_NONE, COM_EVEN, COM_ODD, COM_ZERO, COM_ONE };
44 //void serial_setparams(int port, int speed, int bits, enum par_code parity, int stopbits);
45 //#endif
46 
47 //
48 /*
49 typedef struct {
50  int KL; // # control line
51  int NBue; // # bue
52  int NCBue; // # bue in check
53  int Dep; // # departament
54  char AskCode[20]; // asking barcode
55  char Code[20]; // finding barcode
56  char Name[200]; // full name
57  char PName[20]; // printable name
58  double Price; // price
59  double Quantity; // quantity
60  double Sum; // summa
61  double Discount; // discount
62 } Bue_Item;
63 */
64 
65 
66 typedef struct {
67  char Cmd;
68  unsigned long NM;
69  unsigned int Addr;
70  char Len;
71  char data[16];
72  char CS;
73 } Socket_Rec;
74 
75 //
76 typedef struct {
77  int nbue;
78  char code[20];
79  char name[60];
80 } bue_lst;
81 
82 /*
83 class CCMConnection : public QObject
84 {
85 Q_OBJECT
86 
87 public:
88 
89 };
90 */
91 
92 class CCM_CheckItem : public QObject
93 {
94 Q_OBJECT
95 
96 public:
97  CCM_CheckItem();
98  ~CCM_CheckItem();
99 
100 private:
101  int KL; // # control line
102  int NBue; // # bue
103  int NCBue; // # bue in check
104  int Dep; // # departament
105  char AskCode[20]; // asking barcode
106  char Code[20]; // finding barcode
107  char Name[200]; // full name
108  char PName[20]; // printable name
109  double Price; // price
110  double Quantity; // quantity
111  double Sum; // summa
112  double Discount; // discount
113 };
114 
115 struct LIB_EXPORT PurchaseInfo
116 {
117  PurchaseInfo()
118  {
119  clear();
120  }
121 
122  PurchaseInfo(const PurchaseInfo & in) :
123  m_name(in.m_name),m_dep(in.m_dep),m_price(in.m_price),m_quantity(in.m_quantity),
124  m_qdec(in.m_qdec),m_taxes(in.m_taxes),m_dDiscount(in.m_dDiscount),
125  m_isDiscountInPercent(in.m_isDiscountInPercent), m_iOperation(in.m_iOperation),
126  m_sUnit(in.m_sUnit), m_sComment(in.m_sComment), m_isEmpty(in.m_isEmpty)
127  {
128  }
129 
130  PurchaseInfo(const QString &name, int dep, double price, double quantity, int qdec):
131  m_name(name),m_dep(dep),m_price(price),m_quantity(quantity),m_qdec(qdec),m_isEmpty(false)
132  {
133  }
134 
135  void clear()
136  {
137  m_isEmpty=true;
138  m_name="";
139  m_dep=0;
140  m_price=0;
141  m_quantity=0;
142  m_qdec=3;
143  m_taxes.clear();
144  m_dDiscount=0;
145  m_isDiscountInPercent=false;
146  m_iOperation=-1;
147  m_sUnit="";
148  m_sComment="";
149  }
150 
151  bool isEmpty()
152  {
153  return m_isEmpty;
154  }
155 
156  QString m_name;
157  int m_dep;
158  double m_price;
159  double m_quantity;
160  int m_qdec;
161  QValueList<int> m_taxes;
162  double m_dDiscount;
163  bool m_isDiscountInPercent;
164  int m_iOperation;
165  QString m_sUnit,m_sComment;
166  bool m_isEmpty;
167  bool operator < (const PurchaseInfo & in) const
168  {
169  return m_name<in.m_name;
170  }
171  bool operator == (const PurchaseInfo & in) const
172  {
173  return (m_name==in.m_name) && (m_dep==in.m_dep) && (m_price==in.m_price) && (m_quantity==in.m_quantity);
174  }
175 };
176 
177 /*
178 Class for database connection and work.
179 */
180 /*
181 class CCM_Database : public QObject
182 {
183 public:
184  CCM_Database();
185  ~CCM_Database();
186 private:
187  QSqlDatabase *db;
188 };
189 */
190 //---------------------------------------------------------------------------
191 class KKM_IO : public QObject
192 {
193 Q_OBJECT
194 
195 public:
196  unsigned long MachineNumber;
197  int Channal;
198  KKM_IO(int Chan, unsigned long nm);
199  ~KKM_IO();
200 
201 private:
202 
203 };
204 //---------------------------------------------------------------------------
205 
206 #define EVENT_NONE 0
207 #define EVENT_CLOSECHECK 1
208 #define EVENT_ASKBARCODE 2
209 #define EVENT_RESETCHECK 3
210 #define EVENT_MANUALSALE 4
211 #define EVENT_CONFIRMBUE 5
212 #define EVENT_PRINT_ZERO_CHECK 11
213 #define EVENT_REQUEST_ZREPORT 12
214 
215 #define EVENT_POWEROFF 100
216 #define EVENT_POWERON 101
217 #define EVENT_BUSY 102
218 #define EVENT_READY 103
219 #define EVENT_DRIVER_ACTIVATED 104
220 #define EVENT_DRIVER_ACTIVATION_FAILED 105
221 #define EVENT_CRITICAL_FAIL 106
222 #define EVENT_CONFIRMATION 107
223 #define EVENT_UNKNOWN 128
224 
225 enum CROperations
226 {
227  CRO_SELL=0x0,
228  CRO_BUY=0x1,
229  CRO_SELLRET=0x2,
230  CRO_BUYRET=0x3,
231  CRO_SELLSTORNO=0x4,
232  CRO_BUYSTORNO=0x5,
233  CRO_CASHIN=0x6,
234  CRO_CASHOUT=0x7,
235  CRO_DISCOUNT=0x8,
236  CRO_DISCOUNTPERCENT=0x9,
237  CRO_OPMASK=0xF
238  //CRO_SIMPLEMODE=0x8,
239  //CRO_MODEMASK=0x8,
240  //CRO_CASHLESS=0x10,
241  //CRO_PAYMENTMASK=0x10
242 };
243 
244 //template class LIB_EXPORT QDict <QVariant>;
245 //template class LIB_EXPORT std::vector <PurchaseInfo>;
246 //template class LIB_EXPORT std::allocator <PurchaseInfo>;
247 #include <templexports.h>
248 
249 struct LIB_EXPORT CheckInfo
250 {
251  QValueList<int> m_vTaxes;
252  QMap<int,double> m_mPayment;
253  int m_DefaultOperation;
254  int m_CheckOperation;
255 };
256 
257 enum PassType
258 {
259  PTOperator=0,
260  PTAdmin=1,
261  PTFiscal=2
262 };
263 
264 class LIB_EXPORT TECashRegisterBase : public TEBase
265 {
266 Q_OBJECT
267 
268 public:
269 
270 // enum eventCode {
271 // EVENT_NONE, EVENT_CLOSECHECK, EVENT_ASKBARCODE,
272 // EVENT_RESETCHECK, EVENT_MANUALSALE, EVENT_CONFIRMBUE
273 // };
274 
275  enum Mode { MOD_OFF, MOD_ONLINE, MOD_CHECKONLINE };
276 
277  TECashRegisterBase(int pn, unsigned long nm);
279 
280  static int EANControl(Q_ULLONG code);
281 
282  virtual Q_ULONG readROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
283  virtual Q_ULONG readRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
284  virtual Q_ULONG readIRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
285  virtual Q_ULONG readEROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
286  virtual Q_ULONG writeRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
287  virtual Q_ULONG writeIRAM( char *buf, Q_ULONG Addr, Q_ULONG Len );
288  virtual Q_ULONG writeEROM( char *buf, Q_ULONG Addr, Q_ULONG Len );
289 
290  virtual Q_ULONG readMachineNumber();
291  virtual int readSoftwareVersion();
292  virtual int softwareVersion(){return (int)vSoftwareVersion;};
293  virtual Q_ULONG netNumber();
294  virtual void setNetNumber( Q_ULONG nn );
295  virtual Q_ULONG readNetNumber();
296  virtual void writeNetNumber( Q_ULONG nn );
297  virtual int readCashSum();
298  virtual double cashSum() {return vCashSum;};
299  virtual void setCashSum(double cashSum){vCashSum=cashSum;};
300  virtual void setPollPausing(bool bPollPausing){m_bPollPausing=bPollPausing;};
301  virtual bool pollPausing(){return m_bPollPausing;} // pause polling after particular events
302  virtual bool pollPaused() const {return m_bPollPaused;} // unconditionally pause polling
303  virtual void setPollPaused(bool pollPaused){m_bPollPaused=pollPaused;}
304  virtual double buySum(){return vSum;}; // Sum of buyed/returned position
305  virtual void setBuySum(double sum){vSum=sum;};
306  virtual double quantity(){return vQuantity;};
307  virtual void setQuantity(double quantity){vQuantity=quantity;};
308  virtual double price(){return vPrice;};
309  virtual void setPrice(double price){vPrice=price;};
310  virtual QString productDesc() {return vProdDesc;};
311  virtual void setProductDesc(const QString & prodDesc){vProdDesc=prodDesc;};
312  virtual int precision(){return vQDec;};
313  virtual void setPrecision(int dec){vQDec=dec;};
314  virtual int checkNum(){return m_iChkNum;};
315  virtual void setCheckNum(int iChkNum){m_iChkNum=iChkNum;};
316  virtual int prodNum(){return m_iProdNum;};
317  virtual void setProdNum(int iProdNum){m_iProdNum=iProdNum;};
318  virtual int prodCount(){return m_iProdCnt;};
319  virtual void setProdCount(int iProdCnt){m_iProdCnt=iProdCnt;};
320  virtual int section(){return m_iSection;};
321  virtual void setSection(int iSection){m_iSection=iSection;};
322  virtual enum Mode currentMode(){return vMode;};
323  virtual void setReturnFlag(bool bReturnFlag){m_bReturnFlag=bReturnFlag;}
324  virtual bool returnFlag(){return m_bReturnFlag;}
325 
326  void setCheckHeader(const QString & sCheckHeader){m_sCheckHeader=sCheckHeader;}
327  QString checkHeader() const {return m_sCheckHeader;}
328 
329  // this function puts driver in wait for user action state and returns
330  // When user enters specified command sequense, driver prints check filled with previous call to bueAdd
331  virtual bool printCheck(bool returnFlag)=0; // returns true on ok, false on error
332  virtual bool cancelPrint()=0;
333  virtual bool openCheck()=0;
334 
335 //
336  virtual int openCashbox(int n); // open cash box number n
337  virtual int ZReport();
338  virtual int XReport();
339 
340 // ----------------- New check related functions. ------------------------
341  virtual bool isCheckOpened();
342  virtual bool onlinePrintMode();
343  virtual void setOnlinePrintMode(bool bOnlinePM);
344  virtual bool isOnlinePrintModeSupported();
345 
346  virtual int openCheck(int eDocumentType, int & iReserved);
347  virtual int beginAdd(int iReserved);
348  virtual int addTax(int iTax);
349  virtual int setDiscount(double dDiscount); // absolute value of a discount
350  virtual int setDiscountPercent(double dDiscProcent);
351  virtual int setItemSection(int iSection);
352  virtual int setOperation(int eOperationType);
353  virtual int setUnit(const QString & sUnit);
354  virtual int setComment(const QString & sComment);
355  virtual int setItem(const QString & sName, double dPrice, double dQuantity);
356  virtual int endAdd(int iReserved);
357  virtual int cancelAdd(int iReserved);
358  virtual int setPayment(double dSum, int iType=0);
359  virtual int addCheckTax(int iTax);
360  virtual int cancelCheck(int iReserved);
361  virtual int closeCheck(double & dChange, int iReserved);
362  virtual int curDocumentNumber(int & iDocnum);
363  virtual int curControlLineNumber(int & iLinenum);
364  virtual double summaTotal();
365 
366  virtual int printItemOut(const PurchaseInfo &);
367  virtual int payment(double dSum); //
Definition: tecashregisterbase.h:92
Definition: tecashregisterbase.h:249
Definition: tecashregisterbase.h:66
Definition: tecashregisterbase.h:115
The TECashRegisterBase is base class for all cash registers classes.
Definition: tecashregisterbase.h:191
Definition: tecashregisterbase.h:76
The TEBase is base class for all trade equipment classes.
Definition: tebase.h:148