Skip to content

Commit

Permalink
fix apinprastya#32 Remove soft delete on items
Browse files Browse the repository at this point in the history
  • Loading branch information
apinprastya committed Aug 18, 2019
1 parent 6d217d4 commit 84da21a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions libserver/action/itemaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace LibDB;
ItemAction::ItemAction():
ServerAction("items", "barcode")
{
mFlag = USE_TRANSACTION | SOFT_DELETE;
mFlag = USE_TRANSACTION;
mFunctionMap.insert(MSG_COMMAND::CASHIER_PRICE, std::bind(&ItemAction::prices, this, std::placeholders::_1));
mFunctionMap.insert(MSG_COMMAND::EXPORT, std::bind(&ItemAction::exportData, this, std::placeholders::_1));
mFunctionMap.insert(MSG_COMMAND::IMPORT, std::bind(&ItemAction::importData, this, std::placeholders::_1));
Expand Down Expand Up @@ -162,8 +162,14 @@ Message ItemAction::del(Message *msg)
if(hasFlag(USE_TRANSACTION) && mDb->isSupportTransaction())
mDb->beginTransaction();
mDb->where(mIdField % " = ", msg->data(mIdField));
if(!mDb->update(mTableName, QVariantMap{{"deleted_at", QDateTime::currentDateTime()}, {"stock", 0}})) {
message.setError(mDb->lastError().text());
if(hasFlag(SOFT_DELETE)) {
if(!mDb->update(mTableName, QVariantMap{{"deleted_at", QDateTime::currentDateTime()}, {"stock", 0}})) {
message.setError(mDb->lastError().text());
}
} else {
if(!mDb->del(mTableName)) {
message.setError(mDb->lastError().text());
}
}
mDb->where("barcode = ", msg->data("barcode"))->del("stockcards");
mDb->where("barcode = ", msg->data("barcode"))->del("itemlinks");
Expand Down
2 changes: 1 addition & 1 deletion sultan/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char *argv[])
#endif
a.setApplicationName("sultan");
a.setOrganizationName("lekapin");
a.setApplicationVersion("18.04.01");
a.setApplicationVersion("19.08.01");

#ifndef QT_DEBUG
QDir dir = QDir::home();
Expand Down

0 comments on commit 84da21a

Please sign in to comment.