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 indexes = selModel->selectedRows();
|
||||||
auto& sale = marketplace_->getSales().at(indexes[0].row());
|
auto& sale = marketplace_->getSales().at(indexes[0].row());
|
||||||
PosPrinter printer;
|
PosPrinter printer;
|
||||||
printer.printReceipt(sale.get());
|
printer.printSaleReceipt(sale.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "posprinter.h"
|
#include "posprinter.h"
|
||||||
|
|
||||||
|
#include <marketplace.h>
|
||||||
|
|
||||||
|
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
@ -136,7 +140,7 @@ void PosPrinter::printTest()
|
||||||
write(commandStream.str());
|
write(commandStream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosPrinter::printReceipt(Sale* sale)
|
void PosPrinter::printSaleReceipt(Sale* sale)
|
||||||
{
|
{
|
||||||
std::stringstream commandStream;
|
std::stringstream commandStream;
|
||||||
printHeader();
|
printHeader();
|
||||||
|
@ -152,3 +156,28 @@ void PosPrinter::printReceipt(Sale* sale)
|
||||||
commandStream << Command::LEFT_ALIGN << Command::FEED;
|
commandStream << Command::LEFT_ALIGN << Command::FEED;
|
||||||
write(commandStream.str());
|
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
|
#define POS_PRINTER_H
|
||||||
|
|
||||||
#include <sale.h>
|
#include <sale.h>
|
||||||
|
#include <seller.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ class PosPrinter
|
||||||
void write(const std::string& text);
|
void write(const std::string& text);
|
||||||
void printHeader();
|
void printHeader();
|
||||||
void printTest();
|
void printTest();
|
||||||
void printReceipt(Sale* sale);
|
void printSaleReceipt(Sale* sale);
|
||||||
|
void printSellerReceipt(Seller* seller, int percent, int maxFee);
|
||||||
|
|
||||||
struct Command {
|
struct Command {
|
||||||
static const std::string RESET;
|
static const std::string RESET;
|
||||||
|
|
Loading…
Reference in a new issue