# Creditor

## Creditor's Database

<table><thead><tr><th width="147">UI Name</th><th width="202">Database</th><th width="85">Type</th><th width="184">Remarks</th><th>Important</th></tr></thead><tbody><tr><td>Creditor Account</td><td><pre><code>accNo
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>401-A001</code></td><td></td></tr><tr><td>Control Account</td><td><pre><code>controlAccount
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>400-0000</code></td><td></td></tr><tr><td>Company Name</td><td><pre><code>companyName
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>GLOBAL SHIPPING INC.</code></td><td></td></tr><tr><td>Billing Address [Line 1]</td><td><pre><code>address1
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>123 OCEAN DRIVE</code></td><td>Limit 40 Characters Max</td></tr><tr><td>Billing Address [Line 2]</td><td><pre><code>address2
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>SUITE 200</code></td><td>Limit 40 Characters Max</td></tr><tr><td>Billing Address [Line 3]</td><td><pre><code>address3
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>MARINA BAY</code></td><td>Limit 40 Characters Max</td></tr><tr><td>Billing Address [Line 4]</td><td><pre><code>address4
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>SINGAPORE 018956</code></td><td>Limit 40 Characters Max</td></tr><tr><td>Phone [Line 1]</td><td><pre><code>phone1
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>+6512345678</code></td><td></td></tr><tr><td>Phone [Line 2]</td><td><pre><code>phone2
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>+6598765432</code></td><td></td></tr><tr><td>Attention</td><td><pre><code>attention
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>MR. TERRY</code></td><td></td></tr><tr><td>Email Address</td><td><pre><code>emailAddress
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>contact@globalshipping.com</code></td><td></td></tr><tr><td>Currency</td><td><pre><code>currencyCode
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>SGD</code></td><td></td></tr><tr><td>Credit Term</td><td><pre><code>displayTerm
</code></pre></td><td><strong><code>String</code></strong></td><td>E.g.: <code>NET 30</code></td><td></td></tr></tbody></table>

## Creditor's Sample Code

{% hint style="warning" %}
Remember to change to the **correct field** before proceeding to run **ANY** script.
{% endhint %}

{% tabs %}
{% tab title="Logic Script" %}
{% hint style="info" %}
To find `{fieldName}`, you are required to have access to **Alpha** or use **Network** in Developer Tools `[F12]`.
{% endhint %}

<pre class="language-python" data-full-width="true"><code class="lang-python">import clr
clr.AddReference("Newtonsoft.Json")
clr.AddReference("System.Net")
clr.AddReference("System.IO")

from System.Text import *
from Newtonsoft.Json import *
from Newtonsoft.Json.Linq import *
from System import *

clr.AddReference("System.Drawing")
from System.Drawing import Bitmap, Image
from System.Drawing.Imaging import ImageFormat
from System.IO import MemoryStream, StreamWriter
from System.Net import WebClient
import binascii
from System import BitConverter

#search
<strong>documentList = Module('Company Profile').findAll({ 
</strong>    'Audit.UpdatedDate': { '$gt': Inputs['lastSync'] }, 
    'Audit.UpdatedBy': { "$ne": 'External' }, 
    'Dynamic.Extension.{YOUR-FIELD-ID}': True  # Optional: apply this filter only if required by the specification
})
<strong>debug('documentList', documentList)
</strong>
resultList = []

def preparePayload(data):
    
    payloadData = JObject()
    payloadData["type"] = "APCreditor"
    payloadData["payload"] = JObject()
    if data['{YOUR-CREDITOR-CODE}'] != None and data['{YOUR-CREDITOR-CODE}'] != "":
        payloadData["payload"]["accNo"] = data['{YOUR-CREDITOR-CODE}'] 
    payloadData["payload"]["controlAccount"] = '400-0000'
    payloadData["payload"]["companyName"] = data['{YOUR-COMPANY-NAME}']
    payloadData["payload"]["address1"] = str(data['{YOUR-ADDRESS-1}'])[:40] if data['{YOUR-ADDRESS-1}'] is not None else None
    payloadData["payload"]["address2"] = str(data['{YOUR-ADDRESS-2}'])[:40] if data['{YOUR-ADDRESS-2}'] is not None else None
    payloadData["payload"]["address3"] = str(data['{YOUR-ADDRESS-3}'])[:40] if data['{YOUR-ADDRESS-3}'] is not None else None
    payloadData["payload"]["address4"] = str(data['{YOUR-ADDRESS-4}'])[:40] if data['{YOUR-ADDRESS-4}'] is not None else None
    payloadData["payload"]["phone1"] = data['{YOUR-TEL-1}']
    payloadData["payload"]["phone2"] = data['{YOUR-TEL-2}']
    payloadData["payload"]["attention"] = data['{YOUR-SALES-STAFF}'].ToString()
    payloadData["payload"]["emailAddress"] = data["{YOUR-EMAIL-1}"]
    payloadData["payload"]["currencyCode"] = data['{YOUR-TRADING-CURRENCY}'].ToString()
    payloadData["payload"]["displayTerm"] = data['{YOUR-PAYMENT-TERM}'].ToString()
    
    payloadData["LastModified"] = data.UpdatedDate
    
    return payloadData

#end of added
for entry in documentList:
    payloadData = preparePayload(entry)
    resultList.append(payloadData)
    #debug('payloadData', payloadData)
    
debug('done', resultList)

outputs['results'] = JArray.FromObject(resultList)
</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://inistate.gitbook.io/home/advanced/integration/accounting-1/creditor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
