00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 void CashboxCount::init()
00011 {
00012
00013 coinTable->setLeftMargin(0) ;
00014 coinTable->setColumnReadOnly( 0, TRUE ) ;
00015 coinTable->setColumnReadOnly( 2, TRUE ) ;
00016 coinTable->setColumnWidth( 1, 60 ) ;
00017 coinTable->setColumnWidth( 2, 80 ) ;
00018 coinTable->setColumnStretchable( 0, TRUE ) ;
00019
00020 coinTable->setNumRows( 8 ) ;
00021 coinTable->setText( 0, 0, "2 Euro" ) ;
00022 coinTable->setText( 1, 0, "1 Euro" ) ;
00023 coinTable->setText( 2, 0, "50 cts" ) ;
00024 coinTable->setText( 3, 0, "20 cts" ) ;
00025 coinTable->setText( 4, 0, "10 cts" ) ;
00026 coinTable->setText( 5, 0, "5 cts" ) ;
00027 coinTable->setText( 6, 0, "2 cts" ) ;
00028 coinTable->setText( 7, 0, "1 ct" ) ;
00029
00030
00031 notesTable->setLeftMargin(0) ;
00032 notesTable->setColumnReadOnly( 0, TRUE ) ;
00033 notesTable->setColumnReadOnly( 2, TRUE ) ;
00034 notesTable->setColumnWidth( 1, 60 ) ;
00035 notesTable->setColumnWidth( 2, 80 ) ;
00036 notesTable->setColumnStretchable( 0, TRUE ) ;
00037
00038 notesTable->setNumRows( 8 ) ;
00039 notesTable->setText( 0, 0, "5 Euro" ) ;
00040 notesTable->setText( 1, 0, "10 Euro" ) ;
00041 notesTable->setText( 2, 0, "20 Euro" ) ;
00042 notesTable->setText( 3, 0, "50 Euro" ) ;
00043 notesTable->setText( 4, 0, "100 Euro" ) ;
00044 notesTable->setText( 5, 0, "200 Euro" ) ;
00045 notesTable->setText( 6, 0, "500 Euro" ) ;
00046
00047
00048 otherTable->setLeftMargin(0) ;
00049 otherTable->setColumnReadOnly( 0, TRUE ) ;
00050 otherTable->setColumnWidth( 1, 60 ) ;
00051 otherTable->setColumnStretchable( 0, TRUE ) ;
00052
00053 otherTable->setNumRows( 6 ) ;
00054 otherTable->setText( 0, 0, "Cheques" ) ;
00055 otherTable->setText( 1, 0, "C.C. receipts" ) ;
00056 otherTable->setText( 2, 0, "Internal Coupons" ) ;
00057 otherTable->setText( 3, 0, "External Coupons" ) ;
00058 otherTable->setText( 4, 0, "Special Coupons" ) ;
00059 otherTable->setText( 5, 0, "Liability Coupons" ) ;
00060
00061
00062 coinTotalLabel->setText( QString( "%1").arg( 0.0, 0, 'f', 2 ) ) ;
00063 notesTotalLabel->setText( QString( "%1").arg( 0.0, 0, 'f', 2 ) ) ;
00064 moneyTotalLabel->setText( QString( "%1").arg( 0.0, 0, 'f', 2 ) ) ;
00065 }
00066
00067 void CashboxCount::coinQtyChanged( int r, int col )
00068 {
00069 if ( col == 1 ) {
00070 int coinVal =coinTable->text( r, 0 ).section( " ", 0, 0 ).toInt() ;
00071 bool coinType = ( coinTable->text( r, 0 ).section( " ", 1, 1 ) == "Euro" ) ;
00072 int qty = coinTable->text( r, 1 ).toInt() ;
00073 double value = (double)coinVal * (double)qty ;
00074 if ( !coinType ) value = value / 100 ;
00075 coinTable->setText( r, 2, QString( "%1").arg( value, 0, 'f', 2 ) ) ;
00076 double total =0 ;
00077 for ( int i = 0; i < coinTable->numRows(); i++ ) {
00078 total += coinTable->text( i, 2 ).toDouble() ;
00079 }
00080 coinTotalLabel->setText( QString( "%1").arg( total, 0, 'f', 2 ) ) ;
00081 double mt = notesTotalLabel->text().toDouble() ;
00082 moneyTotalLabel->setText( QString( "%1" ).arg( total + mt, 0, 'f', 2 ) ) ;
00083 }
00084 }
00085
00086
00087 void CashboxCount::notesQtyChanged( int r, int col )
00088 {
00089 if ( col == 1 ) {
00090 int noteVal = notesTable->text( r, 0 ).section( " ", 0, 0 ).toInt() ;
00091 int qty = notesTable->text( r, 1 ).toInt() ;
00092 double value = (double)noteVal * (double)qty ;
00093 notesTable->setText( r, 2, QString( "%1").arg( value, 0, 'f', 2 ) ) ;
00094 double total =0 ;
00095 for ( int i = 0; i < notesTable->numRows(); i++ ) {
00096 total += notesTable->text( i, 2 ).toDouble() ;
00097 }
00098 notesTotalLabel->setText( QString( "%1").arg( total, 0, 'f', 2 ) ) ;
00099 double mt = coinTotalLabel->text().toDouble() ;
00100 moneyTotalLabel->setText( QString( "%1" ).arg( total + mt, 0, 'f', 2 ) ) ;
00101 }
00102 }
00103
00104
00105 void CashboxCount::validateCount()
00106 {
00107 QString ticket ="<HTML><BODY>" ;
00108 ticket.append( "<center>LAB Project</center>"
00109 "<center>Linux Advanced Business Tools</center>" ) ;
00110 ticket.append( "<center>********************</center>" ) ;
00111 ticket.append( QString( "<center><b>%1</b></center>" ).arg( tr( "Cash Count" ) ) ) ;
00112 ticket.append( "<center>********************</center>" ) ;
00113 QString line = QString( "Element" ).leftJustify( 20, ' ', TRUE ) ;
00114 line.append( " Qty Value<br>" ) ;
00115 ticket.append( line ) ;
00116 ticket.append( tr( "Coins" ) + "<br>" ) ;
00117 for ( int i = 0; i < coinTable->numRows(); i++ ) {
00118 line = coinTable->text( i, 0 ).leftJustify( 27, '.', TRUE ) ;
00119 line.append( coinTable->text( i,1 ).rightJustify( 3, ' ', FALSE ) );
00120 line.append( coinTable->text( i, 2).rightJustify( 10, ' ', TRUE ) ) ;
00121 line.append( "<br>" ) ;
00122 ticket.append( line ) ;
00123 }
00124 ticket.append( "<br>" ) ;
00125 ticket.append( QString( tr( "Coins Total" ) ).leftJustify( 30, ' ', FALSE ) ) ;
00126 ticket.append( coinTotalLabel->text().rightJustify( 10, ' ', TRUE ) ) ;
00127 ticket.append( "<br>" ) ;
00128 ticket.append( tr( "Bank Notes" ) + "<br>" ) ;
00129 for ( int i = 0; i < notesTable->numRows(); i++ ) {
00130 line = notesTable->text( i, 0 ).leftJustify( 27, '.', TRUE ) ;
00131 line.append( notesTable->text( i,1 ).rightJustify( 3, ' ', FALSE ) ) ;
00132 line.append( notesTable->text( i, 2).rightJustify( 10, ' ', TRUE ) );
00133 line.append( "<br>" ) ;
00134 ticket.append( line ) ;
00135 }
00136 ticket.append( "<br>" ) ;
00137
00138 ticket.append( tr( "Other" ) + "<br>" ) ;
00139 for ( int i = 0; i < otherTable->numRows(); i++ ) {
00140 line = otherTable->text( i, 0 ).leftJustify( 27, '.', TRUE ) ;
00141 line.append( otherTable->text( i,1 ).rightJustify( 3, ' ', FALSE ) ) ;
00142 line.append( otherTable->text( i, 2).rightJustify( 10, ' ', TRUE ) );
00143 line.append( "<br>" ) ;
00144 ticket.append( line ) ;
00145 }
00146 ticket.append( "<br>" ) ;
00147
00148 ticket.append( QString( tr( "Notes Total" ) ).leftJustify( 30, ' ', FALSE ) ) ;
00149 ticket.append( notesTotalLabel->text().rightJustify( 10, ' ', TRUE ) ) ;
00150 ticket.append( "<br><br>" ) ;
00151 ticket.append( QString( tr( "Grand Total" ) ).leftJustify( 30, ' ', FALSE ) ) ;
00152 ticket.append( moneyTotalLabel->text().rightJustify( 10, ' ', TRUE ) ) ;
00153
00154 ticket.append( QString( "<p>Cashbox : %1<br>Cashier: %2" )
00155 .arg( 1 ).arg( "anubis" ) ) ;
00156 ticket.append( "</BODY></HTML>" ) ;
00157 ticket.replace( " ", " " ) ;
00158 qDebug( ticket ) ;
00159 accept() ;
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 }
00205
00206
00207 void CashboxCount::setMode( const QString & mode )
00208 {
00209
00210 }