]> git.stg.codes - stg.git/blobdiff - projects/stargazer/tariff_impl.cpp
Ticket 37. The timeout variable added, if(stgTime > timeout && timeout
[stg.git] / projects / stargazer / tariff_impl.cpp
index 61c158e8399185e1a154b334a43be9150fb15eb7..c8a0161c6deddb67f67677e3945a2b25ed7cb306 100644 (file)
@@ -147,6 +147,9 @@ else
 //-----------------------------------------------------------------------------
 std::string TARIFF_IMPL::TariffChangeIsAllowed(const TARIFF & to) const
 {
+time_t timeout = GetChangePolicyTimeout();
+if (stgTime > timeout && timeout != 0)
+    return "";
 switch (GetChangePolicy())
     {
     case TARIFF::ALLOW:
@@ -155,14 +158,14 @@ switch (GetChangePolicy())
         if (to.GetFee() < GetFee())
             return "";
         else
-            return "Current tariff " + GetName() + " is more cheap than new tariff " + to.GetName() + ". The policy is " + TARIFF::ChangePolicyToString(GetChangePolicy()) + ".";
+            return "New tariff '" + to.GetName() + "' is more expensive than current tariff '" + GetName() + "'. The policy is '" + TARIFF::ChangePolicyToString(GetChangePolicy()) + "'.";
     case TARIFF::TO_EXPENSIVE:
-        if (to.GetFee() > GetFee())
+        if (to.GetFee() >= GetFee())
             return "";
         else
-            return "Current tariff " + GetName() + " is more expensive than new tariff " + to.GetName() + ". The policy is " + TARIFF::ChangePolicyToString(GetChangePolicy()) + ".";
+            return "New tariff '" + to.GetName() + "' is more cheap than current tariff '" + GetName() + "'. The policy is '" + TARIFF::ChangePolicyToString(GetChangePolicy()) + "'.";
     case TARIFF::DENY:
-        return "Current tariff " + GetName() + ", new tariff " + to.GetName() + ".";
+        return "Current tariff '" + GetName() + "', new tariff '" + to.GetName() + "'. The policy is '" + TARIFF::ChangePolicyToString(GetChangePolicy()) + "'.";
     }
 }
 //-----------------------------------------------------------------------------