printing seller receipt started
This commit is contained in:
parent
6e6510ebcf
commit
88d7225e61
3 changed files with 34 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "posprinter.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <exception>
|
||||
|
@ -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;
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
#define POS_PRINTER_H
|
||||
|
||||
#include <sale.h>
|
||||
#include <seller.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue