Commit 9616397b authored by Hugo Hörnquist's avatar Hugo Hörnquist

money transfer submit button should now update money stats

parent 01a523df
......@@ -312,11 +312,6 @@ MainWindow::MainWindow(QWidget *parent) :
// ==================================================
// QIntValidator* pIntVal = new QIntValidator(0, INT_MAX);
// ui->moneyMoveAmount->setValidator(pIntVal);
// ui->addMoneyEdit->setValidator(pIntVal);
// updateMoneyString();
QSqlTableModel* accModel = new QSqlTableModel();
ui->accTreeView->setModel(accModel);
accModel->setTable("money_simple");
......@@ -325,17 +320,7 @@ MainWindow::MainWindow(QWidget *parent) :
accModel->setHeaderData(1, Qt::Horizontal, "Kronor");
accModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
QSqlRecord rec = accModel->record();
rec.setValue("name", QVariant("Lager (projicerat)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_projected_stock_value().toDouble() / 100.0,
0, 'f', 2)));
accModel->insertRecord(-1, rec);
rec.setValue("name", QVariant("Lager (inköp)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_acquistion_stock_value().toDouble() / 100.0,
0, 'f', 2)));
accModel->insertRecord(-1, rec);
setMoneyAccountValues();
QSqlQuery accQuery("SELECT id, name FROM money");
while (accQuery.next()) {
......@@ -351,7 +336,26 @@ MainWindow::~MainWindow()
void MainWindow::updateMoneyString()
{
qDebug () << "Updating Money Strings";
setMoneyDiffLabels();
setMoneyAccountValues();
}
void MainWindow::setMoneyAccountValues() {
QSqlTableModel* accModel = (QSqlTableModel*) ui->accTreeView->model();
accModel->select();
QSqlRecord rec = accModel->record();
rec.setValue("name", QVariant("Lager (projicerat)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_projected_stock_value().toDouble() / 100.0,
0, 'f', 2)));
accModel->insertRecord(-1, rec);
rec.setValue("name", QVariant("Lager (inköp)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_acquistion_stock_value().toDouble() / 100.0,
0, 'f', 2)));
accModel->insertRecord(-1, rec);
}
/*
......@@ -694,6 +698,7 @@ int MainWindow::setMoneyDiffLabels()
ui->diffExpected->setText(diff_text);
ui->diffTotal->setText(diff_text);
ui->diffDrawer->setText("");
return expected;
}
......@@ -860,4 +865,6 @@ void MainWindow::on_accTransferSubmit_clicked()
ui->accTransferText->setText("");
// TODO update money values
updateMoneyString();
}
......@@ -100,6 +100,7 @@ private:
void addRemoveCommon(QString from, QString to);
void clear_stockDiffTemp();
void setProductFilter();
void setMoneyAccountValues();
QVariant get_projected_stock_value();
QVariant get_acquistion_stock_value();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment