Ejemplo n.º 1
0
void dspInvoiceRegister::sFillList()
{
  display::sFillList();
  list()->expandAll();

  // calculate subtotals and grand total for debit and credit columns and add rows for them
  double debittotal = 0.0;
  double credittotal = 0.0;
  for (int i = 0; i < list()->topLevelItemCount(); i++)
  {
    double debitsum = 0.0;
    double creditsum = 0.0;
    XTreeWidgetItem *item = 0;
    for (int j = 0; j < list()->topLevelItem(i)->childCount(); j++)
    {
      item = list()->topLevelItem(i)->child(j);
//      qDebug("in loop @ %d %p", j, item);
      if (item)
      {
        debitsum += item->rawValue("debit").toDouble();
        creditsum += item->rawValue("credit").toDouble();
        debittotal += item->rawValue("debit").toDouble();
        credittotal += item->rawValue("credit").toDouble();
      }
    }
    if (item)
    {
//      qDebug("adding subtotal %p", item);
      item = new XTreeWidgetItem(list()->topLevelItem(i), -1, -1, tr("Subtotal"));
      item->setData(list()->column("debit"),  Qt::EditRole, formatMoney(debitsum));
      item->setData(list()->column("credit"), Qt::EditRole, formatMoney(creditsum));
    }
  }
  XTreeWidgetItem *item = new XTreeWidgetItem(list(), -1, -1, tr("Total"));
  item->setData(list()->column("debit"),  Qt::EditRole, formatMoney(debittotal));
  item->setData(list()->column("credit"), Qt::EditRole, formatMoney(credittotal));
}
Ejemplo n.º 2
0
/*!
  Populates the list of setup widgets filtered by selectd module.  Selects the first item
  when \a first is true.
  */
