本文整理汇总了C++中MyMoneyFile::payeeByName方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::payeeByName方法的具体用法?C++ MyMoneyFile::payeeByName怎么用?C++ MyMoneyFile::payeeByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::payeeByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPostDate
TransactionHelper::TransactionHelper( const QDate& _date, const QString& _action, MyMoneyMoney _value, const QString& _accountid, const QString& _categoryid, const QString& _currencyid, const QString& _payee )
{
// _currencyid is the currency of the transaction, and of the _value
// both the account and category can have their own currency (athough the category having
// a foreign currency is not yet supported by the program, the reports will still allow it,
// so it must be tested.)
MyMoneyFile* file = MyMoneyFile::instance();
bool haspayee = ! _payee.isEmpty();
MyMoneyPayee payeeTest = file->payeeByName(_payee);
MyMoneyFileTransaction ft;
setPostDate(_date);
QString currencyid = _currencyid;
if ( currencyid.isEmpty() )
currencyid=MyMoneyFile::instance()->baseCurrency().id();
setCommodity(currencyid);
MyMoneyMoney price;
MyMoneySplit splitLeft;
if ( haspayee )
splitLeft.setPayeeId(payeeTest.id());
splitLeft.setAction(_action);
splitLeft.setValue(-_value);
price = MyMoneyFile::instance()->price(currencyid, file->account(_accountid).currencyId(),_date).rate(file->account(_accountid).currencyId());
splitLeft.setShares(-_value * price);
splitLeft.setAccountId(_accountid);
addSplit(splitLeft);
MyMoneySplit splitRight;
if ( haspayee )
splitRight.setPayeeId(payeeTest.id());
splitRight.setAction(_action);
splitRight.setValue(_value);
price = MyMoneyFile::instance()->price(currencyid, file->account(_categoryid).currencyId(),_date).rate(file->account(_categoryid).currencyId());
splitRight.setShares(_value * price );
splitRight.setAccountId(_categoryid);
addSplit(splitRight);
MyMoneyFile::instance()->addTransaction(*this);
ft.commit();
}