diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 2efe39a..93f52b8 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -238,7 +238,7 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked) auto indexes = selModel->selectedRows(); auto& sale = marketplace_->getSales().at(indexes[0].row()); PosPrinter printer; - printer.printReceipt(sale.get()); + printer.printSaleReceipt(sale.get()); } void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked) diff --git a/src/printer/posprinter.cpp b/src/printer/posprinter.cpp index 359bd2a..8e33bc5 100644 --- a/src/printer/posprinter.cpp +++ b/src/printer/posprinter.cpp @@ -1,5 +1,9 @@ #include "posprinter.h" +#include + +#include "boost/date_time/posix_time/posix_time.hpp" + #include #include #include @@ -136,7 +140,7 @@ void PosPrinter::printTest() write(commandStream.str()); } -void PosPrinter::printReceipt(Sale* sale) +void PosPrinter::printSaleReceipt(Sale* sale) { std::stringstream commandStream; printHeader(); @@ -151,4 +155,29 @@ void PosPrinter::printReceipt(Sale* sale) commandStream << "\n\nVielen Dank für Ihren Einkauf!"; commandStream << Command::LEFT_ALIGN << Command::FEED; write(commandStream.str()); +} + +void PosPrinter::printSellerReceipt(Seller* seller, int percent, int maxFee) +{ + std::stringstream commandStream; + printHeader(); + commandStream << Command::RESET << Command::ENCODING << Command::RIGHT_ALIGN; + std::string timeStr = boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()); + commandStream << timeStr << "\n\n"; + commandStream << Command::LEFT_ALIGN; + commandStream << "Verkäufernummer: " << std::setw(4) << seller->getSellerNo() << "\n\n"; + commandStream << "Anzahl Artikel geliefert: " << std::setw(4) << seller->numArticlesOffered() << "\n"; + commandStream << "Anzahl Artikel verkauft: " << std::setw(4) << seller->numArticlesSold() << "\n\n"; + if (seller->getArticles(true).size() == 0) { + commandStream << "Verkaufte Artikel:\n *** keine ***\n"; + } else { + commandStream << "Verkaufte Artikel:\n"; + } + for (auto& article : seller->getArticles(true)) { + commandStream << "Art. " << article->getCompleteArticleNo() << "........... " << article->getPriceAsString() << "\n"; + } + commandStream << "\nGesamt................." << seller->sumAsString() << "\n"; + commandStream << "./. Gebühr............." << marketFeeAsString(seller->sumInCents(), percent, maxFee * 100) << "\n"; + commandStream << "\nAuszahlung............." << paymentAsString(seller->sumInCents(), percent, maxFee * 100) << "\n"; + commandStream << Command::FEED; } \ No newline at end of file diff --git a/src/printer/posprinter.h b/src/printer/posprinter.h index f9573cd..a2ac543 100644 --- a/src/printer/posprinter.h +++ b/src/printer/posprinter.h @@ -2,6 +2,7 @@ #define POS_PRINTER_H #include +#include #include @@ -23,7 +24,8 @@ class PosPrinter void write(const std::string& text); void printHeader(); void printTest(); - void printReceipt(Sale* sale); + void printSaleReceipt(Sale* sale); + void printSellerReceipt(Seller* seller, int percent, int maxFee); struct Command { static const std::string RESET;