Added pay voucher feature. Added dialog with paied vouchers. Added
support for printing receipts on POS printer.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "shopservice.h"
|
||||
#include "numberseriesservice.h"
|
||||
#include "shop-odb.hxx"
|
||||
|
||||
ShopService::ShopService()
|
||||
@@ -76,6 +77,7 @@ void ShopService::calculateItem(QSharedPointer<VoucherItem> item)
|
||||
else
|
||||
{
|
||||
item->setPrice(item->unitPrice() * item->count());
|
||||
item->setPriceWitouthVat(item->price());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +87,39 @@ void ShopService::loadItems(QSharedPointer<Voucher> voucher)
|
||||
voucher->setItems(srv.all(QString("voucher = %1").arg(voucher->id())));
|
||||
}
|
||||
|
||||
void ShopService::pay(QSharedPointer<Voucher> voucher)
|
||||
{
|
||||
Transaction tx;
|
||||
NumberSeriesService srvNs;
|
||||
|
||||
NumberSeriesPtr numSer = srvNs.nextForPlugin("SHOP");
|
||||
QString numSerStr;
|
||||
numSerStr.sprintf("%s%05d", numSer->prefix().toStdString().c_str(), numSer->lastNumber());
|
||||
|
||||
voucher->setNumSer(numSerStr);
|
||||
voucher->setStatus(Voucher::PAID);
|
||||
voucher->setPayDateTime(QDateTime::currentDateTime());
|
||||
|
||||
this->update(voucher);
|
||||
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Voucher> > ShopService::savedVouchers()
|
||||
{
|
||||
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Voucher> > ShopService::tempVouchers()
|
||||
{
|
||||
return all(QString("status = %1").arg(QString::number(Voucher::TEMPORARY)));
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Voucher> > ShopService::paiedVouchers()
|
||||
{
|
||||
return all(QString("status = %1").arg(QString::number(Voucher::PAID)));
|
||||
}
|
||||
|
||||
QDecDouble ShopService::includeVat(QDecDouble price, Enums::VatType vatType)
|
||||
{
|
||||
return price * ((vatRate(vatType) / 100) + QDecDouble(1));
|
||||
|
||||
Reference in New Issue
Block a user