Logo Search packages:      
Sourcecode: lemonpos version File versions  Download package

void lemonView::corteDeCaja (  )  [private, slot]

This slot is used to make a balance for the user (initial + in - out = drawer amount).

Definition at line 1703 of file lemonview.cpp.

References Gaveta::getAvailableInCash(), Gaveta::getInAmount(), Gaveta::getInitialAmount(), Gaveta::getOutAmount(), Gaveta::getTransactionIds(), Azahar::getTransactionInfo(), printBalance(), and Azahar::setDatabase().

{
  qDebug()<<"Doing Balance..";
  preCancelCurrentTransaction();
  QStringList lines;
  QStringList linesHTML;
  QString line;

  QString dId;
  QString dAmount;
  QString dHour;
  QString dMinute;
  QString dPaidWith;
  QString dPayMethod;

  saveBalance();

  // Create lines to print and/or show on dialog...

  //----------Translated strings--------------------
  QString strTitle      = i18n("Balance for user %1", loggedUserName);
  QString strInitAmount = i18n("Initial Amount deposited:");
  QString strInitAmountH= i18n("Deposit");
  QString strInH         = i18n("In");
  QString strOutH        = i18n("Out");
  QString strInDrawerH   = i18n("In Drawer");
  QString strTitlePre    = i18n("Drawer Balance");
  QString strTitleTrans  = i18n("Transactions Details");
  QString strTitleTransH = i18n("Transactions");
  QString strId          = i18n("Id");
  QString strTimeH       = i18n("Time");
  QString strAmount      = i18n("Amount");
  QString strPaidWith    = i18n("Paid with");
  QString strPayMethodH =  i18n("Pay Method");

 //TODO: Hacer el dialogo de balance mejor, con un look uniforme a los demas dialogos.
//       Incluso insertar imagenes en el html del dialogo.

  //HTML
  line = QString("<html><body><h3>%1</h3>").arg(strTitle);
  linesHTML.append(line);
  line = QString("<center><table border=1 cellpadding=5><tr><th colspan=4>%9</th></tr><tr><th>%1</th><th>%2</th><th>%3</th><th>%4</th></tr><tr><td>%5</td><td>%6</td><td>%7</td><td>%8</td></tr></table></ceter><br>")
      .arg(strInitAmountH)
      .arg(strInH)
      .arg(strOutH)
      .arg(strInDrawerH)
      .arg(KGlobal::locale()->formatMoney(drawer->getInitialAmount(), QString(), 2))
      .arg(KGlobal::locale()->formatMoney(drawer->getInAmount(), QString(), 2))
      .arg(KGlobal::locale()->formatMoney(drawer->getOutAmount(), QString(), 2))
      .arg(KGlobal::locale()->formatMoney(drawer->getAvailableInCash(), QString(), 2))
      .arg(strTitlePre);
  linesHTML.append(line);
  line = QString("<table border=1 cellpadding=5><tr><th colspan=5>%1</th></tr><tr><th>%2</th><th>%3</th><th>%4</th><th>%5</th><th>%6</th></tr>")
      .arg(strTitleTransH)
      .arg(strId)
      .arg(strTimeH)
      .arg(strAmount)
      .arg(strPaidWith)
      .arg(strPayMethodH);
  linesHTML.append(line);

  //TXT
  lines.append(strTitle);
  line = QString(KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), KLocale::LongDate));
  lines.append(line);
  lines.append("----------------------------------------");
  line = QString("%1 %2").arg(strInitAmount).arg(KGlobal::locale()->formatMoney(drawer->getInitialAmount(), QString(), 2));
  lines.append(line);
  line = QString("%1 :%2, %3 :%4")
      .arg(strInH)
      .arg(KGlobal::locale()->formatMoney(drawer->getInAmount(), QString(), 2))
      .arg(strOutH)
      .arg(KGlobal::locale()->formatMoney(drawer->getOutAmount(), QString(), 2));
  lines.append(line);
  line = QString(" %1 %2").arg(KGlobal::locale()->formatMoney(drawer->getAvailableInCash(), QString(), 2)).arg(strInDrawerH);
  lines.append(line);
  //Now, add a transactions report per user and for today.
  //At this point, drawer must be initialized and valid.
  line = QString("----------%1----------").arg(strTitleTrans);
  lines.append(line);
  line = QString("%1           %2      %3").arg(strId).arg(strAmount).arg(strPaidWith);
  lines.append(line);
  lines.append("----------  ----------  ----------");
  QList<qulonglong> transactionsByUser = drawer->getTransactionIds();
  //This gets all transactions ids done since last corteDeCaja.
  Azahar *myDb = new Azahar;
  myDb->setDatabase(db);
  for (int i = 0; i < transactionsByUser.size(); ++i) {
    qulonglong idNum = transactionsByUser.at(i);
    TransactionInfo info;
    info = myDb->getTransactionInfo(idNum);

    dId       = QString::number(info.id);
    dAmount   = QString::number(info.amount);
    dHour     = info.time.toString("hh");
    dMinute   = info.time.toString("mm");
    dPaidWith = QString::number(info.paywith);

    while (dId.length()<10) dId = dId.insert(dId.length(), ' ');
    while (dAmount.length()<14) dAmount = dAmount.insert(dAmount.length(), ' ');
    while ((dHour+dMinute).length()<6) dMinute = dMinute.insert(dMinute.length(), ' ');
    while (dPaidWith.length()<10) dPaidWith = dPaidWith.insert(dPaidWith.length(), ' ');

    if (info.paymethod == pCash) dPayMethod = i18n("Cash");/*dPaidWith;*/
    else if (info.paymethod == pCard) dPayMethod = i18n("Card");  else dPayMethod = i18n("Unknown");
    line = QString("%1 %2 %3")
       .arg(dId)
       //.arg(dHour)
       //.arg(dMinute)
       .arg(dAmount)
       //.arg(dPaidWith);
       .arg(dPayMethod);
    lines.append(line);
    line = QString("<tr><td>%1</td><td>%2:%3</td><td>%4</td><td>%5</td><td>%6</td></tr>")
       .arg(dId)
       .arg(dHour)
       .arg(dMinute)
       .arg(dAmount)
       .arg(dPaidWith)
       .arg(dPayMethod);
    linesHTML.append(line);
  }
  line = QString("</table></body></html>");
  linesHTML.append(line);
  operationStarted = false;
  showBalance(linesHTML);
  printBalance(lines);
  slotDoStartOperation();
}


Generated by  Doxygen 1.6.0   Back to index