Skip to content
Snippets Groups Projects
Commit ecb57c8b authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Add total to account list

parent c6510599
Branches
Tags
No related merge requests found
...@@ -59,6 +59,11 @@ ...@@ -59,6 +59,11 @@
// TODO stock diff should show null when actual field is null // 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 * All internal prices should be in öre
* Never trust a front end number unless you KNOW it's good * Never trust a front end number unless you KNOW it's good
...@@ -372,16 +377,29 @@ void MainWindow::setMoneyAccountValues() { ...@@ -372,16 +377,29 @@ void MainWindow::setMoneyAccountValues() {
QSqlRecord rec = accModel->record(); QSqlRecord rec = accModel->record();
QVariant projected_price = get_projected_stock_value();
rec.setValue("name", QVariant("Lager (projicerat)")); rec.setValue("name", QVariant("Lager (projicerat)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_projected_stock_value().toDouble() / 100.0, rec.setValue("amount", QVariant(formatMoney(projected_price.toDouble() / 100.0)));
0, 'f', 2)));
accModel->insertRecord(-1, rec); accModel->insertRecord(-1, rec);
QVariant buy_price = get_acquistion_stock_value();
rec.setValue("name", QVariant("Lager (inköp)")); rec.setValue("name", QVariant("Lager (inköp)"));
rec.setValue("amount", QVariant(QString("%1").arg(get_acquistion_stock_value().toDouble() / 100.0, rec.setValue("amount", QVariant(formatMoney(buy_price.toDouble() / 100.0)));
0, 'f', 2))); 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); accModel->insertRecord(-1, rec);
} }
}
QString MainWindow::formatMoney(double in){
return QString("%1").arg(in, 0, 'f', 2);
}
/* /*
* This updates the QSqlTableModel to contain the same data as the database. * This updates the QSqlTableModel to contain the same data as the database.
......
...@@ -110,6 +110,7 @@ private: ...@@ -110,6 +110,7 @@ private:
QVariant get_acquistion_stock_value(); QVariant get_acquistion_stock_value();
void setStockValues(); void setStockValues();
void setAccTransferCombo(); void setAccTransferCombo();
QString formatMoney(double in);
void open_till(); void open_till();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment