Added load receipt functionality.
This commit is contained in:
@@ -106,6 +106,33 @@ void ShopService::pay(VoucherPtr voucher)
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
void ShopService::moveItems(QList<VoucherItemPtr> items, VoucherPtr source, VoucherPtr target)
|
||||
{
|
||||
Transaction tx;
|
||||
|
||||
if (target->status() == Voucher::NEW && target->id() == 0)
|
||||
{
|
||||
this->saveVoucher(target);
|
||||
}
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
foreach (VoucherItemPtr item, items) {
|
||||
QString sql = QString("update VoucherItem set voucher = %1 where id = %2").arg(QString::number(target->id()), QString::number(item->id()));
|
||||
db->execute(sql.toStdString());
|
||||
}
|
||||
|
||||
loadItems(source);
|
||||
loadItems(target);
|
||||
|
||||
if (source->items().isEmpty())
|
||||
{
|
||||
erase(source);
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
QList<VoucherPtr> ShopService::savedVouchers()
|
||||
{
|
||||
return all(QString("status = %1").arg(QString::number(Voucher::NOT_PAID)));
|
||||
|
||||
Reference in New Issue
Block a user