Пример #1
0
arOpenItem::arOpenItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_save,           SIGNAL(clicked()),                 this, SLOT(sSave()));
  connect(_close,          SIGNAL(clicked()),                 this, SLOT(sClose()));
  connect(_cust,           SIGNAL(newId(int)),                this, SLOT(sPopulateCustInfo(int)));
  connect(_terms,          SIGNAL(newID(int)),                this, SLOT(sPopulateDueDate()));
  connect(_docDate,        SIGNAL(newDate(const QDate&)),     this, SLOT(sPopulateDueDate()));
  connect(_taxLit,         SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail()));
  connect(_amount,         SIGNAL(noConversionRate()),            this, SLOT(noConversionRate()));

  _last = -1;
  _aropenid = -1;

  _arapply->addColumn(tr("Type"),            _dateColumn, Qt::AlignCenter,true, "doctype");
  _arapply->addColumn(tr("Doc. #"),                   -1, Qt::AlignLeft,  true, "docnumber");
  _arapply->addColumn(tr("Apply Date"),      _dateColumn, Qt::AlignCenter,true, "arapply_postdate");
  _arapply->addColumn(tr("Dist. Date"),      _dateColumn, Qt::AlignCenter,true, "arapply_distdate");
  _arapply->addColumn(tr("Amount"),         _moneyColumn, Qt::AlignRight, true, "arapply_applied");
  _arapply->addColumn(tr("Currency"),    _currencyColumn, Qt::AlignLeft,  true, "currabbr");
  _arapply->addColumn(tr("Base Amount"), _bigMoneyColumn, Qt::AlignRight, true, "baseapplied");

  _printOnPost->setVisible(false);

  if (omfgThis->singleCurrency())
      _arapply->hideColumn("currabbr");

  _terms->setType(XComboBox::ARTerms);
  _salesrep->setType(XComboBox::SalesReps);

  _altSalescatid->setType(XComboBox::SalesCategories);

  _rsnCode->setType(XComboBox::ReasonCodes);

  _journalNumber->setEnabled(FALSE);
  _commissionPaid->setEnabled(FALSE);
}
Пример #2
0
void CurrDisplay::sValueLocalChanged(double newValue)
{
    if (_mapper->model() &&
            _mapper->model()->data(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this))).toDouble() != newValue)
        _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)), newValue);

    double oldBase = _valueBase;
    if (ABS(newValue) < EPSILON(_localScale) || _effective.isNull())
    {
        if (ABS(_valueBase) >= EPSILON(_baseScale))
        {
            _valueBase = 0;
            _baseKnown = true;
        }
    }
    else
    {
        XSqlQuery convertVal;
        convertVal.prepare("SELECT currToBase(:curr_id, :value, :date) "
                           " AS baseValue;");
        convertVal.bindValue(":curr_id", id());
        convertVal.bindValue(":value", newValue);
        convertVal.bindValue(":date", _effective);
        convertVal.exec();
        if (convertVal.first())
        {
            _valueBase = convertVal.value("baseValue").toDouble();
            sZeroErrorCount(id(), effective());
            _baseKnown = true;
        }
        else if (convertVal.lastError().type() != QSqlError::NoError)
        {
            if (convertVal.lastError().databaseText().contains("No exchange rate"))
            {
                emit noConversionRate();
                sNoConversionRate(this, id(), effective(), "sValueLocalChanged");
            }
            else
                QMessageBox::critical(this, tr("A System Error occurred at %1::%2.")
                                      .arg(__FILE__)
                                      .arg(__LINE__),
                                      convertVal.lastError().databaseText());
            _baseKnown = false;
        }
    }

    if (ABS(oldBase - _valueBase) > EPSILON(_baseScale))
        emit valueBaseChanged(_valueBase);
}
Пример #3
0
void CurrDisplay::sValueBaseChanged(double newValue)
{
    double oldLocal = _valueLocal;
    if (ABS(newValue) < EPSILON(_baseScale) || _effective.isNull())
    {
        if (ABS(_valueLocal) >= EPSILON(_localScale))
        {
            _valueLocal = 0;
            _valueLocalWidget->clear();
        }
    }
    else
    {
        XSqlQuery convertVal;
        convertVal.prepare("SELECT currToLocal(:curr_id, :value, :date) "
                           " AS localValue;");
        convertVal.bindValue(":curr_id", id());
        convertVal.bindValue(":value", newValue);
        convertVal.bindValue(":date", _effective);
        convertVal.exec();
        if (convertVal.first())
        {
            _valueLocal = convertVal.value("localValue").toDouble();
            sZeroErrorCount(id(), effective());
            _localKnown = true;
        }
        else if (convertVal.lastError().type() != QSqlError::NoError)
        {
            if (convertVal.lastError().databaseText().contains("No exchange rate"))
            {
                emit noConversionRate();
                sNoConversionRate(this, id(), effective(), "sValueBaseChanged");
            }
            else
                QMessageBox::critical(this, tr("A System Error occurred at %1::%2.")
                                      .arg(__FILE__)
                                      .arg(__LINE__),
                                      convertVal.lastError().databaseText());
            _localKnown = false;
        }
    }
    if (ABS(oldLocal - _valueLocal) > EPSILON(_localScale))
        emit valueLocalChanged(_valueLocal);
}