00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _TARIFF_H_
00031 #define _TARIFF_H_
00032
00033
00034
00035
00036 #include <string>
00037 #include <list>
00038
00039
00040 #include "tariffobject.h"
00041 #include "ratingfn.h"
00042 #include "serviceclass.h"
00043
00044
00045
00046 namespace OSB_DB {
00047 class RateCodeGw;
00048 struct TariffGw;
00049 struct TfVersionGw;
00050 class TariffSystemGw;
00051 }
00052
00053 namespace OSB_LIB {
00054 class SumCdr;
00055 }
00056
00057
00058
00059 namespace OSB_LIB {
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00077 class RateCode : public TariffObject {
00079 friend class OSB_DB::RateCodeGw;
00080 public:
00082 typedef Id<RateCode> Oid;
00083 public:
00085 explicit RateCode(const Oid& oid = Oid());
00086 public:
00088 const Oid& oid() const;
00090 const std::string& mnemonic() const;
00097 void setMnemonic(const std::string& mnemonic);
00098 private:
00100 Oid oid_;
00102 std::string mnemonic_;
00103 };
00104
00108 class RateCodes {
00109 public:
00111 typedef std::map<RateCode::Oid, RateCode> Cont;
00112 public:
00114 const Cont& codes() const;
00123 const RateCode& getRateCode(const RateCode::Oid& id);
00124
00132 const RateCode* findRateCode(const RateCode::Oid& id);
00133
00135 void read(const OSB_DB::Session& session);
00136 public:
00138
00139
00150 void create(
00151 const OSB_DB::Session& session,
00152 RateCode* rc
00153 );
00154
00168 void update(
00169 const OSB_DB::Session& session,
00170 RateCode* rc
00171 );
00172
00190 void remove(
00191 const OSB_DB::Session& session,
00192 RateCode* rc
00193 );
00195 private:
00197 Cont codes_;
00198 };
00199
00200
00201
00209 class Tariff : public TariffObject {
00214 friend class OSB_DB::TariffSystemGw;
00219 friend struct OSB_DB::TariffGw;
00224 friend class TariffCatalogue;
00225 public:
00227 typedef Id<Tariff> Oid;
00228 public:
00230 Tariff (const Oid& oid = Oid());
00231 public:
00233
00234
00235 const Oid& oid() const;
00237 bool rounded() const;
00239
00241
00242
00251 void setRounded(bool rounded);
00253
00264 bool read(const OSB_DB::Session& session);
00265
00266 private:
00268
00269
00282 bool insert(const OSB_DB::Session& session);
00283
00298 bool remove(const OSB_DB::Session& session);
00299
00313 bool update(const OSB_DB::Session& session);
00315
00316 private:
00317 Oid oid_;
00318 bool rounded_;
00319 };
00320
00322 typedef std::list<Tariff> Tariffs;
00323
00324
00325
00333 class TfVersion : public ToVersion {
00338 friend struct OSB_DB::TfVersionGw;
00339
00344 friend class TariffCatalogue;
00345 public:
00347 typedef Id2<TfVersion> Oid;
00349 typedef std::set< Id<RatingFn> > AssignedRf;
00350 public:
00352 explicit TfVersion(const Oid& oid = Oid());
00354 explicit TfVersion(const Tariff::Oid& tfOid);
00355 public:
00357 const Oid& oid() const;
00359 Tariff::Oid tfId() const;
00360
00361 long vsId() const;
00363 const AssignedRf& ratingFns() const;
00364
00372 void rate(
00373 UsedService& us,
00374 const Money& money,
00375 Decimal& volume
00376 ) const;
00377
00383 void rate(UsedService& us) const;
00384
00390 void rate(SumCdr& sumCdr) const;
00391
00407 bool patch(
00408 const OSB_DB::Session& session,
00409 OsbErrors& errors,
00410 TfVersion* replacing
00411 );
00412
00426 bool addRatingFn(const RatingFn::Oid& rfId);
00427
00441 bool removeRatingFn(const RatingFn::Oid& rfId);
00442
00458 bool freeze(
00459 const OSB_DB::Session& session,
00460 OsbErrors& errors
00461 );
00462
00483 bool release(
00484 const OSB_DB::Session& session,
00485 OsbErrors& errors
00486
00487
00488
00489 );
00490
00504 bool revoke(
00505 const OSB_DB::Session& session,
00506 OsbErrors& errors
00507 );
00508
00522 bool unfreeze(
00523 const OSB_DB::Session& session,
00524 OsbErrors& errors
00525 );
00526
00527 private:
00537 bool checkObjVs(
00538 const OSB_DB::Session& session,
00539 OsbErrors& errors
00540 );
00541
00550 bool hasReplacement(OSB_LIB::DateTime* nextVs) const;
00551
00558 bool gracePeriodExpired() const;
00559
00560 public:
00572 bool read(const OSB_DB::Session& session);
00573
00574 private:
00576
00577
00590 bool insert(const OSB_DB::Session& session);
00591
00606 bool remove(const OSB_DB::Session& session);
00607
00621 bool update(const OSB_DB::Session& session);
00623
00624 private:
00626 Oid oid_;
00628 AssignedRf ratingFns_;
00629 };
00630
00632 typedef std::map<Tariff::Oid,
00633 std::list<TfVersion> > TfVersions;
00634
00635
00636
00637
00638 }
00639 #endif // #ifndef _TARIFF_H_