~ubuntu-branches/ubuntu/lucid/skrooge/lucid

« back to all changes in this revision

Viewing changes to skgbankmodeler/skgrefundtrackerobject.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2010-02-07 19:00:01 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100207190001-apq0bzl80p0tyr8s
Tags: 0.6.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE skrooge@miraks.com    *
3
 
 *                                                                         *
4
 
 *   This program is free software; you can redistribute it and/or modify  *
5
 
 *   it under the terms of the GNU General Public License as published by  *
6
 
 *   the Free Software Foundation; either version 2 of the License, or     *
7
 
 *   (at your option) any later version.                                   *
8
 
 *                                                                         *
9
 
 *   This program is distributed in the hope that it will be useful,       *
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 
 *   GNU General Public License for more details.                          *
13
 
 *                                                                         *
14
 
 *   You should have received a copy of the GNU General Public License     *
15
 
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>  *
16
 
 ***************************************************************************/
17
 
/** @file
18
 
 * This file is part of Skrooge and implements classes SKGRefundTrackerObject.
19
 
 *
20
 
 * @author Stephane MANKOWSKI / Guillaume DE BURE
21
 
 */
22
 
#include "skgrefundtrackerobject.h"
23
 
#include "skgdocumentbank.h"
24
 
#include "skgtraces.h"
25
 
 
26
 
SKGRefundTrackerObject::SKGRefundTrackerObject(const SKGDocument* iDocument, int iID): SKGNamedObject(iDocument, "v_refund", iID)
27
 
{
28
 
}
29
 
 
30
 
SKGRefundTrackerObject::~SKGRefundTrackerObject()
31
 
{
32
 
}
33
 
 
34
 
SKGRefundTrackerObject::SKGRefundTrackerObject(const SKGRefundTrackerObject& iObject)
35
 
                :SKGNamedObject(iObject)
36
 
{
37
 
}
38
 
 
39
 
SKGRefundTrackerObject::SKGRefundTrackerObject ( const SKGObjectBase& iObject )
40
 
 
41
 
{
42
 
        if ( iObject.getRealTable() =="refund" ) {
43
 
                copyFrom ( iObject );
44
 
        } else {
45
 
                *this=SKGNamedObject::SKGNamedObject ( iObject.getDocument(), "v_refund", iObject.getID() );
46
 
        }
47
 
}
48
 
 
49
 
const SKGRefundTrackerObject& SKGRefundTrackerObject::operator= (const SKGObjectBase& iObject)
50
 
{
51
 
        copyFrom(iObject);
52
 
        return *this;
53
 
}
54
 
 
55
 
SKGError SKGRefundTrackerObject::createRefund ( const SKGDocumentBank* iDocument,
56
 
                const QString& iName,
57
 
                SKGRefundTrackerObject& oRefund,
58
 
                bool iSendPopupMessageOnCreation )
59
 
{
60
 
        SKGError err;
61
 
        SKGTRACEINRC ( 10, "SKGRefundTrackerObject::createRefund", err );
62
 
 
63
 
        //Check if refund is already existing
64
 
        SKGObjectBase::getObject ( iDocument, "v_refund", "t_name='"+SKGServices::stringToSqlString ( iName ) +'\'', oRefund );
65
 
        if ( oRefund.getID() ==0 ) {
66
 
                //No, we have to create it
67
 
                oRefund = SKGRefundTrackerObject ( ( SKGDocumentBank* ) iDocument );
68
 
                err=oRefund.setName ( iName );
69
 
                if ( err.isSucceeded() ) err=oRefund.save();
70
 
 
71
 
                if ( err.isSucceeded() && iSendPopupMessageOnCreation && iDocument ) {
72
 
                        ( ( SKGDocumentBank* ) iDocument )->sendMessage ( tr ( "Refund [%1] has been created" ).arg ( iName ), true );
73
 
                }
74
 
        }
75
 
 
76
 
        return err;
77
 
}
78
 
 
79
 
SKGError SKGRefundTrackerObject::getSubOperations(SKGListSKGObjectBase& oSubOperations) const
80
 
{
81
 
        SKGError err = getObjects(getDocument(), "v_suboperation",
82
 
                                  "r_refund_id="+ SKGServices::intToString(getID()) ,
83
 
                                  oSubOperations);
84
 
        return err;
85
 
}
86
 
 
87
 
SKGError SKGRefundTrackerObject::setClosed(bool iClosed)
88
 
{
89
 
        return setAttribute("t_close", iClosed ? "Y" :"N");
90
 
}
91
 
 
92
 
bool SKGRefundTrackerObject::isClosed() const
93
 
{
94
 
        return (getAttribute("t_close")=="Y" ? true : false);
95
 
}
96
 
 
97
 
SKGError SKGRefundTrackerObject::setComment(const QString& iComment)
98
 
{
99
 
        return setAttribute("t_comment", iComment);
100
 
}
101
 
 
102
 
QString SKGRefundTrackerObject::getComment() const
103
 
{
104
 
        return getAttribute("t_comment");
105
 
}
106
 
 
107
 
double SKGRefundTrackerObject::getCurrentAmount() const
108
 
{
109
 
        return SKGServices::stringToDouble(getAttribute("f_CURRENTAMOUNT"));
110
 
}
111
 
 
112
 
#include "skgrefundtrackerobject.moc"