]> git.stg.codes - stg.git/commitdiff
Fix fee charge rules with non-zero credit
authorMaxim Mamontov <faust.madf@gmail.com>
Thu, 20 Oct 2011 10:53:11 +0000 (13:53 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Thu, 20 Oct 2011 10:53:11 +0000 (13:53 +0300)
projects/stargazer/user_impl.cpp

index ca2e2cae221ae28f2ed807c4e5924381873b8da6..733e625692bed34418c0a2dcdbccf0362fbc5571 100644 (file)
@@ -1243,11 +1243,11 @@ switch (settings->GetFeeChargeType())
         property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     case 1:
         property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     case 1:
-        if (c >= 0)
+        if (c + credit >= 0)
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     case 2:
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     case 2:
-        if (c >= fee)
+        if (c + credit >= fee)
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     }
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
         break;
     }
@@ -1285,8 +1285,10 @@ if (fee == 0.0)
     }
 
 double c = cash;
     }
 
 double c = cash;
-printfd(__FILE__, "login: %8s   Fee=%f PassiveTimePart=%f fee=%f\n",
+printfd(__FILE__, "login: %8s Cash=%f Credit=%f  Fee=%f PassiveTimePart=%f fee=%f\n",
         login.c_str(),
         login.c_str(),
+        cash.ConstData(),
+        credit.ConstData(),
         tariff->GetFee(),
         passiveTimePart,
         fee);
         tariff->GetFee(),
         passiveTimePart,
         fee);
@@ -1297,14 +1299,14 @@ switch (settings->GetFeeChargeType())
         SetPrepaidTraff();
         break;
     case 1:
         SetPrepaidTraff();
         break;
     case 1:
-        if (c >= 0)
+        if (c + credit >= 0)
             {
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
             SetPrepaidTraff();
             }
         break;
     case 2:
             {
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
             SetPrepaidTraff();
             }
         break;
     case 2:
-        if (c >= fee)
+        if (c + credit >= fee)
             {
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
             SetPrepaidTraff();
             {
             property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
             SetPrepaidTraff();