Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTRecord Class Reference

#include <OTRecord.hpp>

Public Types

enum  OTRecordType {
  Mail = 0, Transfer, Receipt, Instrument,
  ErrorState
}
 

Public Member Functions

EXPORT void SetSpecialMail (bool bIsSpecial=true)
 
EXPORT bool IsSpecialMail () const
 
EXPORT bool IsPending () const
 
EXPORT bool IsOutgoing () const
 
EXPORT bool IsRecord () const
 
EXPORT bool IsReceipt () const
 
EXPORT bool IsMail () const
 
EXPORT bool IsTransfer () const
 
EXPORT bool IsCheque () const
 
EXPORT bool IsInvoice () const
 
EXPORT bool IsVoucher () const
 
EXPORT bool IsContract () const
 
EXPORT bool IsPaymentPlan () const
 
EXPORT bool IsCash () const
 
EXPORT bool HasContents () const
 
EXPORT bool HasMemo () const
 
EXPORT bool IsExpired () const
 
EXPORT bool IsCanceled () const
 
EXPORT void SetExpired ()
 
EXPORT void SetCanceled ()
 
EXPORT time64_t GetValidFrom () const
 
EXPORT time64_t GetValidTo () const
 
EXPORT void SetDateRange (time64_t tValidFrom, time64_t tValidTo)
 
EXPORT bool CanDeleteRecord () const
 
EXPORT bool CanAcceptIncoming () const
 
EXPORT bool CanDiscardIncoming () const
 
EXPORT bool CanCancelOutgoing () const
 
EXPORT bool CanDiscardOutgoingCash () const
 
EXPORT bool CancelOutgoing (std::string str_via_acct) const
 
EXPORT bool AcceptIncomingInstrument (const std::string &str_into_acct) const
 
EXPORT bool AcceptIncomingTransfer () const
 
EXPORT bool AcceptIncomingReceipt () const
 
EXPORT bool DiscardIncoming () const
 
EXPORT bool DeleteRecord () const
 
EXPORT bool DiscardOutgoingCash () const
 
EXPORT int32_t GetBoxIndex () const
 
EXPORT void SetBoxIndex (int32_t nBoxIndex)
 
EXPORT int32_t GetMethodID () const
 
EXPORT void SetMethodID (int32_t nMethodID)
 
EXPORT const std::string & GetMsgID () const
 
EXPORT void SetMsgID (const std::string &str_id)
 
EXPORT const std::string & GetMsgType () const
 
EXPORT void SetMsgType (const std::string &str_type)
 
EXPORT const std::string & GetMsgTypeDisplay () const
 
EXPORT void SetMsgTypeDisplay (const std::string &str_type)
 
EXPORT int64_t GetTransactionNum () const
 
EXPORT void SetTransactionNum (int64_t lTransNum)
 
EXPORT int64_t GetTransNumForDisplay () const
 
EXPORT void SetTransNumForDisplay (int64_t lTransNum)
 
EXPORT OTRecordType GetRecordType () const
 
EXPORT const std::string & GetServerID () const
 
EXPORT const std::string & GetAssetID () const
 
EXPORT const std::string & GetCurrencyTLA () const
 
EXPORT const std::string & GetNymID () const
 
EXPORT const std::string & GetAccountID () const
 
EXPORT const std::string & GetAddress () const
 
EXPORT const std::string & GetOtherNymID () const
 
EXPORT const std::string & GetOtherAccountID () const
 
EXPORT const std::string & GetOtherAddress () const
 
EXPORT const std::string & GetName () const
 
EXPORT const std::string & GetDate () const
 
EXPORT const std::string & GetAmount () const
 
EXPORT const std::string & GetInstrumentType () const
 
EXPORT const std::string & GetMemo () const
 
EXPORT const std::string & GetContents () const
 
EXPORT void SetOtherNymID (const std::string &str_ID)
 
EXPORT void SetOtherAccountID (const std::string &str_ID)
 
EXPORT void SetAddress (const std::string &str_Address)
 
EXPORT void SetOtherAddress (const std::string &str_Address)
 
EXPORT void SetMemo (const std::string &str_memo)
 
EXPORT void SetContents (const std::string &str_contents)
 
EXPORT bool HasInitialPayment () const
 
EXPORT bool HasPaymentPlan () const
 
EXPORT time64_t GetInitialPaymentDate () const
 
EXPORT time64_t GetPaymentPlanStartDate () const
 
EXPORT time64_t GetTimeBetweenPayments () const
 
EXPORT int64_t GetInitialPaymentAmount () const
 
EXPORT int64_t GetPaymentPlanAmount () const
 
EXPORT int32_t GetMaximumNoPayments () const
 
EXPORT bool FormatAmount (std::string &str_output) const
 
EXPORT bool FormatDescription (std::string &str_output) const
 
EXPORT bool FormatShortMailDescription (std::string &str_output) const
 
EXPORT bool FormatMailSubject (std::string &str_output) const
 
bool operator< (const OTRecord &rhs)
 
 OTRecord (const std::string &str_server_id, const std::string &str_asset_id, const std::string &str_currency_tla, const std::string &str_nym_id, const std::string &str_account_id, const std::string &str_name, const std::string &str_date, const std::string &str_amount, const std::string &str_type, bool bIsPending, bool bIsOutgoing, bool bIsRecord, bool bIsReceipt, OTRecordType eRecordType)
 

Detailed Description

Definition at line 141 of file OTRecord.hpp.

Member Enumeration Documentation

Constructor & Destructor Documentation

opentxs::OTRecord::OTRecord ( const std::string &  str_server_id,
const std::string &  str_asset_id,
const std::string &  str_currency_tla,
const std::string &  str_nym_id,
const std::string &  str_account_id,
const std::string &  str_name,
const std::string &  str_date,
const std::string &  str_amount,
const std::string &  str_type,
bool  bIsPending,
bool  bIsOutgoing,
bool  bIsRecord,
bool  bIsReceipt,
OTRecordType  eRecordType 
)

Definition at line 1389 of file OTRecord.cpp.

1398  : m_nBoxIndex(-1)
1399  , m_ValidFrom(OT_TIME_ZERO)
1400  , m_ValidTo(OT_TIME_ZERO)
1401  , m_str_server_id(str_server_id)
1402  , m_str_asset_id(str_asset_id)
1403  , m_str_currency_tla(str_currency_tla)
1404  , m_str_nym_id(str_nym_id)
1405  , m_str_account_id(str_account_id)
1406  , m_str_name(str_name)
1407  , m_str_date(str_date)
1408  , m_str_amount(str_amount)
1409  , m_str_type(str_type)
1410  , m_bIsSpecialMail(false)
1411  , m_nMethodID(0)
1412  , m_lTransactionNum(0)
1413  , m_lTransNumForDisplay(0)
1414  , m_bIsPending(bIsPending)
1415  , m_bIsOutgoing(bIsOutgoing)
1416  , m_bIsRecord(bIsRecord)
1417  , m_bIsReceipt(bIsReceipt)
1418  , m_bIsPaymentPlan(false)
1419  , m_bIsSmartContract(false)
1420  , m_bIsVoucher(false)
1421  , m_bIsCheque(false)
1422  , m_bIsInvoice(false)
1423  , m_bIsCash(false)
1424  , m_bIsExpired(false)
1425  , m_bIsCanceled(false)
1426  , m_RecordType(eRecordType)
1427 {
1428 }
#define OT_TIME_ZERO
Definition: Common.hpp:180

