contract.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008              Lilian Qin Lan (lan)
00009 
00010   RCS information
00011    $Name: OSB_060808 $
00012    $Revision: 1.104 $
00013 
00014   License
00015    OSB rating and billing library for communication networks
00016    Copyright (C) 2004, 2005, 2006  OSB systems
00017 
00018    This file may be distributed and/or modify under the terms of the
00019    GNU General Public License (GPL) as published by the Free Software
00020    Foundation which is provided in the file LICENSE.GPL included in the
00021    packaging of this file.
00022 
00023    The file is distributed in the hope that it will be useful, but WITHOUT
00024    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00025    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00026    for more details.
00027 
00028    Holders of a OSB Commercial License may use this file under the terms
00029    and conditions of this commercial license.
00030  */
00031 
00032 #ifndef _CONTRACT_H_
00033 #define _CONTRACT_H_
00034 
00035 // *********************************************************************
00036 // included header files
00037 // + standard includes
00038 
00039 // + local headers
00040 #include "money.h"
00041 #include "osbid.h"           // Id template
00042 #include "persproduct.h"     // list of personalized products
00043 #include "statusrequest.h"
00044 
00045 // *********************************************************************
00046 // class declarations
00047 namespace OSB_DB {
00048     class Session;
00049     class PersProductGw;
00050     class ContractGw;
00051 }
00052 
00053 namespace OSB_LIB {
00054     class RequestHandler;
00055     class Associate;
00056     class AnCList;
00057     class Billcycle;
00058     class OsbErrors;
00059     class TaxKey;
00060 }
00061 
00062 // *********************************************************************
00063 // namespace extensions
00064 namespace OSB_LIB {
00065 
00071     class Contract {
00072         friend class OSB_DB::PersProductGw;
00073         friend class OSB_DB::ContractGw;
00074         friend class Associate;
00075 
00076         friend class RequestHandler;
00077 
00079         friend class AnCList;
00080 
00081     public:
00083         typedef Id<Contract> Oid;
00084 
00086         typedef Id<Associate> OwnerId;
00087 
00088 
00097         enum AccountingType {
00099             atCustomer = 'c',
00101             atSupplier = 's',
00103             atUnknown = '\0'
00104         };
00105 
00113         static AccountingType toAccountingType(char at);
00114 
00122         static char toChar(AccountingType at);
00123 
00124     public:
00126         inline explicit Contract(const Oid& oid = Oid());
00127 
00129 
00130 
00131         inline const Oid& oid() const;
00133         inline const Id<Associate>& ownerId() const;
00135         inline const DateTime& createdDate() const;
00137         inline const Id<TaxKey>& taxkey() const;
00139         inline const Id<Billcycle>& billcycleId() const;
00141         inline const Money& creditLimit() const;
00143         inline AccountingType accountingType() const;
00145         inline const Status& effStatus() const;
00147         inline const DateTime& effStatusDate() const;
00149         inline const Status& prefStatus() const;
00151         inline const DateTime& prefStatusDate() const;
00153         inline const PersProducts& products() const;
00155         inline long objVs() const;
00162         inline const StatusChanges& statusChanges() const;
00169         inline const StatusRequests& statusRequests() const;
00171 
00184         int buildPersParts();
00185 
00187 
00188 
00189         bool setTaxkey(const Id<TaxKey>& tkId)
00190         {
00191             taxkey_ = tkId;
00192             return true;
00193         }
00195         bool setBillCycle(const Id<Billcycle>& bcId)
00196         {
00197             billcycleId_ = bcId;
00198             return true;
00199         }
00201         bool setCreditLimit(const Money& credit)
00202         {
00203             creditLimit_ = credit;
00204             return true;
00205         }
00207         bool setAccountingType(AccountingType accountingType)
00208         {
00209             accountingType_ = accountingType;
00210             return true;
00211         }
00213 
00215 
00216 
00234         bool addPersProduct(
00235             OSB_DB::Session& session,
00236             PersProduct&     pp,
00237             bool             noWait
00238         );
00239 
00256         bool delPersProduct(
00257                   OSB_DB::Session&  session,
00258             const PersProduct::Oid& oid,
00259                   bool              noWait
00260         );
00261 
00269         const PersProduct* findPersProduct(
00270             const PersProduct::Oid& oid
00271         ) const;
00272 
00280         PersProduct* persProduct(const PersProduct::Oid& oid);
00281 
00289         const PersProduct& getPersProduct(
00290             const PersProduct::Oid& oid
00291         ) const;
00293 
00314         bool requestStatus(
00315             const OSB_DB::Session& session,
00316                   StatusRequest&   request,
00317                   OsbErrors&       errors,
00318                   bool             noWait
00319         );
00320 
00328         bool read(
00329             const OSB_DB::Session& session
00330         );
00331 
00343         void readStatusChanges(
00344             const OSB_DB::Session& session,
00345             const Period&          period
00346         );
00347 
00359         void readStatusRequests(
00360             const OSB_DB::Session& session,
00361             const Period&          period
00362         );
00363 
00379         void update(
00380             OSB_DB::Session& session,
00381             bool             noWait
00382         );
00383 
00384     private:
00396         bool insert(
00397             const OSB_DB::Session& session
00398         );
00399 
00414         bool remove(const OSB_DB::Session& session);
00415 
00417 
00418 
00428         OsbError setPrefStatus(
00429             const OSB_DB::Session& session,
00430             const StatusRequest&   request
00431         );
00432 
00449         bool changeStatus(
00450             const OSB_DB::Session& session,
00451                   StatusChange&    change,
00452                   OsbErrors&       errors,
00453                   bool             noWait
00454         );
00455 
00470         bool applyChange(
00471             const OSB_DB::Session& session,
00472             const StatusChange&    change,
00473                   OsbErrors&       errors,
00474                   bool             noWait
00475         );
00477 
00479 
00480 
00491         static void handleObjectStatus(
00492                   ObjectStatus   os,
00493             const Contract::Oid& id
00494         );
00495 
00506         static void lock(
00507             const OSB_DB::Session& session,
00508             const Contract::Oid&   id,
00509                   bool             noWait
00510         );
00511 
00520         void lock(
00521             const OSB_DB::Session& session,
00522                   bool             noWait
00523         ) const;
00524 
00540         void incObjVs(const OSB_DB::Session& session);
00542 
00555         bool delPp(
00556             const OSB_DB::Session&  session,
00557             const PersProduct::Oid& oid
00558         );
00559 
00560     private:
00562         Oid            oid_;
00564         OwnerId        ownerId_;
00566         DateTime       createdDate_;
00568         Id<TaxKey>     taxkey_;
00570         Id<Billcycle>  billcycleId_;
00572         Status         effStatus_;
00574         DateTime       effStatusDate_;
00576         Status         prefStatus_;
00578         DateTime       prefStatusDate_;
00580         long           objVs_;
00582         StatusChanges  chngs_;
00584         StatusRequests reqs_;
00586         PersProducts   products_;
00588         Money          creditLimit_;
00590         AccountingType accountingType_;
00591     };                                  // class Contract
00592 }                                       // namespace OSB_LIB
00593 
00594 // ************************************************************************
00595 // inline definitions
00596 namespace OSB_LIB {
00597 
00598     // ********************************************************************
00599     // class Contract
00600     inline Contract::Contract(const Oid& oid)
00601       : oid_(oid)
00602     {
00603         // empty
00604     }
00605 
00606     inline const Contract::Oid& Contract::oid() const
00607     {
00608         return oid_;
00609     }
00610 
00611     inline const Id<Associate>& Contract::ownerId() const
00612     {
00613         return ownerId_;
00614     }
00615 
00616     inline const DateTime& Contract::createdDate() const
00617     {
00618         return createdDate_;
00619     }
00620 
00621     inline const Id<TaxKey>& Contract::taxkey() const
00622     {
00623         return taxkey_;
00624     }
00625 
00626     inline const Id<Billcycle>& Contract::billcycleId() const
00627     {
00628         return billcycleId_;
00629     }
00630 
00631     inline const Money& Contract::creditLimit() const
00632     {
00633         return creditLimit_;
00634     }
00635 
00636     inline Contract::AccountingType Contract::accountingType() const
00637     {
00638         return accountingType_;
00639     }
00640 
00641     inline const Status& Contract::effStatus() const
00642     {
00643         return effStatus_;
00644     }
00645 
00646     inline const DateTime& Contract::effStatusDate() const
00647     {
00648         return effStatusDate_;
00649     }
00650 
00651     inline const Status& Contract::prefStatus() const
00652     {
00653         return prefStatus_;
00654     }
00655 
00656     inline const DateTime& Contract::prefStatusDate() const
00657     {
00658         return prefStatusDate_;
00659     }
00660 
00661     inline const PersProducts& Contract::products() const
00662     {
00663         return products_;
00664     }
00665 
00666     inline long Contract::objVs() const
00667     {
00668         return objVs_;
00669     }
00670 
00671     inline const StatusChanges& Contract::statusChanges() const
00672     {
00673         return chngs_;
00674     }
00675 
00676     inline const StatusRequests& Contract::statusRequests() const
00677     {
00678         return reqs_;
00679     }
00680 }                                       // namespace VB
00681 #endif                                  // #ifndef _CONTRACT_H_

Generated on Sat Sep 2 14:06:32 2006 for OSB Library by  doxygen 1.4.7