]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
Implemented daily fee charge with backward compatibility.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_tariff.cpp
index c17a77130db24d2ef8c7e10227c0fef6c92fc606..bb855fafc07ba679c057b7bfbda772ae8424f0c6 100644 (file)
@@ -1,8 +1,8 @@
 #include <cstdio> // snprintf
 #include <cstring>
 
+#include "stg/tariffs.h"
 #include "parser.h"
-#include "tariffs.h"
 
 const int pt_mega = 1024 * 1024;
 //-----------------------------------------------------------------------------
@@ -145,6 +145,8 @@ for (; it != dataList.end(); ++it)
             break;
         }
 
+    answerList->push_back("<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>");
+
     answerList->push_back("</tariff>");
     }
 answerList->push_back("</Tariffs>");
@@ -388,7 +390,10 @@ else
         snprintf(st, 50, "Time%d", j);
         if (strcasecmp(el, st) == 0)
             {
-            int h1, m1, h2, m2;
+            int h1 = 0;
+            int m1 = 0;
+            int h2 = 0;
+            int m2 = 0;
             if (ParseTariffTimeStr(attr[1], h1, m1, h2, m2) == 0)
                 {
                 td.dirPrice[j].hDay = h1;
@@ -448,6 +453,12 @@ else
             }
         return 0;
         }
+
+    if (strcasecmp(el, "Period") == 0)
+        {
+        td.tariffConf.period = TARIFF::StringToPeriod(attr[1]);
+        return 0;
+        }
     }
 return -1;
 }