Member Function Documentation

bool opentxs::OTRecord::AcceptIncomingInstrument ( const std::string &  str_into_acct) const

Definition at line 854 of file OTRecord.cpp.

855 {
856  if (!CanAcceptIncoming()) return false;
857 
858  switch (GetRecordType()) {
859  // Accept from Nym's payments inbox.
860  //
861  case OTRecord::Instrument: {
862  if (m_str_server_id.empty() || m_str_nym_id.empty()) {
863  otErr << __FUNCTION__ << ": Error: missing server id ("
864  << m_str_server_id << ") or nym id (" << m_str_nym_id
865  << ")\n";
866  return false;
867  }
868  if (0 == m_lTransactionNum) {
869  otErr << __FUNCTION__
870  << ": Error: Transaction number is 0, in payment "
871  "inbox for server id (" << m_str_server_id << "), nym id ("
872  << m_str_nym_id << ")\n";
873  return false;
874  }
875  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id);
876 
877  // Open the Nym's payments inbox.
878  OTLedger* pInbox =
879  OTAPI_Wrap::OTAPI()->LoadPaymentInbox(theServerID, theNymID);
880  std::unique_ptr<OTLedger> theInboxAngel(pInbox);
881  if (nullptr == pInbox) {
882  otErr << __FUNCTION__
883  << ": Error: Unable to load payment inbox for server "
884  "id (" << m_str_server_id << "), nym id (" << m_str_nym_id
885  << ")\n";
886  return false;
887  }
888  // Find the payment therein that correlates to this OTRecord.
889  //
890  int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);
891 
892  if ((-1) == nIndex) {
893  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
894  << m_lTransactionNum << " in "
895  "payment inbox for server id ("
896  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
897  return false;
898  }
899  // Accept it.
900  //
901  OTString strIndices;
902  strIndices.Format("%d", nIndex);
903  const std::string str_indices(strIndices.Get());
904 
905  OT_ME madeEasy;
906  if (!madeEasy.accept_from_paymentbox(str_into_acct, str_indices,
907  "ANY")) {
908  otErr << __FUNCTION__
909  << ": Error while trying to accept this instrument.\n";
910  return false;
911  }
912  } // case: instrument
913  break;
914  default:
915  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
916  << "\n";
917  return false;
918  }
919 
920  return true;
921 }
EXPORT bool CanAcceptIncoming() const
Definition: OTRecord.cpp:546
EXPORT OTLedger * LoadPaymentInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
OTLOG_IMPORT OTLogStream otErr
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
static EXPORT OT_API * OTAPI()
Definition: OTAPI.cpp:244
bool opentxs::OTRecord::AcceptIncomingReceipt ( ) const

Definition at line 780 of file OTRecord.cpp.

781 {
782  return AcceptIncomingTransferOrReceipt();
783 } // For incoming, (not-yet-accepted) receipts.
bool opentxs::OTRecord::AcceptIncomingTransfer ( ) const

Definition at line 776 of file OTRecord.cpp.

777 {
778  return AcceptIncomingTransferOrReceipt();
779 } // For incoming, pending (not-yet-accepted) transfers.
bool opentxs::OTRecord::CanAcceptIncoming ( ) const

Definition at line 546 of file OTRecord.cpp.