void setup::populate(bool first)
{
  _tree->clear();
  while (_stack->count())
  {
    QWidget* w = _stack->widget(0);
    _stack->removeWidget(w);
    w = 0;
  }

  XTreeWidgetItem* _configItem = new XTreeWidgetItem(_tree, 0, -1, tr("Configure"));
  XTreeWidgetItem* _mapItem = new XTreeWidgetItem(_tree, 0, -1, tr("Accounting Mappings"));
  XTreeWidgetItem* _masterItem = new XTreeWidgetItem(_tree, 0, -1, tr("Master Information"));
  QBrush disabled(Qt::gray);
  XTreeWidgetItem* parent = 0;
  ItemProps ip;
  int id = 0;

  QMapIterator<QString, ItemProps> i(_itemMap);
  while (i.hasNext())
  {
    id++;
    i.next();
    ip = i.value();
    _itemMap[i.key()].index = -1;
    _itemMap[i.key()].id    = -1;

    if (_modules->currentIndex() == 0 ||
        _modules->itemData(_modules->currentIndex()).toInt() & ip.modules)
    {
      if (ip.type == Configure)
        parent = _configItem;
      else if (ip.type == AccountMapping)
        parent = _mapItem;
      else
        parent = _masterItem;

      // Set the item on the list
      XTreeWidgetItem* item  = new XTreeWidgetItem(parent, id);
      item->setData(0, Qt::DisplayRole, QVariant(ip.title));
      item->setData(0, Xt::RawRole, QVariant(i.key()));

      if (!ip.enabled)
      {
        item->setFlags(Qt::NoItemFlags);
        item->setForeground(0,disabled);
      }
      parent->addChild(item);

      _itemMap[i.key()].id = id;
    }
  }

  if (!_configItem->childCount())
    _tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_configItem));

  if (!_mapItem->childCount())
    _tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_mapItem));

  if (!_masterItem->childCount())
    _tree->takeTopLevelItem(_tree->indexOfTopLevelItem(_masterItem));

  _tree->expandAll();
  if (_tree->topLevelItemCount() && first)
    setCurrentIndex(_tree->topLevelItem(0));
}
Ejemplo n.º 3
0
void dspInvoiceRegister::sFillList()
{
  ParameterList params;
  if (! setParams(params))
    return;

  MetaSQLQuery mql(
     "SELECT DISTINCT"
     "       -1 AS gltrans_id, -1 AS altId,"
     "       gltrans_date,  '' AS gltrans_source,"
     "       '' AS doctype, '' AS gltrans_docnumber,"
     "       '' AS notes,   '' AS account,"
     "       CAST(NULL AS NUMERIC) AS debit,"
     "       CAST(NULL AS NUMERIC) AS credit,"
     "       'curr' AS debit_xtnumericrole,"
     "       'curr' AS credit_xtnumericrole,"
     "       0 AS xtindentrole,"
     "       gltrans_date AS transdate,"  // qtdisplay role isn't working right?
     "       1 AS debit_xttotalrole,"
     "       1 AS credit_xttotalrole "
     "FROM gltrans "
     "WHERE ((gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))"
     " AND (gltrans_source = 'A/R')"
     " AND (gltrans_date BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>) "
     "<? if exists(\"accnt_id\") ?>"
     " AND (gltrans_accnt_id=<? value(\"accnt_id\") ?>)"
     "<? endif ?>"
     ") "
     "UNION "
     "SELECT gltrans_id,"
     "       CASE WHEN(gltrans_doctype='IN') THEN 1"
     "            WHEN(gltrans_doctype='CM') THEN 2"
     "            WHEN(gltrans_doctype='DM') THEN 3"
     "            WHEN(gltrans_doctype='CD') THEN 4"
     "            ELSE -1"
     "       END AS altId,"
     "       gltrans_date, gltrans_source,"
     "       CASE WHEN(gltrans_doctype='IN') THEN <? value(\"invoice\") ?>"
     "            WHEN(gltrans_doctype='CM') THEN <? value(\"creditmemo\") ?>"
     "            WHEN(gltrans_doctype='DM') THEN <? value(\"debitmemo\") ?>"
     "            WHEN(gltrans_doctype='CD') THEN <? value(\"cashdeposit\") ?>"
     "            ELSE gltrans_doctype"
     "       END AS doctype,"
     "       gltrans_docnumber,"
     "       CASE WHEN(gltrans_doctype='IN') THEN"
     "                (SELECT invchead_shipto_name"
     "                   FROM aropen LEFT OUTER JOIN"
     "                        invchead"
     "                          ON (invchead_id=aropen_cobmisc_id"
     "                          AND invchead_cust_id=aropen_cust_id)"
     "                  WHERE ((aropen_docnumber=gltrans_docnumber)"
     "                    AND  (aropen_doctype='I')))"
     "            ELSE firstLine(gltrans_notes)"
     "       END AS f_notes,"
     "       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,"
     "       CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)"
     "            ELSE 0"
     "       END AS debit,"
     "       CASE WHEN (gltrans_amount > 0) THEN gltrans_amount"
     "            ELSE 0"
     "       END AS credit,"
     "       'curr' AS debit_xtnumericrole,"
     "       'curr' AS credit_xtnumericrole,"
     "       1 AS xtindentrole,"
     "       NULL AS transdate,"          // qtdisplay role isn't working right?
     "       0 AS debit_xttotalrole,"
     "       0 AS credit_xttotalrole "
     "FROM gltrans, accnt "
     "WHERE ((gltrans_accnt_id=accnt_id)"
     " AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))"
     " AND (gltrans_source = 'A/R')"
     " AND (gltrans_date BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>)"
     "<? if exists(\"accnt_id\") ?>"
     " AND (gltrans_accnt_id=<? value(\"accnt_id\") ?>)"
     "<? endif ?>"
     ") "
     "ORDER BY gltrans_date, gltrans_docnumber, xtindentrole;");

  q = mql.toQuery(params);
  _gltrans->populate(q, true);
  _gltrans->expandAll();

  // calculate subtotals for debit and credit columns and add rows for them
  for (int i = 0; i < _gltrans->topLevelItemCount(); i++)
  {
    double debitsum = 0.0;
    double creditsum = 0.0;
    XTreeWidgetItem *item = 0;
    for (int j = 0; j < _gltrans->topLevelItem(i)->childCount(); j++)
    {
      item = _gltrans->topLevelItem(i)->child(j);
      qDebug("in loop @ %d %p", j, item);
      if (item)
      {
        debitsum += item->rawValue("debit").toDouble();
        creditsum += item->rawValue("credit").toDouble();
      }
    }
    if (item)
    {
      qDebug("adding subtotal %p", item);
      item = new XTreeWidgetItem(_gltrans->topLevelItem(i), -1, -1, tr("Subtotal"));
      item->setData(_gltrans->column("debit"),  Qt::EditRole, formatMoney(debitsum));
      item->setData(_gltrans->column("credit"), Qt::EditRole, formatMoney(creditsum));
    }
  }
}