Inistate Documentation
  • Welcome
  • Workspace
  • Module
  • User
    • Role
    • Profile
    • Management
  • Configuration
    • Builder
    • Studio
  • Features
    • Basic
    • Information
    • Listing
    • Activity
    • Form
    • State
    • Flow
  • Advanced
    • Formula
    • Authorization
    • Automation
      • Automation Block
      • Scripting
    • Notification
    • Template
      • Report Starter Kit
      • Code
    • Logic
    • Integration
      • Accounting 1
        • Invoice
        • Cash Sale
        • Delivery Order
        • Stock Transfer
        • Sales Order
        • Creditor
        • Credit Note
        • Debit Note
        • A/P Invoice
        • A/P Credit Note
        • A/P Debit Note
        • Customer
      • Accounting 2
        • Debtor
        • Purchase Order
        • Good Receive
        • Payment Voucher
        • Customer Invoice
        • Customer Payment
      • Jobs json
      • Error Handling
      • Call Back
    • Scripting (Beta)
Powered by GitBook
On this page
  • Debtor's Database
  • Debtor's Sample Code
  1. Advanced
  2. Integration
  3. Accounting 2

Debtor

Debtor's Database

UI Name
Database
Type
Remarks

Debtor Account

String

E.g.: 400-A001

Company Name

String

E.g.: Gney Software Sdn Bhd

Billing Address 1

String

E.g.: 1, Jalan Melati Indah,

Billing Address 2

String

E.g.: Taman Bukit Mewah,

Billing Address 3

String

E.g.: 43000 Kajang,

Billing Address 4

String

E.g.: Selangor.

Phone

String

E.g.: 012 - 4567890

Credit Term

String

Credit Term must match the same in the Inistate system. E.g.: C.O.D.

Email Address

String

E.g.: example@test.com

Agent

String

E.g.: ADMIN

Debtor's Sample Code

Remember to change to the correct field before proceeding to run ANY script.

This is a sample SQL, may not be as same as your database.

SELECT TOP (10)
    AccNo,
    CompanyName,
    Address1,
    Address2,
    Address3,
    Address4,
    Phone1,
    DisplayTerm,
    EmailAddress,
    SalesAgent,
    LastModified
FROM Debtor
WHERE LastModified > "{LAST_MODIFIED_DATE_TIME}";

In order to sync, you must include LastModified in SELECT

"SQLSync": [
  {
    "name": "AutoCount to Inistate",
    "enabled": false,
    "connectionString": "Data Source={SERVER};Initial Catalog={DATABASE};User Id={DB_USERNAME};Password={DB_PASSWORD};",
    "hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "sql": "SELECT AccNo, CompanyName, Address1, Address2, Address3, Address4, Phone1, DisplayTerm, EmailAddress, SalesAgent, LastModified \nFROM Debtor \nWHERE LastModified > @date",
    "lastSync": "{LAST-SYNC-DATE-TIME}",
    "start": null
  }
]

To find {fieldName}, you are required to have access to Alpha or use Network in Developer Tools [F12].

# debug('test', inputs)
debug("test")
moduleName = "{YOUR-MODULE-NAME}"
inistateKeyField = "DocumentId"
keyField = "Doc"
modifiedDateField = "LastModified"
fields = [["DocumentId", "Doc"], ["LastModified", "LastModified"]]
inistateFields = []

result = list(inputs["list"]).ToList()
for item in result:
    entry = Module(moduleName).find({"Dynamic.Extension.{fieldName}": item["AccNo"]})

    form = Module(moduleName).execute("sync", entry)
    form["{CODE}"] = item["AccNo"]
    form["{COMPANY_NAME}"] = item["CompanyName"]
    form["{ADDRESS_1}"] = item["Address1"]
    form["{ADDRESS_2}"] = item["Address2"]
    form["{ADDRESS_3}"] = item["Address3"]
    form["{ADDRESS_4}"] = item["Address4"]
    form["{PHONE_NO}"] = item["Phone1"]
    form["{CREDITS_TERM}"] = item["DisplayTerm"]
    form["{EMAIL_ADDRESS}"] = item["EmailAddress"]
    form["{AGENT}"] = item["SalesAgent"]

    debug("form", form)
    Module(moduleName).submit(entry, form)

a

PreviousAccounting 2NextPurchase Order

Last updated 4 months ago

AccNo
CompanyName
Address1
Address2
Address3
Address4
Phone1
DisplayTerm
EmailAddress
SalesAgent