547 {
548  // Commented out because a transferReceipt is in the inbox, but it
549  // represents an outgoing payment.
550  // if (IsOutgoing()) // If it's outgoing, then it's definitely not
551  // an incoming thing you can accept.
552  // return false;
553 
554  if (IsRecord()) // Records must be archived or deleted, not accepted
555  // or discarded.
556  return false;
557 
558  if (IsExpired()) return false;
559 
560  if (IsReceipt()) // It's NOT a record... If it's a receipt, then yes,
561  // we can accept it.
562  return true;
563 
564  if (IsMail()) // Can't "accept" mail, can only delete it.
565  return false;
566 
567  if (IsPending() && IsOutgoing()) // It's not a record, it's not
568  // a receipt. If it's pending,
569  // is it Outgoing pending? (Can
570  // only accept INCOMING
571  // pending, not outgoing.)
572  return false;
573 
574  return true;
575 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT bool IsExpired() const
Definition: OTRecord.cpp:1197
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
EXPORT bool IsReceipt() const
Definition: OTRecord.cpp:1185
bool opentxs::OTRecord::CanCancelOutgoing ( ) const

Definition at line 618 of file OTRecord.cpp.

619 {
620  if (!IsOutgoing()) return false;
621 
622  if (IsCanceled()) // It's already canceled!
623  return false;
624 
625  if (!IsPending()) return false;
626 
627  if (IsMail()) return false;
628 
629  if (IsRecord()) // This may be superfluous given the above 'if'
630  // pending.
631  return false;
632 
633  if (IsReceipt()) // Receipts can't be canceled. (Probably
634  // superfluous.)
635  return false;
636 
637  if (OTRecord::Transfer == GetRecordType()) // All outgoing, pending
638  // instruments EXCEPT
639  // transfer can be
640  // canceled.
641  return false;
642 
643  return true;
644 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT bool IsCanceled() const
Definition: OTRecord.cpp:1201
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
EXPORT bool IsReceipt() const
Definition: OTRecord.cpp:1185
bool opentxs::OTRecord::CancelOutgoing ( std::string  str_via_acct) const

Definition at line 1016 of file OTRecord.cpp.

1020 {
1021  if (!CanCancelOutgoing()) return false;
1022 
1023  switch (GetRecordType()) {
1024  case OTRecord::Instrument: {
1025  if (m_str_nym_id.empty()) {
1026  otErr << __FUNCTION__ << ": Error: missing nym id (" << m_str_nym_id
1027  << ")\n";
1028  return false;
1029  }
1030 
1031  const OTIdentifier theNymID(m_str_nym_id);
1032  std::string str_using_acct;
1033 
1034  if (IsCheque()) {
1035  str_using_acct = m_str_account_id;
1036  }
1037  else {
1038  str_using_acct = str_via_acct;
1039  }
1040  if (str_using_acct.empty()) {
1041  otErr << __FUNCTION__ << ": Error: Missing account ID (FAILURE)\n";
1042  return false;
1043  }
1044  if (0 == m_lTransactionNum) {
1045  if (IsCash()) {
1046  // Maybe it's cash...
1047  std::string strOutpayment(
1049  m_str_nym_id, GetBoxIndex()));
1050 
1051  if (strOutpayment.empty()) {
1052  int32_t lIndex = GetBoxIndex();
1053  otErr << __FUNCTION__
1054  << ": Error: Blank outpayment at index " << lIndex
1055  << "\n";
1056  return false;
1057  }
1058  OTString strPayment(strOutpayment);
1059  OTPayment thePayment(strPayment);
1060 
1061  if (!thePayment.IsValid() || !thePayment.SetTempValues()) {
1062  int32_t lIndex = GetBoxIndex();
1063  otErr << __FUNCTION__
1064  << ": Error: Invalid outpayment at index " << lIndex
1065  << "\n";
1066  return false;
1067  }
1068  int64_t lTransNum = 0;
1069  thePayment.GetOpeningNum(lTransNum, theNymID);
1070  if (0 == lTransNum) // Found it.
1071  {
1072  int32_t lIndex = GetBoxIndex();
1073  OTString strIndices;
1074  strIndices.Format("%d", lIndex);
1075  const std::string str_indices(strIndices.Get());
1076  OT_ME madeEasy;
1077 
1078  return madeEasy.cancel_outgoing_payments(
1079  m_str_nym_id, str_using_acct, str_indices);
1080  }
1081  else {
1082  otErr << __FUNCTION__
1083  << ": Error: Transaction number is non-zero ("
1084  << lTransNum
1085  << "), for cash outgoing payment for nym id ("
1086  << m_str_nym_id << ")\n";
1087  return false;
1088  }
1089  } // IsCash()
1090  else {
1091  otErr << __FUNCTION__ << ": Error: Transaction number is 0, "
1092  "for non-cash outgoing payment for "
1093  "nym id (" << m_str_nym_id << ")\n";
1094  return false;
1095  }
1096  }
1097  // Find the payment in the Nym's outpayments box that correlates to this
1098  // OTRecord.
1099  //
1100  int32_t nCount = OTAPI_Wrap::GetNym_OutpaymentsCount(m_str_nym_id);
1101 
1102  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
1103  std::string strOutpayment(
1105  nIndex));
1106 
1107  if (strOutpayment.empty()) {
1108  otErr << __FUNCTION__ << ": Error: Blank outpayment at index "
1109  << nIndex << "\n";
1110  return false;
1111  }
1112  OTString strPayment(strOutpayment);
1113  OTPayment thePayment(strPayment);
1114 
1115  if (!thePayment.IsValid() || !thePayment.SetTempValues()) {
1116  otErr << __FUNCTION__ << ": Error: Invalid outpayment at index "
1117  << nIndex << "\n";
1118  return false;
1119  }
1120  int64_t lTransNum = 0;
1121  thePayment.GetOpeningNum(lTransNum, theNymID);
1122  if (lTransNum == m_lTransactionNum) // Found it.
1123  {
1124  OTString strIndices;
1125  strIndices.Format("%d", nIndex);
1126  const std::string str_indices(strIndices.Get());
1127  OT_ME madeEasy;
1128 
1129  return madeEasy.cancel_outgoing_payments(
1130  m_str_nym_id, str_using_acct, str_indices);
1131  }
1132  } // for
1133  } break;
1134  default:
1135  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
1136  << "\n";
1137  return false;
1138  }
1139 
1140  return true;
1141 }
EXPORT bool IsCheque() const
Definition: OTRecord.cpp:998
EXPORT bool IsCash() const
Definition: OTRecord.cpp:990
EXPORT int32_t GetBoxIndex() const
Definition: OTRecord.cpp:1313
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:758
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
OTLOG_IMPORT OTLogStream otErr
EXPORT bool CanCancelOutgoing() const
Definition: OTRecord.cpp:618
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
static EXPORT std::string GetNym_OutpaymentsContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:763
bool opentxs::OTRecord::CanDeleteRecord ( ) const

Definition at line 532 of file OTRecord.cpp.

