finish current sale

This commit is contained in:
Martin Brodbeck 2018-07-21 21:18:22 +02:00
parent 8b534e1229
commit 150ce946d1
5 changed files with 81 additions and 11 deletions

View file

@ -1,7 +1,7 @@
#include "mainwindow.h"
#include "sellerdialog.h"
#include "pricedialog.h"
#include "sellerdialog.h"
#include <regex>
@ -45,28 +45,30 @@ void MainWindow::on_sellerNoEdit_checkSellerNo()
auto inputText = ui_.sellerNoEdit->text().toStdString();
if (inputText.empty()) {
if (marketplace_->basketSize() > 0) {
marketplace_->finishCurrentSale();
}
return;
}
regex pattern{R"(\d{1,5})"};
smatch result;
if (!regex_match(inputText, result, pattern)) {
return;
}
int sellerNo = std::stoi(result[0]);
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
if (seller) {
std::cout << "!!! Seller gefunden: " << seller->getFirstName() << "\n";
PriceDialog priceDialog(this);
auto dialogResult = priceDialog.exec();
if (dialogResult == QDialog::Accepted)
{
if (dialogResult == QDialog::Accepted) {
int price = priceDialog.getPrice();
auto article = std::make_unique<Article>(price);
article->setSeller(seller);
std::cout << "!!! Neuer Artikel: " << article->getPrice() << "Cent \n";
std::cout << "!!! Neuer Artikel: " << article->getPrice() << " Cent \n";
marketplace_->addArticleToBasket(std::move(article));
}
}