Commit ecb57c8b authored by Hugo Hörnquist's avatar Hugo Hörnquist

Add total to account list

parent c6510599
......@@ -59,6 +59,11 @@
// TODO stock diff should show null when actual field is null
// TODO possibly allow each money account in the database two have
// two nemes. One "true" name, which can alse be used as a key.
// And one "fancy" name, that should never be checked agains, and
// can be allowed to be translated.
/*
* All internal prices should be in öre
* Never trust a front end number unless you KNOW it's good
......@@ -372,15 +377,28 @@ void MainWindow::setMoneyAccountValues() {
QSqlRecord rec = accModel->record();
QVariant projected_price = get_projected_stock_value();
rec.setValue("name", QVariant("Lager (projicerat)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_projected_stock_value().toDouble() / 100.0,
0, 'f', 2)));
rec.setValue("amount", QVariant(formatMoney(projected_price.toDouble() / 100.0)));
accModel->insertRecord(-1, rec);
QVariant buy_price = get_acquistion_stock_value();
rec.setValue("name", QVariant("Lager (inköp)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_acquistion_stock_value().toDouble() / 100.0,
0, 'f', 2)));
rec.setValue("amount", QVariant(formatMoney(buy_price.toDouble() / 100.0)));
accModel->insertRecord(-1, rec);
QSqlQuery query("SELECT sum(amount) FROM money");
if (query.next()) {
qlonglong sum = query.value(0).toLongLong()
+ projected_price.toLongLong();
rec.setValue("name", QVariant("Totalt (projicerat)"));
rec.setValue("amount", QVariant(formatMoney((double) sum / 100.0)));
accModel->insertRecord(-1, rec);
}
}
QString MainWindow::formatMoney(double in){
return QString("%1").arg(in, 0, 'f', 2);
}
/*
......
......@@ -110,6 +110,7 @@ private:
QVariant get_acquistion_stock_value();
void setStockValues();
void setAccTransferCombo();
QString formatMoney(double in);
void open_till();
};
......
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