533 {
534  if (IsMail()) return true;
535 
536  if (!IsRecord()) return false;
537 
538  if (IsPending()) // This may be superfluous given the above 'if'
539  // statement.
540  return false;
541 
542  return true;
543 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
bool opentxs::OTRecord::CanDiscardIncoming ( ) const

Definition at line 578 of file OTRecord.cpp.

579 {
580  if (IsOutgoing()) return false;
581 
582  if (!IsPending()) return false;
583 
584  if (IsMail()) return false;
585 
586  if (IsRecord()) // This may be superfluous given the above 'if'
587  // pending.
588  return false;
589 
590  if (IsReceipt()) // Receipts must be accepted, not discarded.
591  return false;
592 
593  if (OTRecord::Transfer == GetRecordType()) // All incoming, pending
594  // instruments EXCEPT
595  // transfer can be
596  // discarded.
597  return false;
598 
599  return true;
600 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
EXPORT bool IsReceipt() const
Definition: OTRecord.cpp:1185
bool opentxs::OTRecord::CanDiscardOutgoingCash ( ) const

Definition at line 601 of file OTRecord.cpp.

605 {
606  if (!IsOutgoing()) return false;
607 
608  if (!IsPending()) return false;
609 
610  if (!IsCash()) return false;
611 
612  if (!(GetBoxIndex() >= 0)) return false;
613 
614  return true;
615 }
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT bool IsCash() const
Definition: OTRecord.cpp:990
EXPORT int32_t GetBoxIndex() const
Definition: OTRecord.cpp:1313
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
bool opentxs::OTRecord::DeleteRecord ( ) const

Definition at line 655 of file OTRecord.cpp.

656 {
657  if (!CanDeleteRecord()) return false;
658  if (!m_bIsSpecialMail &&
659  (m_str_server_id.empty() || m_str_nym_id.empty())) {
660  otErr << __FUNCTION__ << ": Error: missing server id ("
661  << m_str_server_id << ") or nym id (" << m_str_nym_id << ")\n";
662  return false;
663  }
664  std::string str_using_account;
665 
666  if ((OTRecord::Transfer == GetRecordType()) ||
668  if (m_str_account_id.empty()) {
669  otErr << __FUNCTION__
670  << ": Error: missing account id for transfer or receipt.\n";
671  return false;
672  }
673 
674  str_using_account = m_str_account_id;
675  }
676  else
677  str_using_account = m_str_nym_id; // For instruments.
678  switch (GetRecordType()) {
679  // Delete from in-mail or out-mail.
680  //
681  case OTRecord::Mail: {
682  // If it's a Bitmessage or any other "non-OT" mail, then we can't
683  // delete it here. We have to assume the client application is
684  // smart enough to check for this and perform the deletion itself.
685  // (Not all client apps will even support forms of mail other than
686  // OT mail.)
687  //
688  if (!m_bIsSpecialMail) {
689  if (m_bIsOutgoing) // outgoing mail
690  {
691  int32_t nCount = OTAPI_Wrap::GetNym_OutmailCount(m_str_nym_id);
692  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
693  const std::string str_contents(
695  nIndex));
696 
697  if (str_contents == m_str_contents) // found it.
698  {
700  m_str_nym_id, nIndex);
701  }
702  }
703  }
704  else // incoming mail
705  {
706  int32_t nCount = OTAPI_Wrap::GetNym_MailCount(m_str_nym_id);
707  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
708  const std::string str_contents(
710  nIndex));
711 
712  if (str_contents == m_str_contents) // found it.
713  {
714  return OTAPI_Wrap::Nym_RemoveMailByIndex(m_str_nym_id,
715  nIndex);
716  }
717  }
718  }
719  }
720  else
721  return true;
722 
723  return false;
724  } break;
725  case OTRecord::Transfer: // Delete from asset account recordbox.
726  case OTRecord::Receipt: // Delete from asset account recordbox.
727  case OTRecord::Instrument: // Delete from Nym's recordbox.
728  break;
729  default:
730  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
731  << "\n";
732  return false;
733  }
734  // The below section handles both the Nym's recordbox AND the Asset Account
735  // recordbox.
736  //
737  if (0 == m_lTransactionNum) {
738  otErr << __FUNCTION__
739  << ": Error: Transaction number is 0, in recordbox for "
740  "server id (" << m_str_server_id << "), nym id ("
741  << m_str_nym_id << "), acct id (" << str_using_account << ")\n";
742  return false;
743  }
744  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id),
745  theAcctID(str_using_account); // this last one sometimes contains NymID
746  // (see above.)
747 
748  OTLedger* pRecordbox =
749  OTAPI_Wrap::OTAPI()->LoadRecordBox(theServerID, theNymID, theAcctID);
750  std::unique_ptr<OTLedger> theRecordBoxAngel(pRecordbox);
751  if (nullptr == pRecordbox) {
752  otErr << __FUNCTION__ << ": Failed loading record box for server ID ("
753  << m_str_server_id << ") nymID "
754  "(" << m_str_nym_id << ") accountID ("
755  << str_using_account << ")\n";
756  return false;
757  }
758  // Find the receipt in the recordbox that correlates to this OTRecord.
759  //
760  int nIndex = pRecordbox->GetTransactionIndex(m_lTransactionNum);
761 
762  if ((-1) == nIndex) {
763  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
764  << m_lTransactionNum << " in recordbox "
765  "for server id (" << m_str_server_id
766  << "), nym id (" << m_str_nym_id << "), acct id ("
767  << str_using_account << ")\n";
768  return false;
769  }
770  // Accept it.
771  //
773  m_str_server_id, m_str_nym_id, str_using_account, nIndex,
774  false); // clear all = false. We're only clearing one record.
775 }
EXPORT OTLedger * LoadRecordBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool CanDeleteRecord() const
Definition: OTRecord.cpp:532
static EXPORT std::string GetNym_OutmailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:728
static EXPORT bool ClearRecord(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const int32_t &nIndex, const bool &bClearAll)
Definition: OTAPI.cpp:1599
static EXPORT std::string GetNym_MailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:693
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
static EXPORT bool Nym_RemoveOutmailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:746
static EXPORT int32_t GetNym_OutmailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:723
OTLOG_IMPORT OTLogStream otErr
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
static EXPORT OT_API * OTAPI()
Definition: OTAPI.cpp:244
static EXPORT int32_t GetNym_MailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:688
static EXPORT bool Nym_RemoveMailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:711
bool opentxs::OTRecord::DiscardIncoming ( ) const

Definition at line 924 of file OTRecord.cpp.

925 {
926  if (!CanDiscardIncoming()) return false;
927 
928  switch (GetRecordType()) {
929  case OTRecord::Instrument: {
930  if (m_str_server_id.empty() || m_str_nym_id.empty()) {
931  otErr << __FUNCTION__ << ": Error: missing server id ("
932  << m_str_server_id << ") or nym id (" << m_str_nym_id
933  << ")\n";
934  return false;
935  }
936  if (0 == m_lTransactionNum) {
937  otErr << __FUNCTION__ << ": Error: Transaction number is 0, in "
938  "payment inbox for server id ("
939  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
940  return false;
941  }
942  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id);
943 
944  // Open the Nym's payments inbox.
945  OTLedger* pInbox =
946  OTAPI_Wrap::OTAPI()->LoadPaymentInbox(theServerID, theNymID);
947  std::unique_ptr<OTLedger> theInboxAngel(pInbox);
948  if (nullptr == pInbox) {
949  otErr << __FUNCTION__
950  << ": Error: Unable to load payment inbox for server id ("
951  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
952  return false;
953  }
954  // Find the payment therein that correlates to this OTRecord.
955  //
956  int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);
957 
958  if ((-1) == nIndex) {
959  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
960  << m_lTransactionNum << " in "
961  "payment inbox for server id ("
962  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
963  return false;
964  }
965  // Accept it.
966  //
967  OTString strIndices;
968  strIndices.Format("%d", nIndex);
969  const std::string str_indices(strIndices.Get());
970 
971  OT_ME madeEasy;
972 
973  return madeEasy.discard_incoming_payments(m_str_server_id, m_str_nym_id,
974  str_indices);
975 
976  } // case: instrument
977  break;
978  default:
979  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
980  << "\n";
981  return false;
982  }
983 
984  return true;
985 }
EXPORT OTLedger * LoadPaymentInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
OTLOG_IMPORT OTLogStream otErr
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
EXPORT bool CanDiscardIncoming() const
Definition: OTRecord.cpp:578
static EXPORT OT_API * OTAPI()
Definition: OTAPI.cpp:244
bool opentxs::OTRecord::DiscardOutgoingCash ( ) const

Definition at line 646 of file OTRecord.cpp.

647 {
648  if (!CanDiscardOutgoingCash()) return false;
649  return OTAPI_Wrap::Nym_RemoveOutpaymentsByIndex(m_str_nym_id,
650  GetBoxIndex());
651 }
EXPORT int32_t GetBoxIndex() const
Definition: OTRecord.cpp:1313
static EXPORT bool Nym_RemoveOutpaymentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:781
EXPORT bool CanDiscardOutgoingCash() const
Definition: OTRecord.cpp:601
bool opentxs::OTRecord::FormatAmount ( std::string &  str_output) const

Definition at line 153 of file OTRecord.cpp.

154 {
155  if (m_str_amount.empty() ||
156  m_str_asset_id.empty()) // Need these to do the formatting.
157  {
158  // otOut << __FUNCTION__ << ": Unable to format amount. Type: " <<
159  // m_str_type << " Amount:
160  // " << m_str_amount << " Asset: " << m_str_asset_id << "";
161  return false;
162  }
163  str_output = OTAPI_Wrap::It()->FormatAmount(
164  m_str_asset_id, OTAPI_Wrap::It()->StringToLong(m_str_amount));
165  return (!str_output.empty());
166 }
static EXPORT OTAPI_Exec * It()
Definition: OTAPI.cpp:174
EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT) const
bool opentxs::OTRecord::FormatDescription ( std::string &  str_output) const

