From e9b0bbc89906b4c32cf8f6bceef2a57bcc14852d Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Sat, 6 Aug 2022 08:51:32 -0400 Subject: [PATCH] fix --- wrenchboard/src/shared_tool/jobs.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index 92a5f045..5dfe38b4 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -594,6 +594,7 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) { in["client_id"] = "0"; CVars x; CVars y; + CVars u; CVars z; try { @@ -615,6 +616,11 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) { return ret; } + load_db_record(u,"SELECT code AS currency FROM currency WHERE country = '%s'", y["country"].c_str() ); + logfmt(logINFO, " The Currency code = %s", u["currency"].c_str()); + long wallet_id = CheckWallet( in["member_id"].Long() , u); + logfmt(logINFO, " The wallet_id = %lu", wallet_id); + if (in["client_id"].Long() == in["member_id"].Long()) { out["status"] = "Unable to create offer"; return ret; @@ -626,10 +632,16 @@ long WrenchSendJobsOfferIndividual(CVars in, CVars &out) { return ret; } // no price zero for job on this path - // Now do you have money to do this .... - if (load_db_record(z, " SELECT * FROM members WHERE id =%lu AND balance >= %lu", in["member_id"].Long(), y["price"].Long())) { + // Now do you have money to do this .... + z["balance"] = "0"; + z["balance"].set_valid(true); // just initialize it + if (load_db_record(z, " SELECT * FROM members_wallet WHERE id =%lu AND member_id =%lu AND amount >= %lu",wallet_id, in["member_id"].Long(), y["price"].Long())) { - } + } else { + out["status"] = "Insufficient balance to create this offer"; + logfmt(logINFO, "Price2 = %lu Balance = %lu", y["price"].Long(), z["amount"].Long()); + } + // we re ready to create the offer now x["member_id"] = in["member_id"];