1
/***************************************************************************
2
* Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE skrooge@miraks.com *
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. *
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. *
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
***************************************************************************/
18
* This file is part of Skrooge and implements classes SKGRefundTrackerObject.
20
* @author Stephane MANKOWSKI / Guillaume DE BURE
22
#include "skgrefundtrackerobject.h"
23
#include "skgdocumentbank.h"
24
#include "skgtraces.h"
26
SKGRefundTrackerObject::SKGRefundTrackerObject(const SKGDocument* iDocument, int iID): SKGNamedObject(iDocument, "v_refund", iID)
30
SKGRefundTrackerObject::~SKGRefundTrackerObject()
34
SKGRefundTrackerObject::SKGRefundTrackerObject(const SKGRefundTrackerObject& iObject)
35
:SKGNamedObject(iObject)
39
SKGRefundTrackerObject::SKGRefundTrackerObject ( const SKGObjectBase& iObject )
42
if ( iObject.getRealTable() =="refund" ) {
45
*this=SKGNamedObject::SKGNamedObject ( iObject.getDocument(), "v_refund", iObject.getID() );
49
const SKGRefundTrackerObject& SKGRefundTrackerObject::operator= (const SKGObjectBase& iObject)
55
SKGError SKGRefundTrackerObject::createRefund ( const SKGDocumentBank* iDocument,
57
SKGRefundTrackerObject& oRefund,
58
bool iSendPopupMessageOnCreation )
61
SKGTRACEINRC ( 10, "SKGRefundTrackerObject::createRefund", err );
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();
71
if ( err.isSucceeded() && iSendPopupMessageOnCreation && iDocument ) {
72
( ( SKGDocumentBank* ) iDocument )->sendMessage ( tr ( "Refund [%1] has been created" ).arg ( iName ), true );
79
SKGError SKGRefundTrackerObject::getSubOperations(SKGListSKGObjectBase& oSubOperations) const
81
SKGError err = getObjects(getDocument(), "v_suboperation",
82
"r_refund_id="+ SKGServices::intToString(getID()) ,
87
SKGError SKGRefundTrackerObject::setClosed(bool iClosed)
89
return setAttribute("t_close", iClosed ? "Y" :"N");
92
bool SKGRefundTrackerObject::isClosed() const
94
return (getAttribute("t_close")=="Y" ? true : false);
97
SKGError SKGRefundTrackerObject::setComment(const QString& iComment)
99
return setAttribute("t_comment", iComment);
102
QString SKGRefundTrackerObject::getComment() const
104
return getAttribute("t_comment");
107
double SKGRefundTrackerObject::getCurrentAmount() const
109
return SKGServices::stringToDouble(getAttribute("f_CURRENTAMOUNT"));
112
#include "skgrefundtrackerobject.moc"