Definition at line 235 of file OTRecord.cpp.

236 {
237  OTString strDescription, strStatus, strKind;
238 
239  if (IsRecord()) {
240  if (IsExpired())
241  strStatus = "(EXPIRED)"; // How to tell difference between
242  // instrument that processed successfully
243  // and THEN expired, versus one that
244  // expired before processing successfully?
245  // (See next comment.)
246  else if (IsInvoice())
247  strStatus = "(payment sent)"; // TODO: need an "invalid records" box
248  // for expired and canceled. Otherwise
249  // we may falsely assume "payment
250  // sent" when actually it expired. (We
251  // may also falsely assume payment
252  // expired when actually it was sent.)
253  // Solution is a new box.
254  else
255  strStatus = "";
256  // strStatus = "(record)";
257  }
258  else if (IsPending()) {
259  if (IsExpired())
260  strStatus = "(EXPIRED)";
261  else if (IsInvoice())
262  strStatus = "(unpaid)";
263  else if (!IsCash())
264  strStatus = "(pending)";
265  }
266  if (IsCanceled()) {
267  strStatus = "(CANCELED)";
268 
269  if (IsOutgoing() || IsReceipt()) strKind.Format("%s", "sent ");
270  }
271  else {
272  if (IsOutgoing())
273  strKind.Format(
274  "%s", ((IsPending() && !IsCash()) ? "outgoing " : "sent "));
275  else // incoming.
276  strKind.Format("%s", IsPending()
277  ? "incoming "
278  : (IsReceipt() ? "" : "received "));
279  }
280  OTString strTransNumForDisplay;
281 
282  if (!IsCash())
283  strTransNumForDisplay.Format(" #%ld", GetTransNumForDisplay());
284  if (IsRecord()) {
285  if (IsTransfer())
286  strDescription.Format("%s%s%s %s", strKind.Get(), "transfer",
287  strTransNumForDisplay.Get(), strStatus.Get());
288  else if (IsVoucher())
289  strDescription.Format("%s%s%s %s", strKind.Get(), "payment",
290  strTransNumForDisplay.Get(), strStatus.Get());
291  else if (IsReceipt()) {
292  std::string str_instrument_type;
293 
294  if (0 == GetInstrumentType().compare("transferReceipt"))
295  str_instrument_type = "transfer";
296  else if (0 == GetInstrumentType().compare("finalReceipt"))
297  str_instrument_type = "final receipt (closed)";
298  else if (0 == GetInstrumentType().compare("marketReceipt")) {
299  const int64_t lAmount =
300  OTAPI_Wrap::It()->StringToLong(m_str_amount);
301 
302  // I *think* successful trades have a negative amount -- we'll
303  // find out!
304  //
305  if (lAmount == 0)
306  str_instrument_type = "failed trade";
307  else {
308  str_instrument_type = "market trade (receipt)";
309  }
310  }
311  else if (0 == GetInstrumentType().compare("chequeReceipt")) {
312  const int64_t lAmount =
313  OTAPI_Wrap::It()->StringToLong(m_str_amount);
314 
315  // I paid OUT when this chequeReceipt came through. It must be a
316  // normal cheque that I wrote.
317  if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's
318  // because a canceled cheque has a 0 value.
319  str_instrument_type = "cheque";
320  else // I GOT PAID when this chequeReceipt came through. It must
321  // be an invoice I wrote, that someone paid.
322  {
323  if (IsCanceled())
324  str_instrument_type = "invoice";
325  else
326  str_instrument_type = "invoice (payment received)";
327  }
328  }
329  else if (0 == GetInstrumentType().compare("voucherReceipt")) {
330  str_instrument_type = "payment";
331  }
332  else if (0 == GetInstrumentType().compare("paymentReceipt")) {
333  const int64_t lAmount =
334  OTAPI_Wrap::It()->StringToLong(m_str_amount);
335 
336  if (!IsCanceled() && (lAmount > 0)) strKind.Set("received ");
337 
338  str_instrument_type = "recurring payment";
339  }
340 
341  strDescription.Format("%s%s%s %s", strKind.Get(),
342  str_instrument_type.c_str(),
343  strTransNumForDisplay.Get(), strStatus.Get());
344  }
345  else
346  strDescription.Format("%s%s%s %s", strKind.Get(),
347  GetInstrumentType().c_str(),
348  strTransNumForDisplay.Get(), strStatus.Get());
349  }
350  else {
351  if (IsTransfer())
352  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
353  "transfer", strTransNumForDisplay.Get());
354  else if (IsVoucher())
355  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
356  "payment", strTransNumForDisplay.Get());
357 
358  else if (IsReceipt()) {
359  std::string str_instrument_type;
360 
361  if (0 == GetInstrumentType().compare("transferReceipt")) {
362  if (IsCanceled())
363  str_instrument_type = "transfer";
364  else
365  str_instrument_type = "transfer (receipt)";
366  }
367  else if (0 == GetInstrumentType().compare("finalReceipt"))
368  str_instrument_type = "final receipt";
369  else if (0 == GetInstrumentType().compare("marketReceipt")) {
370  const int64_t lAmount =
371  OTAPI_Wrap::It()->StringToLong(m_str_amount);
372 
373  // I *think* marketReceipts have negative value. We'll just test
374  // for non-zero.
375  if (lAmount == 0)
376  str_instrument_type = "failed trade";
377  else
378  str_instrument_type = "market trade (receipt)";
379  }
380  else if (0 == GetInstrumentType().compare("chequeReceipt")) {
381  const int64_t lAmount =
382  OTAPI_Wrap::It()->StringToLong(m_str_amount);
383 
384  // I paid OUT when this chequeReceipt came through. It must be a
385  // normal cheque that I wrote.
386  if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's
387  // because a canceled cheque has a 0 value.
388  {
389  if (IsCanceled())
390  str_instrument_type = "cheque";
391  else
392  str_instrument_type = "cheque (receipt)";
393  }
394  else // I GOT PAID when this chequeReceipt came through. It
395  // must be an invoice I wrote, that someone paid.
396  {
397  if (IsCanceled())
398  str_instrument_type = "invoice";
399  else
400  str_instrument_type =
401  "sent invoice (receipt: payment received)";
402  }
403  }
404  else if (0 == GetInstrumentType().compare("voucherReceipt")) {
405  if (IsCanceled())
406  str_instrument_type = "payment";
407  else
408  str_instrument_type = "payment (receipt)";
409  }
410  else if (0 == GetInstrumentType().compare("paymentReceipt")) {
411  const int64_t lAmount =
412  OTAPI_Wrap::It()->StringToLong(m_str_amount);
413 
414  if (!IsCanceled() && (lAmount > 0)) strKind.Set("received ");
415 
416  str_instrument_type = "recurring payment (receipt)";
417  }
418 
419  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
420  str_instrument_type.c_str(),
421  strTransNumForDisplay.Get());
422  }
423  else
424  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
425  GetInstrumentType().c_str(),
426  strTransNumForDisplay.Get());
427  }
428  str_output = strDescription.Get();
429  return (!str_output.empty());
430 }
static EXPORT OTAPI_Exec * It()
Definition: OTAPI.cpp:174
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT int64_t StringToLong(const std::string &strNumber) const
Definition: OTAPI_Exec.cpp:286
EXPORT bool IsCash() const
Definition: OTRecord.cpp:990
EXPORT bool IsTransfer() const
Definition: OTRecord.cpp:986
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT bool IsCanceled() const
Definition: OTRecord.cpp:1201
EXPORT bool IsInvoice() const
Definition: OTRecord.cpp:994
EXPORT bool IsExpired() const
Definition: OTRecord.cpp:1197
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
EXPORT bool IsReceipt() const
Definition: OTRecord.cpp:1185
EXPORT int64_t GetTransNumForDisplay() const
Definition: OTRecord.cpp:1151
EXPORT bool IsVoucher() const
Definition: OTRecord.cpp:1002
bool opentxs::OTRecord::FormatMailSubject ( std::string &  str_output) const

