Bugfix - voucher items manipulation fixed.
This commit is contained in:
@@ -173,6 +173,10 @@ void ShopService::pay(VoucherPtr voucher)
|
||||
voucher->setPayDateTime(QDateTime::currentDateTime());
|
||||
|
||||
this->update(voucher, &session);
|
||||
|
||||
if (!session.isValid()) {
|
||||
qDebug() << session.firstError().text();
|
||||
}
|
||||
}
|
||||
|
||||
void ShopService::updateRelatedItem(VoucherItem* item, int countAdded)
|
||||
@@ -526,10 +530,11 @@ void ShopService::update(VoucherPtr entity, qx::QxSession* pSession) {
|
||||
|
||||
Service::update(entity, pSession);
|
||||
auto oldItems = entity->items();
|
||||
entity->clearItems();
|
||||
load(entity);
|
||||
|
||||
for (auto item : entity->items()) {
|
||||
Service<VoucherItem> srvItem;
|
||||
auto items = srvItem.all("voucher = " + QString::number(entity->id()));
|
||||
|
||||
for (auto item : items) {
|
||||
auto newItem = std::find_if(oldItems.begin(), oldItems.end(), [item](auto it){
|
||||
return item->id() == it->id();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user