Skip to content

IouAccount Reference

Constructor

The IouAccount instance for the currently logged in user can be referenced by using TheM.ious.forUser(TheM.user.AFiUserId) if it exists. The properties and methods of the IouAccount class can be referenced by specifying the IouAccount instance, followed by the property or method name, like TheM.ious.forUser(TheM.user.AFiUserId).AFiUserId.

//A new instance of the IouAccount class is instantiated automatically when a new iou is registered between a borrower and a lender. Subsequent IOU registrations between the same borrower and lender will create new transactions on the existing IouAccount instance.

await TheM.ious.doRegister({ 
  borrowerAFiUserId: TheM.user.AFiUserId,
  lenderAFiUserId: 'PUT_lenderAFiUserId_HERE',
  amount: 10.01,
  currency: 'USD',
  narrative: 'PUT_narrative_HERE'
});

Example

await TheM.ious.doRegister({
  borrowerAFiUserId: TheM.user.AFiUserId,
  lenderAFiUserId: 'testaurlx8wfimcrw',
  amount: 10.01,
  currency: 'USD',
  narrative: 'Loan request'
});

Properties

Property table for IouAccount

Property Description Required Schema
AFiUserId Gets (returns) the borrower user ID in ampliFi. Yes {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).AFiUs
erId",
  "type": "string",
  "description": "Gets (returns) the borrower user
ID in ampliFi.",
  "examples": [
    "qweaurlysmbdlsrf"
  ],
  "nullable": false
}
otherAFiUserId Gets (returns) the lender user ID in ampliFi. Yes {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).other
AFiUserId",
  "type": "string",
  "description": "Gets (returns) the lender user ID
in ampliFi.",
  "examples": [
    "testaurlx8wfimcrw"
  ],
  "nullable": false
}
otherUser Gets (returns) the lender user object in ampliFi if the lender is a member of TheM.family array for the currently logged in user. No {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).other
User",
  "type": "object",
  "description": "Gets (returns) the lender user
object in ampliFi if the lender is a member of
TheM.family array for the currently logged in
user.",
  "examples": [
    null
  ],
  "nullable": true
}
balance Gets (returns) the current balance of the IouAccount instance (if it exists) or 0. Yes {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).balan
ce",
  "type": "object",
  "description": "Gets (returns) the current
balance of the IouAccount instance (if it exists) or
0.",
  "examples": [
    40.04
  ],
  "nullable": false
}
currency Gets (returns) the 3 character currency code. No {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).curre
ncy",
  "type": "string",
  "description": "Gets (returns) the 3 character
currency code.",
  "examples": [
    "USD"
  ]
}
transactions Gets (returns) an array of the transactions for this IouAccount instance. No {
  "title":
"TheM.ious.forUser(TheM.user.AFiUserId).trans
actions",
  "type": "array",
  "description": "Gets (returns) an array of the
transactions for this IouAccount instance.",
  "examples": [
    [
      {
        "IOUAccountId":
"qweaurlysmbdlsrftestaurlx8wfimcrw",
        "IOUTransactionId":
"qweioutryle5fpqzunihgslljaetijgr",
        "amount": -10.01,
        "amountUnpaid": 10.01,
        "attachments": {},
        "borrowerAFiUserId": "qweaurlysmbdlsrf",
        "currency": "USD",
        "dts": "Tue Jul 23 2024 11:50:27 GMT-0400 (Eastern
Daylight Time)",
        "images": [],
        "isActive": true,
        "isPending": true,
        "lenderAFiUserId": "testaurlx8wfimcrw",
        "narrative": "Loan request",
        "narrativeCredit": "Loan request",
        "narrativeDebit": "Loan request"
      }
    ]
  ],
  "default": []
}

Methods

Method Name Parameter Descriptions Description Example
doPay
[
{
"title": "givenIOUAccount",
"type": "object",
"nullable": false,
"properties": {
"IOUTransactionId": {
"title": "IOUTransactionId",
"type": "string",
"nullable": false,
"example":
"qweioutryle5fpqzunihgslljaeti
jgr"
}
},
"example": {
"IOUTransactionId":
"qweioutryle5fpqzunihgslljaeti
jgr"
}
},
{
"title": "givenAmount",
"type": "number",
"nullable": false,
"example": 1.01
}
]
Returns a promise that calls the POST iou/:IOUTransactionId/pay endpoint in ampliFi in order to make a payment from the user's (borrower's) main account in ampliFi to the lender's account. The amount may be less than or equal to the amount of the IOU. If no amount is specified, then the remaining IOU balance will be used as the default amount to pay. If the available funds are not sufficient, then a partial payment is made. If the IOU is paid in full, the transaction is deleted. TheM.ious.forUser(TheM.user.AFiUserId).doPay(
  {
   "IOUTransactionId": "qweioutryle5fpqzunihgslljaetijgr"
  }
,1.01);