tax.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Andreas Huggel (ahu)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.16 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _TAX_H_
00031 #define _TAX_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <iosfwd>
00037 #include <string>
00038 #include <map>
00039 
00040 // + local headers
00041 #include "decimal.h"
00042 #include "money.h"
00043 #include "amount.h"
00044 #include "chargetraits.h"
00045 
00046 // *********************************************************************
00047 // namespace extensions
00048 namespace OSB_LIB {
00049 
00050 // *********************************************************************
00051 // type definitions
00052     typedef std::map<std::string,
00053             std::pair<std::string, Decimal> > ParaValue;
00054 
00064     class Tax {
00065     public:
00066         Tax(const TaxTraits& tt) : traits_(tt) {}
00067         virtual ~Tax() {}
00068         virtual TaxAmount calculate(const Money&) const =0;
00069         virtual std::ostream& write(std::ostream&) const =0;
00070         TaxIdVs oid() const { return traits_.taxIdVs(); }
00071         const TaxTraits& traits() const { return traits_; }
00072         // The name of the tax
00073         std::string name;
00074         // Lookup table providing parameter-name and parameter-value
00075         // (all values converted to strings)
00076         ParaValue paraValue;
00077 
00078     protected:
00080         TaxTraits traits_;
00081     };
00082 
00083     inline std::ostream& operator<<(std::ostream& o, const Tax& t)
00084         { return t.write(o); }
00085 
00094     class StandardTax : public Tax {
00095     public:
00096         StandardTax(const TaxTraits& tt,
00097                     const Decimal&   p,
00098                     const Decimal&   a)
00099             : Tax(tt), percentage_(p), absolute_(a) {}
00100 
00101         TaxAmount calculate(const Money&) const;
00102         std::ostream& write(std::ostream&) const;
00103 
00104     private:
00105         Decimal percentage_;
00106         Decimal absolute_;
00107     };
00108 
00109 }                                       // namespace OSB_LIB
00110 #endif                                  // #ifndef _TAX_H_

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