diff --git a/skgbankmodeler/skginterestobject.cpp b/skgbankmodeler/skginterestobject.cpp index 7d68a1ca0..b76452c85 100644 --- a/skgbankmodeler/skginterestobject.cpp +++ b/skgbankmodeler/skginterestobject.cpp @@ -1,132 +1,138 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file defines classes SKGInterestObject. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skginterestobject.h" #include "skgdocument.h" SKGInterestObject::SKGInterestObject(): SKGInterestObject(nullptr) {} SKGInterestObject::SKGInterestObject(SKGDocument* iDocument, int iID): SKGObjectBase(iDocument, QStringLiteral("v_interest"), iID) {} SKGInterestObject::SKGInterestObject(const SKGInterestObject& iObject) = default; SKGInterestObject::SKGInterestObject(const SKGObjectBase& iObject) { if (iObject.getRealTable() == QStringLiteral("interest")) { copyFrom(iObject); } else { *this = SKGObjectBase(iObject.getDocument(), QStringLiteral("v_interest"), iObject.getID()); } } SKGInterestObject& SKGInterestObject::operator= (const SKGObjectBase& iObject) { copyFrom(iObject); return *this; } +SKGInterestObject& SKGInterestObject::operator= (const SKGInterestObject& iObject) +{ + copyFrom(iObject); + return *this; +} + SKGInterestObject::~SKGInterestObject() = default; SKGError SKGInterestObject::setRate(double iValue) { return setAttribute(QStringLiteral("f_rate"), SKGServices::doubleToString(iValue)); } double SKGInterestObject::getRate() const { return SKGServices::stringToDouble(getAttribute(QStringLiteral("f_rate"))); } SKGError SKGInterestObject::setDate(QDate iDate) { return setAttribute(QStringLiteral("d_date"), SKGServices::dateToSqlString(QDateTime(iDate))); } QDate SKGInterestObject::getDate() const { return SKGServices::stringToTime(getAttribute(QStringLiteral("d_date"))).date(); } SKGError SKGInterestObject::setIncomeValueDateMode(SKGInterestObject::ValueDateMode iMode) { return setAttribute(QStringLiteral("t_income_value_date_mode"), (iMode == FIFTEEN ? QStringLiteral("F") : SKGServices::intToString(static_cast(iMode) - 1))); } SKGInterestObject::ValueDateMode SKGInterestObject::getIncomeValueDateMode() const { QString mode = getAttribute(QStringLiteral("t_income_value_date_mode")); return (mode == QStringLiteral("F") ? FIFTEEN : static_cast(SKGServices::stringToInt(mode) + 1)); } SKGError SKGInterestObject::setExpenditueValueDateMode(SKGInterestObject::ValueDateMode iMode) { return setAttribute(QStringLiteral("t_expenditure_value_date_mode"), (iMode == FIFTEEN ? QStringLiteral("F") : SKGServices::intToString(static_cast(iMode) - 1))); } SKGInterestObject::ValueDateMode SKGInterestObject::getExpenditueValueDateMode() const { QString mode = getAttribute(QStringLiteral("t_expenditure_value_date_mode")); return (mode == QStringLiteral("F") ? FIFTEEN : static_cast(SKGServices::stringToInt(mode) + 1)); } SKGError SKGInterestObject::setInterestComputationMode(SKGInterestObject::InterestMode iMode) { return setAttribute(QStringLiteral("t_base"), (iMode == FIFTEEN24 ? QStringLiteral("24") : (iMode == DAYS360 ? QStringLiteral("360") : QStringLiteral("365")))); } SKGInterestObject::InterestMode SKGInterestObject::getInterestComputationMode() const { QString mode = getAttribute(QStringLiteral("t_base")); return (mode == QStringLiteral("24") ? FIFTEEN24 : (mode == QStringLiteral("360") ? DAYS360 : DAYS365)); } QString SKGInterestObject::getWhereclauseId() const { // Could we use the id QString output = SKGObjectBase::getWhereclauseId(); if (output.isEmpty()) { // No, so we use the date and parent if (!(getAttribute(QStringLiteral("d_date")).isEmpty()) && !(getAttribute(QStringLiteral("rd_account_id")).isEmpty())) { output = "d_date='" % getAttribute(QStringLiteral("d_date")) % "' AND rd_account_id=" % getAttribute(QStringLiteral("rd_account_id")); } } return output; } SKGError SKGInterestObject::setAccount(const SKGAccountObject& iAccount) { return setAttribute(QStringLiteral("rd_account_id"), SKGServices::intToString(iAccount.getID())); } SKGError SKGInterestObject::getAccount(SKGAccountObject& oAccount) const { SKGError err = getDocument()->getObject(QStringLiteral("v_account"), "id=" % getAttribute(QStringLiteral("rd_account_id")), oAccount); return err; } diff --git a/skgbankmodeler/skginterestobject.h b/skgbankmodeler/skginterestobject.h index 4d97f1c6f..8bdccd51b 100644 --- a/skgbankmodeler/skginterestobject.h +++ b/skgbankmodeler/skginterestobject.h @@ -1,200 +1,206 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGINTERESTOBJECT_H #define SKGINTERESTOBJECT_H /** @file * This file defines classes SKGInterestObject. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgaccountobject.h" #include "skgbankmodeler_export.h" #include "skgerror.h" #include "skgobjectbase.h" class SKGInterestObject; /** * This class is interest option for an account */ class SKGBANKMODELER_EXPORT SKGInterestObject final : public SKGObjectBase { public: /** * This enumerate defines how to compute value date */ enum ValueDateMode {FIFTEEN = 0, J0, J1, J2, J3, J4, J5 }; /** * This enumerate defines how to compute value date */ Q_ENUM(ValueDateMode) /** * This enumerate defines how to compute interest */ enum InterestMode {FIFTEEN24 = 0, DAYS360, DAYS365 }; /** * This enumerate defines how to compute interest */ Q_ENUM(InterestMode) /** * Default constructor */ explicit SKGInterestObject(); /** * Constructor * @param iDocument the document containing the object * @param iID the identifier in @p iTable of the object */ explicit SKGInterestObject(SKGDocument* iDocument, int iID = 0); /** * Copy constructor * @param iObject the object to copy */ SKGInterestObject(const SKGInterestObject& iObject); /** * Copy constructor * @param iObject the object to copy */ explicit SKGInterestObject(const SKGObjectBase& iObject); /** * Operator affectation * @param iObject the object to copy */ SKGInterestObject& operator= (const SKGObjectBase& iObject); + /** + * Operator affectation + * @param iObject the object to copy + */ + SKGInterestObject& operator= (const SKGInterestObject& iObject); + /** * Destructor */ virtual ~SKGInterestObject(); /** * Get the parent account * @param oAccount the parent account * @return an object managing the error * @see SKGError */ SKGError getAccount(SKGAccountObject& oAccount) const; /** * Set the parent account * @param iAccount the parent account * @return an object managing the error * @see SKGError */ SKGError setAccount(const SKGAccountObject& iAccount); /** * Set the quantity for the date of this unit * @param iValue the quantity * @return an object managing the error * @see SKGError */ SKGError setRate(double iValue); /** * Get the quantity for the date of this unit * @return the quantity */ double getRate() const; /** * Set date of this value * @param iDate the date * @return an object managing the error * @see SKGError */ // cppcheck-suppress passedByValue SKGError setDate(QDate iDate); /** * Get date of this value * @return the date */ QDate getDate() const; /** * Set income value date mode * @param iMode the mode * @return an object managing the error * @see SKGError */ SKGError setIncomeValueDateMode(SKGInterestObject::ValueDateMode iMode); /** * Get income value date mode * @return the income value date mode */ SKGInterestObject::ValueDateMode getIncomeValueDateMode() const; /** * Set expenditue value date mode * @param iMode the mode * @return an object managing the error * @see SKGError */ SKGError setExpenditueValueDateMode(SKGInterestObject::ValueDateMode iMode); /** * Get expenditue value date mode * @return the expenditue value date mode */ SKGInterestObject::ValueDateMode getExpenditueValueDateMode() const; /** * Set interest computation mode * @param iMode the mode * @return an object managing the error * @see SKGError */ SKGError setInterestComputationMode(SKGInterestObject::InterestMode iMode); /** * Get interest computation mode * @return the interest computation mode */ SKGInterestObject::InterestMode getInterestComputationMode() const; protected: /** * Get where clause needed to identify objects. * For this class, the whereclause is based on date + unit * @return the where clause */ QString getWhereclauseId() const override; }; /** * Declare the class */ Q_DECLARE_TYPEINFO(SKGInterestObject, Q_MOVABLE_TYPE); #endif