diff --git a/admin/mainwindow.cpp b/admin/mainwindow.cpp index d50a13bb8b268bb1fb0bf247e897832506171330..0a65cf341c0ec97cfa90259aa996226a83648f20 100644 --- a/admin/mainwindow.cpp +++ b/admin/mainwindow.cpp @@ -346,7 +346,7 @@ void MainWindow::on_inventoryModel_dataChanged(const QModelIndex &topLeft, const int actual = model->data(model->index(row, 5)).toInt(&number); model->setData(model->index(row, 6), - number ? expected - actual + number ? actual - expected : QVariant()); } } diff --git a/create-db.sql b/create-db.sql index f6d29e10264f3d0eb11df333606c88497f5e4d47..7674e69caf741bb7db8fbf91da4b49513681560e 100644 --- a/create-db.sql +++ b/create-db.sql @@ -209,7 +209,7 @@ SELECT d.id AS id, p.name AS name, s.active AS expected, d.amount AS actual, - s.active - d.amount as diff + d.amount - s.active AS diff FROM products p INNER JOIN stock s ON p.id = s.product_id INNER JOIN diff_help d ON p.id = d.product_id;