cancel sales / items finished

This commit is contained in:
Martin Brodbeck 2018-07-28 14:31:37 +02:00
parent 9c56ec55a5
commit 0a22faf856
1 changed files with 7 additions and 1 deletions

View File

@ -171,6 +171,13 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent)
{
if (!parent.isValid()) {
// remove complete sale
emit beginRemoveRows(parent, row, row + count - 1);
auto& sale = marketplace_->getSales().at(row);
sale->setState(Sale::State::DELETE);
std::for_each(sale->getArticles().begin(), sale->getArticles().end(),
[](auto& a) { a->setState(Article::State::DELETE); });
marketplace_->storeToDb();
emit endRemoveRows();
} else if (!parent.parent().isValid()) {
// remove one article from a sale
@ -181,7 +188,6 @@ bool SaleModel::removeRows(int row, int count, const QModelIndex& parent)
sale->removeArticle(articles.at(row));
emit endRemoveRows();
if (articles.size() == 0) {
std::cout << "No articles left.\n";
// marketplace_->removeSale(sale->getUuid());
sale->setState(Sale::State::DELETE);
}