155 , m_pServer(&theServer)
156 , m_lPayoutPerShare(lPayoutPerShare)
157 , m_lAmountPaidOut(0)
158 , m_lAmountReturned(0)
164 if (
nullptr != m_pUserID)
delete m_pUserID;
166 if (
nullptr != m_pPayoutAssetID)
delete m_pPayoutAssetID;
167 m_pPayoutAssetID =
nullptr;
168 if (
nullptr != m_pVoucherAcctID)
delete m_pVoucherAcctID;
169 m_pVoucherAcctID =
nullptr;
170 if (
nullptr != m_pstrMemo)
delete m_pstrMemo;
171 m_pstrMemo =
nullptr;
173 m_lPayoutPerShare = 0;
174 m_lAmountPaidOut = 0;
175 m_lAmountReturned = 0;
189 const int64_t lPayoutAmount =
192 if (lPayoutAmount <= 0) {
193 OTLog::Output(0,
"PayDividendVisitor::Trigger: nothing to pay, "
194 "since this account owns no shares. (Returning "
221 bool bReturnValue =
false;
223 OTCheque theVoucher(theServerID, thePayoutAssetID);
240 int64_t lNewTransactionNumber = 0;
243 theServerNym, lNewTransactionNumber);
249 if (bGotNextTransNum) {
252 lNewTransactionNumber,
282 theVoucher.
SetAsVoucher(theServerNymID, theVoucherAcctID);
288 const OTString strVoucher(theVoucher);
292 bSent = theServer.SendInstrumentToNym(
293 theServerID, theServerNymID,
295 nullptr, &thePayment,
"payDividend");
296 bReturnValue = bSent;
305 const OTString strPayoutAssetID(thePayoutAssetID),
306 strRecipientUserID(RECIPIENT_ID);
308 "issuing voucher (to send to dividend payout "
310 "WAS TRYING TO PAY %ld of asset type %s to Nym %s.\n",
311 lPayoutAmount, strPayoutAssetID.Get(),
312 strRecipientUserID.
Get());
318 OTCheque theReturnVoucher(theServerID, thePayoutAssetID);
320 const bool bIssueReturnVoucher = theReturnVoucher.
IssueCheque(
322 lNewTransactionNumber,
335 if (bIssueReturnVoucher) {
340 theReturnVoucher.
SetAsVoucher(theServerNymID, theVoucherAcctID);
347 const OTString strReturnVoucher(theReturnVoucher);
348 OTPayment theReturnPayment(strReturnVoucher);
351 bSent = theServer.SendInstrumentToNym(
352 theServerID, theServerNymID,
354 nullptr, &theReturnPayment,
364 const OTString strPayoutAssetID(thePayoutAssetID),
365 strSenderUserID(theSenderUserID);
367 "failed issuing voucher (to return back to "
368 "the dividend payout initiator, after a failed "
369 "payment attempt to the originally intended "
370 "recipient.) WAS TRYING TO PAY %ld of asset type "
372 lPayoutAmount, strPayoutAssetID.Get(),
373 strSenderUserID.
Get());
379 const OTString strPayoutAssetID(thePayoutAssetID),
380 strRecipientUserID(RECIPIENT_ID);
382 "PayDividendVisitor::Trigger: ERROR!! Failed issuing next "
384 "number while trying to send a voucher (while paying dividends.) "
385 "WAS TRYING TO PAY %ld of asset type %s to Nym %s.\n",
386 lPayoutAmount, strPayoutAssetID.Get(), strRecipientUserID.
Get());
static EXPORT void vError(const char *szError,...)
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
bool issueNextTransactionNumber(OTPseudonym &nym, int64_t &txNumber, bool storeNumber=true)
EXPORT int64_t GetBalance() const
EXPORT bool SaveContract()
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
virtual ~PayDividendVisitor()
virtual bool Trigger(OTAccount &theAccount)
#define OT_TIME_SIX_MONTHS_IN_SECONDS
PayDividendVisitor(const OTIdentifier &theServerID, const OTIdentifier &theUserID, const OTIdentifier &thePayoutAssetID, const OTIdentifier &theVoucherAcctID, const OTString &strMemo, OTServer &theServer, int64_t lPayoutPerShare, mapOfAccounts *pLoadedAccounts=nullptr)
time64_t OTTimeGetCurrentTime()
const OTPseudonym & GetServerNym() const
std::map< std::string, OTAccount * > mapOfAccounts
int64_t GetPayoutPerShare()
void SetAsVoucher(const OTIdentifier &remitterUserID, const OTIdentifier &remitterAcctID)
EXPORT bool IssueCheque(const int64_t &lAmount, const int64_t &lTransactionNum, const time64_t &VALID_FROM, const time64_t &VALID_TO, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &SENDER_USER_ID, const OTString &strMemo, const OTIdentifier *pRECIPIENT_USER_ID=nullptr)
EXPORT const char * Get() const
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
OTIdentifier * GetUserID()
OTIdentifier * GetVoucherAcctID()
const OTIdentifier & GetUserID() const
int64_t OTTimeGetSecondsFromTime(time64_t time)
EXPORT OTIdentifier * GetServerID()
OTIdentifier * GetPayoutAssetID()