Definition at line 167 of file OTRecord.cpp.

168 {
169  str_output.clear();
170  if (IsMail()) {
171  if (!HasContents())
172  str_output = "(empty subject)";
173  else {
174  std::string str_temp_contents = GetContents();
175 
176  if (str_temp_contents.compare(0, 8, "Subject:") == 0) {
177  // Make the replacement.
178  str_temp_contents.replace(0, 8, "");
179  }
180  // Trim it, since there is probably a space after "Subject:"
181  // (Plus we want it trimmed anyway.)
182  std::string str_contents = OTString::trim(str_temp_contents);
183  // Cut the string at the first newline.
184  //
185  std::string::size_type pos_start = 0;
186  std::string::size_type pos = str_contents.find("\r\n", pos_start);
187 
188  if (std::string::npos == pos) // Didn't find anything.
189  pos = str_contents.find("\n", pos_start);
190  if (std::string::npos != pos) // We found a newline.
191  str_contents.erase(pos, std::string::npos);
192  // Trim it again, just for good measure.
193  str_output = OTString::trim(str_contents);
194  }
195  }
196  return (!str_output.empty());
197 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
EXPORT bool HasContents() const
Definition: OTRecord.cpp:1189
static EXPORT std::string & trim(std::string &str)
Definition: OTString.cpp:398
bool opentxs::OTRecord::FormatShortMailDescription ( std::string &  str_output) const

Definition at line 198 of file OTRecord.cpp.

199 {
200  OTString strDescription;
201 
202  if (IsMail()) {
203  if (!HasContents())
204  strDescription.Set("(empty message)");
205  else {
206  std::string str_temp_contents = GetContents();
207  std::string str_contents = OTString::trim(str_temp_contents);
208 
209  if (str_contents.compare(0, 8, "Subject:") == 0) {
210  // Make the replacement.
211  str_contents.replace(0, 8, "");
212  }
213  bool bTruncated = false;
214 
215  if (str_contents.size() > 30) {
216  str_contents.erase(30, std::string::npos);
217  bTruncated = true;
218  }
219  // Replace any newlines with spaces...
220  //
221  std::replace(str_contents.begin(), str_contents.end(), '\r', ' ');
222  std::replace(str_contents.begin(), str_contents.end(), '\n', ' ');
223 
224  // str_contents.erase(std::remove(str_contents.begin(),
225  // str_contents.end(), '\n'), str_contents.end());
226  // str_contents.erase(std::remove(str_contents.begin(),
227  // str_contents.end(), '\r'), str_contents.end());
228  strDescription.Format("%s%s", OTString::trim(str_contents).c_str(),
229  bTruncated ? "..." : "");
230  }
231  }
232  str_output = strDescription.Get();
233  return (!str_output.empty());
234 }
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
EXPORT bool HasContents() const
Definition: OTRecord.cpp:1189
static EXPORT std::string & trim(std::string &str)
Definition: OTString.cpp:398
const std::string & opentxs::OTRecord::GetAccountID ( ) const

Definition at line 1221 of file OTRecord.cpp.

1222 {
1223  return m_str_account_id;
1224 }
const std::string & opentxs::OTRecord::GetAddress ( ) const

Definition at line 1265 of file OTRecord.cpp.

1266 {
1267  return m_str_my_address;
1268 }
const std::string & opentxs::OTRecord::GetAmount ( ) const

Definition at line 1241 of file OTRecord.cpp.

1242 {
1243  return m_str_amount;
1244 }
const std::string & opentxs::OTRecord::GetAssetID ( ) const

Definition at line 1209 of file OTRecord.cpp.

1210 {
1211  return m_str_asset_id;
1212 }
int32_t opentxs::OTRecord::GetBoxIndex ( ) const

Definition at line 1313 of file OTRecord.cpp.

1314 {
1315  return m_nBoxIndex;
1316 }
const std::string & opentxs::OTRecord::GetContents ( ) const

Definition at line 1253 of file OTRecord.cpp.

1254 {
1255  return m_str_contents;
1256 }
const std::string & opentxs::OTRecord::GetCurrencyTLA ( ) const

Definition at line 1213 of file OTRecord.cpp.

1214 {
1215  return m_str_currency_tla;
1216 }
const std::string & opentxs::OTRecord::GetDate ( ) const

Definition at line 1237 of file OTRecord.cpp.

1238 {
1239  return m_str_date;
1240 }
int64_t opentxs::OTRecord::GetInitialPaymentAmount ( ) const

Definition at line 467 of file OTRecord.cpp.

468 {
469  if (!IsPaymentPlan()) return 0;
470 
471  OTPaymentPlan thePlan;
472  const OTString strPlan(GetContents().c_str());
473 
474  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
475  return thePlan.GetInitialPaymentAmount();
476  return 0;
477 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
time64_t opentxs::OTRecord::GetInitialPaymentDate ( ) const

Definition at line 455 of file OTRecord.cpp.

456 {
457  if (!IsPaymentPlan()) return OT_TIME_ZERO;
458 
459  OTPaymentPlan thePlan;
460  const OTString strPlan(GetContents().c_str());
461 
462  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
463  return thePlan.GetInitialPaymentDate();
464  return OT_TIME_ZERO;
465 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
#define OT_TIME_ZERO
Definition: Common.hpp:180
const std::string & opentxs::OTRecord::GetInstrumentType ( ) const

Definition at line 1245 of file OTRecord.cpp.

1246 {
1247  return m_str_type;
1248 }
int32_t opentxs::OTRecord::GetMaximumNoPayments ( ) const

Definition at line 515 of file OTRecord.cpp.

516 {
517  if (!IsPaymentPlan()) return 0;
518 
519  OTPaymentPlan thePlan;
520  const OTString strPlan(GetContents().c_str());
521 
522  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
523  return thePlan.GetMaximumNoPayments();
524  return 0;
525 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
const std::string & opentxs::OTRecord::GetMemo ( ) const

Definition at line 1249 of file OTRecord.cpp.

1250 {
1251  return m_str_memo;
1252 }
int32_t opentxs::OTRecord::GetMethodID ( ) const

Definition at line 1261 of file OTRecord.cpp.

1262 {
1263  return m_nMethodID;
1264 }
const std::string & opentxs::OTRecord::GetMsgID ( ) const

Definition at line 1273 of file OTRecord.cpp.

1274 {
1275  return m_str_msg_id;
1276 }
const std::string & opentxs::OTRecord::GetMsgType ( ) const

Definition at line 1277 of file OTRecord.cpp.

1278 {
1279  return m_str_msg_type;
1280 }
const std::string & opentxs::OTRecord::GetMsgTypeDisplay ( ) const

Definition at line 1281 of file OTRecord.cpp.

1282 {
1283  return m_str_msg_type_display;
1284 }
const std::string & opentxs::OTRecord::GetName ( ) const

Definition at line 1233 of file OTRecord.cpp.

1234 {
1235  return m_str_name;
1236 }
const std::string & opentxs::OTRecord::GetNymID ( ) const

Definition at line 1217 of file OTRecord.cpp.

1218 {
1219  return m_str_nym_id;
1220 }
const std::string & opentxs::OTRecord::GetOtherAccountID ( ) const

Definition at line 1229 of file OTRecord.cpp.

1230 {
1231  return m_str_other_account_id;
1232 }
const std::string & opentxs::OTRecord::GetOtherAddress ( ) const

Definition at line 1269 of file OTRecord.cpp.

1270 {
1271  return m_str_other_address;
1272 }
const std::string & opentxs::OTRecord::GetOtherNymID ( ) const

Definition at line 1225 of file OTRecord.cpp.

1226 {
1227  return m_str_other_nym_id;
1228 }
int64_t opentxs::OTRecord::GetPaymentPlanAmount ( ) const

Definition at line 503 of file OTRecord.cpp.

504 {
505  if (!IsPaymentPlan()) return 0;
506 
507  OTPaymentPlan thePlan;
508  const OTString strPlan(GetContents().c_str());
509 
510  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
511  return thePlan.GetPaymentPlanAmount();
512  return 0;
513 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
time64_t opentxs::OTRecord::GetPaymentPlanStartDate ( ) const

Definition at line 479 of file OTRecord.cpp.

480 {
481  if (!IsPaymentPlan()) return OT_TIME_ZERO;
482 
483  OTPaymentPlan thePlan;
484  const OTString strPlan(GetContents().c_str());
485 
486  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
487  return thePlan.GetPaymentPlanStartDate();
488  return OT_TIME_ZERO;
489 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
#define OT_TIME_ZERO
Definition: Common.hpp:180
OTRecord::OTRecordType opentxs::OTRecord::GetRecordType ( ) const

Definition at line 526 of file OTRecord.cpp.

527 {
528  return m_RecordType;
529 }
const std::string & opentxs::OTRecord::GetServerID ( ) const

Definition at line 1205 of file OTRecord.cpp.

1206 {
1207  return m_str_server_id;
1208 }
time64_t opentxs::OTRecord::GetTimeBetweenPayments ( ) const

Definition at line 491 of file OTRecord.cpp.

492 {
493  if (!IsPaymentPlan()) return OT_TIME_ZERO;
494 
495  OTPaymentPlan thePlan;
496  const OTString strPlan(GetContents().c_str());
497 
498  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
499  return thePlan.GetTimeBetweenPayments();
500  return OT_TIME_ZERO;
501 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
#define OT_TIME_ZERO
Definition: Common.hpp:180
int64_t opentxs::OTRecord::GetTransactionNum ( ) const

Definition at line 1142 of file OTRecord.cpp.

1143 {
1144  return m_lTransactionNum;
1145 } // Trans Num of receipt in the box. (Unless outpayment, contains number for
int64_t opentxs::OTRecord::GetTransNumForDisplay ( ) const

Definition at line 1151 of file OTRecord.cpp.

1152 {
1153  if (m_lTransNumForDisplay > 0) return m_lTransNumForDisplay;
1154 
1155  return m_lTransactionNum;
1156 }
time64_t opentxs::OTRecord::GetValidFrom ( ) const

Definition at line 1368 of file OTRecord.cpp.

1369 {
1370  return m_ValidFrom;
1371 }
time64_t opentxs::OTRecord::GetValidTo ( ) const

Definition at line 1372 of file OTRecord.cpp.

1373 {
1374  return m_ValidTo;
1375 }
bool opentxs::OTRecord::HasContents ( ) const

Definition at line 1189 of file OTRecord.cpp.

1190 {
1191  return !m_str_contents.empty();
1192 }
bool opentxs::OTRecord::HasInitialPayment ( ) const

Definition at line 431 of file OTRecord.cpp.

432 {
433  if (!IsPaymentPlan()) return false;
434 
435  OTPaymentPlan thePlan;
436  const OTString strPlan(GetContents().c_str());
437 
438  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
439  return true;
440  return false;
441 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
bool opentxs::OTRecord::HasMemo ( ) const

Definition at line 1193 of file OTRecord.cpp.

1194 {
1195  return !m_str_memo.empty();
1196 }
bool opentxs::OTRecord::HasPaymentPlan ( ) const

Definition at line 443 of file OTRecord.cpp.

444 {
445  if (!IsPaymentPlan()) return false;
446 
447  OTPaymentPlan thePlan;
448  const OTString strPlan(GetContents().c_str());
449 
450  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
451  return true;
452  return false;
453 }
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
bool opentxs::OTRecord::IsCanceled ( ) const

Definition at line 1201 of file OTRecord.cpp.

1202 {
1203  return m_bIsCanceled;
1204 }
bool opentxs::OTRecord::IsCash ( ) const

Definition at line 990 of file OTRecord.cpp.

991 {
992  return m_bIsCash;
993 }
bool opentxs::OTRecord::IsCheque ( ) const

Definition at line 998 of file OTRecord.cpp.

999 {
1000  return m_bIsCheque;
1001 }
bool opentxs::OTRecord::IsContract ( ) const

Definition at line 1006 of file OTRecord.cpp.

1007 {
1008  return m_bIsSmartContract;
1009 }
bool opentxs::OTRecord::IsExpired ( ) const

Definition at line 1197 of file OTRecord.cpp.

1198 {
1199  return m_bIsExpired;
1200 }
bool opentxs::OTRecord::IsInvoice ( ) const

Definition at line 994 of file OTRecord.cpp.

995 {
996  return m_bIsInvoice;
997 }
bool opentxs::OTRecord::IsMail ( ) const

Definition at line 1169 of file OTRecord.cpp.

1170 {
1171  return OTRecord::Mail == GetRecordType();
1172 }
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
bool opentxs::OTRecord::IsOutgoing ( ) const

Definition at line 1177 of file OTRecord.cpp.

1178 {
1179  return m_bIsOutgoing;
1180 }
bool opentxs::OTRecord::IsPaymentPlan ( ) const

Definition at line 1010 of file OTRecord.cpp.

1011 {
1012  return m_bIsPaymentPlan;
1013 }
bool opentxs::OTRecord::IsPending ( ) const

Definition at line 1173 of file OTRecord.cpp.

1174 {
1175  return m_bIsPending;
1176 }
bool opentxs::OTRecord::IsReceipt ( ) const

Definition at line 1185 of file OTRecord.cpp.

1186 {
1187  return m_bIsReceipt;
1188 }
bool opentxs::OTRecord::IsRecord ( ) const

Definition at line 1181 of file OTRecord.cpp.

1182 {
1183  return m_bIsRecord;
1184 }
bool opentxs::OTRecord::IsSpecialMail ( ) const

Definition at line 1257 of file OTRecord.cpp.

1258 {
1259  return m_bIsSpecialMail;
1260 }
bool opentxs::OTRecord::IsTransfer ( ) const

Definition at line 986 of file OTRecord.cpp.

987 {
988  return (OTRecord::Transfer == m_RecordType);
989 }
bool opentxs::OTRecord::IsVoucher ( ) const

Definition at line 1002 of file OTRecord.cpp.

1003 {
1004  return m_bIsVoucher;
1005 }
bool opentxs::OTRecord::operator< ( const OTRecord rhs)

Definition at line 1385 of file OTRecord.cpp.

1386 {
1387  return m_ValidFrom < rhs.m_ValidFrom;
1388 }
void opentxs::OTRecord::SetAddress ( const std::string &  str_Address)

Definition at line 1293 of file OTRecord.cpp.

1294 {
1295  m_str_my_address = str_Address;
1296 }
void opentxs::OTRecord::SetBoxIndex ( int32_t  nBoxIndex)

Definition at line 1317 of file OTRecord.cpp.

1318 {
1319  m_nBoxIndex = nBoxIndex;
1320 }
void opentxs::OTRecord::SetCanceled ( )

Definition at line 1165 of file OTRecord.cpp.

1166 {
1167  m_bIsCanceled = true;
1168 }
void opentxs::OTRecord::SetContents ( const std::string &  str_contents)

Definition at line 1333 of file OTRecord.cpp.

1334 {
1335  m_str_contents = str_contents;
1336 
1337  if (!m_str_contents.empty() && (OTRecord::Instrument == GetRecordType())) {
1338  OTString strPayment(m_str_contents);
1339  OTPayment thePayment(strPayment);
1340 
1341  if (thePayment.IsValid() && thePayment.SetTempValues()) {
1342  switch (thePayment.GetType()) {
1343  case OTPayment::PURSE:
1344  m_bIsCash = true;
1345  break;
1346  case OTPayment::CHEQUE:
1347  m_bIsCheque = true;
1348  break;
1349  case OTPayment::VOUCHER:
1350  m_bIsVoucher = true;
1351  break;
1352  case OTPayment::INVOICE:
1353  m_bIsInvoice = true;
1354  break;
1356  m_bIsPaymentPlan = true;
1357  break;
1359  m_bIsSmartContract = true;
1360  break;
1361 
1362  default:
1363  break;
1364  }
1365  }
1366  }
1367 }
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
void opentxs::OTRecord::SetDateRange ( time64_t  tValidFrom,
time64_t  tValidTo 
)

Definition at line 1376 of file OTRecord.cpp.

1377 {
1378  m_ValidFrom = tValidFrom;
1379  m_ValidTo = tValidTo;
1380  time64_t tCurrentTime = OTAPI_Wrap::GetTime();
1381  if ((tValidTo > OT_TIME_ZERO) && (tCurrentTime > tValidTo) && !IsMail() &&
1382  !IsRecord())
1383  SetExpired();
1384 }
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
int64_t time64_t
Definition: Common.hpp:209
EXPORT void SetExpired()
Definition: OTRecord.cpp:1161
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
#define OT_TIME_ZERO
Definition: Common.hpp:180
void opentxs::OTRecord::SetExpired ( )

Definition at line 1161 of file OTRecord.cpp.

1162 {
1163  m_bIsExpired = true;
1164 }
void opentxs::OTRecord::SetMemo ( const std::string &  str_memo)

Definition at line 1321 of file OTRecord.cpp.

1322 {
1323  m_str_memo = str_memo;
1324 }
void opentxs::OTRecord::SetMethodID ( int32_t  nMethodID)

Definition at line 1289 of file OTRecord.cpp.

1290 {
1291  m_nMethodID = nMethodID;
1292 }
void opentxs::OTRecord::SetMsgID ( const std::string &  str_id)

Definition at line 1301 of file OTRecord.cpp.

1302 {
1303  m_str_msg_id = str_id;
1304 }
void opentxs::OTRecord::SetMsgType ( const std::string &  str_type)

Definition at line 1305 of file OTRecord.cpp.

1306 {
1307  m_str_msg_type = str_type;
1308 }
void opentxs::OTRecord::SetMsgTypeDisplay ( const std::string &  str_type)

Definition at line 1309 of file OTRecord.cpp.

1310 {
1311  m_str_msg_type_display = str_type;
1312 }
void opentxs::OTRecord::SetOtherAccountID ( const std::string &  str_ID)

Definition at line 1329 of file OTRecord.cpp.

1330 {
1331  m_str_other_account_id = str_ID;
1332 }
void opentxs::OTRecord::SetOtherAddress ( const std::string &  str_Address)

Definition at line 1297 of file OTRecord.cpp.

1298 {
1299  m_str_other_address = str_Address;
1300 }
void opentxs::OTRecord::SetOtherNymID ( const std::string &  str_ID)

Definition at line 1325 of file OTRecord.cpp.

1326 {
1327  m_str_other_nym_id = str_ID;
1328 }
void opentxs::OTRecord::SetSpecialMail ( bool  bIsSpecial = true)

Definition at line 1285 of file OTRecord.cpp.

1286 {
1287  m_bIsSpecialMail = bIsSpecial;
1288 }
void opentxs::OTRecord::SetTransactionNum ( int64_t  lTransNum)

Definition at line 1147 of file OTRecord.cpp.

1148 {
1149  m_lTransactionNum = lTransNum;
1150 }
void opentxs::OTRecord::SetTransNumForDisplay ( int64_t  lTransNum)

Definition at line 1157 of file OTRecord.cpp.

1158 {
1159  m_lTransNumForDisplay = lTransNum;
1160 }

The documentation for this class was generated from the following files: