Bugfix - voucher items manipulation fixed.

This commit is contained in:
2023-06-02 11:58:13 +02:00
parent 46b2098ffc
commit 8b132c6c51
3 changed files with 21 additions and 6 deletions
+8 -3
View File
@@ -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();
});