SDK Live: Difference between revisions

From eStream Software
 
(169 intermediate revisions by the same user not shown)
Line 16: Line 16:
# Must self do checking else error prompt will unable to “capture”.
# Must self do checking else error prompt will unable to “capture”.
# Only supported in IE for JScript
# Only supported in IE for JScript
<div style="float: right;">  [[#top|[top]]]</div>
==Requirement==
* Microsoft Windows 8.1 and above (recommended with 64 bits windows)
* Intel i5, i7 and above computer.
* 8 GB of RAM (recommended 12 GB and above).
* Firebird (For Automatic Login & Logout Only)
* SQL Accounting
* Windows Scheduler (For Automatic Login & Logout Only)


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
Line 34: Line 44:
:* The SDK can be build in in your system or a Standalone windows Application(Middle Application).
:* The SDK can be build in in your system or a Standalone windows Application(Middle Application).
:* If you build in your system then it can be sync anytime either by a special interface with parameter (eg Date From, Date To & etc) or each transaction after post(not recommended)
:* If you build in your system then it can be sync anytime either by a special interface with parameter (eg Date From, Date To & etc) or each transaction after post(not recommended)
:* If you create a Standalone windows Application(Middle Application) you can make use the windows schedule to sync or call from you system to execute/run the Standalone windows Application(Middle Application).
:* If you create a Standalone windows Application(Middle Application) you can make use the <span style="color:#0000ff">Windows Schedule</span> to sync or call from you system to execute/run the Standalone windows Application(Middle Application).


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
Line 68: Line 78:
|}
|}
:::----------------------------------------------------------------------------------------------------------------------------------------------------
:::----------------------------------------------------------------------------------------------------------------------------------------------------
<div style="float: right;">  [[#top|[top]]]</div>
==Available Programming Language==
* [[#VB._Net| VB. Net]]
* [[#C_Sharp| C Sharp]]
* [[#ASP.Net_C_Sharp| ASP.Net C Sharp]]
* [[#Python| Python]]
* [[#PHP|PHP]]
* [[#Node_JS| Node JS]]
* [[#VB_Script| VB Script]]
* [[#JScript/JavaScript| JavaScript]]
* [[#Delphi| Delphi]]


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
Line 73: Line 96:
==Example External Program==
==Example External Program==
===VB. Net===
===VB. Net===
* Example [https://www.sql.com.my/downloadfile/Fairy/VBDotNet.zip VBDotNet-20200522]
* Example [https://download.sql.com.my/customer/Fairy/VBDotNet.zip VBDotNet-20230819]


===C Sharp===
===C Sharp===
* Example [https://www.sql.com.my/downloadfile/Fairy/CSharp.zip CSharp-20200522]
* Example [https://download.sql.com.my/customer/Fairy/CSharp.zip CSharp-20230819]
 
===Steps (C Sharp & VB.Net Only)===
The [https://download.sql.com.my/customer/Fairy/Video-VBDotNetnCSharp.zip example video] is how to
:01. Open DCF in '''D:\Happy\DB\Default.DCF'''
:02. Datatabase is '''ACC-0008.FDB'''
:03. Click '''Complete Post''' button
:04. Where to check in SQL accounting after Post (Steps-2.gif)


Available Function
Available Function
Line 93: Line 123:
:- Customer Aging - Customer.Aging.RO
:- Customer Aging - Customer.Aging.RO
:- Get Sales Invoice Listing - Sales.IV.RO
:- Get Sales Invoice Listing - Sales.IV.RO
:- Stock Item List Filter by Supplier Item
:- Stock Item List
:- Add SKU with Edit SKU - ST_ITEM
:- Add SKU with Edit SKU - ST_ITEM
:- Del SKU - ST_ITEM
:- Del SKU - ST_ITEM
Line 120: Line 150:
:- Refund Deposit - Deposit Refund
:- Refund Deposit - Deposit Refund
:- Forfeit Deposit - Deposit Forfeit
:- Forfeit Deposit - Deposit Forfeit
:- Enable Support DocNo Format with Month & Year Format
:- Add AR IV
:- Add AR CN
:- Add AR PM Bounce Chq
:- Add GL Ledger RO
:- AR Statement
:- Add Add/Edit AR PM
:- Add LogInOut (For Testing purpose)


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


===History - C Sharp & VB.Net===
===History - C Sharp & VB.Net===
:19 Aug 2023...
::- Add Add/Edit AR PM
::- Add LogInOut (For Testing purpose)
:14 Jun 2022
::- Add AR Statement
::- Fix Error when click 2nd time for Report.
:27 Apr 2022
::- Add/Edit Location
::- Rename Caption for Add Customer to Add/Edit Cust
::- Rename Caption for Add Agent to Add/Edit Agent
::- Add Reconnect
::- Add/Edit ST_Batch
::- Fix bug on KillApp should Sleep 2 seconds after run the KillApp
:18 Mar 2021
::- Enable Support DocNo Format with Month & Year Format
::- Add AR IV
::- Add AR CN
::- Add AR PM Bounce Chq
::- Add GL Ledger RO
:22 May 2020
:22 May 2020
::- Fix Complete Post Action cause SQLAcc still not exit after logout
::- Fix Complete Post Action cause SQLAcc still not exit after logout
Line 200: Line 261:
02 Make sure the Windows user set in ASP.Net Impersonation is Login
02 Make sure the Windows user set in ASP.Net Impersonation is Login


* Example [https://www.estream.com.my/downloadfile/Fairy/ASPDotNet.zip ASPDotNet-20200916]
* Example [https://download.sql.com.my/customer/Fairy/ASPDotNet.zip ASPDotNet-20210816]


Available Function
Available Function
Line 212: Line 273:
:- Add Add/Edit Terms
:- Add Add/Edit Terms
:- Add Add/Edit ST Item
:- Add Add/Edit ST Item
:- Delete Cash Sales
:- Add SL SO


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


History
History
:16 Aug 2021
::- Add SL SO
:19 Feb 2021
::- Delete Cash Sales
:16 Sep 2020
:16 Sep 2020
::- Add Add/Edit ST Item
::- Add Add/Edit ST Item
Line 240: Line 309:
:- pypiwin32 (Mandatory) -> pip install pypiwin32
:- pypiwin32 (Mandatory) -> pip install pypiwin32
:- Pillow (Optional for Picture) -> pip install Pillow
:- Pillow (Optional for Picture) -> pip install Pillow
:- striprtf (Optional for Rich Text to Text) -> pip install striprtf


====Example-Get Agent====
====Common====
* Common.py file for example code
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Agent Script 
! Common Function
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 03 Oct 2023
import win32com.client
import win32com.client
import Common
import os
from time import sleep


ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def KillApp():
    os.system('cmd /c "taskkill /IM "SQLACC.exe" /F"')
    sleep(2) #sleep 2 sec


def CheckLogin():
def CheckLogin():
    global ComServer
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
     B = ComServer.IsLogin
     B = ComServer.IsLogin
     if B == True:
     if B == True:
         ComServer.Logout()
         ComServer.Logout()
     ComServer.Login("ADMIN", "ADMIN", #UserName, Password
        KillApp()
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name
     ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    try:   
        ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                        "D:\\Happy\\DB\\Default.DCF",
                        #"C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                        "ACC-0015.FDB") #Database Name
    except Exception as e:
        print("Oops !", e)
 


def GetData():
def ShowResult(ADataset):
     lSQL = "SELECT * FROM AGENT  "
     if ADataset.RecordCount > 0:
    lSQL = lSQL + "WHERE CODE='FAIRY' "
        while not ADataset.eof:
   
            fc = ADataset.Fields.Count
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
            for x in range(fc):
   
                fn = ADataset.Fields.Items(x).FieldName
    if lDataSet.RecordCount > 0:
                fv = ADataset.FindField(fn).AsString
        print(lDataSet.FindField('Description').AsString)
                lresult = "Index : "+ str(x) + " FieldName : " + fn + " Value : " + fv
                print (lresult)
            print("====")
            ADataset.Next()
     else:
     else:
      print ("Record Not Found")
        print ("Record Not Found")
   
       
try:
       
    CheckLogin()    
def QuotedStr(ACode):
    GetData()
     return "'" + ACode.replace("'", "''") + "'"
finally:
 
     ComServer.Logout()
    ComServer = None   
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 283: Line 371:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Edit Agent====
====Agent====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit Agent Script   
! Agent Script   
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 22 Jul 2023
import win32com.client
import Common
 
     
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def GetListData():
 
     lSQL = "SELECT * FROM AGENT "
def CheckLogin():
     lSQL = lSQL + "WHERE ISACTIVE='T' "
     B = ComServer.IsLogin
    lSQL = lSQL + "ORDER BY CODE "
     if B == True:
   
        ComServer.Logout()
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
     ComServer.Login("ADMIN", "ADMIN", #UserName, Password
       
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
     Common.ShowResult(lDataSet)
                    "ACC-0104.FDB") #Database Name   


def PostData():
def PostData():
     BizObject = ComServer.BizObjects.Find("Agent")
     BizObject = ComServer.BizObjects.Find("Agent")
     lMain = BizObject.DataSets.Find("MainDataSet")
     lMain = BizObject.DataSets.Find("MainDataSet")  
      
      
     lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
     lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
Line 312: Line 399:
         lMain.FindField("CODE").value = "FAIRY"
         lMain.FindField("CODE").value = "FAIRY"
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL"
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL"
     else:
     else:
         BizObject.Params.Find("CODE").Value = lDocKey
         BizObject.Params.Find("Code").Value = lDocKey
         BizObject.Open()
         BizObject.Open()
         BizObject.Edit()
         BizObject.Edit()
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL WIZARD"
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL WIZARD"
       
           
     try:
     try:
         BizObject.Save()
         BizObject.Save()        
     except Exception as e:
     except Exception as e:
         print("Oops!", e)     
         print("Oops!", e)     
     print ("Done")
    BizObject.Close()
     print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("Agent")
      
      
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
    ComServer.Logout()
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 335: Line 452:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Delete Agent====
====Get Company Profile====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Delete Agent Script 
! Get Company Profile
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 22 Jul 2023
import win32com.client
import Common


ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def GetData():
 
     lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, "
def CheckLogin():
     lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, "
     B = ComServer.IsLogin
    lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE "
     if B == True:
   
        ComServer.Logout()
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
      
                    "C:\eStream\SQLAccounting\Share\Default.DCF", #DCF file
    Common.ShowResult(lDataSet)
                    "ACC-0016.FDB") #Database Name
 
def PostData():
     BizObject = ComServer.BizObjects.Find("Agent")
      
      
     lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
try:
       
     Common.CheckLogin()
     if lDocKey is None:
     global ComServer
        print ("Record Not Found")
     ComServer = Common.ComServer     
     else:
     GetData()
        BizObject.Params.Find("CODE").Value = lDocKey
     ComServer.Logout()
        BizObject.Open()
        BizObject.Delete()       
        print ("Done")
 
try:   
     CheckLogin()
     PostData()
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 378: Line 484:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Complete Post====
====Complete Post====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_CS, AR_PM, SL_CN & AR_CN Script  
! SL_CS, AR_PM, SL_CN & AR_CN Script  
Line 384: Line 490:
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 19 Jul 2023
#This will doing following posting
#This will doing following posting
#01. Cash Sales
#01. Cash Sales
Line 391: Line 497:
#04. Edit Credit Note Posted in Step 02 & Knock Off
#04. Edit Credit Note Posted in Step 02 & Knock Off
#05. Customer Refund to Knock off Credit Note
#05. Customer Refund to Knock off Credit Note
import win32com.client
import Common
import datetime
import datetime
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0016.FDB") #Database Name


def PostDataCS():     
def PostDataCS():     
Line 409: Line 505:
     lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
     lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
      
      
     lDate = datetime.datetime(2018, 2, 22, 13, 0)
     lDate = datetime.datetime(2023, 2, 22, 13, 0)
     lDate.strftime('%m/%d/%Y')
     lDate.strftime('%m/%d/%Y')
      
      
     BizObject.New();
     BizObject.New();
    lMain.FindField("DocKey").value = -1
     lMain.FindField("DocNo").AsString = "--IV Test--"
     lMain.FindField("DocNo").AsString = "--IV Test--"
     lMain.FindField("DocDate").value = lDate
     lMain.FindField("DocDate").value = lDate
Line 429: Line 524:
     #For Tax Inclusive = True with override Tax Amount
     #For Tax Inclusive = True with override Tax Amount
     lDetail.Append()
     lDetail.Append()
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("DocKey").value = -1
     lDetail.FindField("Seq").value = 1
     lDetail.FindField("Seq").value = 1
     lDetail.FindField("Account").AsString = "500-000" #Sales Account
     lDetail.FindField("Account").AsString = "500-000" #Sales Account
Line 436: Line 529:
     lDetail.FindField("Description3").AsString = ("Item A Line 1" + ("\r" + "Item A Line 2"))
     lDetail.FindField("Description3").AsString = ("Item A Line 1" + ("\r" + "Item A Line 2"))
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Tax").AsString = "SR"
     lDetail.FindField("Tax").AsString = "SV"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxInclusive").value = 0
     lDetail.FindField("TaxInclusive").value = 0
Line 451: Line 544:
     #For Tax Inclusive = False with override Tax Amount
     #For Tax Inclusive = False with override Tax Amount
     lDetail.Append()
     lDetail.Append()
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("DocKey").value = -1
     lDetail.FindField("Seq").value = 2
     lDetail.FindField("Seq").value = 2
     lDetail.FindField("Account").AsString = "500-000"
     lDetail.FindField("Account").AsString = "500-000"
     lDetail.FindField("Description").AsString = "Sales Item B"
     lDetail.FindField("Description").AsString = "Sales Item B"
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Tax").AsString = "SR"
     lDetail.FindField("Tax").AsString = "SV"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxInclusive").value = 0
     lDetail.FindField("TaxInclusive").value = 0
Line 467: Line 558:
     #For With Item Code
     #For With Item Code
     lDetail.Append()
     lDetail.Append()
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("DocKey").value = -1
     lDetail.FindField("Seq").value = 3
     lDetail.FindField("Seq").value = 3
     lDetail.FindField("ItemCode").AsString = "ANT"
     lDetail.FindField("ItemCode").AsString = "ANT"
Line 476: Line 565:
     lDetail.FindField("UOM").AsString = "UNIT"
     lDetail.FindField("UOM").AsString = "UNIT"
     #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
     #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
     lDetail.FindField("Tax").AsString = "SR"
     lDetail.FindField("Tax").AsString = "SV"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxInclusive").value = 0
     lDetail.FindField("TaxInclusive").value = 0
Line 492: Line 581:
     lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
     lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
      
      
     lDate = datetime.datetime(2018, 2, 22, 13, 0)
     lDate = datetime.datetime(2023, 2, 22, 13, 0)
     lDate.strftime('%m/%d/%Y')
     lDate.strftime('%m/%d/%Y')
      
      
     BizObject.New()
     BizObject.New()
    lMain.FindField("DOCKEY").Value = -1
     lMain.FindField("DocNo").AsString = "--PM Test--"
     lMain.FindField("DocNo").AsString = "--PM Test--"
     lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
     lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
Line 525: Line 613:
     lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
     lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
      
      
     lDate = datetime.datetime(2018, 2, 22, 13, 0)
     lDate = datetime.datetime(2023, 2, 22, 13, 0)
     lDate.strftime('%m/%d/%Y')
     lDate.strftime('%m/%d/%Y')
      
      
     BizObject.New()
     BizObject.New()
    lMain.FindField("DocKey").value = -1
     lMain.FindField("DocNo").AsString = "--CN Test--"
     lMain.FindField("DocNo").AsString = "--CN Test--"
     lMain.FindField("DocDate").value = lDate
     lMain.FindField("DocDate").value = lDate
Line 544: Line 631:
     #For With Item Code
     #For With Item Code
     lDetail.Append()
     lDetail.Append()
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("DocKey").value = -1
     lDetail.FindField("ItemCode").AsString = "ANT"
     lDetail.FindField("ItemCode").AsString = "ANT"
     lDetail.FindField("Description").AsString = "Sales Item B"
     lDetail.FindField("Description").AsString = "Sales Item B"
Line 552: Line 637:
     lDetail.FindField("Remark2").AsString = "01 Jan 2017"  #Invoice Date
     lDetail.FindField("Remark2").AsString = "01 Jan 2017"  #Invoice Date
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Qty").AsFloat = 1
     lDetail.FindField("Tax").AsString = "SR"
     lDetail.FindField("Tax").AsString = "SV"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxRate").AsString = "6%"
     lDetail.FindField("TaxInclusive").value = 0
     lDetail.FindField("TaxInclusive").value = 0
Line 596: Line 681:
     lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
     lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
      
      
     lDate = datetime.datetime(2018, 2, 22, 13, 0)
     lDate = datetime.datetime(2023, 2, 22, 13, 0)
     lDate.strftime('%m/%d/%Y')
     lDate.strftime('%m/%d/%Y')
      
      
     BizObject.New()
     BizObject.New()
    lMain.FindField("DOCKEY").Value = -1
     lMain.FindField("DocNo").AsString = "--CF Test--"
     lMain.FindField("DocNo").AsString = "--CF Test--"
     lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
     lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
Line 625: Line 709:


try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
     print ("Posting Cash Sales")
     print ("Posting Cash Sales")
     PostDataCS()
     PostDataCS()
Line 637: Line 723:
     PostDataCF()
     PostDataCF()
     print ("Done")
     print ("Done")
    ComServer.Logout()
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 645: Line 732:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Get Picture & Description3(Rich Text)====
====Get Picture & Description3(Rich Text)====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Picture & Description3(Rich Text) Script  
! Get Picture & Description3(Rich Text) Script  
Line 651: Line 738:
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 02 Aug 2023
import win32com.client
import os, sys
import Common
from io import BytesIO
from io import BytesIO
from PIL import Image
from PIL import Image
from striprtf.striprtf import rtf_to_text
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name


def GetData():
def GetData():
Line 675: Line 752:
     dt = Image.open(imgdata)
     dt = Image.open(imgdata)
     dt.save("test.jpg")
     dt.save("test.jpg")
     print ("Done Export out...")
     print ("Done Export Picture file...")
    #print (lDataSet.FindField('Picture').Value)
      
      
     rtf = lDataSet.FindField('Description3').AsString
     rtf = lDataSet.FindField('Description3').AsString
     txt = rtf_to_text(rtf)
    print (rtf)
   
    with open('out.rtf', 'w') as output:
        output.write(rtf)
        output.close()
    print ("Done Export RTF file...")
   
     txt = ComServer.Utility.RichTextToPlainText(rtf)
     print (txt)
     print (txt)
      
      
try:
try:
     CheckLogin()    
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer   
     GetData()
     GetData()
finally:
     ComServer.Logout()
     ComServer.Logout()
finally:   
     ComServer = None
     ComServer = None
 
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 693: Line 780:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Get Invoice Next Number====
====Get Invoice Next Number====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Invoice Next Number Script  
! Get Invoice Next Number Script  
Line 699: Line 786:
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Oct 2019
#Updated 19 Jul 2023
import win32com.client
import Common
 
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
 
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name


def GetData():
def GetData():
Line 726: Line 803:
      
      
try:
try:
     CheckLogin()    
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer     
     GetData()
     GetData()
    ComServer.Logout()
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
====Example-Add & Edit Stock Item====
 
====Stock Item====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit Stock Item Script  
! Stock Item Script  
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 16 Sep 2020
#Updated 21 Dec 2023
import win32com.client
import Common
 
     
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def GetListData():
 
     lSQL = "SELECT A.*, B.UOM, B.RATE, B.REFCOST, B.REFPRICE, B.ISBASE FROM ST_ITEM A "
def CheckLogin():
     lSQL = lSQL + "INNER JOIN ST_ITEM_UOM B ON (A.CODE=B.CODE) "
     B = ComServer.IsLogin
     lSQL = lSQL + "WHERE A.ISACTIVE='T' "
     if B == True:
    lSQL = lSQL + "ORDER BY A.CODE, B.RATE"  
        ComServer.Logout()
   
     ComServer.Login("ADMIN", "ADMIN", #UserName, Password
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
       
                    "ACC-0015.FDB") #Database Name
    Common.ShowResult(lDataSet)


def PostData():
def PostData():
Line 809: Line 890:
         lDtl.FindField("RefCost").AsFloat = 22.3
         lDtl.FindField("RefCost").AsFloat = 22.3
         lDtl.FindField("RefPrice").AsFloat = 52
         lDtl.FindField("RefPrice").AsFloat = 52
        lDtl.FindField("ISBASE").AsFloat = 1
         lDtl.Post();
         lDtl.Post();


Line 816: Line 898:
         lDtl.FindField("RefCost").AsFloat = 102.5
         lDtl.FindField("RefCost").AsFloat = 102.5
         lDtl.FindField("RefPrice").AsFloat = 260.45
         lDtl.FindField("RefPrice").AsFloat = 260.45
        lDtl.FindField("ISBASE").AsFloat = 0
         lDtl.Post()
         lDtl.Post()
      
      
Line 836: Line 919:
         print("Oops!", e)     
         print("Oops!", e)     
     BizObject.Close()
     BizObject.Close()
     print ("Done")
     print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("ST_ITEM")
      
      
try:
     lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
     CheckLogin()
       
     PostData()
     if lDocKey is None:
finally:
        print ("Record Not Found")
    ComServer.Logout()
    else:
    ComServer = None
        BizObject.Params.Find("Dockey").Value = lDocKey
</syntaxhighlight>
        BizObject.Open()
|}
        BizObject.Delete()       
 
        print ("Deleting Done")
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Delete Stock Item====
{| class="mw-collapsible mw-collapsed wikitable"
! Delete Stock Item Script
|-
|
<syntaxhighlight lang="Python">
#Updated 19 Oct 2019
import win32com.client
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0104.FDB") #Database Name
def PostData():
    BizObject = ComServer.BizObjects.Find("ST_ITEM")   
    lDocKey = BizObject.FindKeyByRef("CODE", "ANT")
       
    if lDocKey is None:
        print ("SKU Not Found...")
    else:
        try:
            BizObject.Params.Find("Dockey").Value = lDocKey           
            BizObject.Open()
            BizObject.Delete()
        except Exception as e:
            print("Oops!", e)
    BizObject.Close()   
    print ("Done")
   
try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
    ComServer.Logout()
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
 
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 896: Line 958:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Update AR_Customer====
====AR_Customer====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Update AR_Customer Script  
! AR_Customer Script  
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Apr 2020
#Updated 22 Jul 2023
import win32com.client
import Common
 
     
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def GetListData():
 
    lSQL = "SELECT A.*, B.BRANCHTYPE, B.BRANCHNAME, B.ADDRESS1, B.ADDRESS2, B.ADDRESS3, B.ADDRESS4, "
def CheckLogin():
    lSQL = lSQL + "B.GEOLAT, B.GEOLONG, B.ATTENTION, B.PHONE1, B.PHONE2, B.MOBILE, B.FAX1, B.FAX2, B.EMAIL "
     B = ComServer.IsLogin
    lSQL = lSQL + "FROM AR_CUSTOMER A "
     if B == True:
    lSQL = lSQL + "INNER JOIN AR_CUSTOMERBRANCH B ON (A.CODE=B.CODE) "
        ComServer.Logout()
     lSQL = lSQL + "WHERE A.STATUS='A' "
     ComServer.Login("ADMIN", "ADMIN", #UserName, Password
     lSQL = lSQL + "ORDER BY A.CODE, B.BRANCHTYPE "
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
   
                    "ACC-0072.FDB") #Database Name
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
     Common.ShowResult(lDataSet)


def PostData():
def PostData():
Line 961: Line 1,025:


         #Insert back with new Information
         #Insert back with new Information
         lDtl.Edit() #For 1St Branch
         lDtl.Append() #For 1St Branch
        lDtl.FindField("BranchType").AsString  = "B"
         lDtl.FindField("BranchName").AsString  = "BILLING" #Make sure this always same as b4 delete data
         lDtl.FindField("BranchName").AsString  = "BILLING" #Make sure this always same as b4 delete data
         lDtl.FindField("Address1").AsString    = "New Address1"
         lDtl.FindField("Address1").AsString    = "New Address1"
Line 974: Line 1,039:


         lDtl.Append() #For 2nd Branch
         lDtl.Append() #For 2nd Branch
        lDtl.FindField("BranchType").AsString  = "D"
         lDtl.FindField("BranchName").AsString  = "Branch1" #Make sure this always same as b4 delete data
         lDtl.FindField("BranchName").AsString  = "Branch1" #Make sure this always same as b4 delete data
         lDtl.FindField("Address1").AsString    = "New DAddress1"
         lDtl.FindField("Address1").AsString    = "New DAddress1"
Line 990: Line 1,056:
         print("Oops!", e)     
         print("Oops!", e)     
     BizObject.Close()
     BizObject.Close()
     print ("Done")
     print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("AR_CUSTOMER")
      
      
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
    ComServer.Logout() 
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
 
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 1,004: Line 1,095:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Edit SL_CS====
====Sales Invoice====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Edit SL_CS Script
! SL_IV
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 29 May 2020
#Updated 08 Jan 2024
import win32com.client
import Common
import datetime
     
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM SL_IV A "
    lSQL = lSQL + "INNER JOIN SL_IVDTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
    Common.ShowResult(lDataSet)


ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def PostData():
    BizObject = ComServer.BizObjects.Find("SL_IV")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
   
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
   
    lDocKey = BizObject.FindKeyByRef("DocNo", "--IV Test--")
       
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--IV Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("CompanyName").AsString = "Cash Sales"
        lMain.FindField("Address1").AsString = "" #Optional
        lMain.FindField("Address2").AsString = "" #Optional
        lMain.FindField("Address3").AsString = "" #Optional
        lMain.FindField("Address4").AsString = "" #Optional
        lMain.FindField("Phone1").AsString = ""  #Optional
        lMain.FindField("Description").AsString = "Sales"


def CheckLogin():
        #Insert Data - Detail
    B = ComServer.IsLogin
        #For Tax Inclusive = True with override Tax Amount
    if B == True:
        lDetail.Append()
         ComServer.Logout()
        lDetail.FindField("Seq").value = 1
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
        lDetail.FindField("Account").AsString = "500-000" #Sales Account
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
        lDetail.FindField("Description").AsString = "Sales Item A"
                    "ACC-0091.FDB") #Database Name
        lDetail.FindField("Description3").AsString = ("Item A Line 1" + ("\r" + "Item A Line 2"))
         lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 435
        lDetail.FindField("Amount").AsFloat = 410.37 #Exclding GST Amt
        lDetail.FindField("TaxAmt").AsFloat = 24.63


def PostData():
        lDetail.DisableControls()
    lSQL = "SELECT Dockey FROM SL_CS "
        lDetail.FindField("TaxInclusive").value = 1
    lSQL = lSQL + "WHERE DocNo='--CS Test--' "
        lDetail.EnableControls()
    lSQL = lSQL + " AND Code='300-K0001' "
      
      
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        lDetail.Post()
 
        #For Tax Inclusive = False with override Tax Amount
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("Account").AsString = "500-000"
        lDetail.FindField("Description").AsString = "Sales Item B"
        lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 94.43
        lDetail.FindField("Amount").AsFloat = 94.43
        lDetail.FindField("TaxAmt").AsFloat = 5.66
        lDetail.Post()
      
      
     BizObject = ComServer.BizObjects.Find("SL_CS")
        #For With Item Code
    lMain = BizObject.DataSets.Find("MainDataSet")
        lDetail.Append()
    lDtl = BizObject.DataSets.Find("cdsDocDetail")
        lDetail.FindField("Seq").value = 3
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Sales Item B"
        #lDetail.FindField("Account").AsString     = "500-000" #If you wanted override the Sales Account Code
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 200
        lDetail.FindField("TaxAmt").AsFloat = 12
        lDetail.Post()
      
      
     
     else:
     if lDataSet.RecordCount > 0:
         BizObject.Params.Find("Dockey").Value = lDocKey
        lDataSet.First()       
         BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
         BizObject.Open()
         BizObject.Open()
         BizObject.Edit()
         BizObject.Edit()
         lMain.Edit()
         lMain.Edit()
         lMain.FindField("Description").AsString = "Edited Description 123"
         lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"


         #Delete all Detail
         #Delete all Detail
         while lDtl.RecordCount != 0:
         while lDetail.RecordCount != 0:
             lDtl.First()
             lDetail.Last()
             lDtl.Delete()
             lDetail.Delete()
              
              
         #Append Detail
         #Append Detail
         lDtl.Append()
         lDetail.Append()
         lDtl.FindField("DtlKey").value = -1
         #lDetail.FindField("Account").value = "500-000"
         lDtl.FindField("Account").value = "500-0000"
         lDetail.FindField("Description").AsString = "Item A  的第一"
         lDtl.FindField("Description").value = "Item A"
         lDetail.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("More description  的第一 🐱")
         lDtl.FindField("Tax").value = ""
         lDetail.FindField("Tax").value = ""
         lDtl.FindField("TaxInclusive").value = 0
         lDetail.FindField("TaxInclusive").value = 0
         lDtl.FindField("Amount").value = 410.37
         lDetail.FindField("Amount").value = 410.37
         lDtl.FindField("TaxAmt").value = 0
         lDetail.FindField("TaxAmt").value = 0
         lDtl.Post()
         lDetail.Post()
   
       
     try:
     try:
         BizObject.Save()           
         BizObject.Save()           
Line 1,064: Line 1,223:
         print("Oops!", e)     
         print("Oops!", e)     
     BizObject.Close()
     BizObject.Close()
     print ("Done")
     print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never not knock off by Payment or Credit Note
    BizObject = ComServer.BizObjects.Find("SL_IV")
      
      
try:
    lDocKey = BizObject.FindKeyByRef("DocNo", "--IV Test--")
     CheckLogin()
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
 
try:
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
 
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}


<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
====Example-GL Ledger====
 
====Purchase Invoice====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL Ledger Script
! PH_PI
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Aug 2020
#Updated 08 Jan 2024
import win32com.client
import Common
import datetime
     
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM PH_PI A "
    lSQL = lSQL + "INNER JOIN PH_PIDTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='400-L0001' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
    Common.ShowResult(lDataSet)


ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def PostData():
 
     BizObject = ComServer.BizObjects.Find("PH_PI")
def CheckLogin():
     lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
     B = ComServer.IsLogin
     lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name
 
def GetData():
     lSQL = "SELECT A.CODE, B.DESCRIPTION ACCDESC, A.DOCDATE, A.POSTDATE, A.DESCRIPTION, A.DESCRIPTION2,  "
    lSQL = lSQL + "A.LOCALDR, A.LOCALCR, A.REF1, A.REF2 FROM GL_TRANS A "
    lSQL = lSQL + "INNER JOIN GL_ACC B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.CANCELLED='F' "
     lSQL = lSQL + "AND A.POSTDATE BETWEEN '01 JAN 2018'  "
    lSQL = lSQL + "AND '31 DEC 2018' "
    lSQL = lSQL + "AND A.CODE='500-2000' "
    lSQL = lSQL + "ORDER BY A.CODE, A.POSTDATE "
      
      
     lDataSet = ComServer.DBManager.NewDataSet(lSQL)
     lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
      
      
     if lDataSet.RecordCount > 0:
     V = ["--PI Test--", "400-W0001"]  #DocNo, Code
        while not lDataSet.eof:
            print(lDataSet.FindField('CODE').AsString)
            print(lDataSet.FindField('ACCDESC').AsString)
            print(lDataSet.FindField('Description').AsString)
            print(lDataSet.FindField('REF1').AsString)
            print(lDataSet.FindField('LOCALDR').AsString)
            print(lDataSet.FindField('LOCALCR').AsString)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")
      
      
try:
    lDocKey = BizObject.FindKeyByRef("DocNo;Code", V)
    CheckLogin()    
       
    GetData()
    if lDocKey is None:
finally:
        BizObject.New()
    ComServer.Logout()
        lMain.FindField("DocNo").AsString = "--PI Test--"
    ComServer = None
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "400-W0001" #Supplier Account
        lMain.FindField("CompanyName").AsString = "WORLDLINE COMMUNICATION SDN BHD"
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""  #Optional
        lMain.FindField("Description").AsString = "Purchase Invoice"


</syntaxhighlight>
        #Insert Data - Detail   
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Item B"
        #lDetail.FindField("Account").AsString    = "600-000" #If you wanted override the Purchase Account Code
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = ""
        lDetail.FindField("TaxRate").AsString = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 80
        lDetail.FindField("Amount").AsFloat = 160
        lDetail.FindField("TaxAmt").AsFloat = 0
        lDetail.Post()
       
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("ItemCode").AsString = "HFK"
        lDetail.FindField("Description").AsString = "HANDS FREE KITS"
        #lDetail.FindField("Account").AsString    = "600-000" #If you wanted override the Purchase Account Code
        lDetail.FindField("Qty").AsFloat = 3
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = ""
        lDetail.FindField("TaxRate").AsString = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 50
        lDetail.FindField("Amount").AsFloat = 150
        lDetail.FindField("TaxAmt").AsFloat = 0
        lDetail.Post()       
   
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"
 
        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
           
        #Append Detail
        lDetail.Append()
        #lDetail.FindField("Account").value = "600-000"
        lDetail.FindField("Description").AsString = "Item A  的第一"
        lDetail.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("More description  的第一 🐱")
        lDetail.FindField("Tax").value = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("Amount").value = 410.37
        lDetail.FindField("TaxAmt").value = 0
        lDetail.Post()
       
    try:
        BizObject.Save()         
    except Exception as e:
        print("Oops!", e)   
    BizObject.Close()
    print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never not knock off by Payment or Credit Note
    BizObject = ComServer.BizObjects.Find("PH_PI")
   
    V = ["--PI Test--", "400-W0001"]  #DocNo, Code
   
    lDocKey = BizObject.FindKeyByRef("DocNo;Code", V)   
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
 
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
    ComServer = None
    Common.KillApp()
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL Trial Balance====
====GL Ledger====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL Trial Balance Script  
! GL Ledger Script  
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 17 Aug 2020
#Updated 24 Jul 2023
import win32com.client
import Common
import datetime
 
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
 
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name


def GetData():
def GetData():
     RptObject = ComServer.RptObjects.Find('GL.TrialBalance.RO')
     lSQL = "SELECT A.CODE, B.DESCRIPTION ACCDESC, A.DOCDATE, A.POSTDATE, A.DESCRIPTION, A.DESCRIPTION2,  "
    lSQL = lSQL + "A.LOCALDR, A.LOCALCR, A.REF1, A.REF2 FROM GL_TRANS A "
    lSQL = lSQL + "INNER JOIN GL_ACC B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.CANCELLED='F' "
    lSQL = lSQL + "AND A.POSTDATE BETWEEN '01 JAN 2023'  "
    lSQL = lSQL + "AND '31 DEC 2023' "
    lSQL = lSQL + "AND A.CODE='310-000' "
    lSQL = lSQL + "ORDER BY A.CODE, A.POSTDATE "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
      
      
     RptObject.Params.Find("AllProject").Value      = True
    Common.ShowResult(lDataSet)
   
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer     
    GetData()
    ComServer.Logout()
finally:   
    ComServer = None
    Common.KillApp()
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL Trial Balance====
{| class="mw-collapsible mw-collapsed wikitable"
! GL Trial Balance Script
|-
|
<syntaxhighlight lang="Python">
#Updated 25 Jul 2023
import Common
import datetime
 
def GetData():
    RptObject = ComServer.RptObjects.Find('GL.TrialBalance.RO')
   
     RptObject.Params.Find("AllProject").Value      = True
     RptObject.Params.Find("AllAgent").Value        = True
     RptObject.Params.Find("AllAgent").Value        = True
     RptObject.Params.Find("AllArea").Value        = True
     RptObject.Params.Find("AllArea").Value        = True
Line 1,181: Line 1,491:
     lDataSet2 = RptObject.DataSets.Find("cdsGLAccount") #For Account List
     lDataSet2 = RptObject.DataSets.Find("cdsGLAccount") #For Account List
      
      
    if lDataSet2.RecordCount > 0:
        while not lDataSet2.eof:
            print(lDataSet2.FindField('CODE').AsString)
            print(lDataSet2.FindField('DESCRIPTION').AsString)
            print("===")
            lDataSet2.Next()
           
     if lDataSet.RecordCount > 0:
     if lDataSet.RecordCount > 0:
         while not lDataSet.eof:
         while not lDataSet.eof:
Line 1,197: Line 1,514:
      
      
try:
try:
     CheckLogin()    
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer     
     GetData()
     GetData()
finally:
     ComServer.Logout()
     ComServer.Logout()
finally:   
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Get AR_Customer List====
====Terms====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get AR_Customer List Script
! Terms
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 25 Aug 2020
#Updated 25 Jul 2023
import win32com.client
import Common
 
     
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
def GetListData():
 
     lSQL = "SELECT * FROM TERMS "
def CheckLogin():
     lSQL = lSQL + "WHERE ISACTIVE='T' "
    B = ComServer.IsLogin
     lSQL = lSQL + "ORDER BY CODE "
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0112.FDB") #Database Name
 
def GetData():
     lSQL = "SELECT A.*, B.BRANCHTYPE, B.BRANCHNAME, B.ADDRESS1, B.ADDRESS2, B.ADDRESS3, B.ADDRESS4, "
    lSQL = lSQL + "B.GEOLAT, B.GEOLONG, B.ATTENTION, B.PHONE1, B.PHONE2, B.MOBILE, B.FAX1, B.FAX2, B.EMAIL "
    lSQL = lSQL + "FROM AR_CUSTOMER A "
    lSQL = lSQL + "INNER JOIN AR_CUSTOMERBRANCH B ON (A.CODE=B.CODE) "
     lSQL = lSQL + "WHERE A.STATUS='A' "
     lSQL = lSQL + "ORDER BY A.CODE, B.BRANCHTYPE "
      
      
     lDataSet = ComServer.DBManager.NewDataSet(lSQL)
     lDataSet = ComServer.DBManager.NewDataSet(lSQL)
          
          
     while not lDataSet.eof:
     Common.ShowResult(lDataSet)
        fc = lDataSet.Fields.Count
        for x in range(fc):
            fn = lDataSet.Fields.Items(x).FieldName
            fv = lDataSet.FindField(fn).AsString
            lresult = "Index : "+ str(x) + " FieldName : " + fn + " Value : " + fv
            print (lresult)
        print("====")
        lDataSet.Next()
try:
    CheckLogin()     
    GetData()
finally:
    ComServer.Logout()
    ComServer = None
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Edit Terms====
def PostData():
{| class="mw-collapsible mw-collapsed wikitable"
     BizObject = ComServer.BizObjects.Find("Terms")
! Add & Edit Terms Script
     lMain = BizObject.DataSets.Find("MainDataSet")
|-
      
|
     lDocKey = BizObject.FindKeyByRef("CODE", "90 Days")
<syntaxhighlight lang="Python">
#Updated 12 Oct 2020
import win32com.client
 
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
 
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0121.FDB") #Database Name   
 
def PostData():
     BizObject = ComServer.BizObjects.Find("Terms")
     lMain = BizObject.DataSets.Find("MainDataSet")
      
     lDocKey = BizObject.FindKeyByRef("CODE", "90 Days")
          
          
     if lDocKey is None:
     if lDocKey is None:
Line 1,293: Line 1,564:
          
          
     try:
     try:
         BizObject.Save()
         BizObject.Save()        
     except Exception as e:
     except Exception as e:
         print("Oops!", e)     
         print("Oops!", e)     
     print ("Done")
    BizObject.Close()
     print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("Terms")
      
      
    lDocKey = BizObject.FindKeyByRef("CODE", "90 Days")
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Edit Company Category====
====Stock Adjustment====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit Company Category Script
! ST_SJ
|-
|-
|  
|  
<syntaxhighlight lang="Python">
<syntaxhighlight lang="Python">
#Updated 12 Oct 2020
#Updated 08 Jan 2024
import win32com.client
import Common
 
import datetime
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
     
 
def GetListData():
def CheckLogin():
     lSQL = "SELECT A.DOCNO, A.DOCDATE, A.DESCRIPTION, A.DOCAMT, "
     B = ComServer.IsLogin
     lSQL = lSQL + "A.AUTHBY, A.REASON, A.REMARK, "
     if B == True:
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITCOST, "
        ComServer.Logout()
    lSQL = lSQL + "B.AMOUNT, B.REMARK1, B.REMARK2 "
     ComServer.Login("ADMIN", "ADMIN", #UserName, Password
     lSQL = lSQL + "FROM ST_AJ A "
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
    lSQL = lSQL + "INNER JOIN ST_AJDTL B ON (A.DOCKEY=B.DOCKEY) "
                    "ACC-0121.FDB") #Database Name   
    lSQL = lSQL + "WHERE A.DocDate='20 Apr 2013' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
    Common.ShowResult(lDataSet)


def PostData():
def PostData():
     BizObject = ComServer.BizObjects.Find("COMPANYCATEGORY")
     BizObject = ComServer.BizObjects.Find("ST_AJ")
     lMain = BizObject.DataSets.Find("MainDataSet")
     lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
      
      
     lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
       
     lDocKey = BizObject.FindKeyByRef("DocNo", "--AJ Test--")
          
          
     if lDocKey is None:
     if lDocKey is None:
         BizObject.New()
         BizObject.New()
         lMain.FindField("CODE").value = "FAIRY"
         lMain.FindField("DocNo").AsString = "--AJ Test--"
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL"
        lMain.FindField("DocDate").value = lDate
         lMain.FindField("ISACTIVE").value = "T"
        lMain.FindField("PostDate").value = lDate
         lMain.FindField("Description").AsString = "Stock Adjustment"
 
        #Insert Data - Detail - Increase Stock Qty 
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "ANTENA"
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "PCS"
        lDetail.FindField("UnitCOST").AsFloat = 80
        lDetail.FindField("Amount").AsFloat = 160
         lDetail.Post()
       
        #Insert Data - Detail - Reduce Stock Qty
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("ItemCode").AsString = "HFK"
        lDetail.FindField("Description").AsString = "HANDS FREE KITS"
        lDetail.FindField("Qty").AsFloat = -3
        lDetail.FindField("UOM").AsString = "UNIT"
        lDetail.Post()       
   
     else:
     else:
         BizObject.Params.Find("CODE").Value = lDocKey
         BizObject.Params.Find("Dockey").Value = lDocKey
         BizObject.Open()
         BizObject.Open()
         BizObject.Edit()
         BizObject.Edit()
         lMain.FindField("DESCRIPTION").value = "FAIRY TAIL WIZARD"
         lMain.Edit()
         lMain.FindField("ISACTIVE").value = "F"
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"
 
        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
           
        #Append Detail
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "BOM"
        lDetail.FindField("Description").AsString = "Bill Of Material"       
        lDetail.FindField("Qty").AsFloat = -1
         lDetail.FindField("UOM").AsString = "UNIT"
        lDetail.Post()
          
          
     try:
     try:
         BizObject.Save()
         BizObject.Save()        
     except Exception as e:
     except Exception as e:
         print("Oops!", e)     
         print("Oops!", e)     
     print ("Done")
    BizObject.Close()
      
     print ("Posting/Update Done")
 
def DelData():
    BizObject = ComServer.BizObjects.Find("ST_AJ")
       
     lDocKey = BizObject.FindKeyByRef("DocNo", "--AJ Test--")   
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
 
try:
try:
     CheckLogin()
     Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
     PostData()
     PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
finally:
    ComServer.Logout()
     ComServer = None
     ComServer = None
    Common.KillApp()
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
<br>
===PHP===
: Add this in ..\xampp\php\php.ini
[PHP_COM_DOTNET]
extension=php_com_dotnet.dll


====Example-Get Agent====
====Sales Order====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Agent Script 
! Sales Order
|-
|-
|  
|  
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="Python">
<!DOCTYPE html>
#Updated 08 Jan 2024
<html>
import Common
<body>
import datetime
     
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM SL_SO A "
    lSQL = lSQL + "INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
    Common.ShowResult(lDataSet)


<h1>SQL Acc SDK in PHP page</h1>
def PostData():
    BizObject = ComServer.BizObjects.Find("SL_SO")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
   
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
   
    lDocKey = BizObject.FindKeyByRef("DocNo", "--SO Test--")
       
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--SO Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("CompanyName").AsString = "Cash Sales"
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""  #Optional
        lMain.FindField("Description").AsString = "Sales Order"


<?php
        #Insert Data - Detail   
echo "Updated 01 May 2020<br>";
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Sales Item B"
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 200
        lDetail.FindField("TaxAmt").AsFloat = 12
        lDetail.Post()
   
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"


$ComServer = null;
        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
           
        #Append Detail
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "BOM"
        lDetail.FindField("Description").AsString = "Sales Item BOM"
        lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 100
        lDetail.FindField("TaxAmt").AsFloat = 6
        lDetail.Post()
       
    try:
        BizObject.Save()         
    except Exception as e:
        print("Oops!", e)   
    BizObject.Close()
    print ("Posting/Update Done")


function CheckLogin()
def DelData():
{
    BizObject = ComServer.BizObjects.Find("SL_SO")
     global $ComServer;
      
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
     lDocKey = BizObject.FindKeyByRef("DocNo", "--SO Test--")
    $status = $ComServer->IsLogin();
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")


     if ($status == true)
try:
     {
     Common.CheckLogin()
        $ComServer->Logout();
     global ComServer
     }
    ComServer = Common.ComServer
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
    GetListData()
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
     PostData()
                      "ACC-0082.FDB"); #Database Name
      
      
}
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
    ComServer = None
    Common.KillApp()
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>


function GetData()
====Sales.PriceHistory.RO====
{
{| class="mw-collapsible mw-collapsed wikitable"
    global $ComServer;
! Sales.PriceHistory.RO Script
|-
|
<syntaxhighlight lang="Python">
#Updated 01 Apr 2021
import win32com.client
import datetime


    $lSQL = "SELECT * FROM AGENT
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
        WHERE CODE='HALIM'";


     $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
def CheckLogin():
     B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name


     if ($lDataSet->RecordCount > 0)
def GetData():
     {
    RptObject = ComServer.RptObjects.Find('Sales.PriceHistory.RO')
         echo "Result : ";
   
        echo $lDataSet->FindField('Description')->AsString() . "<br>";
     #RptObject.Params.Find("AgentData").Value            = #Not use if AllAgent is true
     }
    #RptObject.Params.Find("TaxData").Value              = #Not use if AllTax is true
     else
    #RptObject.Params.Find("CompanyCategoryData").Value  = #Not use if AllCompanyCategory is true
     {
    RptObject.Params.Find("AllAgent").Value              = True
         echo "Record Not Found";
    RptObject.Params.Find("AllTax").Value                = True
     }
    RptObject.Params.Find("AllShipper").Value            = True
}
    RptObject.Params.Find("AllArea").Value              = True
     RptObject.Params.Find("AllCompany").Value            = True
    RptObject.Params.Find("AllDocProject").Value         = True
    RptObject.Params.Find("AllItem").Value              = False
    RptObject.Params.Find("AllItemProject").Value        = True
    RptObject.Params.Find("AllLocation").Value          = True
    RptObject.Params.Find("AllCompanyCategory").Value    = True
    RptObject.Params.Find("AllBatch").Value              = True
     RptObject.Params.Find("AllTariff").Value            = True
     RptObject.Params.Find("AllStockGroup").Value        = True
     #RptObject.Params.Find("AreaData").Value            = #Not use if AllArea is true
    #RptObject.Params.Find("CategoryData").Value         = #Not use if AllTax is true
    #RptObject.Params.Find("CategoryTpl").Value          = #Not use if AllTax is true
    #RptObject.Params.Find("CompanyData").Value          = #Not use if AllTax is true
     
    lDateFrom = datetime.datetime(2021, 3, 1, 13, 0)
    lDateFrom.strftime('%m/%d/%Y')
    lDateTo = datetime.datetime(2021, 3, 31, 13, 0)
    lDateTo.strftime('%m/%d/%Y')
      
    RptObject.Params.Find("DateFrom").Value        = lDateFrom
    RptObject.Params.Find("DateTo").Value          = lDateTo


if (isset($_POST['BtnData']))
    RptObject.Params.Find("DoCN_SC").Value          = False #Include Credit Note
{
    #RptObject.Params.Find("DocProjectData").Value  = #Not use if AllDocProject is true
     try
    RptObject.Params.Find("DoCS_CP").Value          = True #Include Cash Sales
     {
    RptObject.Params.Find("DoDN_SD").Value          = False #Include Debit Note
        CheckLogin();
    RptObject.Params.Find("DoDO_GR").Value          = False #Include Delivery Order
        GetData();
    RptObject.Params.Find("DoED_EG").Value          = False #Include Extra Delivery Order
        echo date("d M Y h:i:s A") . " - Done";
     RptObject.Params.Find("DoIV_PI").Value          = False #Include Invoice
     }
     RptObject.Params.Find("DoQT_PQ").Value          = False #Include Quotation
     finally
    RptObject.Params.Find("DoSO_PO").Value          = False #Include Sales Order
     {
    #RptObject.Params.Find("ItemCode").Value        = #For Internal use only
        $ComServer->Logout();
    RptObject.Params.Find("ItemData").Value        = "ANT" + "\r" + "BOM"
        #free the object
     #RptObject.Params.Find("ItemProjectData").Value  = #Not use if AllItemProject is true
        $ComServer = null;
     #RptObject.Params.Find("LocationData").Value    = #Not use if AllLocation is true
     }
     #RptObject.Params.Find("MaxRecords").Value      = #Not use if SelectMaxRecords is False
}
    RptObject.Params.Find("SelectDate").Value        = True
 
     RptObject.Params.Find("SelectMaxRecords").Value  = False
?>
    #RptObject.Params.Find("GroupBy").Value          = #Only use if wanted to grouping
     <form method="post">         
    RptObject.Params.Find("HasCategory").Value      = False
        <input type="submit" name="BtnData"
    #RptObject.Params.Find("ItemCategoryData").Value = #Not use if HasCategory is False
                value="Get Agent"/>
     #RptObject.Params.Find("BatchData").Value        = #Not use if AllBatch is true
     </form>
    #RptObject.Params.Find("TariffData").Value      = #Not use if AllTariff is true
</body>
    #RptObject.Params.Find("ShipperData").Value      = #Not use if AllShipper is true
</html>
    RptObject.Params.Find("SortBy").Value            = "DocDate;DocNo"
</syntaxhighlight>
    #RptObject.Params.Find("StockGroupData").Value  = #Not use if AllStockGroup is true
|}
     #RptObject.Params.Find("SummaryInterval 
   
    RptObject.CalculateReport()


    lDataSet = RptObject.DataSets.Find("cdsMain")
       
    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            for idx in range(lDataSet.Fields.Count):
                LFld = lDataSet.Fields.Items(idx).FieldName
                print(LFld + " :"+ lDataSet.FindField(LFld).AsString)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")
   
try:
    CheckLogin()     
    GetData()
finally:
    ComServer.Logout()
    ComServer = None
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Edit Agent====
====Get Edited Sales Invoice List====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit Agent Script
! Get Edited Sales Invoice List Script  
|-
|-
|  
|  
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="Python">
<!DOCTYPE html>
#Updated 19 Jul 2021
<html>
import win32com.client
<body>
 
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")


<h1>SQL Acc SDK in PHP page</h1>
def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name


<?php
def GetData():
echo "Updated 01 May 2020<br>";
    lSQL = "SELECT REFERENCE FROM AUDIT "
    lSQL = lSQL + "WHERE REF LIKE 'SL_IV%' "
    lSQL = lSQL + "AND UPDATEKIND='E' "
    lSQL = lSQL + "AND CAST(DOCDATETIME AS DATE) = '10 JUN 2021' "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)


$ComServer = null;
    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            DocNo = lDataSet.FindField('REFERENCE').AsString
            DocNo = DocNo.split(',')[0]
            DocNo = DocNo.split(':')[1]
   
            print(DocNo)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")


function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
      
      
}
try:
    CheckLogin()     
    GetData()
finally:
    ComServer.Logout()
    ComServer = None


function PostData(){
global $ComServer;
    $BizObject = $ComServer->BizObjects->Find("Agent");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
   
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
if ($lDocKey == null){
        $BizObject->New();
        $lMain->FindField("CODE")->value = "FAIRY";
        $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL";
} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Edit();
        $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL WIZARD";
}
try{
$BizObject->Save();
echo "Posting Done <br>";
}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}
}
if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        PostData();
        echo date("d M Y h:i:s A") . " - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Add/Edit Agent"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Delete Agent====
====SO to DO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Delete Agent Script
! Get Outstanding SO by SO Number transfer to DO Script  
|-
|-
|  
|  
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="Python">
<!DOCTYPE html>
#Updated 29 Nov 2021
<html>
import win32com.client
<body>
import datetime


<h1>SQL Acc SDK in PHP page</h1>
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")


<?php
def CheckLogin():
echo "Updated 01 May 2020<br>";
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "D:\\Happy\\DB\\Default.DCF",
                  # "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0011.FDB") #Database Name


$ComServer = null;
def PostData():
    lSQL = "SELECT Dockey, DocNo,Code, CompanyName, DocProject, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount, DtlProject, "
    lSQL = lSQL + "Tax, TaxRate, TaxInclusive, TaxAmt, COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM ( "
    lSQL = lSQL + "SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName, A.Project DocProject, "
    lSQL = lSQL + "B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount, "
    lSQL = lSQL + "B.Tax, B.TaxRate, B.TaxInclusive, B.TaxAmt, B.Project DtlProject, C.Qty XFQty FROM SL_SO A "
    lSQL = lSQL + "INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY "
    lSQL = lSQL + "                          AND C.FROMDOCTYPE='SO') "
    lSQL = lSQL + "WHERE A.DOCNO='SO-00044') "
    lSQL = lSQL + "GROUP BY Dockey, DocNo, Code, CompanyName, DocProject, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, "
    lSQL = lSQL +" Amount, DtlProject, Tax, TaxRate, TaxInclusive, TaxAmt "
    lSQL = lSQL + "HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0 "
   
    lDataSet = ComServer.DBManager.NewDataSet(lSQL) #Get Outstanding Qty for each itemcode
    #print("==="+ str(lDataSet.RecordCount))
    if lDataSet.RecordCount > 0:
        BizObject = ComServer.BizObjects.Find("SL_DO")
        lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
        lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
   
        lDate = datetime.datetime(2021, 11, 29, 13, 0)
        lDate.strftime('%m/%d/%Y')
   
        BizObject.New();
        lMain.FindField("DocKey").value = -1
        lMain.FindField("DocNo").AsString = "--DO Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = lDataSet.FindField("Code").AsString #Customer Account
        lMain.FindField("CompanyName").AsString = lDataSet.FindField("CompanyName").AsString
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""  #Optional
        lMain.FindField("Project").AsString = lDataSet.FindField("DocProject").AsString
        lMain.FindField("Description").AsString = "Delivery Order"


function CheckLogin()
        #Insert Data - Detail
{
        while not lDataSet.eof:
    global $ComServer;
            lDetail.Append()
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
            lDetail.FindField("DtlKey").value = -1
     $status = $ComServer->IsLogin();
            lDetail.FindField("DocKey").value = -1
            lDetail.FindField("Seq").value = lDataSet.FindField("Seq").Value
            lDetail.FindField("ItemCode").AsString = lDataSet.FindField("ItemCode").AsString
            lDetail.FindField("UOM").AsString = lDataSet.FindField("UOM").AsString
            lDetail.FindField("Qty").AsFloat = lDataSet.FindField("OSQty").AsFloat # Transfer all balance Qty
            lDetail.FindField("DISC").AsString = lDataSet.FindField("DISC").AsString
            lDetail.FindField("Tax").AsString = lDataSet.FindField("Tax").AsString
            lDetail.FindField("TaxRate").AsString = lDataSet.FindField("TaxRate").AsString
            lDetail.FindField("TaxInclusive").value = lDataSet.FindField("TaxInclusive").value
            lDetail.FindField("UnitPrice").AsFloat = lDataSet.FindField("UnitPrice").AsFloat
            lDetail.FindField("Amount").AsFloat = lDataSet.FindField("Amount").AsFloat
            lDetail.FindField("TaxAmt").AsFloat = lDataSet.FindField("TaxAmt").AsFloat
            lDetail.FindField("Project").AsString = lDataSet.FindField("DtlProject").AsString
            lDetail.FindField("FromDocType").AsString = "SO"; #From Document Type
            lDetail.FindField("FromDockey").AsFloat = lDataSet.FindField("Dockey").AsFloat;
            lDetail.FindField("FromDtlkey").AsFloat = lDataSet.FindField("DtlKey").AsFloat;
            lDetail.Post()
            lDataSet.Next()
   
        BizObject.Save()
        BizObject.Close()
    else :
        print ("Record Not Found")
try:
    CheckLogin()
    print ("Posting SO to DO")
     PostData()
    print ("Done")
finally:
    ComServer.Logout()
    ComServer = None


    if ($status == true)
</syntaxhighlight>
    {
|}
        $ComServer->Logout();
<div style="float: right;">  [[#top|[top]]]</div>
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF"#DCF file
                      "ACC-0082.FDB"); #Database Name
   
}


function PostData(){
====Stock Month End - Weighted Average====
global $ComServer;
{| class="mw-collapsible mw-collapsed wikitable"
! Stock Month End - Weighted Average Script
    $BizObject = $ComServer->BizObjects->Find("Agent");
|-
    $lMain = $BizObject->DataSets->Find("MainDataSet");
|
   
<syntaxhighlight lang="Python">
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
#Updated 30 Nov 2021
import win32com.client
if ($lDocKey == null){
import datetime
        echo "Record Not Found";
} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Delete();
        echo "Delete Done<br>";
}
}


if (isset($_POST['BtnData']))
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
{
 
     try
def CheckLogin():
     {
    B = ComServer.IsLogin
         CheckLogin();
    if B == True:
         PostData();
        ComServer.Logout()
        echo date("d M Y h:i:s A") . " - Done";
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
     }
                    "D:\\Happy\\DB\\Default.DCF",
     finally
                  # "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
     {
                    "ACC-0011.FDB") #Database Name
        $ComServer->Logout();
 
        #free the object
def GetData():
        $ComServer = null;
    #Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
    }
    lSQL = "SELECT A.ItemCode, A.Location, A.Batch,  MAX(B.Seq) AS Seq, 2 AS CostingMethod "
}
    lSQL = lSQL + "FROM ST_TR A INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) "
    lSQL = lSQL + "WHERE A.PostDate<='31 Jul 2020' "
    lSQL = lSQL + "GROUP BY A.ItemCode, A.Location, A.Batch "
   
     lDataSet1 = ComServer.DBManager.NewDataSet(lSQL)
 
     if lDataSet1.RecordCount > 0:
         lDataSet1.First()
         while not lDataSet1.eof:
            lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.UTDQty, B.UTDCost FROM ST_TR A "
            lSQL = lSQL + "INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) "
            lSQL = lSQL + "WHERE A.ITEMCODE= '" + lDataSet1.FindField("ItemCode").AsString + "' "
            lSQL = lSQL + "AND B.SEQ= " + lDataSet1.FindField("Seq").AsString
            lSQL = lSQL + " AND A.LOCATION='" + lDataSet1.FindField("Location").AsString + "' "
            lSQL = lSQL + " AND A.BATCH='" + lDataSet1.FindField("Batch").AsString + "' "
            lSQL = lSQL + "AND B.UTDQty<>0 "
            lSQL = lSQL + "ORDER BY A.ItemCode, A.Location, A.Batch "
           
            #print(lSQL)
            lDataSet2 = ComServer.DBManager.NewDataSet(lSQL)
            if lDataSet2.RecordCount > 0:
                lDataSet2.First()
                print("ITEMCODE = "+lDataSet2.FindField("ITEMCODE").AsString)
                print("LOCATION = "+lDataSet2.FindField("LOCATION").AsString)
                print("BATCH = "+lDataSet2.FindField("BATCH").AsString)
                print("UTDQTY = "+lDataSet2.FindField("UTDQTY").AsString)
                print("UTDCOST = "+lDataSet2.FindField("UTDCOST").AsString)
                print("=====")
            else :
                print ("Detail Record Not Found")
            lDataSet1.Next()
           
    else :
        print ("Record Not Found")
try:
    CheckLogin()
    print ("Month End - WA")
     GetData()
     print ("Done")
finally:
     ComServer.Logout()
    ComServer = None


?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Delete Agent"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Complete Post====
====Stock Month End - FIFO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_CS, AR_PM, SL_CN & AR_CN Script  
! Stock Month End - FIFO Script  
|-
|-
|  
|  
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="Python">
<!DOCTYPE html>
#Updated 15 Feb 2022
<html>
import win32com.client
<body>
import datetime


<h1>SQL Acc SDK in PHP page</h1>
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")


<?php
def CheckLogin():
echo "Updated 01 May 2020<br>";
    B = ComServer.IsLogin
#This will doing following posting
    if B == True:
#01. Cash Sales - SL_CS
        ComServer.Logout()
#02. Sales Credit Note - SL_CN
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
#03. Customer Payment With Knock off - AR_PM
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
#04. Edit Credit Note Posted in Step 02 & Knock Off - AR_CN
                    "ACC-0011.FDB") #Database Name
#05. Customer Refund to Knock off Credit Note - AR_CF
 
def GetData():
    #Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting       
 
    lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.QTY, B.COST FROM ST_TR A "
    lSQL = lSQL + "INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO) "
    lSQL = lSQL + "WHERE B.COSTTYPE='U' "
    lSQL = lSQL + "AND A.PostDate<='31 Jul 2022' "
    lSQL = lSQL + "AND A.ITEMCODE ='ANT' "
    lSQL = lSQL + "AND B.Qty<>0 "
    lSQL = lSQL + "AND EXISTS (SELECT MAX(D.Seq) FROM ST_TR C "
    lSQL = lSQL + "            INNER JOIN ST_TR_FIFO D ON (C.TRANSNO=D.TRANSNO) "
    lSQL = lSQL + "            WHERE C.PostDate<='31 Jul 2022' "
    lSQL = lSQL + "            AND C.ItemCode ='ANT' "
    lSQL = lSQL + "            GROUP BY C.ItemCode, C.Location, C.Batch "
    lSQL = lSQL + "            HAVING B.SEQ=MAX(D.Seq) "
    lSQL = lSQL + "            ) "
    lSQL = lSQL + "ORDER BY A.ItemCode, A.Location, A.BATCH, A.TRANSNO "
    print(lSQL)
    lDataSet2 = ComServer.DBManager.NewDataSet(lSQL)
           
    if lDataSet2.RecordCount > 0: #Total Qty & Cost
        lDataSet2.First()
        while not lDataSet2.eof:
            print(" ")
            print("TRANSNO = "+lDataSet2.FindField("TRANSNO").AsString)
            print("ITEMCODE = "+lDataSet2.FindField("ITEMCODE").AsString)
            print("LOCATION = "+lDataSet2.FindField("LOCATION").AsString)
            print("BATCH = "+lDataSet2.FindField("BATCH").AsString)
            print("QTY = "+lDataSet2.FindField("QTY").AsString)
            print("COST = "+lDataSet2.FindField("COST").AsString)
            print("=====")
            print(" ")
            print("===Detail Cost===")
            lSQL = "SELECT TRANSNO, ITEMCODE, COSTSEQ, QTY, COST FROM ST_TR_FIFO "
            lSQL = lSQL + "WHERE ITEMCODE = '" + lDataSet2.FindField("ITEMCODE").AsString
            lSQL = lSQL + "' AND COSTTYPE='B' "
            lSQL = lSQL + "AND TRANSNO="+lDataSet2.FindField("TRANSNO").AsString
            lSQL = lSQL + " ORDER BY COSTSEQ"
                   
            lDataSet3 = ComServer.DBManager.NewDataSet(lSQL)
 
            if lDataSet3.RecordCount > 0: #Detail Cost
                lDataSet3.First()
                while not lDataSet3.eof:
                    print("TRANSNO = "+lDataSet3.FindField("TRANSNO").AsString)
                    print("ITEMCODE = "+lDataSet3.FindField("ITEMCODE").AsString)
                    print("COSTSEQ = "+lDataSet3.FindField("COSTSEQ").AsString)
                    print("QTY = "+lDataSet3.FindField("QTY").AsString)
                    print("COST = "+lDataSet3.FindField("COST").AsString)
                    print("D=====")
                    lDataSet3.Next()
            lDataSet2.Next()
    else :
        print("Detail Record Not Found")
               
try:
    CheckLogin()
    print ("Month End - FIFO")
    GetData()
    print ("Done")
finally:
    #ComServer.Logout()
    ComServer = None
 
 
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Login 2 Database====
{| class="mw-collapsible mw-collapsed wikitable"
! Login 2 Database
|-
|
<syntaxhighlight lang="Python">
#Updated 17 Mar 2022
import win32com.client
import datetime
 
ComServer = win32com.client.Dispatch("SQLAcc.BizApp")


$ComServer = null;
def CheckLogin1():
    ComServer = None
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0024.FDB") #Database Name


function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


     if ($status == true)
def CheckLogin2():
     {
     ComServer = None
         $ComServer->Logout();
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    }
     B = ComServer.IsLogin
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
    if B == True:
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
         ComServer.Logout()
                      "ACC-0082.FDB"); #Database Name
     ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0015.FDB") #Database Name
       
def GetData():   
    lSQL = "SELECT COUNT(*) Nos FROM AR_CUSTOMER A WHERE A.CODE LIKE '%300%' "
      
      
}
    try:
        lDataSet1 = ComServer.DBManager.NewDataSet(lSQL)
        Seq = 0
        if lDataSet1.RecordCount > 0:
            lDataSet1.First()
            Seq = lDataSet1.FindField("Nos").Value
            print(Seq)
        else :
            print ("Record Not Found")
       
    finally:
        lDataSet1 = None


function PostDataCS(){
   
global $ComServer;
try:
     print ("Login 1st DB")
$BizObject = $ComServer->BizObjects->Find("SL_CS");
     CheckLogin1()
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
     GetData()
     $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
     print ("Done 1st DB")
     print ("Login 2nd DB")
     $BizObject->New();
     CheckLogin2()
     $lMain->FindField("DocKey")->value = -1;
     GetData()
     $lMain->FindField("DocNo")->AsString = "--CS Test--";
     print ("Done 2nd DB")  
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
finally:
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
     ComServer.Logout()
     $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
     ComServer = None
     $lMain->FindField("CompanyName")->AsString = "Cash Sales";
     print ("Done...")  
     $lMain->FindField("Address1")->AsString = ""; #Optional
</syntaxhighlight>
     $lMain->FindField("Address2")->AsString = ""; #Optional
|}
    $lMain->FindField("Address3")->AsString = ""; #Optional
<div style="float: right;">  [[#top|[top]]]</div>
    $lMain->FindField("Address4")->AsString = ""; #Optional
 
    $lMain->FindField("Phone1")->AsString = "";   #Optional
====Get Stock Qty Balance====
    $lMain->FindField("Description")->AsString = "Sales";
{| class="mw-collapsible mw-collapsed wikitable"
! Get Stock Qty Balance
    #Insert Data - Detail
|-
    #For Tax Inclusive = True with override Tax Amount
|
    $lDetail->Append();
<syntaxhighlight lang="Python">
    $lDetail->FindField("DtlKey")->value = -1;
#Updated 18 Jan 2024
    $lDetail->FindField("DocKey")->value = -1;
import Common
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
    $lDetail->FindField("Description")->AsString = "Sales Item A";
$txt = <<<EOT
          Item A Line 1
          Item A Line 2
          EOT;
    $lDetail->FindField("Description3")->AsString = $txt;
    $lDetail->FindField("Qty")->AsFloat = 1;
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 435;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
    $lDetail->FindField("TaxAmt")->AsFloat = 24.63;


    $lDetail->DisableControls();
def GetData():
     $lDetail->FindField("TaxInclusive")->value = 1;
     lSQL = "SELECT  ItemCode, Location, Batch, Sum(Qty) Qty  FROM ST_TR  "
    $lDetail->EnableControls();   
     lSQL = lSQL + "WHERE PostDate<='31 Dec 2019' "
    $lDetail->Post();
     lSQL = lSQL + "AND ITEMCODE ='ANT' "
     lSQL = lSQL + "GROUP BY ItemCode, Location, Batch "
     #For Tax Inclusive = False with override Tax Amount
      
    $lDetail->Append();
     lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    $lDetail->FindField("DtlKey")->value = -1;
      
    $lDetail->FindField("DocKey")->value = -1;
     if lDataSet.RecordCount > 0:
     $lDetail->FindField("Seq")->value = 2;
        while not lDataSet.eof:
    $lDetail->FindField("Account")->AsString = "500-000";
            print(lDataSet.FindField('ItemCode').AsString)
     $lDetail->FindField("Description")->AsString = "Sales Item B";
            print(lDataSet.FindField('Location').AsString)
     $lDetail->FindField("Qty")->AsFloat = 1;
            print(lDataSet.FindField('Batch').AsString)
     $lDetail->FindField("Tax")->AsString = "SV";
            print(lDataSet.FindField('Qty').AsString)
     $lDetail->FindField("TaxRate")->AsString = "6%";
            print("===")
     $lDetail->FindField("TaxInclusive")->value = 0;
            lDataSet.Next()
    $lDetail->FindField("UnitPrice")->AsFloat = 94.43;
     else:
    $lDetail->FindField("Amount")->AsFloat = 94.43;
        print ("Record Not Found")
    $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
      
    $lDetail->Post();
try:
     Common.CheckLogin()
    #For With Item Code
     global ComServer
    $lDetail->Append();
     ComServer = Common.ComServer     
    $lDetail->FindField("DtlKey")->value = -1;
     GetData()
    $lDetail->FindField("DocKey")->value = -1;
finally:
    $lDetail->FindField("Seq")->value = 3;
     ComServer = None
    $lDetail->FindField("ItemCode")->AsString = "ANT";
     Common.KillApp()
    $lDetail->FindField("Description")->AsString = "Sales Item B";
 
    #$lDetail->FindField("Account")->AsString = "500-000"; #If you wanted override the Sales Account Code
</syntaxhighlight>
    $lDetail->FindField("UOM")->AsString = "UNIT";
|}
     $lDetail->FindField("Qty")->AsFloat = 2;
<div style="float: right;">   [[#top|[top]]]</div>
     #$lDetail->FindField("DISC")->AsString = "5%+3"; #Optional(eg 5% plus 3 Discount)
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxInclusive")->value = 0;
     $lDetail->FindField("UnitPrice")->AsFloat = 100;
     $lDetail->FindField("Amount")->AsFloat = 200;
     $lDetail->FindField("TaxAmt")->AsFloat = 12;
    $lDetail->Post();
    $BizObject->Save();
    $BizObject->Close();
}


function PostDataPM(){
====Maintain Asset Item====
global $ComServer;
{| class="mw-collapsible mw-collapsed wikitable"
! Maintain Asset Item
    $BizObject = $ComServer->BizObjects->Find("AR_PM");
|-
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
|
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
<syntaxhighlight lang="Python">
#Updated 03 Oct 2023
    $BizObject->New();
import Common
     $lMain->FindField("DOCKEY")->Value = -1;
import datetime
     $lMain->FindField("DocNo")->AsString = "--PM Test--";
     
     $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
def GetListData():
     $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
     lSQL = "SELECT A.DOCNOEX, A.ACQUIREDATE, A.CODE, A.DESCRIPTION, A.ASSETGROUP, "
     $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
     lSQL = lSQL + "A.AGENT, A.AREA, A.COST, A.USEFULLIFE, A.DEPRRATE, A.RESIDUAL, "
     $lMain->FindField("Description")->AsString = "Payment for A/c";
    lSQL = lSQL + "B.POSTDATE, B.DESCRIPTION HISTORYDESC "
     $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
     lSQL = lSQL + "FROM FA_ITEM A "
    $lMain->FindField("ChequeNumber")->AsString = "";
     lSQL = lSQL + "INNER JOIN FA_ITEM_HISTORY B ON (A.Code=B.Code) "
     $lMain->FindField("BankCharge")->AsFloat = 0;
     lSQL = lSQL + "WHERE A.STATUS=1 " #1 = Active 2 = InActive   
     $lMain->FindField("DocAmt")->AsFloat = 200.00;
      
     $lMain->FindField("Cancelled")->AsString = "F";
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
       
     Common.ShowResult(lDataSet)
 
def GetAutoKey(ACode):
    lSQL = "SELECT AUTOKEY FROM FA_ITEM "
     lSQL = lSQL + "WHERE Code= ' + Common.QuotedStr(ACode)
      
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
     return lDataSet.FindField("AutoKey").AsFloat


     #Knock Off IV 
def PostData():
     $V = array("IV", "--CS Test--")#DocType, DocNo
    BizObject = ComServer.BizObjects.Find("FA.Item.OPF")
    lMain = BizObject.DataSets.Find("Main") #lMain contains master data
     lProj = BizObject.DataSets.Find("Project") #lProj contains Project data
     lDepr = BizObject.DataSets.Find("DeprSche") #lDepr contains Depreciation Scheduler data
    lHist = BizObject.DataSets.Find("History") #lHist contains History data
   
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
      
      
     if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
    lDocKey = GetAutoKey("--FA Test--")
         $lDetail->Edit();
       
         $lDetail->FindField("KOAmt")->AsFloat = 147.09; #Partial Knock off
     if lDocKey == 0:
         $lDetail->FindField("KnockOff")->AsString = "T";
        BizObject.New()
         $lDetail->Post();
        lMain.FindField("Code").AsString = "--FA Test--"
}
        lMain.FindField("Description").AsString = "5ft Banquet Table"
    $BizObject->Save();
        lMain.FindField("AcquireDate").value = lDate
    $BizObject->Close();
        lMain.FindField("AssetGroup").AsString = "Default"
}
        lMain.FindField("Cost").AsFloat = 6190.50
        lMain.FindField("UsefulLife").AsFloat = 3
        lMain.FindField("Residual").AsFloat = 1
        lMain.FindField("DocNoEx").AsString = "IV-321578"
        lMain.FindField("Qty").AsFloat = 100
 
        #Insert Data - Depreciation Schedule
        lDate = datetime.datetime(2024, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')
          
        lDepr.Append()
        lDepr.FindField("SCHEDATE").value      = lDate
         lDepr.FindField("Description").AsString = "Depreciation 1/3"
        lDepr.FindField("AMOUNT").AsFloat       = 2063.17
        lDepr.Post()
 
        lDate = datetime.datetime(2025, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')
       
        lDepr.Append()
        lDepr.FindField("SCHEDATE").value      = lDate
         lDepr.FindField("Description").AsString = "Depreciation 2/3"
        lDepr.FindField("AMOUNT").AsFloat      = 2063.17
         lDepr.Post()
 
        lDate = datetime.datetime(2026, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')
 
        lDepr.Append()
        lDepr.FindField("SCHEDATE").value      = lDate
        lDepr.FindField("Description").AsString = "Depreciation 3/3"
        lDepr.FindField("AMOUNT").AsFloat      = 2063.16
        lDepr.Post()       


function PostDataCN(){
        #Insert Data - Hisory 
global $ComServer;
        lDate = datetime.datetime(2023, 1, 20, 13, 0)
        lDate.strftime('%m/%d/%Y')
$BizObject = $ComServer->BizObjects->Find("SL_CN");
       
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
        lHist.Append()
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
        lHist.FindField("PostDate").value = lDate
        lHist.FindField("Description").AsString = "Supplier ABC 4 Units"
    $BizObject->New();
        lHist.Post()
    $lMain->FindField("DocKey")->value = -1;
       
    $lMain->FindField("DocNo")->AsString = "--CN Test--";
        lDate = datetime.datetime(2023, 2, 22, 13, 0)
    $lMain->FindField("DocDate")->value = "04/23/2020"; #MM/DD/YYYY
        lDate.strftime('%m/%d/%Y')
    $lMain->FindField("PostDate")->value = "04/23/2020"; #MM/DD/YYYY
       
    $lMain->FindField("Code")->AsString = "300-C0001";
        lHist.Append()
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
        lHist.FindField("PostDate").value = lDate
    $lMain->FindField("Address1")->AsString = "";
        lHist.FindField("Description").AsString = "Supplier XYZ Sdn Bhd 6 Units"
    $lMain->FindField("Address2")->AsString = "";
        lHist.Post()
    $lMain->FindField("Address3")->AsString = "";
       
    $lMain->FindField("Address4")->AsString = "";
        #Insert Data - Project
    $lMain->FindField("Phone1")->AsString = "";
        lProj.Edit()
    $lMain->FindField("Description")->AsString = "Sales Returned";
        lProj.FindField("Project").AsString = "KL"
        lProj.FindField("Rate").AsFloat = 40.00
    #For With Item Code
        lProj.Post()
    $lDetail->Append();
       
     $lDetail->FindField("DtlKey")->value = -1;
        lProj.Append()
    $lDetail->FindField("DocKey")->value = -1;
        lProj.FindField("Project").AsString = "JB"
    $lDetail->FindField("ItemCode")->AsString = "ANT";
        lProj.FindField("Rate").AsFloat = 60.00
    $lDetail->FindField("Description")->AsString = "Sales Item B";
        lProj.Post()          
    $lDetail->FindField("Description2")->AsString = "Product Spoil"; #Reason
     else:
    $lDetail->FindField("Remark1")->AsString = "--CS Test--";  #Invoice No
        BizObject.Params.Find("Autokey").AsString = lDocKey
    $lDetail->FindField("Remark2")->AsString = "20 Apr 2020";  #Invoice Date
        BizObject.Open()
    $lDetail->FindField("Qty")->AsFloat = 1;
        BizObject.Edit()
    $lDetail->FindField("Tax")->AsString = "SV";
        lMain.Edit()
    $lDetail->FindField("TaxRate")->AsString = "6%";
        lMain.FindField("Description").AsString = "Edited 5ft Banquet Tables"
    $lDetail->FindField("TaxInclusive")->value = 0;
 
    $lDetail->FindField("UnitPrice")->AsFloat = 100;
        #Delete all Project
    $lDetail->FindField("Amount")->AsFloat = 100;
        while lProj.RecordCount != 0:
    $lDetail->FindField("TaxAmt")->AsFloat = 6;
            lProj.First()
    $lDetail->Post();
            lProj.Delete()
           
    $BizObject->Save();
        lProj.Append()
    $BizObject->Close();
        lProj.FindField("Project").AsString = "----"
}
        lProj.FindField("Rate").AsFloat = 10.00
        lProj.Post()
       
        lProj.Append()
        lProj.FindField("Project").AsString = "KL"
        lProj.FindField("Rate").AsFloat = 40.00
        lProj.Post()


function PostKnockIVCN(){
        lProj.Append()
global $ComServer;
        lProj.FindField("Project").AsString = "JB"
        lProj.FindField("Rate").AsFloat = 50.00
    $BizObject = $ComServer->BizObjects->Find("AR_CN");
         lProj.Post()    
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff");
    #Find CN Number
    $lDocNo = "--CN Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
    $BizObject->Params->Find("DocKey")->AsString = $lDocKey;
if ($lDocKey != null){
        $BizObject->Open();
        $BizObject->Edit();
         $lMain->Edit();
          
          
         #Knock Off IV       
         #Insert Data - Hisory 
         $V = array("IV", "--CS Test--");  #DocType, DocNo
         lDate = datetime.datetime(2023, 2, 10, 13, 0)
        lDate.strftime('%m/%d/%Y')
          
          
         if ($lDetail->Locate("DocType;DocNo", $V, False, False)){
         lHist.Append()
            $lDetail->Edit();
        lHist.FindField("PostDate").value = lDate
            $lDetail->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
        lHist.FindField("Description").AsString = "1 of table leg broken"
            $lDetail->FindField("KnockOff")->AsString = "T";
        lHist.Post()      
            $lDetail->Post();
    try:
}
         BizObject.Save()        
         $BizObject->Save();
    except Exception as e:
         $BizObject->Close();
         print("Oops!", e)   
}
    BizObject.Close()
}
    print ("Posting/Update Done")


function PostDataCF(){
def DelData():
global $ComServer;
     BizObject = ComServer.BizObjects.Find("FA.Item.OPF")
      
     $BizObject = $ComServer->BizObjects->Find("AR_CF");
     lDocKey = GetAutoKey("--FA Test--")
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
       
     $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
     if lDocKey == 0:
        print ("Record Not Found")
    $BizObject->New();
     else:
    $lMain->FindField("DOCKEY")->Value = -1;
        BizObject.Params.Find("Autokey").AsString = lDocKey
    $lMain->FindField("DocNo")->AsString = "--CF Test--";
        BizObject.Open()
    $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
        BizObject.Delete()      
     $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
        print ("Deleting Done")
    $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Payment for A/c";
     $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
    $lMain->FindField("ChequeNumber")->AsString = "";
    $lMain->FindField("BankCharge")->AsFloat = 0;
    $lMain->FindField("DocAmt")->AsFloat = 6;
    $lMain->FindField("Cancelled")->AsString = "F";


     #Knock Off CN
try:
     $V = array("CN", "--CN Test--");  #DocType, DocNo
    Common.CheckLogin()
     global ComServer
     ComServer = Common.ComServer
    GetListData()
    PostData()
      
      
     if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
    answer = input("Continue To delete?")
         $lDetail->Edit();
     if answer.lower() in ["y","yes"]:
        $lDetail->FindField("KOAmt")->AsFloat = 4; #Partial Knock off
         DelData()
         $lDetail->FindField("KnockOff")->AsString = "T";
    elif answer.lower() in ["n","no"]:
        $lDetail->Post();
         print ("Deleting Aborted")
}
    else:
     $BizObject->Save();
      print ("Invalid Input")
    $BizObject->Close();
     
}
    ComServer.Logout()  
finally:
    ComServer = None
     Common.KillApp()
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>


if (isset($_POST['BtnData']))
====Customer Payment====
{
{| class="mw-collapsible mw-collapsed wikitable"
    try
! AR_PM
    {
|-
        CheckLogin();
|
        echo date("d M Y h:i:s A")." - Posting Cash Sales<br>";
<syntaxhighlight lang="Python">
        PostDataCS();
#Updated 04 Dec 2023
        echo date("d M Y h:i:s A")." - Posting Customer Payment<br>";
import Common
        PostDataPM();
import datetime
        echo date("d M Y h:i:s A")." - Posting Sales Credit Note<br>";
     
        PostDataCN();
def GetListData():
        echo date("d M Y h:i:s A")." - Posting Knock Off Sales Credit Note<br>";
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, B.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
        PostKnockIVCN();
    lSQL = lSQL + "A.AGENT, A.AREA, A.PAYMENTMETHOD "
        echo date("d M Y h:i:s A")." - Posting Customer Refund<br>";
    lSQL = lSQL + "FROM AR_PM A "
        PostDataCF();
    lSQL = lSQL + "INNER JOIN AR_CUSTOMER B ON (A.CODE=B.CODE) "
        echo date("d M Y h:i:s A")." - Posting Done";
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
     }
    lSQL = lSQL + "AND A.CANCELLED='F' "
     finally
      
    {
     lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        $ComServer->Logout();
          
         #free the object
     Common.ShowResult(lDataSet)
        $ComServer = null;
     }
}


?>
def PostData():
     <form method="post">         
     BizObject = ComServer.BizObjects.Find("AR_PM")
         <input type="submit" name="BtnData"
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
                value="Complete Post"/>
    lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
    </form>
   
</body>
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
</html>
    lDate.strftime('%m/%d/%Y')
</syntaxhighlight>
   
|}
    lDocKey = BizObject.FindKeyByRef("DocNo", "--PM Test--")
       
    if lDocKey is None:
        BizObject.New()
         lMain.FindField("DocNo").AsString = "--PM Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("Description").AsString = "Payment for A/c"
        lMain.FindField("PaymentMethod").AsString = "325-000" #Bank or Cash Account
        lMain.FindField("ChequeNumber").AsString = ""
        lMain.FindField("BankCharge").AsFloat = 0
        lMain.FindField("DocAmt").AsFloat = 10000.00
        lMain.FindField("Cancelled").AsString = "F"   


<div style="float: right;">  [[#top|[top]]]</div>
        #Knock Off IV 
        V = ["IV", "--IV Test--"]  #DocType, DocNo
        if (lDetail.Locate("DocType;DocNo", V, False, False)) :
            lDetail.Edit()
            lDetail.FindField("KOAmt").AsFloat = 147.09 #Partial Knock off
            lDetail.FindField("KnockOff").AsString = "T"
            lDetail.Post()
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Payment for A/c 的第一 🐱"


====Example-Get Invoice Next Number====
        #Knock Off IV 
{| class="mw-collapsible mw-collapsed wikitable"
        V = ["IV", "--IV Test--"]  #DocType, DocNo
! Get Invoice Next Number Script  
        if (lDetail.Locate("DocType;DocNo", V, False, False)) :
            lDetail.Edit()
            lDetail.FindField("KOAmt").AsFloat = 200.09 #Partial Knock off
            lDetail.FindField("KnockOff").AsString = "T"
            lDetail.Post()
       
    try:
        BizObject.Save()         
    except Exception as e:
        print("Oops!", e)   
    BizObject.Close()
    print ("Posting/Update Done")
 
def DelData():
    #Deleting only work if the record never not knock off by Refund
    BizObject = ComServer.BizObjects.Find("AR_PM")
   
    lDocKey = BizObject.FindKeyByRef("DocNo", "--PM Test--")
       
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()       
        print ("Deleting Done")
 
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
   
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
      print ("Invalid Input")
     
    ComServer.Logout() 
finally:
    ComServer = None
    Common.KillApp()
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<br>
 
===PHP===
* Tested PHP Version : 7.4.3/8.1.10
* Add this in ..\xampp\php\php.ini
<pre>
[PHP_COM_DOTNET]
extension=php_com_dotnet.dll
</pre>
 
* Grid.css file for example code
{| class="mw-collapsible mw-collapsed wikitable"
! Grid.css file
|-
|
<pre>
body
{
  margin: 10;
}
table {
  font-family: arial, sans-serif;
  border: 1px solid black;
  border-collapse: collapse;
  table-layout: auto;
}
 
td, th {
  border: 1px solid black;
  text-align: left;
  padding: 8px;
  white-space: nowrap;
}
 
tr:nth-child(even) {
  background-color: #dddddd;
}
</pre>
|}
 
====Get Agent====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Agent Script
|-
|-
|  
|  
Line 1,933: Line 2,739:
<?php
<?php
echo "Updated 01 May 2020<br>";
echo "Updated 01 May 2020<br>";
#This action to Get Next Number for Customer Invoice


$ComServer = null;
$ComServer = null;
Line 1,953: Line 2,758:
}
}


function GetData(){
function GetData()
global $ComServer;
{
    global $ComServer;
     $lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A
 
        INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY)
     $lSQL = "SELECT * FROM AGENT
WHERE A.DOCTYPE='IV'
        WHERE CODE='HALIM'";
AND A.DESCRIPTION='Customer Invoice'
 
AND A.STATESET=1
    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
";
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);


     if ($lDataSet->RecordCount > 0) {
     if ($lDataSet->RecordCount > 0)
$lDataSet->First();
    {
         $fmt = $lDataSet->FindField('Format')->AsString();
        echo "Result : ";
        $NextNo = $lDataSet->FindField('NEXTNUMBER')->AsFloat();
         echo $lDataSet->FindField('Description')->AsString() . "<br>";
    }
        echo date("d M Y h:i:s A")." Format in SQLAcc : " . str_ireplace("d","s", $fmt)."<br>";
    else
        $fmt= str_ireplace(".","'0", $fmt);
    {
        echo date("d M Y h:i:s A")." Format in PHP : " . str_ireplace("d","s", $fmt)."<br>";
        echo "Record Not Found";
echo date("d M Y h:i:s A")." Output in PHP : " .sprintf($fmt,$NextNo)."<br>";
}else {
    echo "Record Not Found";
     }
     }
}
}
Line 1,985: Line 2,784:
         CheckLogin();
         CheckLogin();
         GetData();
         GetData();
         echo date("d M Y h:i:s A")." - Done";
         echo date("d M Y h:i:s A") . " - Done";
     }
     }
     finally
     finally
Line 1,995: Line 2,794:
}
}


?>  
?>
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Get Doc Number"/>  
                 value="Get Agent"/>  
     </form>  
     </form>  
</body>
</body>
Line 2,007: Line 2,806:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add & Edit AR_Customer====
====Add & Edit Agent====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit AR_Customer Script  
! Add & Edit Agent Script
|-
|-
|  
|  
Line 2,020: Line 2,819:


<?php
<?php
echo "Updated 11 Jun 2020<br>";
echo "Updated 01 May 2020<br>";


$ComServer = null;
$ComServer = null;
Line 2,035: Line 2,834:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF", #DCF File
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF", #DCF file
                       "ACC-0035.FDB"); #Database Name
                       "ACC-0082.FDB"); #Database Name
      
      
}
}
Line 2,043: Line 2,842:
global $ComServer;
global $ComServer;
     $BizObject = $ComServer->BizObjects->Find("AR_Customer");
     $BizObject = $ComServer->BizObjects->Find("Agent");
     $lMain = $BizObject->DataSets->Find("MainDataSet");
     $lMain = $BizObject->DataSets->Find("MainDataSet");
$lDtl  = $BizObject->DataSets->Find("cdsBranch");
      
      
     $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
     $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
Line 2,052: Line 2,850:
         $BizObject->New();
         $BizObject->New();
         $lMain->FindField("CODE")->value = "FAIRY";
         $lMain->FindField("CODE")->value = "FAIRY";
         $lMain->FindField("CompanyName")->value = "FAIRY TAIL";
         $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL";
} else{
        $lDtl->Edit(); #For 1St Branch
         $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $lDtl->FindField("BranchName")->AsString  = "BILLING";
         $BizObject->Open();
        $lDtl->FindField("Address1")->AsString    = "Address1";
         $BizObject->Edit();
        $lDtl->FindField("Address2")->AsString    = "Address2";
         $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL WIZARD";
        $lDtl->FindField("Address3")->AsString    = "Address3";
        $lDtl->FindField("Address4")->AsString    = "Address4";
        $lDtl->FindField("Attention")->AsString  = "Attention";
        $lDtl->FindField("Phone1")->AsString      = "Phone1";
        $lDtl->FindField("Fax1")->AsString        = "Fax1";
        $lDtl->FindField("Email")->AsString      = "EmailAddress";
        $lDtl->Post();
 
        $lDtl->Append(); #For 2nd Branch
        $lDtl->FindField("BranchName")->AsString  = "Branch1";
        $lDtl->FindField("Address1")->AsString    = "DAddress1";
        $lDtl->FindField("Address2")->AsString    = "DAddress2";
        $lDtl->FindField("Address3")->AsString    = "DAddress3";
        $lDtl->FindField("Address4")->AsString    = "DAddress4"; 
        $lDtl->FindField("Attention")->AsString  = "DAttention"; 
        $lDtl->FindField("Phone1")->AsString      = "DPhone1";
        $lDtl->FindField("Fax1")->AsString        = "DFax1";
        $lDtl->FindField("Email")->AsString      = "DEmailAddress";
        $lDtl->Post();
} else{
         $BizObject->Params->Find("CODE")->Value = $lDocKey;
         $BizObject->Open();
         $BizObject->Edit();
         $lMain->FindField("CompanyName")->value = "FAIRY TAIL WIZARD";
$r = $lDtl->RecordCount();
$x = 1;
while ($x <= $r ){
$lDtl->First();
            $lDtl->Delete();
$x++;
}
        #Insert back with new Information
        $lDtl->Edit(); #For 1St Branch
        $lDtl->FindField("BranchName")->AsString  = "BILLING"; #Make sure this always same as b4 delete data
        $lDtl->FindField("Address1")->AsString    = "New Address1";
        $lDtl->FindField("Address2")->AsString    = "New Address2";
        $lDtl->FindField("Address3")->AsString    = "New Address3";
        $lDtl->FindField("Address4")->AsString    = "New Address4"; 
        $lDtl->FindField("Attention")->AsString  = "New Attention"; 
        $lDtl->FindField("Phone1")->AsString      = "New Phone1";
        $lDtl->FindField("Fax1")->AsString        = "New Fax1";
        $lDtl->FindField("Email")->AsString      = "New EmailAddress";
        $lDtl->Post();
 
        $lDtl->Append(); #For 2nd Branch
        $lDtl->FindField("BranchName")->AsString  = "Branch1"; #Make sure this always same as b4 delete data
        $lDtl->FindField("Address1")->AsString    = "New DAddress1";
        $lDtl->FindField("Address2")->AsString    = "New DAddress2";
        $lDtl->FindField("Address3")->AsString    = "New DAddress3";
        $lDtl->FindField("Address4")->AsString    = "New DAddress4";
        $lDtl->FindField("Attention")->AsString  = "New DAttention"; 
        $lDtl->FindField("Phone1")->AsString      = "New DPhone1";
        $lDtl->FindField("Fax1")->AsString        = "New DFax1";
        $lDtl->FindField("Email")->AsString      = "New DEmailAddress";
        $lDtl->Post();
}
}
try{
try{
Line 2,145: Line 2,885:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Add/Edit AR Customer"/>  
                 value="Add/Edit Agent"/>  
     </form>  
     </form>  
</body>
</body>
</html>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
====Example-Get Stock List====
 
====Delete Agent====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Stock List Script  
! Delete Agent Script
|-
|-
|  
|  
Line 2,161: Line 2,902:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>
<body>


Line 2,169: Line 2,907:


<?php
<?php
echo "Updated 22 Jun 2020<br>";
echo "Updated 01 May 2020<br>";
#This action to Get Stock Item List


$ComServer = null;
$ComServer = null;
Line 2,185: Line 2,922:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                       "ACC-0024.FDB"); #Database Name
                       "ACC-0082.FDB"); #Database Name
      
      
}
}


function GetData(){
function PostData(){
global $ComServer;
global $ComServer;
     $lSQL = "SELECT A.*, B.UOM, B.RATE, B.REFCOST, B.REFPRICE, B.ISBASE FROM ST_ITEM A
     $BizObject = $ComServer->BizObjects->Find("Agent");
        INNER JOIN ST_ITEM_UOM B ON (A.CODE=B.CODE)  
    $lMain = $BizObject->DataSets->Find("MainDataSet");
WHERE A.ISACTIVE='T'
   
";
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
if ($lDocKey == null){
        echo "Record Not Found";
} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Delete();
        echo "Delete Done<br>";
}
}


    if ($lDataSet->RecordCount > 0) {
if (isset($_POST['BtnData']))
$lDataSet->First();
{
$fc = $lDataSet->Fields->Count-1;
     try
echo "<table>";
     {
echo "<tr>";
         CheckLogin();
for ($x = 0; $x <= $fc; $x++) {
         PostData();
#Insert Header
         echo date("d M Y h:i:s A") . " - Done";
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";
     }
}
     finally
echo "</tr>";
     {
         $ComServer->Logout();
#Looping Dataset
         #free the object
while (! $lDataSet->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}
 
if (isset($_POST['BtnData']))
{
     try
     {
         CheckLogin();
         GetData();
         echo date("d M Y h:i:s A")." - Done";
     }
     finally
     {
         $ComServer->Logout();
         #free the object
         $ComServer = null;
         $ComServer = null;
     }
     }
}
}


?>  
?>
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Get Stock list"/>  
                 value="Delete Agent"/>  
     </form>  
     </form>  
</body>
</body>
Line 2,252: Line 2,970:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_IV====
====Complete Post====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_IV Script  
! SL_CS, AR_PM, SL_CN & AR_CN Script  
|-
|-
|  
|  
Line 2,262: Line 2,981:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>
<body>


Line 2,270: Line 2,986:


<?php
<?php
echo "Updated 24 Jun 2020<br>";
echo "Updated 01 May 2020<br>";
#This action to Post Customer Invoice
#This will doing following posting
#01. Cash Sales - SL_CS
#02. Sales Credit Note - SL_CN
#03. Customer Payment With Knock off - AR_PM
#04. Edit Credit Note Posted in Step 02 & Knock Off - AR_CN
#05. Customer Refund to Knock off Credit Note - AR_CF


$ComServer = null;
$ComServer = null;
Line 2,286: Line 3,007:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                       "ACC-0070.FDB"); #Database Name
                       "ACC-0082.FDB"); #Database Name
      
      
}
}


function PostData(){
function PostDataCS(){
global $ComServer;
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("AR_IV");
$BizObject = $ComServer->BizObjects->Find("SL_CS");
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
     $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
     $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
Line 2,300: Line 3,021:
     $BizObject->New();
     $BizObject->New();
     $lMain->FindField("DocKey")->value = -1;
     $lMain->FindField("DocKey")->value = -1;
     $lMain->FindField("DocNo")->AsString = "--IV Test--";
     $lMain->FindField("DocNo")->AsString = "--CS Test--";
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
     $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
     $lMain->FindField("Description")->AsString = "Sales";
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
    $lMain->FindField("Address1")->AsString = ""; #Optional
    $lMain->FindField("Address2")->AsString = ""; #Optional
    $lMain->FindField("Address3")->AsString = ""; #Optional
    $lMain->FindField("Address4")->AsString = ""; #Optional
    $lMain->FindField("Phone1")->AsString = "";  #Optional
     $lMain->FindField("Description")->AsString = "Sales";
     #Insert Data - Detail
     #Insert Data - Detail
     #For Tax Inclusive = True with override Tax Amount
     #For Tax Inclusive = True with override Tax Amount
Line 2,314: Line 3,041:
     $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
     $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
     $lDetail->FindField("Description")->AsString = "Sales Item A";
     $lDetail->FindField("Description")->AsString = "Sales Item A";
$txt = <<<EOT
          Item A Line 1
          Item A Line 2
          EOT;
    $lDetail->FindField("Description3")->AsString = $txt;
    $lDetail->FindField("Qty")->AsFloat = 1;
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxInclusive")->value = 0;
     $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 435;
     $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
     $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
     $lDetail->FindField("TaxAmt")->AsFloat = 24.63;
     $lDetail->FindField("TaxAmt")->AsFloat = 24.63;
Line 2,332: Line 3,068:
     $lDetail->FindField("Account")->AsString = "500-000";
     $lDetail->FindField("Account")->AsString = "500-000";
     $lDetail->FindField("Description")->AsString = "Sales Item B";
     $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 1;
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxInclusive")->value = 0;
     $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 94.43;
     $lDetail->FindField("Amount")->AsFloat = 94.43;
     $lDetail->FindField("Amount")->AsFloat = 94.43;
     $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
     $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
    $lDetail->Post();
    #For With Item Code
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 3;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    #$lDetail->FindField("Account")->AsString = "500-000"; #If you wanted override the Sales Account Code
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->FindField("Qty")->AsFloat = 2;
    #$lDetail->FindField("DISC")->AsString = "5%+3"; #Optional(eg 5% plus 3 Discount)
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 100;
    $lDetail->FindField("Amount")->AsFloat = 200;
    $lDetail->FindField("TaxAmt")->AsFloat = 12;
     $lDetail->Post();
     $lDetail->Post();
Line 2,343: Line 3,100:
}
}


if (isset($_POST['BtnData']))
function PostDataPM(){
{
global $ComServer;
     try
     {
    $BizObject = $ComServer->BizObjects->Find("AR_PM");
        CheckLogin();
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
PostData();
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
        echo date("d M Y h:i:s A")." - Done";
     }
    $BizObject->New();
     finally
     $lMain->FindField("DOCKEY")->Value = -1;
     {
     $lMain->FindField("DocNo")->AsString = "--PM Test--";
         $ComServer->Logout();
    $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
         #free the object
    $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
         $ComServer = null;
    $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
     }
    $lMain->FindField("Description")->AsString = "Payment for A/c";
    $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
    $lMain->FindField("ChequeNumber")->AsString = "";
    $lMain->FindField("BankCharge")->AsFloat = 0;
    $lMain->FindField("DocAmt")->AsFloat = 200.00;
    $lMain->FindField("Cancelled")->AsString = "F";
 
     #Knock Off IV 
    $V = array("IV", "--CS Test--");  #DocType, DocNo
      
     if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
         $lDetail->Edit();
         $lDetail->FindField("KOAmt")->AsFloat = 147.09; #Partial Knock off
         $lDetail->FindField("KnockOff")->AsString = "T";
        $lDetail->Post();
}
    $BizObject->Save();
     $BizObject->Close();
}
}


?>  
function PostDataCN(){
     <form method="post">          
global $ComServer;
        <input type="submit" name="BtnData"
                value="Post Customer Invoice"/>
$BizObject = $ComServer->BizObjects->Find("SL_CN");
     </form>  
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
</body>
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
</html>
</syntaxhighlight>
    $BizObject->New();
|}
    $lMain->FindField("DocKey")->value = -1;
<div style="float: right;">  [[#top|[top]]]</div>
    $lMain->FindField("DocNo")->AsString = "--CN Test--";
 
    $lMain->FindField("DocDate")->value = "04/23/2020"; #MM/DD/YYYY
====Example-Get Outstanding Invoice List====
     $lMain->FindField("PostDate")->value = "04/23/2020"; #MM/DD/YYYY
{| class="mw-collapsible mw-collapsed wikitable"
    $lMain->FindField("Code")->AsString = "300-C0001";
! Get Outstanding Invoice List Script
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
|-
    $lMain->FindField("Address1")->AsString = "";
|
    $lMain->FindField("Address2")->AsString = "";
<syntaxhighlight lang="PHP">
    $lMain->FindField("Address3")->AsString = "";
<!DOCTYPE html>
    $lMain->FindField("Address4")->AsString = "";
<html>
    $lMain->FindField("Phone1")->AsString = "";
<head>
    $lMain->FindField("Description")->AsString = "Sales Returned";
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
    #For With Item Code
<body>
    $lDetail->Append();
 
    $lDetail->FindField("DtlKey")->value = -1;
<h1>SQL Acc SDK in PHP page</h1>
    $lDetail->FindField("DocKey")->value = -1;
 
    $lDetail->FindField("ItemCode")->AsString = "ANT";
<?php
     $lDetail->FindField("Description")->AsString = "Sales Item B";
echo "Updated 24 Jun 2020<br>";
     $lDetail->FindField("Description2")->AsString = "Product Spoil"; #Reason
#This action to Get Outstanding Invoice List
    $lDetail->FindField("Remark1")->AsString = "--CS Test--";   #Invoice No
 
     $lDetail->FindField("Remark2")->AsString = "20 Apr 2020";  #Invoice Date
$ComServer = null;
    $lDetail->FindField("Qty")->AsFloat = 1;
 
     $lDetail->FindField("Tax")->AsString = "SV";
function CheckLogin()
     $lDetail->FindField("TaxRate")->AsString = "6%";
{
     $lDetail->FindField("TaxInclusive")->value = 0;
     global $ComServer;
     $lDetail->FindField("UnitPrice")->AsFloat = 100;
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $lDetail->FindField("Amount")->AsFloat = 100;
     $status = $ComServer->IsLogin();
    $lDetail->FindField("TaxAmt")->AsFloat = 6;
 
    $lDetail->Post();
     if ($status == true)
     {
    $BizObject->Save();
        $ComServer->Logout();
     $BizObject->Close();
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
      
}
}


function GetData(){
function PostKnockIVCN(){
global $ComServer;
global $ComServer;
     $lSQL = "SELECT A.*, B.COMPANYNAME, (A.DOCAMT-A.PAYMENTAMT) OUTSTANDING  FROM AR_IV A
     $BizObject = $ComServer->BizObjects->Find("AR_CN");
        INNER JOIN AR_CUSTOMER B ON (A.CODE=B.CODE)  
    $lMain = $BizObject->DataSets->Find("MainDataSet");
WHERE (A.DOCAMT-A.PAYMENTAMT)<>0
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff");
AND CANCELLED='F'
";
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
    #Find CN Number
 
    $lDocNo = "--CN Test--";
    if ($lDataSet->RecordCount > 0) {
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
$lDataSet->First();
    $BizObject->Params->Find("DocKey")->AsString = $lDocKey;
$fc = $lDataSet->Fields->Count-1;
echo "<table>";
if ($lDocKey != null){
echo "<tr>";
        $BizObject->Open();
for ($x = 0; $x <= $fc; $x++) {
        $BizObject->Edit();
#Insert Header
        $lMain->Edit();
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";  
       
        #Knock Off IV       
        $V = array("IV", "--CS Test--"); #DocType, DocNo
       
        if ($lDetail->Locate("DocType;DocNo", $V, False, False)){
            $lDetail->Edit();
            $lDetail->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
            $lDetail->FindField("KnockOff")->AsString = "T";
            $lDetail->Post();
}
}
echo "</tr>";
        $BizObject->Save();
        $BizObject->Close();
#Looping Dataset
}
while (! $lDataSet->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}
}


if (isset($_POST['BtnData']))
function PostDataCF(){
{
global $ComServer;
     try
     {
    $BizObject = $ComServer->BizObjects->Find("AR_CF");
         CheckLogin();
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
         GetData();
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
         echo date("d M Y h:i:s A")." - Done";
     }
    $BizObject->New();
     finally
    $lMain->FindField("DOCKEY")->Value = -1;
     {
    $lMain->FindField("DocNo")->AsString = "--CF Test--";
    $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Payment for A/c";
    $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
    $lMain->FindField("ChequeNumber")->AsString = "";
    $lMain->FindField("BankCharge")->AsFloat = 0;
    $lMain->FindField("DocAmt")->AsFloat = 6;
    $lMain->FindField("Cancelled")->AsString = "F";
 
    #Knock Off CN
    $V = array("CN", "--CN Test--");  #DocType, DocNo
   
    if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
        $lDetail->Edit();
        $lDetail->FindField("KOAmt")->AsFloat = 4; #Partial Knock off
        $lDetail->FindField("KnockOff")->AsString = "T";
        $lDetail->Post();
}
    $BizObject->Save();
    $BizObject->Close();
}
 
if (isset($_POST['BtnData']))
{
     try
     {
         CheckLogin();
         echo date("d M Y h:i:s A")." - Posting Cash Sales<br>";
        PostDataCS();
        echo date("d M Y h:i:s A")." - Posting Customer Payment<br>";
        PostDataPM();
        echo date("d M Y h:i:s A")." - Posting Sales Credit Note<br>";
        PostDataCN();
        echo date("d M Y h:i:s A")." - Posting Knock Off Sales Credit Note<br>";
        PostKnockIVCN();
        echo date("d M Y h:i:s A")." - Posting Customer Refund<br>";
        PostDataCF();
         echo date("d M Y h:i:s A")." - Posting Done";
     }
     finally
     {
         $ComServer->Logout();
         $ComServer->Logout();
         #free the object
         #free the object
Line 2,464: Line 3,268:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Get Outstanding Invoice List"/>  
                 value="Complete Post"/>  
     </form>  
     </form>  
</body>
</body>
Line 2,470: Line 3,274:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Stock Month End - Weighted Average====
====Get Invoice Next Number====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Stock Month End - Weighted Average Script  
! Get Invoice Next Number Script  
|-
|-
|  
|  
Line 2,480: Line 3,285:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>
<body>


Line 2,488: Line 3,290:


<?php
<?php
echo "Updated 16 Jul 2020<br>";
echo "Updated 01 May 2020<br>";
#This action to Get Outstanding Invoice List
#This action to Get Next Number for Customer Invoice


$ComServer = null;
$ComServer = null;
Line 2,504: Line 3,306:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                       "ACC-0024.FDB"); #Database Name
                       "ACC-0082.FDB"); #Database Name
      
      
}
}


function GetData(){
function GetData(){
#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
global $ComServer;
global $ComServer;
     $lSQL = "SELECT A.ItemCode, A.Location, A.Batch,  MAX(B.Seq) AS Seq, 2 AS CostingMethod
     $lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A  
        FROM ST_TR A INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO)  
        INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY)
WHERE A.PostDate<='31 Jul 2020'
WHERE A.DOCTYPE='IV'
GROUP BY A.ItemCode, A.Location, A.Batch
AND A.DESCRIPTION='Customer Invoice'
AND A.STATESET=1
";
";
$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
$Seq = "";
$lDataSet1->First();
while (! $lDataSet1->Eof()){
$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
$lDataSet1->Next();
}


    $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.UTDQty, B.UTDCost FROM ST_TR A
     if ($lDataSet->RecordCount > 0) {
        INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO)
$lDataSet->First();
WHERE A.PostDate<='31 Jul 2020'
        $fmt = $lDataSet->FindField('Format')->AsString();
AND B.SEQ IN (".substr_replace($Seq ,"",-1).")
        $NextNo = $lDataSet->FindField('NEXTNUMBER')->AsFloat();
AND B.UTDQty<>0
ORDER BY A.ItemCode, A.Location, A.Batch
";
$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);
     if ($lDataSet2->RecordCount > 0) {
$lDataSet2->First();
$fc = $lDataSet2->Fields->Count-1;
echo "<table>";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
#Insert Header
echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>";
}
echo "</tr>";
#Looping Dataset
        echo date("d M Y h:i:s A")." Format in SQLAcc : " . str_ireplace("d","s", $fmt)."<br>";
while (! $lDataSet2->Eof()){
        $fmt= str_ireplace(".","'0", $fmt);
echo "<tr>";
        echo date("d M Y h:i:s A")." Format in PHP : " . str_ireplace("d","s", $fmt)."<br>";
    for ($x = 0; $x <= $fc; $x++) {
echo date("d M Y h:i:s A")." Output in PHP : " .sprintf($fmt,$NextNo)."<br>";
$lFN = $lDataSet2->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>";  
    }
    echo "</tr>";
$lDataSet2->Next();
}
echo "</table>"."<br>";
}else {
}else {
     echo "Record Not Found";
     echo "Record Not Found";
Line 2,584: Line 3,356:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Month End - WA"/>  
                 value="Get Doc Number"/>  
     </form>  
     </form>  
</body>
</body>
Line 2,590: Line 3,362:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Stock Month End - FIFO====
====Add & Edit AR_Customer====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Stock Month End - FIFO Script  
! Add & Edit AR_Customer Script  
|-
|-
|  
|  
Line 2,600: Line 3,373:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<body>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>


<h1>SQL Acc SDK in PHP page</h1>
<h1>SQL Acc SDK in PHP page</h1>


<?php
<?php
echo "Updated 16 Jul 2020<br>";
echo "Updated 11 Jun 2020<br>";
#This action to Get Outstanding Invoice List


$ComServer = null;
$ComServer = null;
Line 2,624: Line 3,393:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\eStream\SQLAccounting\Share\Default.DCF", #DCF file
                       "C:\\eStream\\SQLAccounting\\Share\\Default.DCF", #DCF File
                       "ACC-0024.FDB"); #Database Name
                       "ACC-0035.FDB"); #Database Name
      
      
}
}


function GetData(){
function PostData(){
#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
global $ComServer;
global $ComServer;
     $lSQL = "SELECT  A.ItemCode, A.Location, A.Batch, MAX(B.Seq) AS Seq, 1 AS CostingMethod
     $BizObject = $ComServer->BizObjects->Find("AR_Customer");
        FROM ST_TR A INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO)  
    $lMain = $BizObject->DataSets->Find("MainDataSet");
WHERE A.PostDate<='31 Jul 2020'
$lDtl  = $BizObject->DataSets->Find("cdsBranch");
AND A.ItemCode IN ('ANT', 'COVER', 'BOM')
   
GROUP BY A.ItemCode, A.Location, A.Batch
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
";
$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
if ($lDocKey == null){
        $BizObject->New();
$Seq = "";
        $lMain->FindField("CODE")->value = "FAIRY";
$lDataSet1->First();
        $lMain->FindField("CompanyName")->value = "FAIRY TAIL";
while (! $lDataSet1->Eof()){
$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
        $lDtl->Edit(); #For 1St Branch
$lDataSet1->Next();
        $lDtl->FindField("BranchName")->AsString  = "BILLING";
}
        $lDtl->FindField("Address1")->AsString    = "Address1";
        $lDtl->FindField("Address2")->AsString    = "Address2";
        $lDtl->FindField("Address3")->AsString    = "Address3";
        $lDtl->FindField("Address4")->AsString    = "Address4";
        $lDtl->FindField("Attention")->AsString  = "Attention";
        $lDtl->FindField("Phone1")->AsString      = "Phone1";
        $lDtl->FindField("Fax1")->AsString       = "Fax1";
        $lDtl->FindField("Email")->AsString      = "EmailAddress";
        $lDtl->Post();


    $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.QTY, B.COST FROM ST_TR A
        $lDtl->Append(); #For 2nd Branch
        INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO)  
        $lDtl->FindField("BranchName")->AsString  = "Branch1";
WHERE B.COSTTYPE='U'
        $lDtl->FindField("Address1")->AsString    = "DAddress1";
AND A.PostDate<='31 Jul 2020'
        $lDtl->FindField("Address2")->AsString    = "DAddress2";
AND B.SEQ IN (".substr_replace($Seq ,"",-1).")
        $lDtl->FindField("Address3")->AsString    = "DAddress3";
AND A.ItemCode IN ('ANT1.0', 'COVER', 'BOM')
        $lDtl->FindField("Address4")->AsString    = "DAddress4"; 
AND B.Qty<>0
        $lDtl->FindField("Attention")->AsString  = "DAttention"
ORDER BY A.ItemCode, A.Location, A.Batch
        $lDtl->FindField("Phone1")->AsString      = "DPhone1";
";
        $lDtl->FindField("Fax1")->AsString        = "DFax1";
        $lDtl->FindField("Email")->AsString      = "DEmailAddress";
$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);
        $lDtl->Post();
} else{
    if ($lDataSet2->RecordCount > 0) {
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
$lDataSet2->First();
        $BizObject->Open();
$fc = $lDataSet2->Fields->Count-1;
        $BizObject->Edit();
echo "<table>";
        $lMain->FindField("CompanyName")->value = "FAIRY TAIL WIZARD";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
$r = $lDtl->RecordCount();
#Insert Header
$x = 1;
echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>";  
while ($x <= $r ){
$lDtl->First();
            $lDtl->Delete();
$x++;
}
}
echo "</tr>";
#Looping Dataset
        #Insert back with new Information
while (! $lDataSet2->Eof()){
        $lDtl->Edit(); #For 1St Branch
echo "<tr>";
        $lDtl->FindField("BranchName")->AsString  = "BILLING"; #Make sure this always same as b4 delete data
    for ($x = 0; $x <= $fc; $x++) {
        $lDtl->FindField("Address1")->AsString    = "New Address1";
$lFN = $lDataSet2->Fields->Items($x)->FieldName();
        $lDtl->FindField("Address2")->AsString    = "New Address2";
    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>";  
        $lDtl->FindField("Address3")->AsString    = "New Address3";
    }
        $lDtl->FindField("Address4")->AsString    = "New Address4"; 
    echo "</tr>";
        $lDtl->FindField("Attention")->AsString  = "New Attention";
$lDataSet2->Next();
        $lDtl->FindField("Phone1")->AsString      = "New Phone1";
}
        $lDtl->FindField("Fax1")->AsString       = "New Fax1";
echo "</table>"."<br>";
        $lDtl->FindField("Email")->AsString      = "New EmailAddress";
}else {
        $lDtl->Post();
    echo "Record Not Found";
 
    }
        $lDtl->Append(); #For 2nd Branch
        $lDtl->FindField("BranchName")->AsString  = "Branch1"; #Make sure this always same as b4 delete data
#FIFO Detail Key to link with $lDataSet2 & $lDataSet3 is TRANSNO
        $lDtl->FindField("Address1")->AsString    = "New DAddress1";
$Seq = "";
        $lDtl->FindField("Address2")->AsString    = "New DAddress2";
$lDataSet2->First();
        $lDtl->FindField("Address3")->AsString    = "New DAddress3";
while (! $lDataSet2->Eof()){
        $lDtl->FindField("Address4")->AsString    = "New DAddress4";  
$Seq = $Seq.$lDataSet2->FindField("TRANSNO")->AsString .",";
        $lDtl->FindField("Attention")->AsString  = "New DAttention";
$lDataSet2->Next();
        $lDtl->FindField("Phone1")->AsString      = "New DPhone1";
        $lDtl->FindField("Fax1")->AsString        = "New DFax1";
        $lDtl->FindField("Email")->AsString       = "New DEmailAddress";
        $lDtl->Post();
}
}
 
try{
    $lSQL = "SELECT  TransNo, Cost, SUM(Qty) AS Qty, MIN(CostSeq) AS Seq FROM ST_TR_FIFO
$BizObject->Save();
        WHERE CostType='B'
echo "Posting Done <br>";
AND TRANSNO IN (".substr_replace($Seq ,"",-1).")
}catch (Exception $e) {
GROUP BY TransNo, Cost
    echo 'Caught exception: ',  $e->getMessage(), "\n";
";
}
$lDataSet3 = $ComServer->DBManager->NewDataSet($lSQL);
 
    if ($lDataSet3->RecordCount > 0) {
$lDataSet3->First();
$fc = $lDataSet3->Fields->Count-1;
echo "<table>";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
#Insert Header
echo "<td>".$lDataSet3->Fields->Items($x)->FieldName()."</td>";
}
echo "</tr>";
#Looping Dataset
while (! $lDataSet3->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet3->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet3->FindField($lFN)->AsString()."</td>";  
    }
    echo "</tr>";
$lDataSet3->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}
}


Line 2,735: Line 3,489:
     {
     {
         CheckLogin();
         CheckLogin();
         GetData();
         PostData();
         echo date("d M Y h:i:s A")." - Done";
         echo date("d M Y h:i:s A") . " - Done";
     }
     }
     finally
     finally
     {
     {
         #$ComServer->Logout();
         $ComServer->Logout();
         #free the object
         #free the object
         $ComServer = null;
         $ComServer = null;
Line 2,746: Line 3,500:
}
}


?>  
?>
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Month End - FIFO"/>  
                 value="Add/Edit AR Customer"/>  
     </form>  
     </form>  
</body>
</body>
</html>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Stock List====
====Example-Add & Edit Stock Item====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add & Edit Stock Item Script  
! Get Stock List Script  
|-
|-
|  
|  
Line 2,765: Line 3,519:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>
<body>


Line 2,770: Line 3,527:


<?php
<?php
echo "Updated 05 Aug 2020<br>";
echo "Updated 22 Jun 2020<br>";
#This action to Get Stock Item List
 
$ComServer = null;
$ComServer = null;


Line 2,789: Line 3,548:
}
}


function PostData(){
function GetData(){
global $ComServer;
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("ST_ITEM");
    $lSQL = "SELECT A.*, B.UOM, B.RATE, B.REFCOST, B.REFPRICE, B.ISBASE FROM ST_ITEM A
    $lMain = $BizObject->DataSets->Find("MainDataSet");
        INNER JOIN ST_ITEM_UOM B ON (A.CODE=B.CODE)  
    $lUOM  = $BizObject->DataSets->Find("cdsUOM");
WHERE A.ISACTIVE='T'
$lBarcode = $BizObject->DataSets->Find("cdsBarcode");  
";
$lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY-PHP");
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);


if ($lDocKey == null){
    if ($lDataSet->RecordCount > 0) {
        $BizObject->New();
$lDataSet->First();
        $lMain->FindField("CODE")->AsString = "FAIRY-PHP";
$fc = $lDataSet->Fields->Count-1;
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL";
echo "<table>";
        $lMain->FindField("STOCKGROUP")->AsString = "DEFAULT";
echo "<tr>";
        $lMain->FindField("STOCKCONTROL")->AsString = "T";
for ($x = 0; $x <= $fc; $x++) {
        $lMain->FindField("ISACTIVE")->AsString = "T";
#Insert Header
 
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";  
        $lUOM->Edit(); #For 1St UOM
}
        $lUOM->FindField("UOM")->AsString = "PCS";
echo "</tr>";
        $lUOM->FindField("Rate")->AsFloat = 1;
        $lUOM->FindField("RefCost")->AsFloat = 10.2;
#Looping Dataset
        $lUOM->FindField("RefPrice")->AsFloat = 25;
while (! $lDataSet->Eof()){
        $lUOM->Post();
echo "<tr>";
 
    for ($x = 0; $x <= $fc; $x++) {
         $lUOM->Append(); #For 2nd UOM
$lFN = $lDataSet->Fields->Items($x)->FieldName();
         $lUOM->FindField("UOM")->AsString = "CTN";
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";
         $lUOM->FindField("Rate")->AsFloat = 12;
    }
         $lUOM->FindField("RefCost")->AsFloat = 102;
    echo "</tr>";
         $lUOM->FindField("RefPrice")->AsFloat = 240;
$lDataSet->Next();
        $lUOM->Post();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}
 
if (isset($_POST['BtnData']))
{
    try
    {
         CheckLogin();
         GetData();
         echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
         $ComServer->Logout();
        #free the object
         $ComServer = null;
    }
}


        $lBarcode->Append(); #For 1st UOM Barcode
?>  
        $lBarcode->FindField("BARCODE")->AsString = "123456789";
    <form method="post">          
$lBarcode->FindField("UOM")->AsString = "PCS";
        <input type="submit" name="BtnData"
        $lBarcode->Post();
                value="Get Stock list"/>  
    </form>  
        $lBarcode->Append(); #For 2nd UOM Barcode
</body>
        $lBarcode->FindField("BARCODE")->AsString = "987654321";
</html>
$lBarcode->FindField("UOM")->AsString = "CTN";
</syntaxhighlight>
        $lBarcode->Post();
|}
} else{
<div style="float: right;">   [[#top|[top]]]</div>
        $BizObject->Params->Find("Dockey")->AsString = $lDocKey;
 
        $BizObject->Open();
====AR_IV====
        $BizObject->Edit();
{| class="mw-collapsible mw-collapsed wikitable"
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL WIZARD";
! AR_IV Script
|-
$r = $lUOM->RecordCount();
|
$x = 1;
<syntaxhighlight lang="PHP">
while ($x <= $r ){
<!DOCTYPE html>
$lUOM->First();
<html>
            $lUOM->Delete();
<head>
$x++;
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
}
</head>
<body>
$r = $lBarcode->RecordCount();
$x = 1;
while ($x <= $r ){
$lBarcode->First();
            $lBarcode->Delete();
$x++;
}
        $lUOM->Append(); #For 1St UOM
        $lUOM->FindField("UOM")->AsString = "PCS"; #Make sure this always same as b4 delete data
        $lUOM->FindField("Rate")->AsFloat = 1; #Make sure this always same as b4 delete data
        $lUOM->FindField("RefCost")->AsFloat = 22.3;
        $lUOM->FindField("RefPrice")->AsFloat = 52;
        $lUOM->Post();


        $lUOM->Append(); #For 2nd UOM
<h1>SQL Acc SDK in PHP page</h1>
        $lUOM->FindField("UOM")->AsString = "CTN"; #Make sure this always same as b4 delete data
        $lUOM->FindField("Rate")->AsFloat = 12; #Make sure this always same as b4 delete data
        $lUOM->FindField("RefCost")->AsFloat = 102.5;
        $lUOM->FindField("RefPrice")->AsFloat = 260.45;
        $lUOM->Post();
        $lBarcode->Append(); #For 1st UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "456321789";
$lBarcode->FindField("UOM")->AsString = "PCS";
        $lBarcode->Post();
        $lBarcode->Append(); #For 2nd UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "321456987";
$lBarcode->FindField("UOM")->AsString = "CTN";
        $lBarcode->Post();
}
try{
        $BizObject->Save();
        $BizObject->Close();
}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}


<?php
echo "Updated 24 Jun 2020<br>";
#This action to Post Customer Invoice


if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting Stock Item<br>";
        PostData();
echo date("d M Y h:i:s A")." - Done<br>";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Add & Edit Stock Item"/>
    </form>
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
====Example-Add Stock Issue====
{| class="mw-collapsible mw-collapsed wikitable"
! Add Stock Issue Script
|-
|
<syntaxhighlight lang="PHP">
<!DOCTYPE html>
<html>
<body>
<h1>SQL Acc SDK in PHP page</h1>
<?php
echo "Updated 21 Oct 2020<br>";
$ComServer = null;
$ComServer = null;


Line 2,941: Line 3,644:
     }
     }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "ACC-0024.FDB"); #Database Name
                       "ACC-0070.FDB"); #Database Name
   
}
 
function CheckLogin1()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
      
      
}
}
Line 2,956: Line 3,652:
global $ComServer;
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("ST_IS");
$BizObject = $ComServer->BizObjects->Find("AR_IV");
     $lMain = $BizObject->DataSets->Find("MainDataSet");  
     $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
     $lDetail = $BizObject->DataSets->Find("cdsDocDetail");  
     $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
     $BizObject->New();
     $BizObject->New();
     $lMain->FindField("DocKey")->value = -1;
     $lMain->FindField("DocKey")->value = -1;
     $lMain->FindField("DocNo")->AsString = "--IS Test--";
     $lMain->FindField("DocNo")->AsString = "--IV Test--";
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("Description")->AsString = "Stock Issue";
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
     $lMain->FindField("Description")->AsString = "Sales";
     #Insert Data - Detail
     #Insert Data - Detail
    #For Tax Inclusive = True with override Tax Amount
     $lDetail->Append();
     $lDetail->Append();
     $lDetail->FindField("DtlKey")->value = -1;
     $lDetail->FindField("DtlKey")->value = -1;
     $lDetail->FindField("DocKey")->value = -1;
     $lDetail->FindField("DocKey")->value = -1;
     $lDetail->FindField("Seq")->value = 1;
     $lDetail->FindField("Seq")->value = 1;
     $lDetail->FindField("ItemCode")->AsString = "ANT";
     $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
     $lDetail->FindField("Description")->AsString = "Sales Item B";
     $lDetail->FindField("Description")->AsString = "Sales Item A";
     $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("UOM")->AsString = "BOX";
    $lDetail->FindField("TaxRate")->AsString = "6%";
     $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
     $lDetail->FindField("TaxAmt")->AsFloat = 24.63;
 
    $lDetail->DisableControls();
    $lDetail->FindField("TaxInclusive")->value = 1;
    $lDetail->EnableControls();  
     $lDetail->Post();
     $lDetail->Post();
 
    #For Tax Inclusive = False with override Tax Amount
     $lDetail->Append();
     $lDetail->Append();
     $lDetail->FindField("DtlKey")->value = -1;
     $lDetail->FindField("DtlKey")->value = -1;
     $lDetail->FindField("DocKey")->value = -1;
     $lDetail->FindField("DocKey")->value = -1;
     $lDetail->FindField("Seq")->value = 2;
     $lDetail->FindField("Seq")->value = 2;
     $lDetail->FindField("ItemCode")->AsString = "N-CHARGER";
     $lDetail->FindField("Account")->AsString = "500-000";
     $lDetail->FindField("Description")->AsString = "NOKIA CHARGER";
     $lDetail->FindField("Description")->AsString = "Sales Item B";
     $lDetail->FindField("Qty")->AsFloat = 5;
     $lDetail->FindField("Tax")->AsString = "SV";
     $lDetail->FindField("UOM")->AsString = "UNIT";
     $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 94.43;
    $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
     $lDetail->Post();
     $lDetail->Post();
     $BizObject->Save();
     $BizObject->Save();
     $BizObject->Close();
     $BizObject->Close();
try{
        $BizObject->Save();
        $BizObject->Close();
}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}
}


if (isset($_POST['BtnData']))
if (isset($_POST['BtnData']))
Line 3,004: Line 3,705:
     try
     try
     {
     {
         CheckLogin1();
         CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
PostData();
         PostData();
         echo date("d M Y h:i:s A")." - Done";
echo date("d M Y h:i:s A")." - Done<br>";
     }
     }
     finally
     finally
Line 3,020: Line 3,720:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Add Stock Issue"/>  
                 value="Post Customer Invoice"/>  
     </form>  
     </form>  
</body>
</body>
Line 3,028: Line 3,728:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Add Points====
====Get Outstanding Invoice List====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Add Points Script  
! Get Outstanding Invoice List Script  
|-
|-
|  
|  
Line 3,036: Line 3,736:
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>
<body>


Line 3,041: Line 3,744:


<?php
<?php
echo "Updated 30 Oct 2020<br>";
echo "Updated 24 Jun 2020<br>";
#This action to Get Outstanding Invoice List
 
$ComServer = null;
$ComServer = null;


Line 3,060: Line 3,765:
}
}


function PostData(){
function GetData(){
global $ComServer;
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("Sales.Points.OPF");
    $lSQL = "SELECT A.*, B.COMPANYNAME, (A.DOCAMT-A.PAYMENTAMT) OUTSTANDING  FROM AR_IV A
    $lMain = $BizObject->DataSets->Find("Main"); #lMain contains master data
        INNER JOIN AR_CUSTOMER B ON (A.CODE=B.CODE)  
WHERE (A.DOCAMT-A.PAYMENTAMT)<>0
AND CANCELLED='F'
";
    $BizObject->New();
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
     $lMain->FindField("DocKey")->value = -1;
 
    $lMain->FindField("DocNo")->AsString = "--Point Test--";
     if ($lDataSet->RecordCount > 0) {
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
$lDataSet->First();
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
$fc = $lDataSet->Fields->Count-1;
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
echo "<table>";
$lMain->FindField("DESCRIPTION")->AsString = "Points Earn";
echo "<tr>";
    $lMain->FindField("FromDocType")->AsString = "CS";
for ($x = 0; $x <= $fc; $x++) {
$lMain->FindField("FromDocNo")->AsString = "CS-01234";
#Insert Header
$lMain->FindField("FROMDOCAMT")->AsFloat = 100.10;
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";  
$lMain->FindField("Points")->AsFloat = 10;
}
echo "</tr>";
try{
$BizObject->Save();
#Looping Dataset
}catch (Exception $e) {
while (! $lDataSet->Eof()){
echo 'Caught exception: ',  $e->getMessage(), "\n";
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";  
    }
    echo "</tr>";
$lDataSet->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
     }
     }
}
}


if (isset($_POST['BtnData']))
if (isset($_POST['BtnData']))
Line 3,091: Line 3,808:
     {
     {
         CheckLogin();
         CheckLogin();
         echo date("d M Y h:i:s A")." - Posting Point<br>";
        GetData();
        PostData();
         echo date("d M Y h:i:s A")." - Done";
     }
     }
     finally
     finally
Line 3,105: Line 3,822:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Post Point"/>  
                 value="Get Outstanding Invoice List"/>  
     </form>  
     </form>  
</body>
</body>
Line 3,113: Line 3,830:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_CN====
====Stock Month End - Weighted Average====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_CN Script  
! Stock Month End - Weighted Average Script  
|-
|-
|  
|  
Line 3,129: Line 3,846:


<?php
<?php
echo "Updated 12 Dec 2020<br>";
echo "Updated 01 Dec 2021<br>";
#This action to Post Customer Credit Note
 


$ComServer = null;
$ComServer = null;
Line 3,146: Line 3,863:
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                       "ACC-0040.FDB"); #Database Name
                       "ACC-0024.FDB"); #Database Name
      
      
}
}


function PostData(){
function GetData(){
#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
global $ComServer;
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("AR_CN");
    $lSQL = "SELECT A.ItemCode, A.Location, A.Batch,  MAX(B.Seq) AS Seq, 2 AS CostingMethod
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
        FROM ST_TR A INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO)  
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
WHERE A.PostDate<='31 Jul 2020'
$lKO = $BizObject->DataSets->Find("cdsKnockOff");
AND A.ITEMCODE='Adj_Voucher'
GROUP BY A.ItemCode, A.Location, A.Batch
";
    $BizObject->New();
$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--CN Test1--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("Description")->AsString = "Sales";
    #Insert Data - Detail
$Seq = "";
    #For Tax Inclusive = True with override Tax Amount
$lDataSet1->First();
    $lDetail->Append();
while (! $lDataSet1->Eof()){
    $lDetail->FindField("DtlKey")->value = -1;
$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
    $lDetail->FindField("DocKey")->value = -1;
$lDataSet1->Next();
    $lDetail->FindField("Seq")->value = 1;
}
    $lDetail->FindField("Account")->AsString = "510-000"; #Sales Return Account
    $lDetail->FindField("Description")->AsString = "Return Item A";
    $lDetail->FindField("Tax")->AsString = "";
    $lDetail->FindField("TaxRate")->AsString = "";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
    $lDetail->FindField("TaxAmt")->AsFloat = 0;
$lDetail->Post();


     $V = array("IV", "IV-00003"); #DocType, DocNo
     $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.UTDQty, B.UTDCost FROM ST_TR A
       
        INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO)
     if ($lKO->Locate("DocType;DocNo", $V, False, False)){
WHERE A.PostDate<='31 Jul 2020'
        $lKO->Edit();
AND A.ITEMCODE='Adj_Voucher'
        $lKO->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
AND B.SEQ IN (".substr_replace($Seq ,"",-1).")
        $lKO->FindField("KnockOff")->AsString = "T";
AND B.UTDQty<>0
        $lKO->Post();
ORDER BY A.ItemCode, A.Location, A.Batch
}
";
     $BizObject->Save();
     $BizObject->Close();
$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);
     if ($lDataSet2->RecordCount > 0) {
$lDataSet2->First();
$fc = $lDataSet2->Fields->Count-1;
echo "<table>";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
#Insert Header
echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>";
}
echo "</tr>";
#Looping Dataset
while (! $lDataSet2->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet2->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet2->Next();
}
echo "</table>"."<br>";
}else {
     echo "Record Not Found";
     }
}
}


Line 3,198: Line 3,930:
     {
     {
         CheckLogin();
         CheckLogin();
PostData();
        GetData();
         echo date("d M Y h:i:s A")." - Done";
         echo date("d M Y h:i:s A")." - Done";
     }
     }
Line 3,212: Line 3,944:
     <form method="post">           
     <form method="post">           
         <input type="submit" name="BtnData"
         <input type="submit" name="BtnData"
                 value="Post Customer Credit Note"/>  
                 value="Month End - WA"/>  
     </form>  
     </form>  
</body>
</body>
Line 3,220: Line 3,952:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-SO to DO====
====Stock Month End - FIFO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SO to DO Script  
! Stock Month End - FIFO Script  
|-
|-
|  
|  
<syntaxhighlight lang="PHP">
<syntaxhighlight lang="PHP">
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>


</syntaxhighlight>
<h1>SQL Acc SDK in PHP page</h1>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
<?php
<br>
echo "Updated 16 Jul 2020<br>";
#This action to Get Outstanding Invoice List
 
$ComServer = null;


===VB Script===
function CheckLogin()
====Example-Get Company Profile====
{
{| class="mw-collapsible mw-collapsed wikitable"
    global $ComServer;
! Company Profile Script 
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
|-
    $status = $ComServer->IsLogin();
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
Call GetCoInfo
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetCoInfo
Dim ComServer, RptObject, lDataSet
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO")
  'Step 3: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsProfile")


  MsgBox "Count " & lDataSet.RecordCount
    if ($status == true)
    {
  'Step 5 Retrieve the output
        $ComServer->Logout();
  lDataSet.First
    }
  While (not lDataSet.eof)
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
MsgBox "Company Name : " & lDataSet.FindField("CompanyName").AsString
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
MsgBox "Remark : " & lDataSet.FindField("Remark").AsString
   
}


MsgBox "ROC No : " & lDataSet.FindField("RegisterNo").AsString
function GetData(){
 
#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
MsgBox "GST No : " & lDataSet.FindField("GSTNo").AsString
global $ComServer;
MsgBox "Address 1 : " & lDataSet.FindField("Address1").AsString
    $lSQL = "SELECT  A.ItemCode, A.Location, A.Batch, MAX(B.Seq) AS Seq, 1 AS CostingMethod
        FROM ST_TR A INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO)
WHERE A.PostDate<='31 Jul 2020'
AND A.ItemCode IN ('ANT', 'COVER', 'BOM')
GROUP BY A.ItemCode, A.Location, A.Batch
";
MsgBox "Address 2 : " & lDataSet.FindField("Address2").AsString
$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
MsgBox "Address 3 : " & lDataSet.FindField("Address3").AsString
$Seq = "";
$lDataSet1->First();
MsgBox "Address 4 : " & lDataSet.FindField("Address4").AsString
while (! $lDataSet1->Eof()){
$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
MsgBox "Attention : " & lDataSet.FindField("Attention").AsString
$lDataSet1->Next();
}
 
    $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.QTY, B.COST FROM ST_TR A
        INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO)
WHERE B.COSTTYPE='U'
AND A.PostDate<='31 Jul 2020'
AND B.SEQ IN (".substr_replace($Seq ,"",-1).")
AND A.ItemCode IN ('ANT1.0', 'COVER', 'BOM')
AND B.Qty<>0
ORDER BY A.ItemCode, A.Location, A.Batch
";
$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);
    if ($lDataSet2->RecordCount > 0) {
$lDataSet2->First();
$fc = $lDataSet2->Fields->Count-1;
echo "<table>";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
#Insert Header
echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>";
}
echo "</tr>";
#Looping Dataset
while (! $lDataSet2->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet2->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet2->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
MsgBox "Phone : " & lDataSet.FindField("Phone1").AsString
#FIFO Detail Key to link with $lDataSet2 & $lDataSet3 is TRANSNO
$Seq = "";
MsgBox "Fax : " & lDataSet.FindField("Fax1").AsString
$lDataSet2->First();
while (! $lDataSet2->Eof()){
MsgBox "E-Mail : " & lDataSet.FindField("EMail").AsString
$Seq = $Seq.$lDataSet2->FindField("TRANSNO")->AsString .",";
lDataSet.Next
$lDataSet2->Next();
  Wend
}


  'Step 6 : Logout after done 
    $lSQL = "SELECT  TransNo, Cost, SUM(Qty) AS Qty, MIN(CostSeq) AS Seq FROM ST_TR_FIFO
  ComServer.Logout   
        WHERE CostType='B'
End Function
AND TRANSNO IN (".substr_replace($Seq ,"",-1).")
GROUP BY TransNo, Cost
";
$lDataSet3 = $ComServer->DBManager->NewDataSet($lSQL);
 
    if ($lDataSet3->RecordCount > 0) {
$lDataSet3->First();
$fc = $lDataSet3->Fields->Count-1;
echo "<table>";
echo "<tr>";
for ($x = 0; $x <= $fc; $x++) {
#Insert Header
echo "<td>".$lDataSet3->Fields->Items($x)->FieldName()."</td>";
}
echo "</tr>";
#Looping Dataset
while (! $lDataSet3->Eof()){
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet3->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet3->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet3->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}
 
if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        #$ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Month End - FIFO"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Complete Post====
====Add & Edit Stock Item====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_CS, AR_PM, SL_CN & AR_CN Script
! Add & Edit Stock Item Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Updated 13 Sep 2018
<!DOCTYPE html>
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
<html>
'This will doing following posting
<body>
'01. Cash Sales
'02. Sales Credit Note
'03. Customer Payment With Knock off
'04. Edit Credit Note Posted in Step 02 & Knock Off
Call CheckLogin
Call InsertData


Dim ComServer
<h1>SQL Acc SDK in PHP page</h1>


Function CreateSQLAccServer
<?php
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
echo "Updated 05 Aug 2020<br>";
End Function
$ComServer = null;


function CheckLogin
function CheckLogin()
  'Step 1: Create Com Server object
{
  Set ComServer = CreateSQLAccServer 'Create Com Server
    global $ComServer;
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    $status = $ComServer->IsLogin();
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


Function InsertData
    if ($status == true)
Dim BizObject, lMain, lDetail, lDate
    {
  'Step 2: Find and Create the Biz Objects
        $ComServer->Logout();
  Set BizObject = ComServer.BizObjects.Find("SL_CS")  
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
   
}


  'Step 3: Set Dataset
function PostData(){
  Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
global $ComServer;
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
$BizObject = $ComServer->BizObjects->Find("ST_ITEM");
  'Begin Looping yr data
    $lMain = $BizObject->DataSets->Find("MainDataSet");
  'Step 4 : Insert Data - Master
     $lUOM  = $BizObject->DataSets->Find("cdsUOM");
  lDate = CDate("January 1, 2017")
$lBarcode = $BizObject->DataSets->Find("cdsBarcode");
  BizObject.New
  lMain.FindField("DocKey").value        = -1
$lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY-PHP");
  lMain.FindField("DocNo").AsString      = "--IV Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Sales"
      
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 1
  lDetail.FindField("Account").AsString    = "500-000" 'Sales Account
  lDetail.FindField("Description").AsString = "Sales Item A"
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 435
  lDetail.FindField("Amount").AsFloat      = 410.37 'Exclding GST Amt
  lDetail.FindField("TaxAmt").AsFloat      = 24.63
 
  lDetail.DisableControls
  lDetail.FindField("TaxInclusive").value  = 1
  lDetail.EnableControls
 
  lDetail.Post
 
  'For Tax Inclusive = False with override Tax Amount
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("Account").AsString    = "500-000"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 94.43
  lDetail.FindField("Amount").AsFloat      = 94.43
  lDetail.FindField("TaxAmt").AsFloat      = 5.66
  lDetail.Post


  'For With Item Code
if ($lDocKey == null){
  lDetail.Append
         $BizObject->New();
  lDetail.FindField("DtlKey").value         = -1
         $lMain->FindField("CODE")->AsString = "FAIRY-PHP";
  lDetail.FindField("DocKey").value         = -1
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL";
  lDetail.FindField("Seq").value            = 3
        $lMain->FindField("STOCKGROUP")->AsString = "DEFAULT";
  lDetail.FindField("ItemCode").AsString   = "ANT"
         $lMain->FindField("STOCKCONTROL")->AsString = "T";
  lDetail.FindField("Description").AsString = "Sales Item B"
         $lMain->FindField("ISACTIVE")->AsString = "T";
  'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString         = "UNIT"
  'lDetail.FindField("DISC").AsString       = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100 
  lDetail.FindField("Amount").AsFloat      = 200
  lDetail.FindField("TaxAmt").AsFloat      = 12
  lDetail.Post


  'Step 6: Save Document
        $lUOM->Edit(); #For 1St UOM
  BizObject.Save
        $lUOM->FindField("UOM")->AsString = "PCS";
  BizObject.Close
        $lUOM->FindField("Rate")->AsFloat = 1;
 
        $lUOM->FindField("RefCost")->AsFloat = 10.2;
  'Step 7: Payment
        $lUOM->FindField("RefPrice")->AsFloat = 25;
  Call InsertARPM
        $lUOM->Post();
 
  'Step 8: Credit Note
  Call InsertSLCN
  'End Looping yr data


  'Step 9 : Logout after done 
        $lUOM->Append(); #For 2nd UOM
  'ComServer.Logout
        $lUOM->FindField("UOM")->AsString = "CTN";
 
        $lUOM->FindField("Rate")->AsFloat = 12;
  MsgBox "Done"
        $lUOM->FindField("RefCost")->AsFloat = 102;
End Function
        $lUOM->FindField("RefPrice")->AsFloat = 240;
        $lUOM->Post();


Function InsertARPM
        $lBarcode->Append(); #For 1st UOM Barcode
Dim BizObject, lMain, lDetail, lDate, v(1)
        $lBarcode->FindField("BARCODE")->AsString = "123456789";
  'Step 2: Find and Create the Biz Objects
$lBarcode->FindField("UOM")->AsString = "PCS";
  Set BizObject = ComServer.BizObjects.Find("AR_PM")  
        $lBarcode->Post();
  'Step 3: Set Dataset
        $lBarcode->Append(); #For 2nd UOM Barcode
  Set lMain = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
        $lBarcode->FindField("BARCODE")->AsString = "987654321";
  Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains detail data 
$lBarcode->FindField("UOM")->AsString = "CTN";
 
        $lBarcode->Post();
  'Step 4 : Posting
} else{
    lDate = CDate("January 23, 2017")
        $BizObject->Params->Find("Dockey")->AsString = $lDocKey;
    BizObject.New
        $BizObject->Open();
    lMain.FindField("DOCKEY").Value          = -1
         $BizObject->Edit();
    lMain.FindField("DocNo").AsString         = "--PM Test--"  
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL WIZARD";
    lMain.FindField("CODE").AsString         = "300-C0001" 'Customer Account
    lMain.FindField("DocDate").Value          = lDate
$r = $lUOM->RecordCount();
    lMain.FindField("PostDate").Value         = lDate
$x = 1;
    lMain.FindField("Description").AsString   = "Payment for A/c"
while ($x <= $r ){
    lMain.FindField("PaymentMethod").AsString = "320-000" 'Bank or Cash Account
$lUOM->First();
lMain.FindField("ChequeNumber").AsString  = ""
            $lUOM->Delete();
lMain.FindField("BankCharge").AsFloat    = 0
$x++;
    lMain.FindField("DocAmt").AsFloat         = 200.00
}
    lMain.FindField("Cancelled").AsString     = "F"
  'Step 5: Knock Off IV
$r = $lBarcode->RecordCount();
    lIVNO = "--IV Test--"
$x = 1;
    v(0) = "IV"
while ($x <= $r ){
    v(1) = lIVNO
$lBarcode->First();
            $lBarcode->Delete();
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
$x++;
      lDetail.Edit
}
      lDetail.FindField("KOAmt").AsFloat     = 147.09 'Partial Knock off
      lDetail.FindField("KnockOff").AsString = "T"
         $lUOM->Append(); #For 1St UOM
      lDetail.Post
        $lUOM->FindField("UOM")->AsString = "PCS"; #Make sure this always same as b4 delete data
End IF 
        $lUOM->FindField("Rate")->AsFloat = 1; #Make sure this always same as b4 delete data
  'Step 6: Save Document
        $lUOM->FindField("RefCost")->AsFloat = 22.3;
    BizObject.Save
        $lUOM->FindField("RefPrice")->AsFloat = 52;
    BizObject.Close
        $lUOM->Post();
End Function


Function InsertSLCN
        $lUOM->Append(); #For 2nd UOM
Dim BizObject, lMain, lDetail, lDate
        $lUOM->FindField("UOM")->AsString = "CTN"; #Make sure this always same as b4 delete data
  'Step 2: Find and Create the Biz Objects
        $lUOM->FindField("Rate")->AsFloat = 12; #Make sure this always same as b4 delete data
  Set BizObject = ComServer.BizObjects.Find("SL_CN")  
        $lUOM->FindField("RefCost")->AsFloat = 102.5;
        $lUOM->FindField("RefPrice")->AsFloat = 260.45;
        $lUOM->Post();
        $lBarcode->Append(); #For 1st UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "456321789";
$lBarcode->FindField("UOM")->AsString = "PCS";
        $lBarcode->Post();
        $lBarcode->Append(); #For 2nd UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "321456987";
$lBarcode->FindField("UOM")->AsString = "CTN";
        $lBarcode->Post();
}
try{
        $BizObject->Save();
        $BizObject->Close();
}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}


  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
  'Step 4 : Insert Data - Master
  lDate = CDate("January 24, 2017")
  BizObject.New
  lMain.FindField("DocKey").value        = -1
  lMain.FindField("DocNo").AsString      = "--CN Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Code").AsString        = "300-C0001"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = ""
  lMain.FindField("Address2").AsString    = ""
  lMain.FindField("Address3").AsString    = ""
  lMain.FindField("Address4").AsString    = ""
  lMain.FindField("Phone1").AsString      = "" 
  lMain.FindField("Description").AsString = "Sales Returned"
   
  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value          = -1
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString  = "Sales Item B"
  lDetail.FindField("Description2").AsString = "Product Spoil" 'Reason
  lDetail.FindField("Remark1").AsString      = "--IV Test--"  'Invoice No
  lDetail.FindField("Remark2").AsString      = "01 Jan 2017"  'Invoice Date
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString          = "SR"
  lDetail.FindField("TaxRate").AsString      = "6%"
  lDetail.FindField("TaxInclusive").value    = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100
  lDetail.FindField("Amount").AsFloat        = 100
  lDetail.FindField("TaxAmt").AsFloat        = 6 
  lDetail.Post


  'Step 6: Save Document
if (isset($_POST['BtnData']))
  BizObject.Save
{
  BizObject.Close
    try
 
    {
  'Step 7: Knock Off Invoice
        CheckLogin();
   Call KnockIV
        echo date("d M Y h:i:s A")." - Begin Posting Stock Item<br>";
End Function
        PostData();
echo date("d M Y h:i:s A")." - Done<br>";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Add & Edit Stock Item"/>
    </form>
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">   [[#top|[top]]]</div>


Function KnockIV
====Add Stock Issue====
Dim BizObject, lMain, lDetail, lDate, v(1)
{| class="mw-collapsible mw-collapsed wikitable"
  'Step 2: Find and Create the Biz Objects
! Add Stock Issue Script
  Set BizObject = ComServer.BizObjects.Find("AR_CN")
|-
|
  'Step 3: Set Dataset
<syntaxhighlight lang="PHP">
  Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
<!DOCTYPE html>
  Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains Knock off data 
<html>
 
<body>
  'Step 4 : Find CN Number
  lDocNo = "--CN Test--"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey
 
  If not IsNull(lDocKey) Then
    BizObject.Open
    BizObject.Edit
    lMain.Edit
  'Step 5: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("KOAmt").AsFloat    = 106 'Fully Knock off
      lDetail.FindField("KnockOff").AsString = "T"
      lDetail.Post
End IF   
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
  END IF
End Function
</syntaxhighlight>
|}


<div style="float: right;">   [[#top|[top]]]</div>
<h1>SQL Acc SDK in PHP page</h1>


====Example-AR_IV====
<?php
{| class="mw-collapsible mw-collapsed wikitable"
echo "Updated 21 Oct 2020<br>";
! AR_IV Script 
$ComServer = null;
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call InsertARIV


Function CreateSQLAccServer
function CheckLogin()
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
{
End Function
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


Function InsertARIV
    if ($status == true)
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
   
}


  'Step 1: Create Com Server object
function CheckLogin1()
  Set ComServer = CreateSQLAccServer 'Create Com Server
{
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    global $ComServer;
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  END IF
   
}


  'Step 2: Find and Create the Biz Objects
function PostData(){
  Set BizObject = ComServer.BizObjects.Find("AR_IV")  
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("ST_IS");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail");
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--IS Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Issue";
    #Insert Data - Detail
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("UOM")->AsString = "BOX";
    $lDetail->Post();


  'Step 3: Set Dataset
    $lDetail->Append();
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
    $lDetail->FindField("DtlKey")->value = -1;
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
    $lDetail->FindField("DocKey")->value = -1;
 
    $lDetail->FindField("Seq")->value = 2;
  'Step 4 : Insert Data - Master
    $lDetail->FindField("ItemCode")->AsString = "N-CHARGER";
  lDate = CDate("January 1, 2016")
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER";
  BizObject.New
     $lDetail->FindField("Qty")->AsFloat = 5;
  lMainDataSet.FindField("DocKey").value = -1
    $lDetail->FindField("UOM")->AsString = "UNIT";
  lMainDataSet.FindField("DocNo").value = "--IV Test--"
    $lDetail->Post();
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
    $BizObject->Save();
  lMainDataSet.FindField("Code").value = "300-A0003"
    $BizObject->Close();
  lMainDataSet.FindField("Description").value = "Sales"
      
try{
  'Step 5: Insert Data - Detail
        $BizObject->Save();
  'For Tax Inclusive = True with override Tax Amount
        $BizObject->Close();
  lDetailDataSet.Append
}catch (Exception $e) {
  lDetailDataSet.FindField("DtlKey").value = -1
    echo 'Caught exception: ', $e->getMessage(), "\n";
  lDetailDataSet.FindField("DocKey").value = -1
    }
  lDetailDataSet.FindField("Account").value = "500-000"
}
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
 
  lDetailDataSet.FindField("Tax").value =  "SR"
 
  lDetailDataSet.FindField("TaxInclusive").value =  0
if (isset($_POST['BtnData']))
  lDetailDataSet.FindField("Amount").value = 410.37
{
  lDetailDataSet.FindField("TaxAmt").value = 24.63
    try
 
    {
  lDetailDataSet.DisableControls
        CheckLogin1();
  lDetailDataSet.FindField("TaxInclusive").value = 1
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
  lDetailDataSet.EnableControls
        PostData();
 
echo date("d M Y h:i:s A")." - Done<br>";
  lDetailDataSet.FindField("Changed").value = "F"
    }
  lDetailDataSet.Post
    finally
 
    {
  'For Tax Inclusive = False with override Tax Amount
        $ComServer->Logout();
  lDetailDataSet.Append
        #free the object
  lDetailDataSet.FindField("DtlKey").value = -1
        $ComServer = null;
  lDetailDataSet.FindField("DocKey").value = -1
    }
  lDetailDataSet.FindField("Account").value = "500-000"
}
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post


  'Step 6: Save Document
?>
  BizObject.Save
    <form method="post">         
  BizObject.Close
        <input type="submit" name="BtnData"
  MsgBox "Done"
                value="Add Stock Issue"/>
End Function
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_IV-Edit====
====Add Points====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_IV Edit Script
! Add Points Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Available in Version 5.2018.833.759 & above
<!DOCTYPE html>
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
<html>
Call CheckLogin
<body>
Call GetData
Call PostData


Dim ComServer, lDataSet
<h1>SQL Acc SDK in PHP page</h1>


Function CreateSQLAccServer
<?php
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
echo "Updated 30 Oct 2020<br>";
End Function
$ComServer = null;


function CheckLogin
function CheckLogin()
  'Step 1: Create Com Server object
{
  Set ComServer = CreateSQLAccServer 'Create Com Server
    global $ComServer;
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    $status = $ComServer->IsLogin();
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


Function GetData
    if ($status == true)
Dim lSQL
    {
  lSQL = "SELECT Dockey FROM AR_IV "
        $ComServer->Logout();
  lSQL = lSQL & "WHERE DocNo='IV-00002' "
    }
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
End Function
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
   
}


Function PostData
function PostData(){
Dim BizObject, lMain, lDetail
global $ComServer;
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_IV")  
$BizObject = $ComServer->BizObjects->Find("Sales.Points.OPF");
 
    $lMain = $BizObject->DataSets->Find("Main"); #lMain contains master data
  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
     $BizObject->New();
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
    $lMain->FindField("DocKey")->value = -1;
 
     $lMain->FindField("DocNo")->AsString = "--Point Test--";
  'Step 4 : Find Doc Number
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
  If lDataSet.RecordCount > 0 Then 
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
lDataSet.First
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
     BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
$lMain->FindField("DESCRIPTION")->AsString = "Points Earn";
 
    $lMain->FindField("FromDocType")->AsString = "CS";
 
$lMain->FindField("FromDocNo")->AsString = "CS-01234";
    BizObject.Open
$lMain->FindField("FROMDOCAMT")->AsFloat = 100.10;
    BizObject.Edit
$lMain->FindField("Points")->AsFloat = 10;
     lMain.Edit
lMain.FindField("Description").AsString = "Sales - Edited"  
try{
 
$BizObject->Save();
  'Step 5: Delete all Detail
}catch (Exception $e) {
     While lDetail.RecordCount <> 0
echo 'Caught exception: ',  $e->getMessage(), "\n";
      lDetail.First
    }
  lDetail.Delete
}
    Wend
 
  'Step 6: Append Detail
 
  lDetail.Append 
if (isset($_POST['BtnData']))
  lDetail.FindField("DtlKey").value = -1
{
  lDetail.FindField("Account").value = "500-000"
    try
  lDetail.FindField("Description").value = "Sales Item A - Edited"
    {
  lDetail.FindField("Tax").value = "SR"
        CheckLogin();
  lDetail.FindField("TaxRate").value = "6%"
        echo date("d M Y h:i:s A")." - Posting Point<br>";
  lDetail.FindField("TaxInclusive").value = 0
        PostData();
  lDetail.FindField("Amount").value = 100
    }
  lDetail.FindField("TaxAmt").value = 6
    finally
 
     {
  lDetail.DisableControls
        $ComServer->Logout();
  lDetail.FindField("TaxInclusive").value =  1
        #free the object
  lDetail.EnableControls
        $ComServer = null;
 
     }
  lDetail.FindField("Changed").value = "F"
}
  lDetail.Post
 
 
?>
  'Step 7: Save Document
     <form method="post">         
     BizObject.Save
        <input type="submit" name="BtnData"
     BizObject.Close
                value="Post Point"/>
 
    </form>
  'Step 8 : Logout after done 
</body>
    'ComServer.Logout 
</html>
     MsgBox "Done"  
Else
MsgBox "Record Not Found"  
  END IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_PM====
====AR_CN====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script
! AR_CN Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
<!DOCTYPE html>
Call PostData
<html>
<head>
Function CreateSQLAccServer
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
</head>
End Function
<body>
 
Function PostData
<h1>SQL Acc SDK in PHP page</h1>
Dim ComServer, BizObject, lIVNo, v(1), lDate
 
<?php
  'Step 1: Create Com Server object
echo "Updated 12 Dec 2020<br>";
  Set ComServer = CreateSQLAccServer 'Create Com Server
#This action to Post Customer Credit Note
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
 
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
$ComServer = null;
  END IF
 
function CheckLogin()
  'Step 2: Find and Create the Biz Objects
{
  Set BizObject = ComServer.BizObjects.Find("AR_PM")
     global $ComServer;
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  'Step 3: Set Dataset
     $status = $ComServer->IsLogin();
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data 
 
  'Step 4 : Posting
    lDate = CDate("January 23, 2017")
    BizObject.New
    lMain.FindField("DOCKEY").Value          = -1
    lMain.FindField("DocNo").AsString        = "--PM Test--"
     lMain.FindField("CODE").AsString          = "300-C0001"
     lMain.FindField("DocDate").Value          = lDate
    lMain.FindField("PostDate").Value        = lDate
    lMain.FindField("Description").AsString  = "Payment for A/c"
    lMain.FindField("PaymentMethod").AsString = "310-000"
    lMain.FindField("DocAmt").AsFloat        = 65.57
    lMain.FindField("Cancelled").AsString    = "F"
  'Step 5: Knock Off IV
     lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
    if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
      lDetailDataSet.Edit
      lDetailDataSet.FindField("KOAmt").value = 65.57
      lDetailDataSet.FindField("KnockOff").AsString = "T"
      lDetailDataSet.Post
End IF 
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  'END IF
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0040.FDB"); #Database Name
   
}


====Example-AR_PM-Edit====
function PostData(){
{| class="mw-collapsible mw-collapsed wikitable"
global $ComServer;
! AR_PM Edit Script 
|-
$BizObject = $ComServer->BizObjects->Find("AR_CN");
|
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
<syntaxhighlight lang="vb">
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
$lKO = $BizObject->DataSets->Find("cdsKnockOff");
Call EditARPM
    $BizObject->New();
Function CreateSQLAccServer
    $lMain->FindField("DocKey")->value = -1;
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    $lMain->FindField("DocNo")->AsString = "--CN Test1--";
End Function
     $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
Function EditARPM
     $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
Dim ComServer, BizObject, lDataSet, lDataSet2, lDocKey, lDocNo, lIVNo, v(1)
     $lMain->FindField("Description")->AsString = "Sales";
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
  END IF
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_PM")  
  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data
 
  'Step 4 : Find OR Number
  lDocNo = "OR-00022"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey
 
  If not IsNull(lDocKey) Then
     BizObject.Open
    BizObject.Edit
    lMainDataSet.Edit
lMainDataSet.FindField("Description").AsString = "testing"
  'Step 5: Knock Off IV
     lIVNO = "IV-00006"
     v(0) = "IV"
     v(1) = lIVNO
     if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
    #Insert Data - Detail
      lDetailDataSet.Edit
    #For Tax Inclusive = True with override Tax Amount
      lDetailDataSet.FindField("KOAmt").value = 50.12
    $lDetail->Append();
      lDetailDataSet.FindField("KnockOff").AsString = "T"
    $lDetail->FindField("DtlKey")->value = -1;
      lDetailDataSet.Post
    $lDetail->FindField("DocKey")->value = -1;
  MsgBox "yes"
    $lDetail->FindField("Seq")->value = 1;
End IF 
    $lDetail->FindField("Account")->AsString = "510-000"; #Sales Return Account
  'Step 6: Save Document
    $lDetail->FindField("Description")->AsString = "Return Item A";
     BizObject.Save
    $lDetail->FindField("Tax")->AsString = "";
     BizObject.Close
    $lDetail->FindField("TaxRate")->AsString = "";
     MsgBox "Done"
    $lDetail->FindField("TaxInclusive")->value = 0;
  END IF
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
End Function
    $lDetail->FindField("TaxAmt")->AsFloat = 0;
$lDetail->Post();
 
    $V = array("IV", "IV-00003");  #DocType, DocNo
       
     if ($lKO->Locate("DocType;DocNo", $V, False, False)){
        $lKO->Edit();
        $lKO->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
        $lKO->FindField("KnockOff")->AsString = "T";
        $lKO->Post();
}
     $BizObject->Save();
     $BizObject->Close();
}
 
if (isset($_POST['BtnData']))
{
    try
     {
        CheckLogin();
PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Post Customer Credit Note"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.RO====
====SO to DO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.RO Report Object Script
! SO to DO Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg customer_ro.vbs
<!DOCTYPE html>
Call GetCustomerData
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>


Function CreateSQLAccServer
<h1>SQL Acc SDK in PHP page</h1>
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


Function GetCustomerData
<?php
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
echo "Updated 15 Jan 2021<br>";
  'Step 1: Create Com Server object
#This action to
  Set ComServer = CreateSQLAccServer 'Create Com Server
#01. Get Oustanding SO
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
#02. Post To DO
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF


  'Step 2: Find and Create the Report Objects
$ComServer = null;
  Set RptObject = ComServer.RptObjects.Find("Customer.RO")


  'Step 3: Spool parameters
function CheckLogin()
  RptObject.Params.Find("AllAgent").Value = true
{
  RptObject.Params.Find("AllArea").Value = true
    global $ComServer;
  RptObject.Params.Find("AllCompany").Value = false
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  RptObject.Params.Find("AllCompanyCategory").Value = true
    $status = $ComServer->IsLogin();
  RptObject.Params.Find("AllCurrency").Value = true
  RptObject.Params.Find("AllTerms").Value = true
  RptObject.Params.Find("SelectDate").Value = true
  RptObject.Params.Find("PrintActive").Value = true
  RptObject.Params.Find("PrintInactive").Value = false
  RptObject.Params.Find("PrintPending").Value = false
  RptObject.Params.Find("PrintProspect").Value = false
  RptObject.Params.Find("PrintSuspend").Value = false
  lDateFrom = CDate("January 1, 2000")
  lDateTo = CDate("December 31, 2014")


  RptObject.Params.Find("DateFrom").Value = lDateFrom
    if ($status == true)
  RptObject.Params.Find("DateTo").Value = lDateTo
    {
  RptObject.Params.Find("CompanyData").Value = "300-A0003"
        $ComServer->Logout();
 
    }
  'Step 4: Perform Report calculation
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  RptObject.CalculateReport()
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
                      "ACC-0024.FDB"); #Database Name
  Set lDataSet2 = RptObject.DataSets.Find("cdsBranch")
   
  MsgBox "Count " & lDataSet.RecordCount
}


  'Step 5 Retrieve the output
function PostData(){
  lDataSet.First
global $ComServer;
  While (not lDataSet.eof)
     MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString
    $lSQL = "SELECT Dockey, DocNo,Code, CompanyName, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount,
lDataSet2.First
            COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM (
    While (not lDataSet2.eof)
            SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName,
  MsgBox lDataSet2.FindField("Address1").AsString
            B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount,
  lDataSet2.Next
            C.Qty XFQty FROM SL_SO A
     Wend
            INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY)
lDataSet.Next
            LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY
  Wend
                                      AND C.FROMDOCTYPE='SO')
End Function
            WHERE A.DOCNO='SO-00140')
            GROUP BY Dockey, DocNo, Code, CompanyName, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount
HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0
";
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL); #Get Oustanding SO Qty
 
     if ($lDataSet->RecordCount > 0) {
$BizObject = $ComServer->BizObjects->Find("SL_DO");
        $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
        $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
$lDataSet->First();
$BizObject->New();
$lMain->FindField("DocKey")->value = -1;
$lMain->FindField("DocNo")->AsString = "--DO Test--";
$lMain->FindField("DocDate")->value = "01/20/2021"; #MM/DD/YYYY
$lMain->FindField("PostDate")->value = "01/20/2021"; #MM/DD/YYYY
$lMain->FindField("Code")->AsString = $lDataSet->FindField("Code")->AsString;
$lMain->FindField("CompanyName")->AsString = $lDataSet->FindField("CompanyName")->AsString;
$lMain->FindField("Description")->AsString = "Delivery Order";
 
while (! $lDataSet->Eof()){
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("ItemCode")->AsString = $lDataSet->FindField("ItemCode")->AsString;
    $lDetail->FindField("UOM")->AsString = $lDataSet->FindField("UOM")->AsString;
$lDetail->FindField("Qty")->AsFloat = $lDataSet->FindField("OSQty")->AsFloat;
    $lDetail->FindField("DISC")->value = $lDataSet->FindField("DISC")->value;
    $lDetail->FindField("Tax")->AsString = "";
    $lDetail->FindField("TaxRate")->AsString = "";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = $lDataSet->FindField("UnitPrice")->AsFloat;
    $lDetail->FindField("Amount")->AsFloat = $lDataSet->FindField("Amount")->AsFloat;
    $lDetail->FindField("TaxAmt")->AsFloat = 0;
$lDetail->FindField("FromDocType")->AsString = "SO";
$lDetail->FindField("FromDockey")->AsFloat = $lDataSet->FindField("Dockey")->AsFloat;
$lDetail->FindField("FromDtlkey")->AsFloat = $lDataSet->FindField("DtlKey")->AsFloat;
    $lDetail->Post();
$lDataSet->Next();
 
}
        $BizObject->Save();
        $BizObject->Close();
}else {
    echo "Record Not Found";
    }
}
 
if (isset($_POST['BtnData']))
{
    try
     {
        CheckLogin();
PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Post SO to DO"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.Statement.RO====
====ST_AJ====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.Statement.RO  Report Object Script
! ST_AJ Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg customer_statement_ro.vbs
<!DOCTYPE html>
Call GetCustStatementData
<html>
<head>
Function CreateSQLAccServer
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
</head>
End Function
<body>


Function GetCustStatementData
<h1>SQL Acc SDK in PHP page</h1>
Const Quote = """"
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF


  'Step 2: Find and Create the Report Objects
<?php
  Set RptObject = ComServer.RptObjects.Find("Customer.Statement.RO")
echo "Updated 08 Feb 2021<br>";
  'Step 3: Spool parameters
  lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
      "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
      "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
      "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
      "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
      "</ROWDATA></DATAPACKET>"
'  RptObject.Params.Find("AgentData").Value            =  'Not use if AllAgent is True
  RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed
  RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
  RptObject.Params.Find("AllAgent").Value            = true
  RptObject.Params.Find("AllArea").Value              = true
  RptObject.Params.Find("AllCompany").Value          = false
  RptObject.Params.Find("AllCompanyCategory").Value  = true
  RptObject.Params.Find("AllControlAccount").Value    = true
  RptObject.Params.Find("AllCurrency").Value          = true
  RptObject.Params.Find("AllDocProject").Value        = true
'  RptObject.Params.Find("AreaData").Value            =  'Not use if AllArea is True
'  RptObject.Params.Find("CompanyCategoryData").Value  =  'Not use if AllCompanyCategory is True
  RptObject.Params.Find("CompanyData").Value          = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
'  RptObject.Params.Find("ControlAccountData").Value  =  'Not use if AllControlAccount is True
'  RptObject.Params.Find("CurrencyData").Value        =  'Not use if AllCurrency is True
  lDateFrom = CDate("August 1, 2016")
  lDateTo = CDate("August 31, 2016")
  RptObject.Params.Find("DateFrom").Value            = lDateFrom
  RptObject.Params.Find("DateTo").Value              = lDateTo
'  RptObject.Params.Find("DocProjectData").Value      =  'Not use if AllDocProject is True
  RptObject.Params.Find("IncludeZeroBalance").Value  = false
  RptObject.Params.Find("SelectDate").Value          = true
  RptObject.Params.Find("SortBy").Value              = "CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount"
  RptObject.Params.Find("StatementDate").Value        = lDateTo ' Norm same as DateTo
  RptObject.Params.Find("StatementType").Value        = "O" 'O = Open Item, B = B/F
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
  MsgBox "Count " & lDataSet.RecordCount


  'Step 5 Retrieve the output
$ComServer = null;
  lDataSet.First
 
  While (not lDataSet.eof)
function CheckLogin()
     MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("Balance").AsString
{
lDataSet2.First
     global $ComServer;
    While (not lDataSet2.eof)
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  MsgBox lDataSet2.FindField("DocNo").AsString
     $status = $ComServer->IsLogin();
  lDataSet2.Next
     Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0100.FDB"); #Database Name
   
}


====Example-GL.CB.RO====
function PostData(){
{| class="mw-collapsible mw-collapsed wikitable"
global $ComServer;
! GL.CB.RO  Report Object Script 
|-
$BizObject = $ComServer->BizObjects->Find("ST_AJ");
|
    $lMain = $BizObject->DataSets->Find("MainDataSet");
<syntaxhighlight lang="vb">
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail");
'Copy below script & paste to notepad & name it as eg GL.CB.RO.vbs
Call GetCLCBData
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
Function CreateSQLAccServer
    $lMain->FindField("DocNo")->AsString = "--AJ Test--";
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
End Function
     $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Adjustment";
Function GetCLCBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
    #Insert Data - Detail - Increase Stock Qty
  'Step 1: Create Com Server object
    $lDetail->Append();
  Set ComServer = CreateSQLAccServer 'Create Com Server
    $lDetail->FindField("DtlKey")->value = -1;
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    $lDetail->FindField("DocKey")->value = -1;
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
    $lDetail->FindField("Seq")->value = 1;
  END IF
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "ANTENA";
  'Step 2: Find and Create the Report Objects
    $lDetail->FindField("Qty")->AsFloat = 2;
  Set RptObject = ComServer.RptObjects.Find("GL.CB.RO")  
    $lDetail->FindField("UOM")->AsString = "BOX";
    $lDetail->Post();
  'Step 3: Spool parameters
    #Insert Data - Detail - Reduce Stock Qty
  RptObject.Params.Find("AllCurrency").Value    = true
    $lDetail->Append();
  RptObject.Params.Find("AllDocProject").Value  = true
    $lDetail->FindField("DtlKey")->value = -1;
  RptObject.Params.Find("AllDocument").Value    = true
    $lDetail->FindField("DocKey")->value = -1;
  RptObject.Params.Find("AllItemProject").Value = true
    $lDetail->FindField("Seq")->value = 2;
  RptObject.Params.Find("AllItemArea").Value    = true
    $lDetail->FindField("ItemCode")->AsString = "N-CHARGER";
  RptObject.Params.Find("AllItemAgent").Value  = true
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER";
  RptObject.Params.Find("AllDocAgent").Value    = true
    $lDetail->FindField("Qty")->AsFloat = -5;
  RptObject.Params.Find("AllDocArea").Value     = true
    $lDetail->FindField("UOM")->AsString = "UNIT";
  RptObject.Params.Find("AllPaymentMethod").Value = false
    $lDetail->Post();
  'RptObject.Params.Find("CurrencyData").Value    = 'Not use if AllCurrency is true
 
    $BizObject->Save();
  lDateFrom = CDate("January 01, 2017")
    $BizObject->Close();
  lDateTo = CDate("December 31, 2017")
try{
  'For Post Date From & Date To'
        $BizObject->Save();
  RptObject.Params.Find("DateFrom").Value = lDateFrom
        $BizObject->Close();
  RptObject.Params.Find("DateTo").Value  = lDateTo
}catch (Exception $e) {
 
    echo 'Caught exception: ',  $e->getMessage(), "\n";
  'RptObject.Params.Find("DocProjectData").Value  = 'Not use if AllDocProject is true
    }
  'RptObject.Params.Find("DocAreaData").Value    = 'Not use if AllDocArea is true
}
  'RptObject.Params.Find("DocAgentData").Value    = 'Not use if AllDocAgent is true
 
  'RptObject.Params.Find("ItemAgentData").Value  = 'Not use if AllItemAgent is true
if (isset($_POST['BtnData']))
  RptObject.Params.Find("DocType").Value          = "PV" 'PV for Payment Voucher & OR for Official Receipt
{
  'RptObject.Params.Find("DocumentData").Value    = 'Not use if AllDocument is true
    try
  'RptObject.Params.Find("GroupBy").Value        = 'If you wanted to grouping the data
     {
  RptObject.Params.Find("IncludeCancelled").Value = false
        CheckLogin();
  'RptObject.Params.Find("ItemAreaData").Value    = 'Not use if AllItemArea is true
PostData();
  'RptObject.Params.Find("ItemProjectData").Value = 'Not use if AllItemProject is true
        echo date("d M Y h:i:s A")." - Done";
  RptObject.Params.Find("PaymentMethodData").Value  = "310-001"
    }
  RptObject.Params.Find("PrintDocumentStyle").Value = false
    finally
  RptObject.Params.Find("SelectDate").Value        = true 'For Post Date
    {
  'RptObject.Params.Find("SelectDocDate").Value    = 'For Doc Date
        $ComServer->Logout();
  RptObject.Params.Find("SortBy").Value            = "PostDate;DocNo"
        #free the object
        $ComServer = null;
  'Step 4: Perform Report calculation
     }
  RptObject.CalculateReport()
}
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
 
  Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
?>
  Set lDataSet3 = RptObject.DataSets.Find("cdsTax")
    <form method="post">         
  MsgBox "Count " & lDataSet.RecordCount
        <input type="submit" name="BtnData"
                value="Post ST_AJ"/>
  'Step 5 Retrieve the output
    </form>
  lDataSet.First
</body>
  While (not lDataSet.eof)
</html>
     MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
  lDataSet2.Next
     Wend
lDataSet.Next
  Wend
  'For GST List
  MsgBox "GST Code Count " & lDataSet3.RecordCount
  lDataSet3.First
  While (not lDataSet3.eof)
    MsgBox lDataSet3.FindField("Code").AsString
lDataSet3.Next
  Wend
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_Customer====
====Get Stock Serial Number balance====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_Customer - Script
! Get Stock Serial Number Balance List Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
<!DOCTYPE html>
Call CheckLogin
<html>
Call InsertData
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>


Dim ComServer
<h1>SQL Acc SDK in PHP page</h1>


Function CreateSQLAccServer
<?php
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
echo "Updated 21 May 2021<br>";
End Function


function CheckLogin
$ComServer = null;
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


Function InsertData
function CheckLogin()
Dim BizObject, lMain, lDetail
{
  'Step 2: Find and Create the Biz Objects
    global $ComServer;
  Set BizObject = ComServer.BizObjects.Find("AR_Customer")  
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


  'Step 3: Set Dataset
    if ($status == true)
  Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
    {
  Set lDetail = BizObject.DataSets.Find("cdsBranch") 'lDetail contains detail data 
        $ComServer->Logout();
 
    }
  'Begin Looping yr data
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  'Step 4 : Insert Data - Master
                      "D:\Happy\DB\Default.DCF",  #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
  BizObject.New
                      "ACC-0024.FDB"); #Database Name
  lMain.FindField("Code").AsString      = "300-Test"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
      
      
  'Step 5: Insert Data - Detail
}
  'For 1st Branch
 
  lDetail.Edit
function GetData(){
  lDetail.FindField("BranchName").AsString = "BILLING"
global $ComServer;
  lDetail.FindField("Address1").AsString    = "Address1"
  lDetail.FindField("Address2").AsString    = "Address2"
    $lSQL = "SELECT ItemCode, Location, Batch, SerialNumber, SUM(Qty) Qty  FROM ST_TR_SN  
  lDetail.FindField("Address3").AsString    = "Address3"
        GROUP BY ItemCode, Location, Batch, SerialNumber
  lDetail.FindField("Address4").AsString    = "Address4"
HAVING SUM(Qty) > 0
  lDetail.FindField("Attention").AsString  = "Attention" 
";
  lDetail.FindField("Phone1").AsString      = "Phone1"
  lDetail.FindField("Fax1").AsString        = "Fax1"
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
  lDetail.FindField("Email").AsString      = "EmailAddress"
 
  lDetail.Post
    if ($lDataSet->RecordCount > 0) {
 
$lDataSet->First();
  'For 2nd Branch
$fc = $lDataSet->Fields->Count-1;
  lDetail.Append
echo "<table>";
  lDetail.FindField("BranchName").AsString  = "Branch1"
echo "<tr>";
  lDetail.FindField("Address1").AsString    = "DAddress1"
for ($x = 0; $x <= $fc; $x++) {
  lDetail.FindField("Address2").AsString    = "DAddress2"
#Insert Header
  lDetail.FindField("Address3").AsString   = "DAddress3"
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";
  lDetail.FindField("Address4").AsString    = "DAddress4"
}
  lDetail.FindField("Attention").AsString  = "DAttention" 
echo "</tr>";
  lDetail.FindField("Phone1").AsString      = "DPhone1"
  lDetail.FindField("Fax1").AsString        = "DFax1"
#Looping Dataset
  lDetail.FindField("Email").AsString      = "DEmailAddress"
while (! $lDataSet->Eof()){
  lDetail.Post
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $lDataSet->Fields->Items($x)->FieldName();
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$lDataSet->Next();
}
echo "</table>"."<br>";
}else {
    echo "Record Not Found";
    }
}


  'Step 6: Save Document
if (isset($_POST['BtnData']))
  BizObject.Save
{
  BizObject.Close
    try
    {
  'End Looping yr data
        CheckLogin();
 
GetData();
  'Step 7 : Logout after done 
        echo date("d M Y h:i:s A")." - Done";
  'ComServer.Logout
    }
 
    finally
  MsgBox "Done"
    {
End Function
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Get SN Balance"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_Customer-Edit====
====SL_IV-Add, Edit & Delete====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_Customer - Edit Script
! Insert, Edit & Delete Invoice Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
<!DOCTYPE html>
Call EditARCustomer
<html>
<body>
Function CreateSQLAccServer
 
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
<h1>SQL Acc SDK in PHP page</h1>
End Function
 
<?php
Function EditARCustomer
echo "Updated 14 Mar 2022<br>";
Dim ComServer, BizObject, lDataSet, lDataSet2
$ComServer = null;
 
  'Step 1 Create Com Server object
function CheckLogin()
  Set ComServer = CreateSQLAccServer 'Create Com Server
{
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    global $ComServer;
     ComServer.Login "ADMIN", "ADMIN", "C\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  END IF
    $status = $ComServer->IsLogin();
 
  'Step 2 Find and Create the Biz Objects
     if ($status == true)
  Set BizObject = ComServer.BizObjects.Find("AR_Customer")  
     {
        $ComServer->Logout();
  'Step 3 Set Dataset
     }
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet") 'lMainDataSet contains master data
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  Set lDetailDataSet = BizObject.DataSets.Find("cdsBranch") 'lDetailDataSet contains detail data 
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
 
                      "ACC-0015.FDB"); #Database Name
  'Step 4 Find Customer Code
      
  BizObject.Params.Find("Code").Value = "300-Test"
}
 
  BizObject.Open
  BizObject.Edit
  lMainDataSet.Edit
  lMainDataSet.FindField("CompanyName").value = "Testing 123-Changed"
  'Step 5 For 1st Branch
    v = "BILLING"
     if (lDetailDataSet.Locate("BranchName", v, false, false)) then
  lDetailDataSet.Edit
      lDetailDataSet.FindField("Address1").AsString  = "Address1-Changed"
      lDetailDataSet.FindField("Address2").AsString  = "Address2-Changed"
      lDetailDataSet.FindField("Address3").AsString  = "Address3-Changed"
      lDetailDataSet.FindField("Address4").AsString  = "Address4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "Attention-Changed"
      lDetailDataSet.FindField("Phone1").AsString     = "Phone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString      = "Fax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "EmailAddress-Changed"
      lDetailDataSet.Post
end if
'Step 5 For 2nd Branch
     v = "Branch1"
     if (lDetailDataSet.Locate("BranchName", v, false, false)) then
      lDetailDataSet.Edit
      lDetailDataSet.FindField("Address1").AsString  = "DAddress1-Changed"
      lDetailDataSet.FindField("Address2").AsString  = "DAddress2-Changed"
      lDetailDataSet.FindField("Address3").AsString  = "DAddress3-Changed"
      lDetailDataSet.FindField("Address4").AsString  = "DAddress4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "DAttention-Changed"
      lDetailDataSet.FindField("Phone1").AsString     = "DPhone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString      = "DFax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "DEmailAddress-Changed"
      lDetailDataSet.Post 
  end IF
  'Step 6 Save Customer
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
function PostDataIV(){
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("SL_IV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
    #Find IV Number
    $lDocNo = "--IV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
$BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("CompanyName")->AsString = "Cash Sales-Edited";
        $lMain->FindField("Address1")->AsString = ""; #Optional
        $lMain->FindField("Address2")->AsString = ""; #Optional
        $lMain->FindField("Address3")->AsString = ""; #Optional
        $lMain->FindField("Address4")->AsString = ""; #Optional
        $lMain->FindField("Phone1")->AsString = "";   #Optional
        $lMain->FindField("Description")->AsString = "Sales - Edited";


====Example-GL.TrialBalance.RO====
$r = $lDetail->RecordCount();
$x = 1;
while ($x <= $r ){
$lDetail->First();
            $lDetail->Delete();
$x++;
}
        $lDetail->Append();
        $lDetail->FindField("ItemCode")->AsString = "COVER";
        $lDetail->FindField("Description")->AsString = "Sales Item Cover";
    $lDetail->FindField("UOM")->AsString = "UNIT";
        $lDetail->FindField("Qty")->AsFloat = 3;
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("UnitPrice")->AsFloat = 5.60;
        $lDetail->FindField("Amount")->AsFloat = 16.80;
        $lDetail->FindField("TaxAmt")->AsFloat = 0;
        $lDetail->Post();
} else {
      echo "New Invoice<br>";
  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
  $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("CompanyName")->AsString = "Cash Sales";
      $lMain->FindField("Address1")->AsString = ""; #Optional
      $lMain->FindField("Address2")->AsString = ""; #Optional
      $lMain->FindField("Address3")->AsString = ""; #Optional
      $lMain->FindField("Address4")->AsString = ""; #Optional
      $lMain->FindField("Phone1")->AsString = "";  #Optional
      $lMain->FindField("Description")->AsString = "Sales";
  #$lMain->FindField('DocAmt')->value = $Amt;
      $lDetail->Append();
      $lDetail->FindField("ItemCode")->AsString = "ANT";
      $lDetail->FindField("Description")->AsString = "Sales Item ANT";
  $lDetail->FindField("UOM")->AsString = "UNIT";
      $lDetail->FindField("Qty")->AsFloat = 1;
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("UnitPrice")->AsFloat = 100;
      $lDetail->FindField("Amount")->AsFloat = 100;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();
 
 
      $lDetail->Append();
      $lDetail->FindField("ItemCode")->AsString = "BOM";
      $lDetail->FindField("Description")->AsString = "Sales Item BOM";
  $lDetail->FindField("UOM")->AsString = "UNIT";
      $lDetail->FindField("Qty")->AsFloat = 2;
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("UnitPrice")->AsFloat = 150;
      $lDetail->FindField("Amount")->AsFloat = 300;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();
}
    $BizObject->Save();
echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();
}
 
function PostDelIV(){
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("SL_IV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    #Find IV Number
    $lDocNo = "--IV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
$BizObject->Open();
        $BizObject->Delete();
echo date("d M Y h:i:s A")." - Record deleted<br>";
} else {
echo date("d M Y h:i:s A")." - Document Not Found<br>";
}
}
if (isset($_POST['BtnPost']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostDataIV();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
if (isset($_POST['BtnDel']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
        PostDelIV();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnPost"
                value="Post Sales IV"/>
        <input type="submit" name="BtnDel"
                value="Post Delete IV"/>
    </form>
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL_PV-Add, Edit & Delete====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL Trial Balance  Report Object Script
! Insert, Edit & Delete Invoice Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg GL.TrialBalance.RO.vbs
<!DOCTYPE html>
Call GetGLTBData
<html>
<body>
Function CreateSQLAccServer
 
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
<h1>SQL Acc SDK in PHP page</h1>
End Function
Function GetGLTBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("GL.TrialBalance.RO")
  'Step 3: Spool parameters
  RptObject.Params.Find("AllProject").Value      = true
  RptObject.Params.Find("AllAgent").Value        = true
  RptObject.Params.Find("AllArea").Value        = true
  RptObject.Params.Find("LedgerType").Value      = "G" 'G = Legder, S = Debtor, P = Supplier
  'RptObject.Params.Find("ProjectData").Value    = 'Not use if AllArea is true
  RptObject.Params.Find("ShowZeroBalance").Value = false
  RptObject.Params.Find("SortBy").Value          = "PostDate;DocNo"
  RptObject.Params.Find("UseDescription2").Value = false
 
  lDateFrom = CDate("October 27, 2016")
  lDateTo = CDate("December 31, 2016")
  'For Post Date From & Date To'
  RptObject.Params.Find("DateFrom").Value      = lDateFrom
  RptObject.Params.Find("DateTo").Value        = lDateTo


  'RptObject.Params.Find("AgentData").Value      = 'Not use if AllAgent is true
<?php
  'RptObject.Params.Find("AreaData").Value      = 'Not use if AllArea is true
echo "Updated 15 Mar 2022<br>";
 
$ComServer = null;
  RptObject.Params.Find("SortBy").Value          = "Code;Description"
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsGLAccount")


  MsgBox "Count " & lDataSet.RecordCount
function CheckLogin()
{
  'Step 5 Retrieve the output
    global $ComServer;
  lDataSet.First
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
  While (not lDataSet.eof)
    $status = $ComServer->IsLogin();
     MsgBox "Month To Date"
 
MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("MTDDR").AsString & " CR=>" & lDataSet.FindField("MTDCR").AsString
    if ($status == true)
    {
        $ComServer->Logout();
    }
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0015.FDB"); #Database Name
   
}
 
function PostData(){
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("GL_PV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
MsgBox "Year To Date"
    #Find PV Number
MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("YTDDR").AsString & " CR=>" & lDataSet.FindField("YTDCR").AsString
    $lDocNo = "--PV Test--";
lDataSet.Next
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
  Wend
 
if ($lDocKey != null){
  'For Account List
        echo "Dockey = ".$lDocKey."<br>";
  lDataSet2.First
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
  While (not lDataSet2.eof)
$BizObject->Open();
MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
        $BizObject->Edit();
lDataSet2.Next
        $lMain->Edit();
  Wend
    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
 
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
End Function
        $lMain->FindField("Description")->AsString = "Tenaga Malaysia - Edited";
</syntaxhighlight>
$lMain->FindField("PaymentMethod")->AsString = "310-001"; #GL Bank/Cash account code
|}
$lMain->FindField("CHEQUENUMBER")->AsString = "MBB 123456"; #Optional
$lMain->FindField("Cancelled")->AsString = "F";


<div style="float: right;">   [[#top|[top]]]</div>
$r = $lDetail->RecordCount();
$x = 1;
while ($x <= $r ){
$lDetail->First();
            $lDetail->Delete();
$x++;
}
        $lDetail->Append();
        $lDetail->FindField("Code")->AsString = "907-000";
        $lDetail->FindField("Description")->AsString = "TNB Bill for Feb 2022 - Edited";
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("Amount")->AsFloat = 168.80;
        $lDetail->FindField("TaxAmt")->AsFloat = 0;
        $lDetail->Post();
} else {
      echo "New PV<br>";
  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("Description")->AsString = "Tenaga Malaysia";
  $lMain->FindField("PaymentMethod")->AsString = "310-001"; #GL Bank/Cash account code
  $lMain->FindField("CHEQUENUMBER")->AsString = "MBB 123456"; #Optional
  $lMain->FindField("Cancelled")->AsString = "F";
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "907-000"; #GL Account
      $lDetail->FindField("Description")->AsString = "TNB Bill for Jan 2022";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("Amount")->AsFloat = 100.80;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();


====Example-Customer.Aging.RO====
      $lDetail->Append();
{| class="mw-collapsible mw-collapsed wikitable"
      $lDetail->FindField("Code")->AsString = "907-000";
! Customer Aging  Report Object Script 
      $lDetail->FindField("Description")->AsString = "TNB Bill for Feb 2022";
|-
      $lDetail->FindField("Tax")->AsString = "";
|
      $lDetail->FindField("TaxRate")->AsString = "";
<syntaxhighlight lang="vb">
      $lDetail->FindField("TaxInclusive")->value = 0;
'Copy below script & paste to notepad & name it as eg customer_aging_ro.vbs
      $lDetail->FindField("Amount")->AsFloat = 68.00;
Call GetCustStatementData
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();
Function CreateSQLAccServer
}
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    $BizObject->Save();
End Function
echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();
}


Function GetCustStatementData
function DelData(){
Const Quote = """"
global $ComServer;
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
  'Step 1: Create Com Server object
$BizObject = $ComServer->BizObjects->Find("GL_PV");
  Set ComServer = CreateSQLAccServer 'Create Com Server
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
    #Find PV Number
  END IF
    $lDocNo = "--PV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
$BizObject->Open();
        $BizObject->Delete();
echo date("d M Y h:i:s A")." - Record deleted<br>";
} else {
echo date("d M Y h:i:s A")." - Document Not Found<br>";
}
}
if (isset($_POST['BtnPost']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostData();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}


  'Step 2: Find and Create the Report Objects
if (isset($_POST['BtnDel']))
  Set RptObject = ComServer.RptObjects.Find("Customer.Aging.RO")  
{
    try
  'Step 3: Spool parameters
    {
  lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
        CheckLogin();
      "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
      "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
        DelData();
      "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
    }
      "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
    finally
      "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
    {
      "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
        $ComServer->Logout();
      "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
        #free the object
      "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
         $ComServer = null;
      "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
    }
      "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
}
      "</ROWDATA></DATAPACKET>"
  RptObject.Params.Find("ActualGroupBy").Value         = "Code;CompanyName" 'Fixed
'  RptObject.Params.Find("AgentData").Value            =  'Not use if AllAgent is True
  RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed


  lDateTo = CDate("August 31, 2016")
?>
  RptObject.Params.Find("AgingDate").Value            = lDateTo 
    <form method="post">            
 
        <input type="submit" name="BtnPost"
  RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
                value="Post GL PV"/>
  RptObject.Params.Find("AllAgent").Value            = true
         <input type="submit" name="BtnDel"
  RptObject.Params.Find("AllArea").Value              = true
                value="Delete PV"/>
  RptObject.Params.Find("AllCompany").Value           = false
     </form>
  RptObject.Params.Find("AllCompanyCategory").Value  = true
</body>
  RptObject.Params.Find("AllControlAccount").Value    = true
</html>
  RptObject.Params.Find("AllCurrency").Value          = true
  RptObject.Params.Find("AllDocProject").Value        = true
'  RptObject.Params.Find("AreaData").Value            = 'Not use if AllArea is True
'  RptObject.Params.Find("CompanyCategoryData").Value  =  'Not use if AllCompanyCategory is True
  RptObject.Params.Find("CompanyData").Value          = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
'  RptObject.Params.Find("ControlAccountData").Value  =  'Not use if AllControlAccount is True
'  RptObject.Params.Find("CurrencyData").Value         = 'Not use if AllCurrency is True
'  RptObject.Params.Find("DocProjectData").Value      = 'Not use if AllDocProject is True
  RptObject.Params.Find("FilterPostDate").Value        = false
'  RptObject.Params.Find("GroupBy").Value              = 'Not use
  RptObject.Params.Find("IncludePDC").Value        = false
  RptObject.Params.Find("IncludeZeroBalance").Value  = false
  RptObject.Params.Find("SortBy").Value              = "Code;CompanyName"
  RptObject.Params.Find("DateTo").Value              = lDateTo
 
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("C1").AsString
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("C1").AsString
  lDataSet2.Next
     Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL.JE.RO====
====GL_JE-Add, Edit & Delete====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL Journal Voucher Report Object Script
! Insert, Edit & Delete Invoice Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg GLJE_ro.vbs
<!DOCTYPE html>
Call GetCustomerData
<html>
<body>


Function CreateSQLAccServer
<h1>SQL Acc SDK in PHP page</h1>
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


Function GetCustomerData
<?php
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
echo "Updated 15 Mar 2022<br>";
  'Step 1: Create Com Server object
$ComServer = null;
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF


  'Step 2: Find and Create the Report Objects
function CheckLogin()
  Set RptObject = ComServer.RptObjects.Find("GL.JE.RO")  
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


  'Step 3: Spool parameters
    if ($status == true)
  RptObject.Params.Find("AllCurrency").Value = true
    {
  RptObject.Params.Find("AllDocProject").Value = true
        $ComServer->Logout();
  RptObject.Params.Find("AllDocument").Value = true
    }
  RptObject.Params.Find("AllItemProject").Value = true
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  RptObject.Params.Find("AllItemArea").Value = true
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
  RptObject.Params.Find("AllItemAgent").Value = true
                      "ACC-0015.FDB"); #Database Name
  RptObject.Params.Find("AllDocAgent").Value = true
   
  RptObject.Params.Find("AllDocArea").Value = true
}
  RptObject.Params.Find("AllPaymentMethod").Value = true


  lDateFrom = CDate("December 1, 2017")
function PostData(){
  lDateTo = CDate("December 31, 2017")
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("GL_JE");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
    #Find JE Number
    $lDocNo = "--JE Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
$BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("Description")->AsString = "Credit Card Charges - Edited";
$lMain->FindField("Cancelled")->AsString = "F";


  RptObject.Params.Find("DateFrom").Value = lDateFrom
$r = $lDetail->RecordCount();
  RptObject.Params.Find("DocDateFrom").Value = lDateFrom
$x = 1;
  RptObject.Params.Find("DateTo").Value = lDateTo
while ($x <= $r ){
  RptObject.Params.Find("DocDateTo").Value = lDateTo
$lDetail->First();
  RptObject.Params.Find("IncludeCancelled").Value = false
            $lDetail->Delete();
  RptObject.Params.Find("PrintDocumentStyle").Value = false
$x++;
  RptObject.Params.Find("SelectDate").Value = true 'Post Date
}
  RptObject.Params.Find("SelectDocDate").Value = false 'Doc Date
        $lDetail->Append();
 
        $lDetail->FindField("Code")->AsString = "902-000";
  'Step 4: Perform Report calculation
        $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges - Edited";
  RptObject.CalculateReport()
        $lDetail->FindField("Tax")->AsString = "";
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
        $lDetail->FindField("TaxRate")->AsString = "";
  Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
        $lDetail->FindField("TaxInclusive")->value = 0;
  MsgBox "Count " & lDataSet.RecordCount
        $lDetail->FindField("LocalDR")->AsFloat = 78.88;
$lDetail->FindField("DR")->AsFloat = 78.88; #If Wanted DR <> LocalDR
        $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
        $lDetail->Post();
        $lDetail->Append();
        $lDetail->FindField("Code")->AsString = "310-001";
        $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges - Edited";
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("LocalCR")->AsFloat = 78.88;
$lDetail->FindField("CR")->AsFloat = 78.88; #If Wanted CR <> LocalCR
        $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
        $lDetail->Post();
} else {
      echo "New JE<br>";
  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("Description")->AsString = "Credit Card Charges";
  $lMain->FindField("Cancelled")->AsString = "F";
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "902-000";
      $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("LocalDR")->AsFloat = 88.88;
  $lDetail->FindField("DR")->AsFloat = 88.88; #If Wanted DR <> LocalDR
      $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
      $lDetail->Post();
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "310-001";
      $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("LocalCR")->AsFloat = 88.88;
  $lDetail->FindField("CR")->AsFloat = 88.88; #If Wanted CR <> LocalCR
      $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
      $lDetail->Post();
}
    $BizObject->Save();
echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();
}


  'Step 5 Retrieve the output
function DelData(){
  lDataSet.First
global $ComServer;
  While (not lDataSet.eof)
     MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
$BizObject = $ComServer->BizObjects->Find("GL_JE");
lDataSet2.First
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
    #Find JE Number
  lDataSet2.Next
     $lDocNo = "--JE Test--";
     Wend
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
lDataSet.Next
  Wend
if ($lDocKey != null){
End Function
        echo "Dockey = ".$lDocKey."<br>";
</syntaxhighlight>
$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
|}
$BizObject->Open();
        $BizObject->Delete();
echo date("d M Y h:i:s A")." - Record deleted<br>";
} else {
echo date("d M Y h:i:s A")." - Document Not Found<br>";
}
}
if (isset($_POST['BtnPost']))
{
    try
     {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostData();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}


<div style="float: right;">   [[#top|[top]]]</div>
if (isset($_POST['BtnDel']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
        DelData();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}


====Example-SL_CS====
?>
{| class="mw-collapsible mw-collapsed wikitable"
    <form method="post">         
! SL_CS Script
        <input type="submit" name="BtnPost"
                value="Post GL JE"/>
        <input type="submit" name="BtnDel"
                value="Delete JE"/>
    </form>
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Outstanding SO List====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Outstanding SO List Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
<!DOCTYPE html>
Call InsertData
<html>
<body>
 
<h1>SQL Acc SDK in PHP page</h1>


Function CreateSQLAccServer
<?php
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
echo "Updated 09 Jun 2022<br>";
End Function
$ComServer = null;


Function InsertData
function CheckLogin()
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();


  'Step 1: Create Com Server object
    if ($status == true)
  Set ComServer = CreateSQLAccServer 'Create Com Server
    {
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
        $ComServer->Logout();
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
    }
  END IF
     $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF", #DCF file
                      "ACC-0015.FDB"); #Database Name
   
}


  'Step 2: Find and Create the Biz Objects
function GetData(){
  Set BizObject = ComServer.BizObjects.Find("SL_CS")  
global $ComServer;
    $lSQL = "SELECT Dockey, DocNo,Code, CompanyName, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount,
            COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM (
            SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName,
            B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount,
            C.Qty XFQty FROM SL_SO A
            INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY)
            LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY
                                      AND C.FROMDOCTYPE='SO')
            WHERE A.Cancelled='F')
            GROUP BY Dockey, DocNo, Code, CompanyName, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount
            HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0
";
$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);


  'Step 3: Set Dataset
    if ($lDataSet->RecordCount > 0) {
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
$lDataSet->First();
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
$fc = $lDataSet->Fields->Count-1;
 
echo "<table>";
  'Step 4 : Insert Data - Master
echo "<tr>";
  lDate = CDate("January 1, 2016")
for ($x = 0; $x <= $fc; $x++) {
  BizObject.New
#Insert Header
  lMainDataSet.FindField("DocKey").value = -1
echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>";
  lMainDataSet.FindField("DocNo").value = "--IV Test--"
}
  lMainDataSet.FindField("DocDate").value = lDate
echo "</tr>";
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Code").value = "300-C0001" 'Customer Code
#Looping Dataset
  lMainDataSet.FindField("Description").value = "Sales"
while (! $lDataSet->Eof()){
   
echo "<tr>";
  'Step 5: Insert Data - Detail
    for ($x = 0; $x <= $fc; $x++) {
  'For Tax Inclusive = True with override Tax Amount
$lFN = $lDataSet->Fields->Items($x)->FieldName();
  lDetailDataSet.Append
    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>";
  lDetailDataSet.FindField("DtlKey").value = -1
    }
  lDetailDataSet.FindField("DocKey").value = -1
    echo "</tr>";
  lDetailDataSet.FindField("Account").value = "500-000" 'Sales Account Code  & can ignore if had itemcode
$lDataSet->Next();
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
}
  lDetailDataSet.FindField("Qty").value =  1
echo "</table>"."<br>";
  lDetailDataSet.FindField("Tax").value =  "SR"
}else {
  lDetailDataSet.FindField("TaxInclusive").value =  0
    echo "Record Not Found";
  lDetailDataSet.FindField("UnitPrice").value = 410.37
    }
  lDetailDataSet.FindField("Amount").value = 410.37
}
  lDetailDataSet.FindField("TaxAmt").value = 24.63
 
 
if (isset($_POST['BtnData']))
  lDetailDataSet.DisableControls
{
  lDetailDataSet.FindField("TaxInclusive").value =  1
    try
  lDetailDataSet.EnableControls
    {
 
        CheckLogin();
  lDetailDataSet.FindField("Changed").value = "F"
        echo date("d M Y h:i:s A")." - Get Data<br>";
  lDetailDataSet.Post
        GetData();
 
echo date("d M Y h:i:s A")." - Done<br>";
  'For Tax Inclusive = False with override Tax Amount
    }
  lDetailDataSet.Append
    finally
  lDetailDataSet.FindField("DtlKey").value = -1
    {
  lDetailDataSet.FindField("DocKey").value = -1
        $ComServer->Logout();
  lDetailDataSet.FindField("Account").value = "500-000"
        #free the object
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
        $ComServer = null;
  lDetailDataSet.FindField("Qty").value =  1
    }
  lDetailDataSet.FindField("Tax").value =  "SR"
}
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("UnitPrice").value = 94.43
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post


  'For With Item Code
?>
  lDetailDataSet.Append
    <form method="post">         
  lDetailDataSet.FindField("DtlKey").value = -1
        <input type="submit" name="BtnData"
  lDetailDataSet.FindField("DocKey").value = -1
                value="Get Outstanding SO List"/>
  lDetailDataSet.FindField("ItemCode").value = "ANT"
    </form>
  lDetailDataSet.FindField("Description").value = "Sales Item B"
</body>
  lDetailDataSet.FindField("Qty").value =  2
</html>
  lDetailDataSet.FindField("Tax").value = "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("UnitPrice").value = 100
  lDetailDataSet.FindField("Amount").value = 200
  lDetailDataSet.FindField("TaxAmt").value = 12
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  ComServer.Logout
  MsgBox "Done"
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Stock Item Picture====
====Example-Customer.PM.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.PM.RO Script
! Get Stock Item Picture Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg Customer.PM.RO.vbs
<!DOCTYPE html>
Call GetARPMData
<html>
<body>
Function CreateSQLAccServer
 
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
<h1>SQL Acc SDK in PHP page</h1>
End Function
 
<?php
Function GetARPMData
echo "Updated 14 Sep 2022<br>";
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
 
  'Step 1: Create Com Server object
$ComServer = null;
  Set ComServer = CreateSQLAccServer 'Create Com Server
 
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
function CheckLogin()
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
{
  END IF
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
  'Step 2: Find and Create the Report Objects
    $status = $ComServer->IsLogin();
  Set RptObject = ComServer.RptObjects.Find("Customer.PM.RO")
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value    = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("AllAgent").Value                = true
  RptObject.Params.Find("AllCompanyCategory").Value      = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value              = true
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocument").Value            = false
  RptObject.Params.Find("AllPaymentMethod").Value        = true
  'RptObject.Params.Find("AreaData").Value                = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyData").Value            = 'Not use if AllCompany is true
  'RptObject.Params.Find("CurrencyData").Value            = 'Not use if AllCurrency is true


  lDateFrom = CDate("January 01, 2017")
    if ($status == true)
  lDateTo = CDate("December 31, 2017")
    {
 
        $ComServer->Logout();
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
    }
  RptObject.Params.Find("DateTo").Value                  = lDateTo
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  RptObject.Params.Find("DocumentData").Value            = "VCOR-00049"
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
  'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
                      "ACC-0082.FDB"); #Database Name
  RptObject.Params.Find("IncludeCancelled").Value        = false
   
  'RptObject.Params.Find("PaymentMethodData").Value      = 'Not use if AllPaymentMethod is true
}
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
 
  RptObject.Params.Find("SelectDate").Value              = true
function GetData(){
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = false
    global $ComServer;
  RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
  RptObject.Params.Find("AllDocProject").Value          = true
    $lSQL = "SELECT Picture FROM ST_ITEM
  RptObject.Params.Find("AllItemProject").Value          = true
            WHERE Code='ANT' ";
  'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
  'RptObject.Params.Find("ItemProjectData").Value        = 'Not use if AllItemProject is true 
    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
 
 
  'Step 4: Perform Report calculation
    if ($lDataSet->RecordCount > 0) {
  RptObject.CalculateReport()
$lDataSet->First();
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsKnockOff")
$raw = $lDataSet->FindField('Picture')->Value();
  Set lDataSet3 = RptObject.DataSets.Find("cdsKnockOffDetail")
  MsgBox "Count " & lDataSet.RecordCount
        $b = [];
        foreach($raw as $p) {
  'Step 5 Retrieve the output
            array_push($b, chr($p));
  lDataSet.First
        }
  While (not lDataSet.eof)
 
    MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
echo '<img src=data:image/*;base64,'.base64_encode(implode($b)).' alt="My Picture" style="width:128px;height:128px">';
MsgBox "cdsKnockOff Count " & lDataSet2.RecordCount
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("FromDocKey").AsString & " " & lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("KOAmt").AsString
  lDataSet2.Next
    Wend
    MsgBox "cdsKnockOffDetail Count " & lDataSet3.RecordCount
lDataSet3.First
    While (not lDataSet3.eof)
      MsgBox lDataSet3.FindField("FromDocKey").AsString & " " & lDataSet3.FindField("DocNo").AsString & " " & lDataSet3.FindField("KOAmt").AsString
    lDataSet3.Next
    Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
}else {
    echo "Record Not Found";
    }
}


====Example-Sales.IV.RO====
if (isset($_POST['BtnData']))
{| class="mw-collapsible mw-collapsed wikitable"
{
! Sales.IV.RO Script 
    try
|-
    {
|
        CheckLogin();
<syntaxhighlight lang="vb">
        GetData();
'Copy below script & paste to notepad & name it as eg Sales.IV.RO.vbs
echo "<br>";
Call GetSalesIVData
         echo date("d M Y h:i:s A")." - Done";
     }
Function CreateSQLAccServer
    finally
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    {
End Function
        $ComServer->Logout();
        #free the object
Function GetSalesIVData
        $ComServer = null;
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
    }
  'Step 1: Create Com Server object
}
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Sales.IV.RO")
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  RptObject.Params.Find("AllAgent").Value              = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value            = false
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllDocument").Value            = true
  RptObject.Params.Find("AllItem").Value                = true
  RptObject.Params.Find("AllItemProject").Value         = true
  RptObject.Params.Find("AllLocation").Value            = true
  RptObject.Params.Find("AllStockGroup").Value          = true
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllBatch").Value              = true
  RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
  'RptObject.Params.Find("TariffData").Value            = 'Not use if TariffData is true - For Version 776 & above
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyCategoryData").Value    = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-C0001"
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true


  lDateFrom = CDate("January 01, 2017")
?>
  lDateTo = CDate("December 31, 2017")
    <form method="post">         
 
        <input type="submit" name="BtnData"
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
                 value="Get Item Picture"/>
  RptObject.Params.Find("DateTo").Value                  = lDateTo
     </form>
  'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
</body>
  'RptObject.Params.Find("DocumentData").Value            = 'Not use if AllDocument is true
</html>
  'RptObject.Params.Find("GroupBy").Value                 = 'If you wanted to grouping the data
</syntaxhighlight>
  'RptObject.Params.Find("CategoryData").Value            = 'Not use if HasCategory is false
|}
  'RptObject.Params.Find("CategoryTpl").Value            = 'For Internal use only
<div style="float: right;">  [[#top|[top]]]</div>
  RptObject.Params.Find("IncludeCancelled").Value        = false
  RptObject.Params.Find("HasCategory").Value            = false
  'RptObject.Params.Find("ItemData").Value                = 'Not use if AllItem is true
  'RptObject.Params.Find("ItemProjectData").Value        = 'Not use if AllItemProject is true
  'RptObject.Params.Find("LocationData").Value            = 'Not use if AllLocation is true
  'RptObject.Params.Find("ItemCategoryData").Value        = 'For Internal use only
  'RptObject.Params.Find("BatchData").Value              = 'Not use if AllBatch is true
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
  RptObject.Params.Find("SelectDate").Value              = true
  RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
  'RptObject.Params.Find("StockGroupData").Value          = 'Not use if AllStockGroup is true
 
 
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
  MsgBox "Count " & lDataSet.RecordCount
  'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
     MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("DocKey").AsString & " " & lDataSet2.FindField("ItemCode").AsString & " " & lDataSet2.FindField("Amount").AsString
  lDataSet2.Next
    Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.DueDocument.RO====
====Customer.Aging.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.DueDocument.RO Script
! Customer.Aging.RO Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="PHP">
'Copy below script & paste to notepad & name it as eg Customer.DueDocument.RO.vbs
<!DOCTYPE html>
Call GetData
<html>
<head>
Function CreateSQLAccServer
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
</head>
End Function
<body>
 
Function GetData
<h1>SQL Acc SDK in PHP page</h1>
Dim ComServer, RptObject, lDataSet, lDateTo
 
  'Step 1: Create Com Server object
<?php
  Set ComServer = CreateSQLAccServer 'Create Com Server
echo "Updated 26 Sep 2022<br>";
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
 
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
$ComServer = null;
  END IF
 
function CheckLogin()
  'Step 2: Find and Create the Report Objects
{
  Set RptObject = ComServer.RptObjects.Find("Customer.DueDocument.RO")
     global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
  'Step 3: Spool parameters
    $status = $ComServer->IsLogin();
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
 
  RptObject.Params.Find("AllAgent").Value              = true
    if ($status == true)
  RptObject.Params.Find("AllArea").Value                = true
    {
  RptObject.Params.Find("AllCompany").Value            = false
         #$ComServer->Logout();
  RptObject.Params.Find("AllCompanyCategory").Value     = true
    }
  RptObject.Params.Find("AllCurrency").Value            = true
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
  RptObject.Params.Find("AllDocProject").Value          = true
                      "C:\eStream\SQLAccounting\Share\Default.DCF", #DCF file
  RptObject.Params.Find("AllItemProject").Value        = true
                      "ACC-0082.FDB"); #Database Name
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-A0003"
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("GroupBy").Value              = 'If you wanted to grouping the data
  'RptObject.Params.Find("ItemProjectData").Value      = 'Not use if AllItemProject is true
  RptObject.Params.Find("PrintContra").Value            = true
  RptObject.Params.Find("PrintCreditNote").Value        = true
  RptObject.Params.Find("PrintDebitNote").Value         = true
  RptObject.Params.Find("PrintInvoice").Value          = true
  RptObject.Params.Find("PrintOverDue").Value          = true
  RptObject.Params.Find("PrintUnDue").Value            = true
  RptObject.Params.Find("ShowForeignCurrency").Value    = true
  RptObject.Params.Find("ShowLocalCurrency").Value      = true
  RptObject.Params.Find("SortBy").Value                = "PostDate;DocNo;Code"
 
  lDateTo = CDate("April 12, 2018")
 
  RptObject.Params.Find("DateTo").Value                = lDateTo
  RptObject.Params.Find("IncludePDCheque").Value        = true 
      
      
  'Step 4: Perform Report calculation
}
  RptObject.CalculateReport()
 
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
function SetGrid($DataSet){
  MsgBox "Count " & lDataSet.RecordCount
echo "<table>";
   
echo "<tr>";
  'Step 5 Retrieve the output
    $DataSet->First();
  lDataSet.First
$fc = $DataSet->Fields->Count-1;
  While (not lDataSet.eof)
for ($x = 0; $x <= $fc; $x++) {
    MsgBox "Dockey " & lDataSet.FindField("DocKey").AsString
#Insert Header
MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
echo "<td>".$DataSet->Fields->Items($x)->FieldName()."</td>";
MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
}
MsgBox "Outstanding " & lDataSet.FindField("Outstanding").AsString
echo "</tr>";
MsgBox "Code " & lDataSet.FindField("Code").AsString
lDataSet.Next
#Looping Dataset
  Wend
while (! $DataSet->Eof()){
End Function
echo "<tr>";
    for ($x = 0; $x <= $fc; $x++) {
$lFN = $DataSet->Fields->Items($x)->FieldName();
    echo "<td>".$DataSet->FindField($lFN)->AsString()."</td>";
    }
    echo "</tr>";
$DataSet->Next();
}
    echo "</table>"."<br>";
}
 
function GetData(){
global $ComServer;
    $lSQL = '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>
        <FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>
            <FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>
            <FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>
            </FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>
            <ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>
            <ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>
            <ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>
            <ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>
            <ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>
            <ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>
            </ROWDATA></DATAPACKET>';
$lRptVar = $ComServer->RptObjects->Find('Customer.Aging.RO');
$lRptVar->Params->Find('ActualGroupBy')->AsString = 'Code;CompanyName'; #Fixed
# $lRptVar->Params->Find('AgentData')->AsBlob              = ; #Not use if AllAgent is True
    $lRptVar->Params->Find('AgingData')->AsString          = $lSQL;
    $lRptVar->Params->Find('AgingDate')->AsDate            = '23 Sep 2022';
    $lRptVar->Params->Find('AgingOn')->AsString            = 'I'; #Fixed
    $lRptVar->Params->Find('AllAgent')->AsBoolean          = True;
    $lRptVar->Params->Find('AllArea')->AsBoolean            = True;
    $lRptVar->Params->Find('AllCompany')->AsBoolean        = True;
    $lRptVar->Params->Find('AllCompanyCategory')->AsBoolean = True;
    $lRptVar->Params->Find('AllControlAccount')->AsBoolean  = True;
    $lRptVar->Params->Find('AllCurrency')->AsBoolean        = True;
    $lRptVar->Params->Find('AllDocProject')->AsBoolean      = True;
#    $lRptVar->Params->Find('AreaData')->AsBlob            = ; #Not use if AllArea is True
#    $lRptVar->Params->Find('CompanyCategoryData')->AsBlob = ; #Not use if AllCompanyCategory is True
#    $lRptVar->Params->Find('CompanyData')->AsBlob        = ; #Not use if AllCompany is True
#    $lRptVar->Params->Find('ControlAccountData')->AsBlob = ; #Not use if AllControlAccount is True
#    $lRptVar->Params->Find('CurrencyData')->AsBlob        = ; #Not use if AllCurrency is True
#    $lRptVar->Params->Find('DocProjectData')->AsBlob      = ; #Not use if AllDocProject is True
    $lRptVar->Params->Find('FilterPostDate')->AsBoolean      = True;
#    $lRptVar->Params->Find('GroupBy
    $lRptVar->Params->Find('IncludePDC')->AsBoolean        = False;
    $lRptVar->Params->Find('IncludeZeroBalance')->AsBoolean = False;
    $lRptVar->Params->Find('SortBy')->AsString              = 'Code;CompanyName';
    $lRptVar->Params->Find('DateTo')->AsDate                = '23 Sep 2022';
    $lRptVar->Params->Find('IncludeKnockedOffDetail')->AsBoolean = False;
$lRptVar->CalculateReport();
$lDataSetHdr = $lRptVar->DataSets->Find('cdsAgingHeader');
$lDataSet = $lRptVar->DataSets->Find('cdsMain');
$lDataSet2 = $lRptVar->DataSets->Find('cdsDocument');
$lDataSetCO = $lRptVar->DataSets->Find('cdsCompany');
 
    if ($lDataSet->RecordCount > 0) {
echo "Header"."<br>";
SetGrid($lDataSetHdr);
echo "Main Data"."<br>";
SetGrid($lDataSet);
echo "Detail Invoice"."<br>";
SetGrid($lDataSet2);
 
echo "Company Information"."<br>";
SetGrid($lDataSetCO);
 
}else {
    echo "Record Not Found";
    }
}
 
if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
echo "<br>";
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        #$ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Get AR Aging"/>
    </form>
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<br>


<div style="float: right;">  [[#top|[top]]]</div>
===Node JS===
: Module Require in Node JS
:- Winax (Mandatory) -> npm install winax
 
====Common====
* Common.js file for example code


====Example-Customer.IV.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.IV.RO Script 
! Common Function
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="nodejsrepl">
'Copy below script & paste to notepad & name it as eg Customer.IV.RO.vbs
/* Updated 31 Jul 2023 */
Call GetData
var winax = require('C:\\node_js\\node_modules\\winax'); /* Path where you install winax */
var cp = require('child_process');
Function CreateSQLAccServer
 
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
exports.KillApp = function KillApp(){
End Function
cp.exec('start cmd.exe /C "taskkill /IM "SQLACC.exe" /F"');
   
}
Function GetData
 
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
exports.CreateSQLAccServer = function CreateSQLAccServer() {  
  'Step 1: Create Com Server object
  var ComServer;
   Set ComServer = CreateSQLAccServer 'Create Com Server
   ComServer = new winax.Object('SQLAcc.BizApp');
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   if (!ComServer.IsLogin) {          /* check whether user has logon */
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
     ComServer.Login('ADMIN', 'ADMIN', /* UserName, Password */
   END IF
/* 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', */
'D:\\Happy\\DB\\DEFAULT.DCF', /* DCF File */
   'Step 2: Find and Create the Report Objects
'ACC-0024.FDB'); /* FDB Name */
   Set RptObject = ComServer.RptObjects.Find("Customer.IV.RO")  
  }
   return ComServer;
  'Step 3: Spool parameters
}
  'RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is true
 
  'RptObject.Params.Find("CompanyCategoryData").Value   = 'Not use if AllCompanyCategory is true
exports.ShowResult = function ShowResult(ADataset){
  RptObject.Params.Find("AllAgent").Value              = true
   var fc, fn, fv, lresult;
   RptObject.Params.Find("AllCompanyCategory").Value     = true
   ADataset.First;
  RptObject.Params.Find("AllArea").Value                = true
  while (!ADataset.Eof){
  RptObject.Params.Find("AllCompany").Value            = true
  fc = ADataset.Fields.Count;
  RptObject.Params.Find("AllCurrency").Value            = true
  for (let i = 0; i < fc; i++) {
  RptObject.Params.Find("AllDocument").Value            = false
  fn = ADataset.Fields.Items(i).FieldName;
  RptObject.Params.Find("AllPaymentMethod").Value      = true
          fv = ADataset.FindField(fn).AsString;
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  lresult =  "Index : "+ i + " FieldName : " + fn + " Value : " + fv;
   'RptObject.Params.Find("CompanyData").Value          = 'Not use if AllCompany is true
  console.log(lresult);
   'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
      }
  console.log("====");
      ADataset.Next();  
   }
}
 
exports.ShowMsg = function ShowMsgShowMsg(AMsg){
     try {
        var WSH = new winax.Object('WScript.Shell');
        WSH.popup(AMsg);
    } catch (e) {
        console.log(e);
    }
}
 
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Company Profile====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Company Profile
|-
|
<syntaxhighlight lang="nodejsrepl">
/* Updated 22 Jul 2023 */
var Common = require('./Common');
var ComServer, lDataSet;
 
function GetData() {
  var lSQL;
  lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, ";
  lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, ";
   lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE ";
   lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    
   lDateFrom = CDate("January 01, 2017")
   Common.ShowResult(lDataSet);
  lDateTo = CDate("December 31, 2017")
}
 
 
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
try{
  RptObject.Params.Find("DateTo").Value                  = lDateTo
ComServer = Common.CreateSQLAccServer();
  RptObject.Params.Find("DocumentData").Value            =  "IV-00012"
GetData();
  'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
ComServer.Logout();
  RptObject.Params.Find("IncludeCancelled").Value        = true
} catch(e){
  'RptObject.Params.Find("PaymentMethodData").Value      = 'Not use if AllPaymentMethod is true
console.error(e.message)
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
} finally {
  RptObject.Params.Find("SelectDate").Value              = true
Common.KillApp();
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = true
}
  RptObject.Params.Find("SortBy").Value                  = "DocDate;DocNo;Code"
</syntaxhighlight>
  RptObject.Params.Find("AllDocProject").Value          = true
|}
  RptObject.Params.Find("AllItemProject").Value          = true
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("ItemProjectData  ").Value      = 'Not use if AllItemProject is true
   
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
  MsgBox "Count " & lDataSet.RecordCount
  'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
MsgBox "PaymentAmt " & lDataSet.FindField("PaymentAmt").AsString
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox "Account " & lDataSet2.FindField("Account").AsString
  MsgBox "Description " & lDataSet2.FindField("Description").AsString
  MsgBox "Amount " & lDataSet2.FindField("Amount").AsString
  lDataSet2.Next
    Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Sales.OutstandingSO.RO====
====Complete Post====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Sales.OutstandingSO.RO Script 
! Complete Post
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="nodejsrepl">
'Copy below script & paste to notepad & name it as eg Sales.OutstandingSO.RO.vbs
/* Updated 22 Jul 2023
Call GetData
This will doing following posting
01. Cash Sales
Function CreateSQLAccServer
02. Sales Credit Note
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
03. Customer Payment With Knock off
End Function
04. Edit Credit Note Posted in Step 02 & Knock Off
05. Customer Refund to Knock off Credit Note
Function GetData
*/
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
var Common = require('./Common');
  'Step 1: Create Com Server object
var ComServer;
   Set ComServer = CreateSQLAccServer 'Create Com Server
 
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
function PostDataCS() {
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  var BizObject, lMain, lDetail;
   END IF
   BizObject = ComServer.BizObjects.Find('SL_CS') ;
 
   'Step 2: Find and Create the Report Objects
   lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
   Set RptObject = ComServer.RptObjects.Find("Sales.OutstandingSO.RO")  
   lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */
 
   'Step 3: Spool parameters
  /*Begin Looping yr data*/
   'RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is true
   /*Insert Data - Master*/
   'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
   BizObject.New();
   'RptObject.Params.Find("LocationData").Value        = 'Not use if AllLocation is true
  lMain.FindField('DocNo').AsString      = "--CS Test--";
   'RptObject.Params.Find("StockGroupData").Value      = 'Not use if AllStockGroup is true
  lMain.FindField('DocDate').value        = "20/12/2022";
   RptObject.Params.Find("AllAgent").Value              = true
   lMain.FindField('PostDate').value      = "20/12/2022";
   RptObject.Params.Find("AllArea").Value              = true
  lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
   RptObject.Params.Find("AllCompany").Value           = true
  lMain.FindField('CompanyName').AsString = "Cash Sales"
   RptObject.Params.Find("AllDocument").Value          = false
   lMain.FindField('Address1').AsString    = ""; /*Optional*/
   RptObject.Params.Find("AllItem").Value              = true
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
   RptObject.Params.Find("AllItemProject").Value        = true
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
   'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
   lMain.FindField('Address4').AsString    = ""; /*Optional*/
   'RptObject.Params.Find("CompanyData").Value          = 'Not use if AllCompany is true
   lMain.FindField('Phone1').AsString      = ""; /*Optional*/
   RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
   lMain.FindField('Description').AsString = "Sales";
   'RptObject.Params.Find("TariffData").Value            = 'Not use if TariffData is true - For Version 776 & above
 
 
  /*Insert Data - Detail*/
  /*For Tax Inclusive = True with override Tax Amount*/
   lDetail.Append();
  lDetail.FindField('Seq').value           = 1;
   lDetail.FindField('Account').AsString    = "500-000"; /*Sales Account*/
  lDetail.FindField('Description').AsString = "Sales Item A";
   lDetail.FindField('Qty').AsFloat          = 1;
   lDetail.FindField('Tax').AsString        = "SV";
  lDetail.FindField('TaxRate').AsString    = "6%";
   lDetail.FindField('TaxInclusive').value  = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 435;
   lDetail.FindField('Amount').AsFloat      = 410.37; /*Exclding Tax Amt*/
   lDetail.FindField('TaxAmt').AsFloat      = 24.63;
 
   lDetail.DisableControls();
  lDetail.FindField('TaxInclusive').value  = 1;
  lDetail.EnableControls();
    
    
   lDateFrom = CDate("January 01, 2017")
   lDetail.Post();
  lDateTo = CDate("December 31, 2017")  
    
    
   'RptObject.Params.Find("DateFrom").Value              = lDateFrom
   /*For Tax Inclusive = False with override Tax Amount*/
   'RptObject.Params.Find("DateTo").Value                = lDateTo
  lDetail.Append();
   'RptObject.Params.Find("DeliveryDateFrom").Value      = lDateFrom
  lDetail.FindField('Seq').value            = 2;
   'RptObject.Params.Find("DeliveryDateTo").Value        = lDateTo
   lDetail.FindField('Account').AsString    = "500-000";
   RptObject.Params.Find("DocumentData").Value          = "SO-00007"& vbCRLF & "SO-00009"
  lDetail.FindField('Description').AsString = "Sales Item B";
   'RptObject.Params.Find("GroupBy").Value              = 'If you wanted to grouping the data
   lDetail.FindField('Qty').AsFloat          = 1;
   RptObject.Params.Find("IncludeCancelled").Value      = false
   lDetail.FindField('Tax').AsString        = "SV";
   'RptObject.Params.Find("ItemData").Value              = 'Not use if AllItem is true
   lDetail.FindField('TaxRate').AsString    = "6%";
   RptObject.Params.Find("PrintFulfilledItem").Value    = true 'Print transfered info
   lDetail.FindField('TaxInclusive').value  = 0;
   RptObject.Params.Find("PrintOutstandingItem").Value   = true 'Print untransfer info
   lDetail.FindField('UnitPrice').AsFloat    = 94.43;
   'RptObject.Params.Find("ItemProjectData").Value      = 'Not use if AllItemProject is true
   lDetail.FindField('Amount').AsFloat      = 94.43;
   RptObject.Params.Find("SelectDate").Value            = false
   lDetail.FindField('TaxAmt').AsFloat      = 5.66;
   RptObject.Params.Find("SelectDeliveryDate").Value    = false
   lDetail.Post()
   RptObject.Params.Find("SortBy").Value                = "DocDate;DocNo;Code"
 
   RptObject.Params.Find("AllDocProject").Value         = true
   /*For With Item Code*/
   RptObject.Params.Find("AllLocation").Value            = true
   lDetail.Append();
   RptObject.Params.Find("AllCompanyCategory").Value    = true
  lDetail.FindField('Seq').value            = 3;
   RptObject.Params.Find("AllBatch").Value              = true
   lDetail.FindField('ItemCode').AsString    = "ANT";
   RptObject.Params.Find("HasCategory").Value            = false
   lDetail.FindField('Description').AsString = "Sales Item B";
   RptObject.Params.Find("AllStockGroup").Value          = true
   /*lDetail.FindField('Account').AsString    = "500-000"; If you wanted override the Sales Account Code*/
   'RptObject.Params.Find("CategoryData").Value          = 'For Internal use only
   lDetail.FindField('Qty').AsFloat         = 2;
   'RptObject.Params.Find("CategoryTpl").Value          = 'For Internal use only
   lDetail.FindField('UOM').AsString        = "UNIT";
   'RptObject.Params.Find("ItemCategoryData").Value      = 'For Internal use only
   /*lDetail.FindField('DISC').AsString        = "5%+3"; Optional (eg 5% plus 3 Discount)*/
   'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
   lDetail.FindField('Tax').AsString        = "SV";
   'RptObject.Params.Find("BatchData").Value            = 'Not use if AllBatch is true
   lDetail.FindField('TaxRate').AsString    = "6%";
   RptObject.Params.Find("TranferDocFilterDate").Value   = false
   lDetail.FindField('TaxInclusive').value  = 0;
 
   lDetail.FindField('UnitPrice').AsFloat    = 100;
   lDetail.FindField('Amount').AsFloat      = 200;
   lDetail.FindField('TaxAmt').AsFloat      = 12;
   lDetail.Post();
 
  /*Save Document*/
   BizObject.Save();
   BizObject.Close(); 
}
 
function PostDataPM() {
   var BizObject, lMain, lDetail, v;
      
      
   'Step 4: Perform Report calculation
   BizObject = ComServer.BizObjects.Find('AR_PM') ;
  RptObject.CalculateReport()
 
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
   Set lDataSet2 = RptObject.DataSets.Find("cdsTransfer")
   lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
   MsgBox "Count " & lDataSet.RecordCount
    
  BizObject.New();
   'Step 5 Retrieve the output
    
   lDataSet.First
   lMain.FindField('DocNo').AsString        = "--PM Test--";
  While (not lDataSet.eof)
  lMain.FindField('Code').AsString         = "300-C0001";
    MsgBox "DocKey " & lDataSet.FindField("DocKey").AsString
  lMain.FindField('DocDate').value          = "20/12/2022";
MsgBox "DtlKey " & lDataSet.FindField("Dtlkey").AsString
  lMain.FindField('PostDate').value        = "20/12/2022";
MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
  lMain.FindField('Description').AsString   = "Payment for A/";
MsgBox "Item Code " & lDataSet.FindField("ItemCode").AsString
  lMain.FindField('PaymentMethod').AsString = "320-000"; /*Bank or Cash Account*/
MsgBox "Org Qty " & lDataSet.FindField("SQty").AsString
  lMain.FindField('ChequeNumber').AsString = "";
MsgBox "Outstanding Qty " & lDataSet.FindField("OutstandingQty").AsString
  lMain.FindField('BankCharge').AsFloat    = 0;
  lMain.FindField('DocAmt').AsFloat        = 200.00;
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
  lMain.FindField('Cancelled').AsString     = "F";
lDataSet2.First
 
    While (not lDataSet2.eof)
  v = ComServer.CreateOleVariantArray(2);
      MsgBox "FromDocKey " & lDataSet2.FindField("FromDocKey").AsString
  v.SetItem(0, 'IV'); /*Knock Off DocType IV or DN*/
  MsgBox "FromDtlKey " & lDataSet2.FindField("FromDtlkey").AsString
  v.SetItem(1, '--CS Test--'); /*Knock Off DocNo*/
  MsgBox "DocType " & lDataSet2.FindField("DocType").AsString
 
  MsgBox "DocNo " & lDataSet2.FindField("DocNo").AsString
  if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
  MsgBox "DocDate " & lDataSet2.FindField("DocDate").AsString
      lDetail.Edit();
  MsgBox "Transfer Qty " & lDataSet2.FindField("TransferQty").AsString
      lDetail.FindField('KOAmt').AsFloat    = "147.09"; /*Partial Knock Off*/  
  lDataSet2.Next
      lDetail.FindField('KnockOff').AsString = 'T';
     Wend
      lDetail.Post();
lDataSet.Next
  }
   Wend
     /* Save document */ 
End Function
  BizObject.Save();
</syntaxhighlight>
   BizObject.Close();
|}
}


<div style="float: right;">  [[#top|[top]]]</div>
function PostDataCN() {
  var BizObject, lMain, lDetail;
  BizObject = ComServer.BizObjects.Find('SL_CN') ;


====Example-Common.PaymentMethod.RO====
   lMain   = BizObject.DataSets.Find('MainDataSet'); /*lMain contains master data*/
{| class="mw-collapsible mw-collapsed wikitable"
   lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */
! Common.PaymentMethod.RO Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg Common.PaymentMethod.RO.vbs
Call GetInfo
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetInfo
Dim ComServer, RptObject, lDataSet1, lDataSet2
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
   END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.PaymentMethod.RO")  
   
   'Step 3: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsPaymentAccount") 'You can link with lDataSet1 using Code to get the description


   MsgBox "Count " & lDataSet1.RecordCount
   /*Begin Looping yr data*/
  /*Insert Data - Master*/
   'Step 5 Retrieve the output
  BizObject.New();
   lDataSet1.First
  lMain.FindField('DocNo').AsString      = "--CN Test--";
   While (not lDataSet1.eof)
  lMain.FindField('DocDate').value        = "21/12/2022";
MsgBox "Code : " & lDataSet1.FindField("Code").AsString  
  lMain.FindField('PostDate').value      = "21/12/2022";
lDataSet1.Next
   lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
   Wend   
   lMain.FindField('CompanyName').AsString = "Cash Sales"
   lMain.FindField('Address1').AsString    = ""; /*Optional*/
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
  lMain.FindField('Address4').AsString   = ""; /*Optional*/
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
   lMain.FindField('Description').AsString = "Sales Returned";
    
    
   MsgBox "Count " & lDataSet2.RecordCount
   /*Insert Data - Detail*/ 
  /*For With Item Code*/
  lDetail.Append();
  lDetail.FindField('Seq').value            = 1;
  lDetail.FindField('ItemCode').AsString    = "ANT";
  lDetail.FindField('Description').AsString  = "Sales Item B";
  lDetail.FindField('Description2').AsString = "Product Spoil"; /*Reason*/
  lDetail.FindField('Remark1').AsString      = "--IV Test--"; /*Invoice No*/
  lDetail.FindField('Remark2').AsString      = "20 Dec 2022"; /*Invoide Date*/
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('UOM').AsString        = "UNIT";
  lDetail.FindField('Tax').AsString        = "SV";
  lDetail.FindField('TaxRate').AsString    = "6%";
  lDetail.FindField('TaxInclusive').value  = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 100;
  lDetail.FindField('Amount').AsFloat      = 100;
  lDetail.FindField('TaxAmt').AsFloat      = 6;
  lDetail.Post();
    
    
   lDataSet2.First
   /*Save Document*/
   While (not lDataSet2.eof)
   BizObject.Save();
MsgBox "Code : " & lDataSet2.FindField("Code").AsString
  BizObject.Close()
MsgBox "Description : " & lDataSet2.FindField("Description").AsString
}
lDataSet2.Next
 
   Wend   
function PostKnockIVCN() {
End Function
   var BizObject, lMain, lDetail, v, lDocNo, lDocKey;
</syntaxhighlight>
   
|}
  BizObject = ComServer.BizObjects.Find('AR_CN') ;


<div style="float: right;">   [[#top|[top]]]</div>
  lMain  = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
 
  /* Find CN Number */
  lDocNo = "--CN Test--"
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
  BizObject.Params.Find('DocKey').Value = lDocKey;
 
  if (lDocKey != null) {
  BizObject.Open();
  BizObject.Edit();
  lMain.Edit();
 
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType IV or DN*/
  v.SetItem(1, '--CS Test--'); /*Knock Off DocNo*/
 
  if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
  lDetail.Edit();
      lDetail.FindField('KOAmt').AsFloat    = "100"; /*Partial Knock Off*/    
      lDetail.FindField('KnockOff').AsString = 'T';
      lDetail.Post();
  }
    /* Save document */
  BizObject.Save();
  BizObject.Close();
  }
}


====Example-Common.Agent.RO====
function PostDataCF() {
{| class="mw-collapsible mw-collapsed wikitable"
  var BizObject, lMain, lDetail, v;
! Common.Agent.RO Script  
   
|-
  BizObject = ComServer.BizObjects.Find('AR_CF') ;
|
 
<syntaxhighlight lang="vb">
  lMain  = BizObject.DataSets.Find('MainDataSet'); /*lMain contains master data*/
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
  lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
Call GetInfo
 
  BizObject.New();
Function CreateSQLAccServer
 
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   lMain.FindField('DocNo').AsString        = "--CF Test--";
End Function
   lMain.FindField('Code').AsString          = "300-C0001";
   lMain.FindField('DocDate').value          = "24/12/2022";
Function GetInfo
   lMain.FindField('PostDate').value        = "24/12/2022";
Dim ComServer, RptObject, lDataSet1
  lMain.FindField('Description').AsString  = "Payment for A/";
   'Step 1: Create Com Server object
  lMain.FindField('PaymentMethod').AsString = "320-000"; /*Bank or Cash Account*/
   Set ComServer = CreateSQLAccServer 'Create Com Server
   lMain.FindField('ChequeNumber').AsString = "";
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   lMain.FindField('BankCharge').AsFloat    = 0;
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   lMain.FindField('DocAmt').AsFloat        = 6.00;
   END IF
  lMain.FindField('Cancelled').AsString    = "F";
   
 
   'Step 2: Find and Create the Report Objects
   v = ComServer.CreateOleVariantArray(2);
   Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO")
   v.SetItem(0, 'CN'); /*Knock Off DocType*/
   v.SetItem(1, '--CN Test--'); /*Knock Off DocNo*/
   'Step 3: Perform Report calculation
   RptObject.CalculateReport()
   Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
    
    
   MsgBox "Count " & lDataSet1.RecordCount
   if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
   
      lDetail.Edit();
   'Step 5 Retrieve the output
      lDetail.FindField('KOAmt').AsFloat    = "4"; /*Partial Knock Off*/  
   lDataSet1.First
      lDetail.FindField('KnockOff').AsString = 'T';
  While (not lDataSet1.eof)
      lDetail.Post();
MsgBox "Code : " & lDataSet1.FindField("Code").AsString
  }
MsgBox "Description : " & lDataSet1.FindField("Description").AsString
    /* Save document */  
lDataSet1.Next
   BizObject.Save();
  Wend     
   BizObject.Close();
End Function
}
 
try{
ComServer = Common.CreateSQLAccServer();
console.log("Posting Cash Sales");
    PostDataCS();
    console.log("Posting Payment");
    PostDataPM();
    console.log("Posting Sales CN");
    PostDataCN();
    console.log("Posting Knock Off CN");
    PostKnockIVCN();
    console.log("Posting Customer Refund");
    PostDataCF();
    console.log("Done");
ComServer.Logout();
} catch(e){
console.error(e.message)
} finally {
Common.KillApp();
}
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Stock.Item.RO====
====Get Picture & Description3(Rich Text)====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Stock.Item.RO Script
! Get Picture & Description3(Rich Text) Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="nodejsrepl">
'Copy below script & paste to notepad & name it as eg Stock.Item.RO.vbs
/* Updated 31 Jul 2023 */
Call GetInfo
var Common = require('./Common');
   
var ComServer, lDataSet;
Function CreateSQLAccServer
const fs = require('fs');
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
 
End Function
function saveImage(filename, data){
   
  var myBuffer = new Buffer.alloc(data.length);
Function GetInfo
  for (var i = 0; i < data.length; i++) {
Dim ComServer, RptObject, lDataSet1, lDataSet2, lDateFrom, lDateTo
      myBuffer[i] = data[i];
   'Step 1 Create Com Server object
  }
  fs.writeFile(filename, myBuffer, function(err) {
      if(err) {
          console.log(err);
      } else {
          console.log("The Image file was saved!");
      }
  });
}
 
function ExpFile(AFName, AData){
const FN = new console.Console(fs.createWriteStream(AFName));
    FN.log(AData);
}
 
function GetData() {
  var lSQL, txt, rtf;
  lSQL = "SELECT Description3, Picture FROM ST_ITEM ";
  lSQL = lSQL + "WHERE Code='ANT' ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL); 
 
  lDataSet.First;
  rtf = lDataSet.FindField('Description3').AsString;
  console.log(rtf);
 
  ExpFile('./output.rtf', rtf);
 
  txt = ComServer.Utility.RichTextToPlainText(rtf);
  Common.ShowMsg(txt);
  /* console.log(txt); <= Not support Unicode */
 
  ExpFile('./output.txt', txt); 
  console.log('Done Export');
 
  saveImage("./Pic.jpg", lDataSet.FindField('Picture').Value);
}
 
try{
ComServer = Common.CreateSQLAccServer();
GetData();
ComServer.Logout();
} catch(e){
console.error(e.message)
} finally {
Common.KillApp();
}
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
====Get Stock Qty Balance====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Picture & Description3(Rich Text) Script
|-
|
<syntaxhighlight lang="nodejsrepl">
/* Updated 18 Jan 2024 */
var Common = require('./Common');
var ComServer;
 
function GetListData() {
  var lSQL, lDataSet;
  lSQL = "SELECT  ItemCode, Location, Batch, Sum(Qty) Qty  FROM ST_TR  ";
  lSQL = lSQL + "WHERE PostDate<='31 Dec 2019' ";
  lSQL = lSQL + "AND ITEMCODE ='ANT' ";
  lSQL = lSQL + "GROUP BY ItemCode, Location, Batch ";
 
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);
 
  Common.ShowResult(lDataSet);
}
 
try{
ComServer = Common.CreateSQLAccServer();
GetListData();
ComServer.Logout();
} catch(e){
console.error(e.message)
} finally {
Common.KillApp();
}
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<br />
 
===VB Script===
====Get Company Profile====
{| class="mw-collapsible mw-collapsed wikitable"
! Company Profile Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
Call GetCoInfo
   
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
   
Function GetCoInfo
Dim ComServer, RptObject, lDataSet
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C\DB\SQLAcc.DCF", "ACC-0002.FDB"  
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   END IF
   END IF
   
   
   'Step 2 Find and Create the Report Objects
   'Step 2: Find and Create the Report Objects
   Set RptObject = ComServer.RptObjects.Find("Stock.Item.RO")  
   Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO")  
   
   
   'Step 3 Spool parameters
   'Step 3: Perform Report calculation  
    RptObject.Params.Find("AllItem").AsBoolean              = true
   RptObject.CalculateReport()
    RptObject.Params.Find("AllStockGroup").AsBoolean        = true
   Set lDataSet = RptObject.DataSets.Find("cdsProfile")
    RptObject.Params.Find("AllCustomerPriceTag").AsBoolean  = true
 
    RptObject.Params.Find("AllSupplierPriceTag").AsBoolean  = true
   MsgBox "Count " & lDataSet.RecordCount
    'RptObject.Params.Find("CategoryData").AsBlob            =  'Not use
    'RptObject.Params.Find("CategoryTpl").AsBlob            =  'Not use
    'RptObject.Params.Find("CustomerPriceTagData").AsBlob    =  'Not use if AllCustomerPriceTag is True
    'RptObject.Params.Find("SupplierPriceTagData").AsBlob    =  'Not use if AllSupplierPriceTag is True
    lDateFrom = CDate("January 01, 2017")
    lDateTo = CDate("December 31, 2017")
 
    'RptObject.Params.Find("DateFrom").AsDate                = lDateFrom 'Not use if SelectDate is False
    'RptObject.Params.Find("DateTo").AsDate                  = lDateTo
    RptObject.Params.Find("HasAltStockItem").AsBoolean      = false
    RptObject.Params.Find("HasBarcode").AsBoolean          = false
    RptObject.Params.Find("HasBOM").AsBoolean              = false
    RptObject.Params.Find("HasCategory").AsBoolean          = false
    RptObject.Params.Find("HasCustomerItem").AsBoolean      = false
    RptObject.Params.Find("HasOpeningBalance").AsBoolean    = false
    RptObject.Params.Find("HasPurchasePrice").AsBoolean    = false
    RptObject.Params.Find("HasSellingPrice").AsBoolean      = false
    RptObject.Params.Find("HasSupplierItem").AsBoolean      = false
    'RptObject.Params.Find("ItemData").AsBlob                = 'Not use if AllItem is True
    'RptObject.Params.Find("ItemCategoryData").AsBlob        = 'Not use if SelectCategory is False
    RptObject.Params.Find("PrintActive").AsBoolean          = true
    RptObject.Params.Find("PrintInActive").AsBoolean        = true
    RptObject.Params.Find("PrintNonStockControl").AsBoolean = true
    RptObject.Params.Find("PrintStockControl").AsBoolean    = true
    RptObject.Params.Find("SelectCategory").AsBoolean      = false
    RptObject.Params.Find("SelectDate").AsBoolean          = false
    RptObject.Params.Find("SortBy").AsString                  = "Code"
    'RptObject.Params.Find("StockGroupData").AsBlob        =  'Not use if AllStockGroup is True 
   
  'Step 4 Perform Report calculation  
   RptObject.CalculateReport()
   Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsUOM") ' To link Master Data use Code
   MsgBox "Count " & lDataSet1.RecordCount
   
   
   'Step 5 Retrieve the output  
   'Step 5 Retrieve the output  
   lDataSet1.First
   lDataSet.First
   While (not lDataSet1.eof)
   While (not lDataSet.eof)
    MsgBox "Code " & lDataSet1.FindField("Code").AsString  
MsgBox "Company Name : " & lDataSet.FindField("CompanyName").AsString  
    MsgBox "Description " & lDataSet1.FindField("Description").AsString  
    MsgBox "Balance Qty " & lDataSet1.FindField("BalSQty").AsString  
MsgBox "Remark : " & lDataSet.FindField("Remark").AsString
    lDataSet1.Next
 
  Wend
MsgBox "ROC No : " & lDataSet.FindField("RegisterNo").AsString


  MsgBox "Count " & lDataSet2.RecordCount
MsgBox "GST No : " & lDataSet.FindField("GSTNo").AsString
  lDataSet2.First
  While (not lDataSet2.eof)
MsgBox "Address 1 : " & lDataSet.FindField("Address1").AsString
    MsgBox "Code " & lDataSet2.FindField("Code").AsString  
MsgBox "UOM " & lDataSet2.FindField("UOM").AsString  
MsgBox "Address 2 : " & lDataSet.FindField("Address2").AsString
MsgBox "Rate " & lDataSet2.FindField("Rate").AsString  
MsgBox "RefPrice " & lDataSet2.FindField("RefPrice").AsString
MsgBox "Address 3 : " & lDataSet.FindField("Address3").AsString
    lDataSet2.Next
   Wend
MsgBox "Address 4 : " & lDataSet.FindField("Address4").AsString
MsgBox "Attention : " & lDataSet.FindField("Attention").AsString
MsgBox "Phone : " & lDataSet.FindField("Phone1").AsString
MsgBox "Fax : " & lDataSet.FindField("Fax1").AsString
MsgBox "E-Mail : " & lDataSet.FindField("EMail").AsString
lDataSet.Next
   Wend
 
  'Step 6 : Logout after done 
  ComServer.Logout   
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 5,235: Line 6,349:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Stock Item Balance====
====Complete Post====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Get Stock Item Balance Script   
! SL_CS, AR_PM, SL_CN & AR_CN Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Updated 13 Sep 2018
'Copy below script & paste to notepad & name it as eg ItemBalance.vbs
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
'This will doing following posting
'01. Cash Sales
'02. Sales Credit Note
'03. Customer Payment With Knock off
'04. Edit Credit Note Posted in Step 02 & Knock Off
Call CheckLogin
Call CheckLogin
Call GetData
Call InsertData


Dim ComServer
Dim ComServer
Line 5,261: Line 6,380:
End Function
End Function


Function GetData
Function InsertData
Dim lDataSet, lSQL
Dim BizObject, lMain, lDetail, lDate
   lSQL = "SELECT A.Location, A.Batch, A.ItemCode, B.Description, Sum(A.Qty) Qty FROM ST_TR A "
  'Step 2: Find and Create the Biz Objects
  lSQL = lSQL & "INNER JOIN ST_ITEM B ON (A.ITEMCODE=B.CODE) "
   Set BizObject = ComServer.BizObjects.Find("SL_CS")  
  lSQL = lSQL & "WHERE B.IsActive='T' "
 
   lSQL = lSQL & "AND A.PostDate <= '31 Dec 2017' "
   'Step 3: Set Dataset
   lSQL = lSQL & "AND A.ItemCode= 'ANT' "
   Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
   lSQL = lSQL & "GROUP by A.Location, A.Batch, A.ItemCode, B.Description"
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    
   lDataSet.First
   'Begin Looping yr data
  While (not lDataSet.eof)
   'Step 4 : Insert Data - Master
    MsgBox "Location : " & lDataSet.FindField("Location").AsString
   lDate = CDate("January 1, 2017")
    MsgBox "Batch : " & lDataSet.FindField("Batch").AsString
   BizObject.New
    MsgBox "Item Code : " & lDataSet.FindField("ItemCode").AsString
MsgBox "Item Description : " & lDataSet.FindField("Description").AsString
MsgBox "Balance Qty : " & lDataSet.FindField("Qty").AsString
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Example-ST_IS====
{| class="mw-collapsible mw-collapsed wikitable"
! ST_IS Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg StockIssue.vbs
Call CheckLogin
Call InsertData
 
Dim ComServer
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function
 
Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_IS")
 
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data
 
   'Step 4 : Insert Data - Master
   lDate = CDate("January 1, 2017")
   BizObject.New
   lMain.FindField("DocKey").value        = -1
   lMain.FindField("DocKey").value        = -1
   lMain.FindField("DocNo").AsString      = "--IS Test--"
   lMain.FindField("DocNo").AsString      = "--IV Test--"
   lMain.FindField("DocDate").value        = lDate
   lMain.FindField("DocDate").value        = lDate
   lMain.FindField("PostDate").value      = lDate
   lMain.FindField("PostDate").value      = lDate
   lMain.FindField("Description").AsString = "Stock Issue"
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
   lMain.FindField("Description").AsString = "Sales"
      
      
   'Step 5: Insert Data - Detail
   'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
   lDetail.Append
   lDetail.Append
   lDetail.FindField("DtlKey").value        = -1
   lDetail.FindField("DtlKey").value        = -1
   lDetail.FindField("DocKey").value        = -1
   lDetail.FindField("DocKey").value        = -1
   lDetail.FindField("ItemCode").AsString   = "ANT"
   lDetail.FindField("Seq").value            = 1
   lDetail.FindField("Description").AsString = "Issue out Item A"
  lDetail.FindField("Account").AsString     = "500-000" 'Sales Account
   lDetail.FindField("Qty").AsFloat          = 2
   lDetail.FindField("Description").AsString = "Sales Item A"
   lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 435
  lDetail.FindField("Amount").AsFloat      = 410.37 'Exclding GST Amt
  lDetail.FindField("TaxAmt").AsFloat      = 24.63
 
  lDetail.DisableControls
  lDetail.FindField("TaxInclusive").value  = 1
  lDetail.EnableControls
 
  lDetail.Post
 
  'For Tax Inclusive = False with override Tax Amount
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("Account").AsString    = "500-000"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 94.43
  lDetail.FindField("Amount").AsFloat      = 94.43
  lDetail.FindField("TaxAmt").AsFloat      = 5.66
   lDetail.Post
   lDetail.Post


  'For With Item Code
   lDetail.Append
   lDetail.Append
   lDetail.FindField("DtlKey").value        = -1
   lDetail.FindField("DtlKey").value        = -1
   lDetail.FindField("DocKey").value        = -1
   lDetail.FindField("DocKey").value        = -1
   lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Seq").value            = 3
   lDetail.FindField("Description").AsString = "Issue out Item A"
   lDetail.FindField("ItemCode").AsString    = "ANT"
   lDetail.FindField("Qty").AsFloat          = 4
   lDetail.FindField("Description").AsString = "Sales Item B"
   lDetail.Post
  'lDetail.FindField("Account").AsString    = "500-000" 'If you wanted override the Sales Account Code
   lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString        = "UNIT"
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100 
  lDetail.FindField("Amount").AsFloat      = 200
  lDetail.FindField("TaxAmt").AsFloat      = 12
   lDetail.Post
 
   'Step 6: Save Document
   'Step 6: Save Document
   BizObject.Save
   BizObject.Save
   BizObject.Close
   BizObject.Close
   
 
   ComServer.Logout 'Logout after done
   'Step 7: Payment
   MsgBox "Done" 
   Call InsertARPM
End Function
 
</syntaxhighlight>
  'Step 8: Credit Note
|}
  Call InsertSLCN
  'End Looping yr data


<div style="float: right;">  [[#top|[top]]]</div>
  'Step 9 : Logout after done  
 
  'ComServer.Logout
====Example-ST_RC====
 
{| class="mw-collapsible mw-collapsed wikitable"
   MsgBox "Done"
! ST_RC Script  
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg StockReceived.vbs
Call CheckLogin
Call InsertData
 
Dim ComServer
 
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function


function CheckLogin
Function InsertARPM
  'Step 1: Create Com Server object
Dim BizObject, lMain, lDetail, lDate, v(1)
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function
 
Function InsertData
Dim BizObject, lMain, lDetail, lDate
   'Step 2: Find and Create the Biz Objects
   'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("ST_RC")  
   Set BizObject = ComServer.BizObjects.Find("AR_PM")  
 
   'Step 3: Set Dataset
   'Step 3: Set Dataset
   Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   Set lMain = BizObject.DataSets.Find("MainDataSet")   'lMain contains master data
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
   Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains detail data   
    
    
   'Step 4 : Insert Data - Master
   'Step 4 : Posting
  lDate = CDate("January 1, 2017")
    lDate = CDate("January 23, 2017")
  BizObject.New
    BizObject.New
  lMain.FindField("DocKey").value        = -1
    lMain.FindField("DOCKEY").Value          = -1
  lMain.FindField("DocNo").AsString       = "--RC Test--"
    lMain.FindField("DocNo").AsString         = "--PM Test--"  
  lMain.FindField("DocDate").value        = lDate
    lMain.FindField("CODE").AsString          = "300-C0001" 'Customer Account
  lMain.FindField("PostDate").value      = lDate
    lMain.FindField("DocDate").Value          = lDate
  lMain.FindField("Description").AsString = "Stock Received"
    lMain.FindField("PostDate").Value        = lDate
      
     lMain.FindField("Description").AsString  = "Payment for A/c"
  'Step 5: Insert Data - Detail
    lMain.FindField("PaymentMethod").AsString = "320-000" 'Bank or Cash Account
  lDetail.Append
lMain.FindField("ChequeNumber").AsString = ""
  lDetail.FindField("DtlKey").value        = -1
lMain.FindField("BankCharge").AsFloat     = 0
  lDetail.FindField("DocKey").value        = -1
    lMain.FindField("DocAmt").AsFloat         = 200.00
  lDetail.FindField("ItemCode").AsString   = "ANT"
    lMain.FindField("Cancelled").AsString    = "F"
  lDetail.FindField("Description").AsString = "Received Item A"
   'Step 5: Knock Off IV
  lDetail.FindField("Qty").AsFloat         = 2
    lIVNO = "--IV Test--"
  lDetail.FindField("UnitCost").AsFloat     = 25.15
    v(0) = "IV"
  lDetail.Post
    v(1) = lIVNO
 
  lDetail.Append
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
  lDetail.FindField("DtlKey").value        = -1
      lDetail.Edit
   lDetail.FindField("DocKey").value        = -1
      lDetail.FindField("KOAmt").AsFloat     = 147.09 'Partial Knock off
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
      lDetail.FindField("KnockOff").AsString = "T"
  lDetail.FindField("Description").AsString = "Received Item A"
      lDetail.Post
  lDetail.FindField("Qty").AsFloat         = 4
End IF  
  lDetail.FindField("UnitCost").AsFloat    = 54
  lDetail.Post   
   'Step 6: Save Document
   'Step 6: Save Document
  BizObject.Save
    BizObject.Save
  BizObject.Close
    BizObject.Close
   
  ComServer.Logout 'Logout after done
  MsgBox "Done" 
End Function
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
Function InsertSLCN
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_CN")


====Example-ST_AJ====
   'Step 3: Set Dataset
{| class="mw-collapsible mw-collapsed wikitable"
   Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
! ST_AJ Script 
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
|-
    
|
   'Step 4 : Insert Data - Master
<syntaxhighlight lang="vb">
   lDate = CDate("January 24, 2017")
'Copy below script & paste to notepad & name it as eg StockAdjustment.vbs
   BizObject.New
Call CheckLogin
Call InsertData
 
Dim ComServer
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function
 
Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_AJ")
 
   'Step 3: Set Dataset
   Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
    
   'Step 4 : Insert Data - Master
   lDate = CDate("January 1, 2017")
   BizObject.New
   lMain.FindField("DocKey").value        = -1
   lMain.FindField("DocKey").value        = -1
   lMain.FindField("DocNo").AsString      = "--AJ Test--"
   lMain.FindField("DocNo").AsString      = "--CN Test--"
   lMain.FindField("DocDate").value        = lDate
   lMain.FindField("DocDate").value        = lDate
   lMain.FindField("PostDate").value      = lDate
   lMain.FindField("PostDate").value      = lDate
   lMain.FindField("Description").AsString = "Stock Adjustment"
  lMain.FindField("Code").AsString        = "300-C0001"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = ""
  lMain.FindField("Address2").AsString    = ""
  lMain.FindField("Address3").AsString    = ""
  lMain.FindField("Address4").AsString    = ""
  lMain.FindField("Phone1").AsString      = "" 
   lMain.FindField("Description").AsString = "Sales Returned"
      
      
   'Step 5: Insert Data - Detail
   'For With Item Code
   lDetail.Append
   lDetail.Append
   lDetail.FindField("DtlKey").value         = -1
   lDetail.FindField("DtlKey").value         = -1
   lDetail.FindField("DocKey").value         = -1
   lDetail.FindField("DocKey").value         = -1
   lDetail.FindField("ItemCode").AsString   = "ANT"
   lDetail.FindField("ItemCode").AsString     = "ANT"
   lDetail.FindField("Description").AsString = "Adjust IN Item A"
   lDetail.FindField("Description").AsString = "Sales Item B"
   lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("Description2").AsString = "Product Spoil" 'Reason
   lDetail.FindField("UnitCost").AsFloat    = 25.15 'Only IN need UnitCost
  lDetail.FindField("Remark1").AsString      = "--IV Test--"  'Invoice No
   lDetail.Post
  lDetail.FindField("Remark2").AsString      = "01 Jan 2017"  'Invoice Date
   lDetail.FindField("Qty").AsFloat           = 1
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString      = "6%"
  lDetail.FindField("TaxInclusive").value    = 0
   lDetail.FindField("UnitPrice").AsFloat    = 100
  lDetail.FindField("Amount").AsFloat        = 100
  lDetail.FindField("TaxAmt").AsFloat        = 6 
   lDetail.Post


  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Description").AsString = "Adjust OUT Item A"
  lDetail.FindField("Qty").AsFloat          = -4
  lDetail.Post 
   'Step 6: Save Document
   'Step 6: Save Document
   BizObject.Save
   BizObject.Save
   BizObject.Close
   BizObject.Close
   
 
   ComServer.Logout 'Logout after done
  'Step 7: Knock Off Invoice
   MsgBox "Done"   
  Call KnockIV
End Function
 
Function KnockIV
Dim BizObject, lMain, lDetail, lDate, v(1)
  'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("AR_CN")
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains Knock off data  
 
  'Step 4 : Find CN Number
  lDocNo = "--CN Test--"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey
 
  If not IsNull(lDocKey) Then
    BizObject.Open
    BizObject.Edit
    lMain.Edit
  'Step 5: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("KOAmt").AsFloat    = 106 'Fully Knock off
      lDetail.FindField("KnockOff").AsString = "T"
      lDetail.Post
End IF   
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
  END IF
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 5,502: Line 6,609:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-ST_XF====
====AR_IV====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! ST_XF Script   
! AR_IV Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg ST_XF.vbs
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call CheckLogin
Call InsertARIV
Call InsertData
 
Dim ComServer


Function CreateSQLAccServer
Function CreateSQLAccServer
Line 5,518: Line 6,622:
End Function
End Function


function CheckLogin
Function InsertARIV
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
 
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
End Function


Function InsertData
Dim BizObject, lMain, lDetail, lDate
   'Step 2: Find and Create the Biz Objects
   'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("ST_XF")  
   Set BizObject = ComServer.BizObjects.Find("AR_IV")  


   'Step 3: Set Dataset
   'Step 3: Set Dataset
   Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
   Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data   
    
    
  'Begin Looping yr data
   'Step 4 : Insert Data - Master
   'Step 4 : Insert Data - Master
   lDate = CDate("January 1, 2017")
   lDate = CDate("January 1, 2016")
   BizObject.New
   BizObject.New
   lMain.FindField("DocKey").value         = -1
   lMainDataSet.FindField("DocKey").value = -1
   lMain.FindField("DocNo").AsString      = "--XF Test--"
   lMainDataSet.FindField("DocNo").value = "--IV Test--"
   lMain.FindField("DocDate").value       = lDate
   lMainDataSet.FindField("DocDate").value = lDate
   lMain.FindField("PostDate").value       = lDate
   lMainDataSet.FindField("PostDate").value = lDate
   lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account - Optional
   lMainDataSet.FindField("Code").value = "300-A0003"
   lMain.FindField("CompanyName").AsString = "Cash Sales" 'Optional
   lMainDataSet.FindField("Description").value = "Sales"
  lMain.FindField("Description").AsString = "Stock Transfer"
      
      
   'Step 5: Insert Data - Detail
   'Step 5: Insert Data - Detail
   lDetail.Append
   'For Tax Inclusive = True with override Tax Amount
   lDetail.FindField("DtlKey").value         = -1
  lDetailDataSet.Append
   lDetail.FindField("DocKey").value         = -1
   lDetailDataSet.FindField("DtlKey").value = -1
   lDetail.FindField("ItemCode").AsString    = "ANT"
   lDetailDataSet.FindField("DocKey").value = -1
   lDetail.FindField("Description").AsString = "Transfer Item A"
   lDetailDataSet.FindField("Account").value = "500-000"
   lDetail.FindField("Qty").AsFloat          = 10
   lDetailDataSet.FindField("Description").value = "Sales Item A"
   lDetail.FindField("UOM").AsString          = "UNIT"
   lDetailDataSet.FindField("Tax").value = "SR"
   lDetail.FindField("FromLocation").AsString = "----"
   lDetailDataSet.FindField("TaxInclusive").value = 0
   lDetail.FindField("ToLocation").AsString  = "BALAKONG"
  lDetailDataSet.FindField("Amount").value = 410.37
   lDetail.Post
   lDetailDataSet.FindField("TaxAmt").value = 24.63
 
 
   lDetail.Append
  lDetailDataSet.DisableControls
   lDetail.FindField("DtlKey").value         = -1
  lDetailDataSet.FindField("TaxInclusive").value =  1
   lDetail.FindField("DocKey").value         = -1
  lDetailDataSet.EnableControls
   lDetail.FindField("ItemCode").AsString    = "HFK"
 
   lDetail.FindField("Description").AsString = "Transfer Item B"
   lDetailDataSet.FindField("Changed").value = "F"
   lDetail.FindField("Qty").AsFloat          = 5
   lDetailDataSet.Post
   lDetail.FindField("UOM").AsString          = "UNIT"
 
   lDetail.FindField("FromLocation").AsString = "----"
  'For Tax Inclusive = False with override Tax Amount
   lDetail.FindField("ToLocation").AsString  = "BALAKONG"
   lDetailDataSet.Append
   lDetail.Post
   lDetailDataSet.FindField("DtlKey").value = -1
   lDetailDataSet.FindField("DocKey").value = -1
   lDetailDataSet.FindField("Account").value = "500-000"
   lDetailDataSet.FindField("Description").value = "Sales Item B"
   lDetailDataSet.FindField("Tax").value = "SR"
   lDetailDataSet.FindField("TaxInclusive").value = 0
  lDetailDataSet.FindField("Amount").value = 94.43
   lDetailDataSet.FindField("TaxAmt").value = 5.66
   lDetailDataSet.FindField("Changed").value = "F"
   lDetailDataSet.Post


   'Step 6: Save Document
   'Step 6: Save Document
   BizObject.Save
   BizObject.Save
   BizObject.Close
   BizObject.Close
 
   MsgBox "Done"
  'Step 7 : Logout after done 
  'ComServer.Logout
 
   MsgBox "Done"
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 5,585: Line 6,690:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AP_PI-Edit====
====AR_IV-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AP_PI Edit Script   
! AR_IV Edit Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg AP_PI.vbs
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call CheckLogin
Call CheckLogin
Call GetData
Call GetData
Line 5,614: Line 6,719:
Function GetData
Function GetData
Dim lSQL
Dim lSQL
   lSQL = "SELECT Dockey FROM PH_PI "
   lSQL = "SELECT Dockey FROM AR_IV "
   lSQL = lSQL & "WHERE DocNo='PI-00001' "
   lSQL = lSQL & "WHERE DocNo='IV-00002' "
  lSQL = lSQL & "AND Code='400-D0001' "
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function
End Function
Line 5,623: Line 6,727:
Dim BizObject, lMain, lDetail
Dim BizObject, lMain, lDetail
   'Step 2: Find and Create the Biz Objects
   'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("PH_PI")  
   Set BizObject = ComServer.BizObjects.Find("AR_IV")  


   'Step 3: Set Dataset
   'Step 3: Set Dataset
Line 5,638: Line 6,742:
     BizObject.Edit
     BizObject.Edit
     lMain.Edit
     lMain.Edit
lMain.FindField("Description").AsString = "testing"  
lMain.FindField("Description").AsString = "Sales - Edited"  
    
    
   'Step 5: Delete all Detail
   'Step 5: Delete all Detail
Line 5,646: Line 6,750:
     Wend
     Wend
   'Step 6: Append Detail
   'Step 6: Append Detail
    lDetail.Append
  lDetail.Append
    lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("Account").value = "610-2000"
  lDetail.FindField("Account").value = "500-000"
    lDetail.FindField("Description").value =  "Purchase Item A"
  lDetail.FindField("Description").value =  "Sales Item A - Edited"
    lDetail.FindField("Tax").value =  ""
  lDetail.FindField("Tax").value =  "SR"
    lDetail.FindField("TaxInclusive").value =  0
  lDetail.FindField("TaxRate").value =  "6%"
    lDetail.FindField("Amount").value = 410.37
  lDetail.FindField("TaxInclusive").value =  0
    lDetail.FindField("TaxAmt").value = 0
  lDetail.FindField("Amount").value = 100
    lDetail.Post
  lDetail.FindField("TaxAmt").value = 6
    
    
   'Step 7: Save Document
  lDetail.DisableControls
     BizObject.Save
  lDetail.FindField("TaxInclusive").value =  1
  lDetail.EnableControls
 
  lDetail.FindField("Changed").value = "F"
  lDetail.Post
 
   'Step 7: Save Document
     BizObject.Save
     BizObject.Close
     BizObject.Close
    
    
Line 5,666: Line 6,777:
MsgBox "Record Not Found"  
MsgBox "Record Not Found"  
   END IF  
   END IF  
 
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 5,673: Line 6,783:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-SL_DO to SL_IV====
====AR_PM====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_DO to SL_IV Script   
! AR_PM Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Updated 26 Oct 2018
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call PostData
Call CheckLogin
Call InsertData1
Call InsertData2
 
Dim ComServer
 
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
function CheckLogin
Function PostData
Dim ComServer, BizObject, lIVNo, v(1), lDate
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
End Function
 
Function InsertData1
Dim BizObject, lMain, lDetail, lDate
   'Step 2: Find and Create the Biz Objects
   'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("SL_DO")  
   Set BizObject = ComServer.BizObjects.Find("AR_PM")  
 
   'Step 3: Set Dataset
   'Step 3: Set Dataset
   Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   Set lMain = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
   Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data   
    
    
  'Begin Looping yr data
   'Step 4 : Posting
   'Step 4 : Insert Data - Master
    lDate = CDate("January 23, 2017")
  lDate = CDate("January 1, 2017")
    BizObject.New
  BizObject.New
    lMain.FindField("DOCKEY").Value          = -1
  lMain.FindField("DocKey").value        = -1
    lMain.FindField("DocNo").AsString         = "--PM Test--"  
  lMain.FindField("DocNo").AsString       = "--DO Test--"
    lMain.FindField("CODE").AsString         = "300-C0001"
  lMain.FindField("DocDate").value        = lDate
    lMain.FindField("DocDate").Value          = lDate
  lMain.FindField("PostDate").value      = lDate
    lMain.FindField("PostDate").Value        = lDate
  lMain.FindField("Code").AsString       = "300-C0001" 'Customer Account
    lMain.FindField("Description").AsString   = "Payment for A/c"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
    lMain.FindField("PaymentMethod").AsString = "310-000"
  'lMain.FindField("Address1").AsString    = "" 'Optional
    lMain.FindField("DocAmt").AsFloat        = 65.57
  'lMain.FindField("Address2").AsString   = "" 'Optional
    lMain.FindField("Cancelled").AsString     = "F"
  'lMain.FindField("Address3").AsString   = "" 'Optional
   'Step 5: Knock Off IV
  'lMain.FindField("Address4").AsString    = "" 'Optional
    lIVNO = "--IV Test--"
  'lMain.FindField("Phone1").AsString      = "" 'Optional
    v(0) = "IV"
  lMain.FindField("Description").AsString = "Delivery Order"
    v(1) = lIVNO
   
   'Step 5: Insert Data - Detail
    if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
  lDetail.Append
      lDetailDataSet.Edit
  lDetail.FindField("DtlKey").value        = -1
      lDetailDataSet.FindField("KOAmt").value = 65.57
  lDetail.FindField("DocKey").value        = -1
      lDetailDataSet.FindField("KnockOff").AsString = "T"
  lDetail.FindField("Seq").value            = 1
      lDetailDataSet.Post
  lDetail.FindField("ItemCode").AsString    = "ANT"
End IF 
  lDetail.FindField("Description").AsString = "Sales Item A"
   'Step 6: Save Document
  lDetail.FindField("UOM").AsString        = "BOX"
    BizObject.Save
  lDetail.FindField("Qty").AsFloat          = 2
    BizObject.Close
  'lDetail.FindField("DISC").AsString       = "5%+3" 'Optional (eg 5% plus 3 Discount)
     MsgBox "Done"
  lDetail.FindField("Tax").AsString        = "SR"
   'END IF
   lDetail.FindField("TaxRate").AsString     = "6%"
End Function
   lDetail.FindField("TaxInclusive").value  = 0
</syntaxhighlight>
  lDetail.FindField("UnitPrice").AsFloat    = 100 
|}
  lDetail.FindField("Amount").AsFloat      = 200
 
  lDetail.FindField("TaxAmt").AsFloat      = 12
<div style="float: right;">   [[#top|[top]]]</div>
   lDetail.Post


  lDetail.Append
====AR_PM-Edit====
  lDetail.FindField("DtlKey").value        = -1
{| class="mw-collapsible mw-collapsed wikitable"
  lDetail.FindField("DocKey").value        = -1
! AR_PM Edit Script 
  lDetail.FindField("Seq").value            = 2
|-
  lDetail.FindField("ItemCode").AsString    = "COVER"
|
  lDetail.FindField("Description").AsString = "Sales Item B"
<syntaxhighlight lang="vb">
  lDetail.FindField("UOM").AsString        = "UNIT"
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
  lDetail.FindField("Qty").AsFloat          = 3
Call EditARPM
  lDetail.FindField("Tax").AsString        = "SR"
   
  lDetail.FindField("TaxRate").AsString    = "6%"
Function CreateSQLAccServer
  lDetail.FindField("TaxInclusive").value  = 0
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  lDetail.FindField("UnitPrice").AsFloat    = 10  
   lDetail.FindField("Amount").AsFloat      = 30
  lDetail.FindField("TaxAmt").AsFloat      = 1.80
  lDetail.Post 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "DO Posting Done" 
End Function
End Function
 
Function InsertData2
Function EditARPM
Dim BizObject, lMain, lDetail, lDate, lDODtl, lxFer, lSQL, v(2)
Dim ComServer, BizObject, lDataSet, lDataSet2, lDocKey, lDocNo, lIVNo, v(1)
   'Step 1: Check Is transtered or not
   lSQL = "SELECT DocKey FROM SL_IVDTL "
   'Step 1: Create Com Server object
  lSQL = lSQL & "WHERE FromDockey=(SELECT DocKey FROM SL_DO "
   Set ComServer = CreateSQLAccServer 'Create Com Server
  lSQL = lSQL & "WHERE DocNo='--DO Test--') "
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   Set lxFer = ComServer.DBManager.NewDataSet(lSQL)
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
 
  END IF
  if lxFer.RecordCount = 0 then
    'Step 2: Get DO Information
  'Step 2: Find and Create the Biz Objects
     lSQL = "SELECT * FROM SL_DODTL "
  Set BizObject = ComServer.BizObjects.Find("AR_PM")  
    lSQL = lSQL & "WHERE Dockey=(SELECT DocKey FROM SL_DO "  
    lSQL = lSQL & "WHERE DocNo='--DO Test--') "
  'Step 3: Set Dataset
    Set lDODtl = ComServer.DBManager.NewDataSet(lSQL)   
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data   
'Step 3: Find and Create the Biz Objects
    Set BizObject = ComServer.BizObjects.Find("SL_IV")  
 
    'Step 4: Set Dataset
    Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
    Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data   
    
    
    'Step 5 : Insert Data - Master
  'Step 4 : Find OR Number
    lDate = CDate("January 1, 2017")
  lDocNo = "OR-00022"
    BizObject.New
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
    lMain.FindField("DocKey").value        = -1
  BizObject.Params.Find("DocKey").Value = lDocKey
    lMain.FindField("DocNo").AsString      = "--IV Test--"
 
    lMain.FindField("DocDate").value        = lDate
  If not IsNull(lDocKey) Then
    lMain.FindField("PostDate").value      = lDate
     BizObject.Open
    lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
     BizObject.Edit
    lMain.FindField("CompanyName").AsString = "Cash Sales"
     lMainDataSet.Edit
     'lMain.FindField("Address1").AsString    = "" 'Optional
lMainDataSet.FindField("Description").AsString = "testing"
     'lMain.FindField("Address2").AsString    = "" 'Optional
  'Step 5: Knock Off IV
     'lMain.FindField("Address3").AsString    = "" 'Optional
     lIVNO = "IV-00006"
    'lMain.FindField("Address4").AsString   = "" 'Optional
     v(0) = "IV"
    'lMain.FindField("Phone1").AsString      = "" 'Optional
     v(1) = lIVNO
     lMain.FindField("Description").AsString = "Sales"
   
    'Step 6: Insert Data - Detail
     v(0) = "COVER"
     v(1) = "UNIT"
     if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
     if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
       lDetail.Append
       lDetailDataSet.Edit
       lDetail.FindField("DtlKey").value         = -1
       lDetailDataSet.FindField("KOAmt").value = 50.12
      lDetail.FindField("DocKey").value        = -1
       lDetailDataSet.FindField("KnockOff").AsString = "T"
      lDetail.FindField("Seq").value            = 1
       lDetailDataSet.Post
       lDetail.FindField("ItemCode").AsString   = lDODtl.FindField("ItemCode").AsString
  MsgBox "yes"
       lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      'lDetail.FindField("Account").AsString    = "500-000" 'If you wanted override the Sales Account Code
      lDetail.FindField("UOM").AsString        = lDODtl.FindField("UOM").AsString
  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
      lDetail.FindField("Tax").AsString        = lDODtl.FindField("Tax").AsString
      lDetail.FindField("TaxRate").AsString    = lDODtl.FindField("TaxRate").AsString
      lDetail.FindField("TaxInclusive").value  = lDODtl.FindField("TaxInclusive").Value
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitPrice").AsFloat
      lDetail.FindField("Amount").AsFloat      = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("TaxAmt").AsFloat      = lDODtl.FindField("TaxAmt").AsFloat
  lDetail.FindField("FromDocType").AsString = "DO"
  lDetail.FindField("FromDockey").AsFloat  = lDODtl.FindField("DocKey").AsFloat
  lDetail.FindField("FromDtlkey").AsFloat  = lDODtl.FindField("DtlKey").AsFloat
      lDetail.Post
End IF   
End IF   
    v(0) = "ANT"
   'Step 6: Save Document
    v(1) = "BOX"
     BizObject.Save
     BizObject.Close
    if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
    MsgBox "Done"
      lDetail.Append
   END IF
      lDetail.FindField("DtlKey").value        = -1
      lDetail.FindField("DocKey").value        = -1
      lDetail.FindField("Seq").value            = 2
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      'lDetail.FindField("Account").AsString    = "500-000" 'If you wanted override the Sales Account Code
      lDetail.FindField("UOM").AsString        = lDODtl.FindField("UOM").AsString
  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
      lDetail.FindField("Tax").AsString        = lDODtl.FindField("Tax").AsString
      lDetail.FindField("TaxRate").AsString    = lDODtl.FindField("TaxRate").AsString
      lDetail.FindField("TaxInclusive").value  = lDODtl.FindField("TaxInclusive").Value
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitPrice").AsFloat
      lDetail.FindField("Amount").AsFloat      = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("TaxAmt").AsFloat      = lDODtl.FindField("TaxAmt").AsFloat
  lDetail.FindField("FromDocType").AsString = "DO"
  lDetail.FindField("FromDockey").AsFloat  = lDODtl.FindField("DocKey").AsFloat
  lDetail.FindField("FromDtlkey").AsFloat  = lDODtl.FindField("DtlKey").AsFloat
      lDetail.Post
End IF 
   'Step 7: Save Document
     BizObject.Save
     BizObject.Close
 
  'Step 8 : Logout after done 
  'ComServer.Logout
 
  MsgBox "Posting IV Done"
   else MsgBox "--DO Test-- had been transfered. Posting IV aborted" 
  End IF
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-SL_IV-Edit====
====Customer.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_IV-Edit Script   
! Customer.RO Report Object Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg customer_ro.vbs
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call GetCustomerData
Call CheckLogin
Call GetData
Call PostData
 
Dim ComServer, lDataSet


Function CreateSQLAccServer
Function CreateSQLAccServer
Line 5,887: Line 6,921:
End Function
End Function


function CheckLogin
Function GetCustomerData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
End Function


Function GetData
   'Step 2: Find and Create the Report Objects
Dim lSQL
   Set RptObject = ComServer.RptObjects.Find("Customer.RO")  
  lSQL = "SELECT Dockey FROM SL_IV "
   lSQL = lSQL & "WHERE DocNo='IV-00010' "
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


Function PostData
   'Step 3: Spool parameters
Dim BizObject, lMain, lDetail
  RptObject.Params.Find("AllAgent").Value = true
   'Step 2: Find and Create the Biz Objects
  RptObject.Params.Find("AllArea").Value = true
   Set BizObject = ComServer.BizObjects.Find("SL_IV")  
  RptObject.Params.Find("AllCompany").Value = false
  RptObject.Params.Find("AllCompanyCategory").Value = true
  RptObject.Params.Find("AllCurrency").Value = true
  RptObject.Params.Find("AllTerms").Value = true
  RptObject.Params.Find("SelectDate").Value = true
  RptObject.Params.Find("PrintActive").Value = true
  RptObject.Params.Find("PrintInactive").Value = false
  RptObject.Params.Find("PrintPending").Value = false
   RptObject.Params.Find("PrintProspect").Value = false
  RptObject.Params.Find("PrintSuspend").Value = false
  lDateFrom = CDate("January 1, 2000")
  lDateTo = CDate("December 31, 2014")


   'Step 3: Set Dataset
   RptObject.Params.Find("DateFrom").Value = lDateFrom
   Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   RptObject.Params.Find("DateTo").Value = lDateTo
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
   RptObject.Params.Find("CompanyData").Value = "300-A0003"
    
    
   'Step 4 : Find Doc Number
   'Step 4: Perform Report calculation
   If lDataSet.RecordCount > 0 Then    
   RptObject.CalculateReport()
lDataSet.First
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
  Set lDataSet2 = RptObject.DataSets.Find("cdsBranch")
    
  MsgBox "Count " & lDataSet.RecordCount
    
 
    BizObject.Open
   'Step 5 Retrieve the output
    BizObject.Edit
   lDataSet.First
     lMain.Edit
  While (not lDataSet.eof)
lMain.FindField("Description").AsString = "Sales - Edited"  
     MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString
 
lDataSet2.First
  'Step 5: Delete all Detail
     While (not lDataSet2.eof)
     While lDetail.RecordCount <> 0
  MsgBox lDataSet2.FindField("Address1").AsString
      lDetail.First
  lDataSet2.Next
  lDetail.Delete
     Wend
     Wend
  'Step 6: Append Detail
lDataSet.Next
    lDetail.Append
   Wend
    lDetail.FindField("DtlKey").value = -1
End Function
    lDetail.FindField("Account").value = "500-000"
</syntaxhighlight>
    lDetail.FindField("Description").value =  "Edited Item A"
    lDetail.FindField("Tax").value =  ""
    lDetail.FindField("TaxInclusive").value =  0
    lDetail.FindField("Amount").value = 410.37
    lDetail.FindField("TaxAmt").value = 0
    lDetail.Post
 
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
 
  'Step 8 : Logout after done 
    'ComServer.Logout 
    MsgBox "Done"
Else
MsgBox "Record Not Found"
   END IF
End Function
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL_JE====
====Customer.Statement.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_JE Script   
! Customer.Statement.RO  Report Object Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
'Copy below script & paste to notepad & name it as eg customer_statement_ro.vbs
Call InsertGLJE
Call GetCustStatementData
   
   
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
Function InsertGLJE
Function GetCustStatementData
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
Const Quote = """"
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   END IF
   END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.Statement.RO")
   
   
   'Step 2: Find and Create the Biz Objects
   'Step 3: Spool parameters
   Set BizObject = ComServer.BizObjects.Find("GL_JE")
   lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
      "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
  'Step 3: Set Dataset
      "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
      "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
      "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
 
      "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
  'Step 4 : Insert Data - Master
      "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
  lDate = CDate("January 23, 2017")
      "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
  BizObject.New
      "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
  lMainDataSet.FindField("DocKey").value = -1
      "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
  lMainDataSet.FindField("DocNo").value = "--JV Test--"
      "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
  lMainDataSet.FindField("DocDate").value = lDate
      "</ROWDATA></DATAPACKET>"
   lMainDataSet.FindField("PostDate").value = lDate
'  RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is True
   lMainDataSet.FindField("Description").value = "testing desc header"
   RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed
  lMainDataSet.Post
   RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
 
   RptObject.Params.Find("AllAgent").Value            = true
  'Step 5: Insert Data - Detail
   RptObject.Params.Find("AllArea").Value              = true
   'For Tax Inclusive
   RptObject.Params.Find("AllCompany").Value          = false
  lDetailDataSet.Append
   RptObject.Params.Find("AllCompanyCategory").Value  = true
  lDetailDataSet.FindField("DtlKey").value = -1
   RptObject.Params.Find("AllControlAccount").Value    = true
   lDetailDataSet.FindField("DocKey").value = -1
   RptObject.Params.Find("AllCurrency").Value          = true
   lDetailDataSet.FindField("SEQ").value = 1
   RptObject.Params.Find("AllDocProject").Value        = true
   lDetailDataSet.FindField("Code").value = "610-1000"
' RptObject.Params.Find("AreaData").Value            =  'Not use if AllArea is True
   lDetailDataSet.FindField("Project").value = "----"
' RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is True
   lDetailDataSet.FindField("Description").value = "testing desc1"
   RptObject.Params.Find("CompanyData").Value         = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
   lDetailDataSet.FindField("Tax").value =  "TX"
'  RptObject.Params.Find("ControlAccountData").Value  = 'Not use if AllControlAccount is True
  'lDetailDataSet.FindField("LOCALTAXAMT").value = 17.32 //For JE you can't override (i.e. system auto calc)
'  RptObject.Params.Find("CurrencyData").Value        = 'Not use if AllCurrency is True
   lDetailDataSet.FindField("TaxInclusive").Value = 1
   lDateFrom = CDate("August 1, 2016")
  lDetailDataSet.FindField("LocalDR").value = 306 '//Including GST if TAXINCLUSIVE = 1
  lDateTo = CDate("August 31, 2016")
  lDetailDataSet.FindField("DR").value = 306 '//If wanted DR <> LocalDR
   RptObject.Params.Find("DateFrom").Value            = lDateFrom
   lDetailDataSet.FindField("Changed").value = "F"
   RptObject.Params.Find("DateTo").Value              = lDateTo
    
'  RptObject.Params.Find("DocProjectData").Value      = 'Not use if AllDocProject is True
  'For Tax Exclusive
   RptObject.Params.Find("IncludeZeroBalance").Value  = false
  lDetailDataSet.Append
   RptObject.Params.Find("SelectDate").Value          = true
  lDetailDataSet.FindField("DtlKey").value = -1
   RptObject.Params.Find("SortBy").Value              = "CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount"
   lDetailDataSet.FindField("DocKey").value = -1
   RptObject.Params.Find("StatementDate").Value        = lDateTo ' Norm same as DateTo
  lDetailDataSet.FindField("SEQ").value = 2
   RptObject.Params.Find("StatementType").Value        = "O" 'O = Open Item, B = B/F
   lDetailDataSet.FindField("Code").value = "605-200"
   
   lDetailDataSet.FindField("Project").value = "----"
   'Step 4: Perform Report calculation
   lDetailDataSet.FindField("Description").value = "testing desc2"
  RptObject.CalculateReport()
   lDetailDataSet.FindField("Tax").value = "TX"
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
   lDetailDataSet.FindField("TaxInclusive").value 0
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
   lDetailDataSet.FindField("LocalCR").value = 100
   MsgBox "Count " & lDataSet.RecordCount
   lDetailDataSet.FindField("Changed").value = "F"
   lDetailDataSet.Post


   'For No GST
   'Step 5 Retrieve the output
   lDetailDataSet.Append
   lDataSet.First
   lDetailDataSet.FindField("DtlKey").value = -1
   While (not lDataSet.eof)
  lDetailDataSet.FindField("DocKey").value = -1
    MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("Balance").AsString
  lDetailDataSet.FindField("SEQ").value = 3
lDataSet2.First
  lDetailDataSet.FindField("Code").value = "610-002"
    While (not lDataSet2.eof)
  lDetailDataSet.FindField("Project").value = "----"
  MsgBox lDataSet2.FindField("DocNo").AsString
  lDetailDataSet.FindField("Description").value =  "testing desc3"
  lDataSet2.Next
  lDetailDataSet.FindField("Tax").value =  ""
    Wend
  lDetailDataSet.FindField("TaxInclusive").value =  0
lDataSet.Next
  lDetailDataSet.FindField("LocalCR").value = 200
   Wend
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
   MsgBox "Done"
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 6,046: Line 7,062:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL_JE-Edit====
====GL.CB.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_JE-Edit Script   
! GL.CB.RO  Report Object Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GL.CB.RO.vbs
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
Call GetCLCBData
Call CheckLogin
Call GetData
Call PostData
 
Dim ComServer, lDataSet
 
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
function CheckLogin
Function GetCLCBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
End Function
 
   'Step 2: Find and Create the Report Objects
Function GetData
   Set RptObject = ComServer.RptObjects.Find("GL.CB.RO")  
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_JE "
   'Step 3: Spool parameters
   lSQL = lSQL & "WHERE DocNo='JV-00002' "
  RptObject.Params.Find("AllCurrency").Value    = true
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
   RptObject.Params.Find("AllDocProject").Value  = true
End Function
  RptObject.Params.Find("AllDocument").Value    = true
 
  RptObject.Params.Find("AllItemProject").Value = true
Function PostData
   RptObject.Params.Find("AllItemArea").Value    = true
Dim BizObject, lMain, lDetail
   RptObject.Params.Find("AllItemAgent").Value  = true
   'Step 2: Find and Create the Biz Objects
   RptObject.Params.Find("AllDocAgent").Value    = true
   Set BizObject = ComServer.BizObjects.Find("GL_JE")  
  RptObject.Params.Find("AllDocArea").Value    = true
 
   RptObject.Params.Find("AllPaymentMethod").Value = false
   'Step 3: Set Dataset
  'RptObject.Params.Find("CurrencyData").Value    = 'Not use if AllCurrency is true
   Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
    
    
   'Step 4 : Find Doc Number
   lDateFrom = CDate("January 01, 2017")
   If lDataSet.RecordCount > 0 Then    
   lDateTo = CDate("December 31, 2017")
lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
   'For Post Date From & Date To'
  RptObject.Params.Find("DateFrom").Value = lDateFrom
  RptObject.Params.Find("DateTo").Value  = lDateTo
    
    
    
   'RptObject.Params.Find("DocProjectData").Value  = 'Not use if AllDocProject is true
    BizObject.Open
  'RptObject.Params.Find("DocAreaData").Value    = 'Not use if AllDocArea is true
    BizObject.Edit
   'RptObject.Params.Find("DocAgentData").Value    = 'Not use if AllDocAgent is true
    lMain.Edit
   'RptObject.Params.Find("ItemAgentData").Value  = 'Not use if AllItemAgent is true
lMain.FindField("Description").AsString = "Journal - Edited"
   RptObject.Params.Find("DocType").Value          = "PV" 'PV for Payment Voucher & OR for Official Receipt
 
   'RptObject.Params.Find("DocumentData").Value    = 'Not use if AllDocument is true
   'Step 5: Delete all Detail
  'RptObject.Params.Find("GroupBy").Value        = 'If you wanted to grouping the data
    While lDetail.RecordCount <> 0
   RptObject.Params.Find("IncludeCancelled").Value = false
      lDetail.First
   'RptObject.Params.Find("ItemAreaData").Value    = 'Not use if AllItemArea is true
  lDetail.Delete
   'RptObject.Params.Find("ItemProjectData").Value = 'Not use if AllItemProject is true
    Wend
   RptObject.Params.Find("PaymentMethodData").Value  = "310-001"
   'Step 6: Append Detail
   RptObject.Params.Find("PrintDocumentStyle").Value = false
  lDetail.Append
   RptObject.Params.Find("SelectDate").Value        = true 'For Post Date
  lDetail.FindField("DtlKey").value = -1
   'RptObject.Params.Find("SelectDocDate").Value    = 'For Doc Date
   lDetail.FindField("Code").value = "610-000"
   RptObject.Params.Find("SortBy").Value            = "PostDate;DocNo"  
   lDetail.FindField("Description").value = "testing desc1"
   lDetail.FindField("Project").value = "P12W1"
   'Step 4: Perform Report calculation
   lDetail.FindField("Tax").value = ""
  RptObject.CalculateReport()
   lDetail.FindField("TaxInclusive").value = 0
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
   lDetail.FindField("LocalDR").value = 200
  Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
   lDetail.FindField("DR").value = 200
   Set lDataSet3 = RptObject.DataSets.Find("cdsTax")
   lDetail.Post  
  MsgBox "Count " & lDataSet.RecordCount
 
   lDetail.Append
   'Step 5 Retrieve the output
  lDetail.FindField("DtlKey").value = -1
  lDataSet.First
   lDetail.FindField("Code").value = "531-000"
  While (not lDataSet.eof)
   lDetail.FindField("Description").value =  "testing desc2"
    MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
   lDetail.FindField("Project").value = "P13W1"
lDataSet2.First
   lDetail.FindField("Tax").value =  ""
    While (not lDataSet2.eof)
  lDetail.FindField("TaxInclusive").value =  0
  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
  lDetail.FindField("LocalCR").value = 200
  lDataSet2.Next
  lDetail.FindField("CR").value = 200
    Wend
  lDetail.Post
lDataSet.Next
    
   Wend
   'Step 7: Save Document
   'For GST List
    BizObject.Save
  MsgBox "GST Code Count " & lDataSet3.RecordCount
    BizObject.Close
  lDataSet3.First
    
   While (not lDataSet3.eof)
  'Step 8 : Logout after done 
     MsgBox lDataSet3.FindField("Code").AsString
    'ComServer.Logout 
lDataSet3.Next
     MsgBox "Done"  
   Wend
Else
MsgBox "Record Not Found"
   END IF
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL_JE-Delete====
====AR_Customer====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_JE-Delete Script   
! AR_Customer - Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
Call CheckLogin
Call CheckLogin
Call GetData
Call InsertData
Call DelData


Dim ComServer, lDataSet
Dim ComServer


Function CreateSQLAccServer
Function CreateSQLAccServer
Line 6,170: Line 7,177:
End Function
End Function


Function GetData
Function InsertData
Dim lSQL
Dim BizObject, lMain, lDetail
   lSQL = "SELECT Dockey FROM GL_JE "
   'Step 2: Find and Create the Biz Objects
  lSQL = lSQL & "WHERE DocNo='JV-00002' "
   Set BizObject = ComServer.BizObjects.Find("AR_Customer")  
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


Function DelData
   'Step 3: Set Dataset
Dim BizObject
   Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
   'Step 2: Find and Create the Biz Objects
   Set lDetail = BizObject.DataSets.Find("cdsBranch") 'lDetail contains detail data 
   Set BizObject = ComServer.BizObjects.Find("GL_JE")  
  'Step 3 : Find Doc Number
   If lDataSet.RecordCount > 0 Then
lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
    BizObject.Open
    BizObject.Delete
    BizObject.Close
    
    
   'Step 4 : Logout after done 
  'Begin Looping yr data
     'ComServer.Logout  
   'Step 4 : Insert Data - Master
    MsgBox "Done"  
  BizObject.New
Else
  lMain.FindField("Code").AsString      = "300-Test"
MsgBox "Record Not Found"  
  lMain.FindField("CompanyName").AsString = "Cash Sales"
   END IF
      
End Function
  'Step 5: Insert Data - Detail
</syntaxhighlight>
  'For 1st Branch
|}
  lDetail.Edit
<div style="float: right;">   [[#top|[top]]]</div>
  lDetail.FindField("BranchName").AsString = "BILLING"
 
  lDetail.FindField("Address1").AsString    = "Address1"
====Example-Get Invoice Next Number====
  lDetail.FindField("Address2").AsString    = "Address2"
{| class="mw-collapsible mw-collapsed wikitable"
  lDetail.FindField("Address3").AsString    = "Address3"
! Get Invoice Next Number Script  
   lDetail.FindField("Address4").AsString    = "Address4" 
|-
  lDetail.FindField("Attention").AsString  = "Attention" 
|
  lDetail.FindField("Phone1").AsString      = "Phone1"
<syntaxhighlight lang="vb">
  lDetail.FindField("Fax1").AsString        = "Fax1"
'Available in Version 5.2018.833.759 & above
  lDetail.FindField("Email").AsString      = "EmailAddress"
'Copy below script & paste to notepad & name it as eg GetNextNo.vbs
  lDetail.Post
Call CheckLogin
 
Call GetData
   'For 2nd Branch
Call ShowNextNo
  lDetail.Append
  lDetail.FindField("BranchName").AsString  = "Branch1"
  lDetail.FindField("Address1").AsString    = "DAddress1"
  lDetail.FindField("Address2").AsString    = "DAddress2"
  lDetail.FindField("Address3").AsString    = "DAddress3"
  lDetail.FindField("Address4").AsString    = "DAddress4" 
  lDetail.FindField("Attention").AsString  = "DAttention"   
  lDetail.FindField("Phone1").AsString      = "DPhone1"
  lDetail.FindField("Fax1").AsString        = "DFax1"
  lDetail.FindField("Email").AsString      = "DEmailAddress"
  lDetail.Post
 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  'End Looping yr data
 
  'Step 7 : Logout after done 
  'ComServer.Logout
 
  MsgBox "Done" 
End Function
</syntaxhighlight>
|}


Dim ComServer, lDataSet
<div style="float: right;">  [[#top|[top]]]</div>


====AR_Customer-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
! AR_Customer - Edit Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
Call EditARCustomer
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
function CheckLogin
Function EditARCustomer
   'Step 1: Create Com Server object
Dim ComServer, BizObject, lDataSet, lDataSet2
   'Step 1 Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
  'Step 2 Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_Customer")
  'Step 3 Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet") 'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsBranch") 'lDetailDataSet contains detail data 
 
  'Step 4 Find Customer Code
  BizObject.Params.Find("Code").Value = "300-Test"
 
  BizObject.Open
  BizObject.Edit
  lMainDataSet.Edit
  lMainDataSet.FindField("CompanyName").value = "Testing 123-Changed"
  'Step 5 For 1st Branch
    v = "BILLING"
    if (lDetailDataSet.Locate("BranchName", v, false, false)) then
  lDetailDataSet.Edit
      lDetailDataSet.FindField("Address1").AsString  = "Address1-Changed"
      lDetailDataSet.FindField("Address2").AsString  = "Address2-Changed"
      lDetailDataSet.FindField("Address3").AsString  = "Address3-Changed"
      lDetailDataSet.FindField("Address4").AsString  = "Address4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "Attention-Changed"
      lDetailDataSet.FindField("Phone1").AsString    = "Phone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString      = "Fax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "EmailAddress-Changed"
      lDetailDataSet.Post
end if
'Step 5 For 2nd Branch
    v = "Branch1"
    if (lDetailDataSet.Locate("BranchName", v, false, false)) then
      lDetailDataSet.Edit
      lDetailDataSet.FindField("Address1").AsString  = "DAddress1-Changed"
      lDetailDataSet.FindField("Address2").AsString  = "DAddress2-Changed"
      lDetailDataSet.FindField("Address3").AsString  = "DAddress3-Changed"
      lDetailDataSet.FindField("Address4").AsString  = "DAddress4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "DAttention-Changed"
      lDetailDataSet.FindField("Phone1").AsString    = "DPhone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString      = "DFax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "DEmailAddress-Changed"
      lDetailDataSet.Post 
  end IF
  'Step 6 Save Customer
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function
End Function
</syntaxhighlight>
|}


Function GetData
<div style="float: right;">  [[#top|[top]]]</div>
Dim lSQL
 
  lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A "
====GL.TrialBalance.RO====
  lSQL = lSQL & "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) "
{| class="mw-collapsible mw-collapsed wikitable"
  lSQL = lSQL & "WHERE A.DOCTYPE='IV' "
! GL Trial Balance  Report Object Script   
  lSQL = lSQL & "AND A.DESCRIPTION='Customer Invoice' "
  lSQL = lSQL & "AND A.STATESET=1 "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function
 
Function ShowNextNo
Dim Desc, Fmt, NextNo, lResult, sb
  set sb = CreateObject("System.Text.StringBuilder")
  'Step 2 : Find Doc Number
  If lDataSet.RecordCount > 0 Then 
lDataSet.First
    Desc = lDataSet.FindField("Description").AsString
Fmt  = lDataSet.FindField("Format").AsString
NextNo = lDataSet.FindField("NEXTNUMBER").Value
'Convert from IV-%.5d to IV-{0:d5}
sb.Append_3 Fmt
sb.Replace "d", ""
sb.Replace "%.","{0:d"
Fmt = sb.ToString & "}"
sb.Length = 0 'clear sb list
sb.AppendFormat Fmt, NextNo
lResult = sb.ToString
    MsgBox Desc
MsgBox Fmt
MsgBox NextNo
MsgBox lResult
Else
MsgBox "Record Not Found"
  END IF   
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Example-Auto Run Doc. Number====
{| class="mw-collapsible mw-collapsed wikitable"
! Sales Order Auto Run Doc Number Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg SL_SO.vbs
'Copy below script & paste to notepad & name it as eg GL.TrialBalance.RO.vbs
'If had prompt Set Default - Just click Yes to avoid keep prompt
Call GetGLTBData
Call CheckLogin
Call GetData
Call InsertData
 
Dim ComServer, lDataSet
 
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
function CheckLogin
Function GetGLTBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
                'UserName, Password, DCF full path, Database filename
   END IF
   END IF
End Function
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("GL.TrialBalance.RO")
  'Step 3: Spool parameters
  RptObject.Params.Find("AllProject").Value      = true
  RptObject.Params.Find("AllAgent").Value        = true
  RptObject.Params.Find("AllArea").Value        = true
  RptObject.Params.Find("LedgerType").Value      = "G" 'G = Legder, S = Debtor, P = Supplier
  'RptObject.Params.Find("ProjectData").Value    = 'Not use if AllArea is true
  RptObject.Params.Find("ShowZeroBalance").Value = false
  RptObject.Params.Find("SortBy").Value          = "PostDate;DocNo"
  RptObject.Params.Find("UseDescription2").Value = false
 
  lDateFrom = CDate("October 27, 2016")
  lDateTo = CDate("December 31, 2016")
  'For Post Date From & Date To'
  RptObject.Params.Find("DateFrom").Value      = lDateFrom
  RptObject.Params.Find("DateTo").Value        = lDateTo


Function GetData
  'RptObject.Params.Find("AgentData").Value      = 'Not use if AllAgent is true
Dim lSQL
  'RptObject.Params.Find("AreaData").Value      = 'Not use if AllArea is true
   lSQL = "SELECT * FROM SY_DOCNO "
 
   lSQL = lSQL & "WHERE DESCRIPTION='Customer Sales Order 2' "
   RptObject.Params.Find("SortBy").Value          = "Code;Description"  
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
  'Step 4: Perform Report calculation
   RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsGLAccount")
 
  MsgBox "Count " & lDataSet.RecordCount
  'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "Month To Date"
MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("MTDDR").AsString & " CR=>" & lDataSet.FindField("MTDCR").AsString
MsgBox "Year To Date"
MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("YTDDR").AsString & " CR=>" & lDataSet.FindField("YTDCR").AsString
lDataSet.Next
  Wend
 
  'For Account List
  lDataSet2.First
  While (not lDataSet2.eof)
MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
lDataSet2.Next
  Wend
 
End Function
End Function
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>


Function InsertData
====Customer.Aging.RO====
Dim BizObject, lMain, lDetail, lDate
{| class="mw-collapsible mw-collapsed wikitable"
  'Step 2: Find and Create the Biz Objects
! Customer Aging  Report Object Script   
  Set BizObject = ComServer.BizObjects.Find("SL_SO")
 
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2019")
  BizObject.New
  lMain.FindField("DocKey").value        = -1
  lMain.FindField("DocNo").AsString      = "<<New>>"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Sales Order"
  lMain.FindField("DocNoSetKey").value    = lDataSet.FindField("DocKey").value
   
  'Step 5: Insert Data - Detail
  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 3
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString        = "UNIT"
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString        = ""
  lDetail.FindField("TaxRate").AsString    = ""
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100 
  lDetail.FindField("Amount").AsFloat      = 200
  lDetail.FindField("TaxAmt").AsFloat      = 0
  lDetail.Post
 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
 
  'Step 7 : Logout after done 
  'ComServer.Logout
 
  MsgBox "Done" 
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Example-GL_PV====
{| class="mw-collapsible mw-collapsed wikitable"
! Cash Book PV Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
'Copy below script & paste to notepad & name it as eg customer_aging_ro.vbs
Call PostData
Call GetCustStatementData
   
   
Function CreateSQLAccServer
Function CreateSQLAccServer
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
End Function
 
Function PostData
Function GetCustStatementData
Dim ComServer, BizObject, lIVNo, lDate
Const Quote = """"
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
   'Step 1: Create Com Server object
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
   Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"  
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   END IF
   END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.Aging.RO")
   
   
   'Step 2: Find and Create the Biz Objects
   'Step 3: Spool parameters
   Set BizObject = ComServer.BizObjects.Find("GL_PV")  
  lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
      "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
      "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
      "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
      "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
      "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
      "</ROWDATA></DATAPACKET>"
  RptObject.Params.Find("ActualGroupBy").Value        = "Code;CompanyName" 'Fixed
'  RptObject.Params.Find("AgentData").Value            =  'Not use if AllAgent is True
  RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed
 
  lDateTo = CDate("August 31, 2016")
  RptObject.Params.Find("AgingDate").Value            = lDateTo 
 
  RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
  RptObject.Params.Find("AllAgent").Value            = true
  RptObject.Params.Find("AllArea").Value              = true
  RptObject.Params.Find("AllCompany").Value          = false
  RptObject.Params.Find("AllCompanyCategory").Value  = true
  RptObject.Params.Find("AllControlAccount").Value    = true
  RptObject.Params.Find("AllCurrency").Value          = true
  RptObject.Params.Find("AllDocProject").Value        = true
'  RptObject.Params.Find("AreaData").Value            =  'Not use if AllArea is True
'  RptObject.Params.Find("CompanyCategoryData").Value  =  'Not use if AllCompanyCategory is True
  RptObject.Params.Find("CompanyData").Value          = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
'  RptObject.Params.Find("ControlAccountData").Value   = 'Not use if AllControlAccount is True
'  RptObject.Params.Find("CurrencyData").Value        =  'Not use if AllCurrency is True
'  RptObject.Params.Find("DocProjectData").Value      =  'Not use if AllDocProject is True
  RptObject.Params.Find("FilterPostDate").Value        = false
'  RptObject.Params.Find("GroupBy").Value              = 'Not use
  RptObject.Params.Find("IncludePDC").Value        = false
  RptObject.Params.Find("IncludeZeroBalance").Value  = false
  RptObject.Params.Find("SortBy").Value              = "Code;CompanyName"
  RptObject.Params.Find("DateTo").Value              = lDateTo
 
   
   
   'Step 3: Set Dataset
   'Step 4: Perform Report calculation
   Set lMain = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
   RptObject.CalculateReport()
   Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
    
   Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
  'Step 4 : Posting
   MsgBox "Count " & lDataSet.RecordCount
    lDate = CDate("January 23, 2020")
    BizObject.New
    lMain.FindField("DOCKEY").Value          = -1
    lMain.FindField("DocNo").AsString        = "--CB PV Test--"
    lMain.FindField("DocDate").Value          = lDate
    lMain.FindField("PostDate").Value        = lDate
    lMain.FindField("Description").AsString   = "Compacc System"
    lMain.FindField("PaymentMethod").AsString = "310-001"
lMain.FindField("CHEQUENUMBER").AsString = "MBB 213245"
    lMain.FindField("DocAmt").AsFloat        = 2019.57
    lMain.FindField("Cancelled").AsString    = "F"
lMain.Post
 
    lDetailDataSet.Append
    lDetailDataSet.FindField("DTLKEY").value = -1
lDetailDataSet.FindField("DOCKEY").value = -1
lDetailDataSet.FindField("Code").AsString = "200-300"
    lDetailDataSet.FindField("DESCRIPTION").AsString = "Maybank - Asus A555LD-xx313H"
lDetailDataSet.FindField("TAX").AsString = ""
lDetailDataSet.FindField("TAXAMT").AsFloat = 0
lDetailDataSet.FindField("TAXINCLUSIVE").AsFloat = 0
lDetailDataSet.FindField("AMOUNT").AsFloat = 2019.57
    lDetailDataSet.Post


   'Step 5: Save Document
   'Step 5 Retrieve the output
     BizObject.Save
  lDataSet.First
     BizObject.Close
  While (not lDataSet.eof)
    MsgBox "Done"
     MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("C1").AsString
lDataSet2.First
     While (not lDataSet2.eof)
  MsgBox lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("C1").AsString
  lDataSet2.Next
    Wend
lDataSet.Next
  Wend
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
<br />
===JScript/JavaScript===
This Script only can run using Internet Explorer (till IE 11)


====Example-AR_IV====
====GL.JE.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_IV Script   
! GL Journal Voucher Report Object Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg GLJE_ro.vbs
<head>
Call GetCustomerData
<title>Add Customer Invoice</title>
 
<script language="JScript">
Function CreateSQLAccServer
var ComServer;
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
function CreateSQLAccServer() {
 
   ComServer = new ActiveXObject('SQLAcc.BizApp');
Function GetCustomerData
  if (!ComServer.IsLogin) {            /* check whether user has logon */
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
   'Step 1: Create Com Server object
/* UserName, Password */
   Set ComServer = CreateSQLAccServer 'Create Com Server
  }
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
}
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   END IF
function AutoInvoice() {
  var BizObject, lMainDataSet, lDetailDataSet;
   CreateSQLAccServer();
   BizObject = ComServer.BizObjects.Find('AR_IV');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
   lDetailDataSet = BizObject.DataSets.Find('cdsDocDetail');
  BizObject.New();
  lMainDataSet.FindField('DocKey').value = -1;
  lMainDataSet.FindField('DocNo').value = "--IV Test--";
  lMainDataSet.FindField('DocDate').value = "01/10/2016";
  lMainDataSet.FindField('PostDate').value = "01/10/2016";
  lMainDataSet.FindField('Code').value = "300-A0003";
   lMainDataSet.FindField('Description').value = "Sales";


   /*For Tax Inclusive = True with override Tax Amount*/
   'Step 2: Find and Create the Report Objects
  lDetailDataSet.Append();
   Set RptObject = ComServer.RptObjects.Find("GL.JE.RO")  
  lDetailDataSet.FindField('DtlKey').value = -1;
   lDetailDataSet.FindField('DocKey').value = -1;
  lDetailDataSet.FindField('Account').value = "500-000";
  lDetailDataSet.FindField('Description').value =  "Sales Item A";
  lDetailDataSet.FindField('Tax').value =  "SR";
  lDetailDataSet.FindField('TaxInclusive').value =  0;
  lDetailDataSet.FindField('Amount').value = 410.37;
  lDetailDataSet.FindField('TaxAmt').value = 24.63;
  lDetailDataSet.DisableControls();
  lDetailDataSet.FindField('TaxInclusive').value =  1;
  lDetailDataSet.EnableControls();
  lDetailDataSet.FindField('Changed').value = "F";
  lDetailDataSet.Post();


   /*For Tax Inclusive = False with override Tax Amount*/
   'Step 3: Spool parameters
   lDetailDataSet.Append();
  RptObject.Params.Find("AllCurrency").Value = true
   lDetailDataSet.FindField('DtlKey').value = -1;
   RptObject.Params.Find("AllDocProject").Value = true
   lDetailDataSet.FindField('DocKey').value = -1;
   RptObject.Params.Find("AllDocument").Value = true
   lDetailDataSet.FindField('Account').value = "500-000";
   RptObject.Params.Find("AllItemProject").Value = true
   lDetailDataSet.FindField('Description').value = "Sales Item B";
   RptObject.Params.Find("AllItemArea").Value = true
   lDetailDataSet.FindField('Tax').value = "SR";
  RptObject.Params.Find("AllItemAgent").Value = true
   lDetailDataSet.FindField('TaxInclusive').value = 0;
   RptObject.Params.Find("AllDocAgent").Value = true
   lDetailDataSet.FindField('Amount').value = 94.43;
  RptObject.Params.Find("AllDocArea").Value = true
   lDetailDataSet.FindField('TaxAmt').value = 5.66;
   RptObject.Params.Find("AllPaymentMethod").Value = true
   lDetailDataSet.FindField('Changed').value = "F";
 
   lDetailDataSet.Post();
  lDateFrom = CDate("December 1, 2017")
  lDateTo = CDate("December 31, 2017")
 
  RptObject.Params.Find("DateFrom").Value = lDateFrom
  RptObject.Params.Find("DocDateFrom").Value = lDateFrom
   RptObject.Params.Find("DateTo").Value = lDateTo
   RptObject.Params.Find("DocDateTo").Value = lDateTo
  RptObject.Params.Find("IncludeCancelled").Value = false
   RptObject.Params.Find("PrintDocumentStyle").Value = false
  RptObject.Params.Find("SelectDate").Value = true 'Post Date
   RptObject.Params.Find("SelectDocDate").Value = false 'Doc Date
 
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
   Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
  MsgBox "Count " & lDataSet.RecordCount


   /* Save document */ 
   'Step 5 Retrieve the output
    BizObject.Save();
  lDataSet.First
     BizObject.Close();
  While (not lDataSet.eof)
     alert('Customer Invoice - has been saved.');
     MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
}
lDataSet2.First
</script>
     While (not lDataSet2.eof)
</head>
  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
<body>
  lDataSet2.Next
<input type="submit" value="SYNC" name="btnSubmit" onclick="AutoInvoice()">
    Wend
</body>
lDataSet.Next
</html>
  Wend
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-SL_CS====
====SL_CS====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_CS Script   
! SL_CS Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
<head>
Call InsertData
<title>Add Cash Sales</title>
 
<script language="JScript">
Function CreateSQLAccServer
var ComServer;
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


function CreateSQLAccServer() {
Function InsertData
  ComServer = new ActiveXObject('SQLAcc.BizApp');
Dim ComServer, BizObject, lDate
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}


function InsertData() {
  'Step 1: Create Com Server object
   var BizObject, lMain, lDetail;
   Set ComServer = CreateSQLAccServer 'Create Com Server
 
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   CreateSQLAccServer();
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
   END IF


   /*Step 2: Find and Create the Biz Objects*/
   'Step 2: Find and Create the Biz Objects
   BizObject = ComServer.BizObjects.Find('SL_CS') ;
   Set BizObject = ComServer.BizObjects.Find("SL_CS")  


   /*Step 3: Set Dataset*/
   'Step 3: Set Dataset
   lMain  = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
   Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
   lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */  
   Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data   
    
    
   /*Begin Looping yr data*/
   'Step 4 : Insert Data - Master
  /*Step 4 : Insert Data - Master*/
  lDate = CDate("January 1, 2016")
   BizObject.New();
   BizObject.New
   lMain.FindField('DocKey').value         = -1;
   lMainDataSet.FindField("DocKey").value = -1
   lMain.FindField('DocNo').AsString      = "--IV Test--";
   lMainDataSet.FindField("DocNo").value = "--IV Test--"
   lMain.FindField('DocDate').value       = "20/12/2017";
   lMainDataSet.FindField("DocDate").value = lDate
   lMain.FindField('PostDate').value       = "20/12/2017";
   lMainDataSet.FindField("PostDate").value = lDate
   lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
   lMainDataSet.FindField("Code").value = "300-C0001" 'Customer Code
   lMain.FindField('CompanyName').AsString = "Cash Sales"
   lMainDataSet.FindField("Description").value = "Sales"
  lMain.FindField('Address1').AsString    = ""; /*Optional*/
      
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
   'Step 5: Insert Data - Detail
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
   'For Tax Inclusive = True with override Tax Amount
  lMain.FindField('Address4').AsString    = ""; /*Optional*/
   lDetailDataSet.Append
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
   lDetailDataSet.FindField("DtlKey").value = -1
  lMain.FindField('Description').AsString = "Sales";
   lDetailDataSet.FindField("DocKey").value = -1
      
   lDetailDataSet.FindField("Account").value = "500-000" 'Sales Account Code  & can ignore if had itemcode
   /*Step 5: Insert Data - Detail*/
   lDetailDataSet.FindField("Description").value = "Sales Item A"
   /*For Tax Inclusive = True with override Tax Amount*/
   lDetailDataSet.FindField("Qty").value = 1
   lDetail.Append();
   lDetailDataSet.FindField("Tax").value = "SR"
   lDetail.FindField('DtlKey').value         = -1;
   lDetailDataSet.FindField("TaxInclusive").value = 0
   lDetail.FindField('DocKey').value         = -1;
   lDetailDataSet.FindField("UnitPrice").value = 410.37
   lDetail.FindField('Seq').value           = 1;
   lDetailDataSet.FindField("Amount").value = 410.37
  lDetail.FindField('Account').AsString    = "500-000"; /*Sales Account*/
   lDetailDataSet.FindField("TaxAmt").value = 24.63
   lDetail.FindField('Description').AsString = "Sales Item A";
   lDetail.FindField('Qty').AsFloat          = 1;
   lDetail.FindField('Tax').AsString        = "SR";
   lDetail.FindField('TaxRate').AsString    = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
   lDetail.FindField('UnitPrice').AsFloat    = 435;
   lDetail.FindField('Amount').AsFloat      = 410.37; /*Exclding GST Amt*/
   lDetail.FindField('TaxAmt').AsFloat      = 24.63;
    
    
   lDetail.DisableControls();
   lDetailDataSet.DisableControls
   lDetail.FindField('TaxInclusive').value   = 1;
   lDetailDataSet.FindField("TaxInclusive").value = 1
   lDetail.EnableControls();
   lDetailDataSet.EnableControls
    
    
   lDetail.Post();
   lDetailDataSet.Post
    
    
   /*For Tax Inclusive = False with override Tax Amount*/
   'For Tax Inclusive = False with override Tax Amount
   lDetail.Append();
   lDetailDataSet.Append
   lDetail.FindField('DtlKey').value         = -1;
   lDetailDataSet.FindField("DtlKey").value = -1
   lDetail.FindField('DocKey').value         = -1;
   lDetailDataSet.FindField("DocKey").value = -1
   lDetail.FindField('Seq').value           = 2;
   lDetailDataSet.FindField("Account").value = "500-000"
  lDetail.FindField('Account').AsString    = "500-000";
   lDetailDataSet.FindField("Description").value = "Sales Item B"
   lDetail.FindField('Description').AsString = "Sales Item B";
   lDetailDataSet.FindField("Qty").value = 1
   lDetail.FindField('Qty').AsFloat          = 1;
   lDetailDataSet.FindField("Tax").value = "SR"
   lDetail.FindField('Tax').AsString        = "SR";
   lDetailDataSet.FindField("TaxInclusive").value = 0
   lDetail.FindField('TaxRate').AsString    = "6%";
   lDetailDataSet.FindField("UnitPrice").value = 94.43
  lDetail.FindField('TaxInclusive').value   = 0;
   lDetailDataSet.FindField("Amount").value = 94.43
   lDetail.FindField('UnitPrice').AsFloat    = 94.43;
   lDetailDataSet.FindField("TaxAmt").value = 5.66
   lDetail.FindField('Amount').AsFloat      = 94.43;
   lDetailDataSet.Post
   lDetail.FindField('TaxAmt').AsFloat      = 5.66;
   lDetail.Post();


   /*For With Item Code*/
   'For With Item Code
   lDetail.Append();
   lDetailDataSet.Append
   lDetail.FindField('DtlKey').value         = -1;
   lDetailDataSet.FindField("DtlKey").value = -1
   lDetail.FindField('DocKey').value         = -1;
   lDetailDataSet.FindField("DocKey").value = -1
   lDetail.FindField('Seq').value           = 3;
   lDetailDataSet.FindField("ItemCode").value = "ANT"
  lDetail.FindField('ItemCode').AsString    = "ANT";
   lDetailDataSet.FindField("Description").value = "Sales Item B"
   lDetail.FindField('Description').AsString = "Sales Item B";
   lDetailDataSet.FindField("Qty").value = 2
   /*lDetail.FindField('Account').AsString    = "500-000"; If you wanted override the Sales Account Code*/
   lDetailDataSet.FindField("Tax").value = "SR"
  lDetail.FindField('Qty').AsFloat          = 2;
   lDetailDataSet.FindField("TaxInclusive").value = 0
   lDetail.FindField('UOM').AsString        = "UNIT";
   lDetailDataSet.FindField("UnitPrice").value = 100
  /*lDetail.FindField('DISC').AsString        = "5%+3"; Optional (eg 5% plus 3 Discount)*/
   lDetailDataSet.FindField("Amount").value = 200
  lDetail.FindField('Tax').AsString        = "SR";
   lDetailDataSet.FindField("TaxAmt").value = 12
   lDetail.FindField('TaxRate').AsString    = "6%";
   lDetailDataSet.Post
  lDetail.FindField('TaxInclusive').value   = 0;
   lDetail.FindField('UnitPrice').AsFloat    = 100;
   lDetail.FindField('Amount').AsFloat      = 200;
   lDetail.FindField('TaxAmt').AsFloat      = 12;
   lDetail.Post();


   /*Step 6: Save Document*/
   'Step 6: Save Document
   BizObject.Save();
   BizObject.Save
   BizObject.Close();
   BizObject.Close
    alert('Document has been saved.');
  ComServer.Logout
}
  MsgBox "Done"
</script>
End Function
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="InsertData()">
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_PM====
====Customer.PM.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script   
! Customer.PM.RO Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg Customer.PM.RO.vbs
<head>
Call GetARPMData
<title>Add Customer Payment</title>
<script language="JScript">
Function CreateSQLAccServer
var ComServer;
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetARPMData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.PM.RO")
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value    = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("AllAgent").Value                = true
  RptObject.Params.Find("AllCompanyCategory").Value      = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value              = true
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocument").Value            = false
  RptObject.Params.Find("AllPaymentMethod").Value        = true
  'RptObject.Params.Find("AreaData").Value                = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyData").Value            = 'Not use if AllCompany is true
  'RptObject.Params.Find("CurrencyData").Value            = 'Not use if AllCurrency is true


function CreateSQLAccServer() {
   lDateFrom = CDate("January 01, 2017")
   ComServer = new ActiveXObject("SQLAcc.BizApp");
   lDateTo = CDate("December 31, 2017")
   if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
 
function AutoPayment() {
  var BizObject, lMainDataSet, lKnockOffDataSet, V;
    
    
   CreateSQLAccServer();
   RptObject.Params.Find("DateFrom").Value                = lDateFrom
 
   RptObject.Params.Find("DateTo").Value                  = lDateTo
   BizObject = ComServer.BizObjects.Find('AR_PM');
   RptObject.Params.Find("DocumentData").Value            = "VCOR-00049"
   lMainDataSet = BizObject.DataSets.Find('MainDataSet');
   'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
   lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
   RptObject.Params.Find("IncludeCancelled").Value        = false
   BizObject.New();
   'RptObject.Params.Find("PaymentMethodData").Value      = 'Not use if AllPaymentMethod is true
    
   RptObject.Params.Find("PrintDocumentStyle").Value      = false
   lMainDataSet.FindField('DocKey').value = -1;
   RptObject.Params.Find("SelectDate").Value              = true
   lMainDataSet.FindField('DocNo').value = "Test";
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = false
   lMainDataSet.FindField('Code').value = "888";
   RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
   lMainDataSet.FindField('DocDate').value = "01/09/2015";
   RptObject.Params.Find("AllDocProject").Value          = true
   lMainDataSet.FindField('PostDate').value = "01/09/2015";
  RptObject.Params.Find("AllItemProject").Value          = true
   lMainDataSet.FindField('Project').value = "----";
   'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
   'RptObject.Params.Find("ItemProjectData").Value        = 'Not use if AllItemProject is true 
    
    
   lMainDataSet.FindField('Description').value = "";
   'Step 4: Perform Report calculation
   lMainDataSet.FindField('PaymentMethod').value = "320-000";
  RptObject.CalculateReport()
   lMainDataSet.FindField('Journal').value = "CASH";
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
   lMainDataSet.FindField('ChequeNumber').value = "";
   Set lDataSet2 = RptObject.DataSets.Find("cdsKnockOff")
   lMainDataSet.FindField('CurrencyCode').value = "----";
   Set lDataSet3 = RptObject.DataSets.Find("cdsKnockOffDetail")
   lMainDataSet.FindField('CurrencyRate').value = "1.0000000000";
   MsgBox "Count " & lDataSet.RecordCount
   lMainDataSet.FindField('DocAmt').value = "106.00";
  lMainDataSet.FindField('BankCharge').value = "0";
   'Step 5 Retrieve the output
  lMainDataSet.FindField('UnappliedAmt').value = "0";
  lDataSet.First
  lMainDataSet.FindField('Cancelled').value = 'F';
   While (not lDataSet.eof)
 
    MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
  v = ComServer.CreateOleVariantArray(2);
MsgBox "cdsKnockOff Count " & lDataSet2.RecordCount
  v.SetItem(0, 'IV'); /*Knock Off DocType*/
lDataSet2.First
  v.SetItem(1, 'IV-00111'); /*Knock Off DocNo*/
    While (not lDataSet2.eof)
 
  MsgBox lDataSet2.FindField("FromDocKey").AsString & " " & lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("KOAmt").AsString
  if (lKnockOffDataSet.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
  lDataSet2.Next
          lKnockOffDataSet.Edit();
     Wend
          lKnockOffDataSet.FindField('DocAmt').value = "106";  
     MsgBox "cdsKnockOffDetail Count " & lDataSet3.RecordCount
          lKnockOffDataSet.FindField('KnockOff').AsString = 'T';
lDataSet3.First
          lKnockOffDataSet.Post(); }
     While (not lDataSet3.eof)
     /* Save document */ 
      MsgBox lDataSet3.FindField("FromDocKey").AsString & " " & lDataSet3.FindField("DocNo").AsString & " " & lDataSet3.FindField("KOAmt").AsString
     BizObject.Save();
    lDataSet3.Next
     BizObject.Close();
    Wend
    alert("Customer Payment - has been saved.");
lDataSet.Next
}
  Wend
</script>
End Function
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="AutoPayment()">
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.IV.RO====
====Sales.IV.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.IV.RO Report Object Script   
! Sales.IV.RO Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg Sales.IV.RO.vbs
   <head>
Call GetSalesIVData
     <title>Customer.IV.RO</title>
     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Function CreateSQLAccServer
    <script type="text/javascript">
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
var ComServer;
End Function
Function GetSalesIVData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Sales.IV.RO")
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  RptObject.Params.Find("AllAgent").Value              = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value            = false
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllDocument").Value            = true
  RptObject.Params.Find("AllItem").Value                = true
  RptObject.Params.Find("AllItemProject").Value        = true
  RptObject.Params.Find("AllLocation").Value            = true
  RptObject.Params.Find("AllStockGroup").Value          = true
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllBatch").Value              = true
  RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
  'RptObject.Params.Find("TariffData").Value            = 'Not use if TariffData is true - For Version 776 & above
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyCategoryData").Value    = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-C0001"
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true


function CreateSQLAccServer() {
   lDateFrom = CDate("January 01, 2017")
   ComServer = new ActiveXObject("SQLAcc.BizApp");
   lDateTo = CDate("December 31, 2017")
   if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}     
 
function GetData() { 
  var lMain, lDetail, lRptVar, lDateFrom, lDateTo;
    
    
   elem = document.getElementById('txt1');
   RptObject.Params.Find("DateFrom").Value                = lDateFrom
    
  RptObject.Params.Find("DateTo").Value                  = lDateTo
   CreateSQLAccServer();
  'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
 
  'RptObject.Params.Find("DocumentData").Value            = 'Not use if AllDocument is true
   lDateFrom = new Date("January 1 2015");
  'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
   lDateTo = new Date("December 31, 2015");  
  'RptObject.Params.Find("CategoryData").Value            = 'Not use if HasCategory is false
  'RptObject.Params.Find("CategoryTpl").Value            = 'For Internal use only
  RptObject.Params.Find("IncludeCancelled").Value        = false
  RptObject.Params.Find("HasCategory").Value            = false
  'RptObject.Params.Find("ItemData").Value                = 'Not use if AllItem is true
   'RptObject.Params.Find("ItemProjectData").Value        = 'Not use if AllItemProject is true
   'RptObject.Params.Find("LocationData").Value            = 'Not use if AllLocation is true
  'RptObject.Params.Find("ItemCategoryData").Value        = 'For Internal use only
   'RptObject.Params.Find("BatchData").Value              = 'Not use if AllBatch is true
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
   RptObject.Params.Find("SelectDate").Value              = true
  RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
  'RptObject.Params.Find("StockGroupData").Value          = 'Not use if AllStockGroup is true
    
    
  lRptVar = ComServer.RptObjects.Find('Customer.IV.RO');
  lRptVar.Params.Find('SelectDate').Value          = true;
  lRptVar.Params.Find('DateFrom').Value            = lDateFrom.valueOf();
  lRptVar.Params.Find('DateTo').Value              = lDateTo.valueOf();
  lRptVar.Params.Find('AllAgent').Value            = false;
  lRptVar.Params.Find('AgentData').Value            = "----\nLF"; /*Filter by Agent code ---- & HALIM */
  lRptVar.Params.Find('AllArea').Value              = true;
  lRptVar.Params.Find('AllCompany').Value          = true;
  lRptVar.Params.Find('AllCurrency').Value          = true;
  lRptVar.Params.Find('AllDocProject').Value        = true;
  lRptVar.Params.Find('AllCompanyCategory').Value  = true;
  lRptVar.Params.Find('AllDocument').Value          = true;
  lRptVar.Params.Find('IncludeCancelled').Value  = false;
  lRptVar.Params.Find('PrintDocumentStyle').Value = false;
  lRptVar.Params.Find('AllItemProject').Value    = true;
  lRptVar.Params.Find('AllPaymentMethod').Value  = true;
  lRptVar.CalculateReport(); 
    
    
   lMain   = lRptVar.DataSets.Find('cdsMain');
   'Step 4: Perform Report calculation
   lDetail = lRptVar.DataSets.Find('cdsDocDetail');
  RptObject.CalculateReport()
   /*alert("Count -" + lRptVar.DataSets.Find('cdsDocDetail').RecordCount);*/
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
   elem.innerHTML += 'From Main'+'\n';
   Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
   
   MsgBox "Count " & lDataSet.RecordCount
   lMain.First();
   while (!lMain.eof) {
   'Step 5 Retrieve the output
     elem.innerHTML += lMain.FindField('DocKey').AsString + ' ' +
   lDataSet.First
                  lMain.FindField('DocNo').AsString + ' ' + lMain.FindField('DocDate').AsString + ' '+
   While (not lDataSet.eof)
                      lMain.FindField('CompanyName').AsString + ' ' + lMain.FindField('DocAmt').AsString + '\n';
     MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
lMain.Next(); 
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
  }
lDataSet2.First
  elem.innerHTML += 'End Main'+'\n\n';
    While (not lDataSet2.eof)
 
  MsgBox lDataSet2.FindField("DocKey").AsString & " " & lDataSet2.FindField("ItemCode").AsString & " " & lDataSet2.FindField("Amount").AsString
  elem.innerHTML += 'From Detail'+'\n';
  lDataSet2.Next
  lDetail.First();
    Wend
  while (!lDetail.eof) {
lDataSet.Next
    elem.innerHTML += lDetail.FindField('Dockey').AsString + ' ' + lDetail.FindField('Account').AsString + ' ' +
   Wend
                  lDetail.FindField('Description').AsString + ' ' + lDetail.FindField('Amount').AsString + '\n';
End Function
lDetail.Next(); 
  } 
  elem.innerHTML += 'End Detail'+'\n\n';
}
 
    </script>
   </head>
  <body>
    <form>
      <textarea id="txt1" rows="30" cols="116"></textarea>
      <input type="button" value="Calculate" onclick="GetData()">
    </form>
  </body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.RO====
====Customer.DueDocument.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.RO Report Object Script   
! Customer.DueDocument.RO Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg Customer.DueDocument.RO.vbs
<head>
Call GetData
<title>Add Customer Invoice</title>
<script language='JScript'>
Function CreateSQLAccServer
var ComServer;
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetData
Dim ComServer, RptObject, lDataSet, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
   
   
function CreateSQLAccServer() {
  'Step 2: Find and Create the Report Objects
   ComServer = new ActiveXObject('SQLAcc.BizApp');
  Set RptObject = ComServer.RptObjects.Find("Customer.DueDocument.RO")  
   if (!ComServer.IsLogin) {           /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
  'Step 3: Spool parameters
/* UserName, Password */
   'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
   }
  RptObject.Params.Find("AllAgent").Value              = true
}
  RptObject.Params.Find("AllArea").Value                = true
 
  RptObject.Params.Find("AllCompany").Value            = false
function GetCustomerData() {
   RptObject.Params.Find("AllCompanyCategory").Value    = true
   var RptObject, lDataSet, lDataSet2;
  RptObject.Params.Find("AllCurrency").Value           = true
   edOutput.value = '';
  RptObject.Params.Find("AllDocProject").Value          = true
   edOutput2.value = '';
  RptObject.Params.Find("AllItemProject").Value        = true
   //Step 1: Create Com Server object
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
   CreateSQLAccServer();
  'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-A0003"
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("GroupBy").Value              = 'If you wanted to grouping the data
  'RptObject.Params.Find("ItemProjectData").Value      = 'Not use if AllItemProject is true
   RptObject.Params.Find("PrintContra").Value            = true
  RptObject.Params.Find("PrintCreditNote").Value        = true
  RptObject.Params.Find("PrintDebitNote").Value        = true
  RptObject.Params.Find("PrintInvoice").Value          = true
   RptObject.Params.Find("PrintOverDue").Value          = true
   RptObject.Params.Find("PrintUnDue").Value            = true
   RptObject.Params.Find("ShowForeignCurrency").Value    = true
   RptObject.Params.Find("ShowLocalCurrency").Value      = true
   RptObject.Params.Find("SortBy").Value                = "PostDate;DocNo;Code"
    
    
   //Step 2: Find and Create the Report Objects
   lDateTo = CDate("April 12, 2018")
  RptObject = ComServer.RptObjects.Find('Customer.RO');
    
    
  //Step 3: Spool parameters
   RptObject.Params.Find("DateTo").Value                 = lDateTo
   RptObject.Params.Find('AllAgent').Value = true;
   RptObject.Params.Find("IncludePDCheque").Value       = true
   RptObject.Params.Find('AllArea').Value = true;
   
   RptObject.Params.Find('AllCompany').Value = true;
   'Step 4: Perform Report calculation
   RptObject.Params.Find('AllCompanyCategory').Value = true;
   RptObject.CalculateReport()
   RptObject.Params.Find('AllCurrency').Value = true;
   Set lDataSet = RptObject.DataSets.Find("cdsMain")
   RptObject.Params.Find('AllTerms').Value = true;
   MsgBox "Count " & lDataSet.RecordCount
   RptObject.Params.Find('SelectDate').Value = true;
   RptObject.Params.Find('PrintActive').Value = true;
   'Step 5 Retrieve the output
   RptObject.Params.Find('PrintInactive').Value = false;
   lDataSet.First
  RptObject.Params.Find('PrintPending').Value = false;
   While (not lDataSet.eof)
  RptObject.Params.Find('PrintProspect').Value = false;
    MsgBox "Dockey " & lDataSet.FindField("DocKey").AsString
  RptObject.Params.Find('PrintSuspend').Value = false;
MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
  //RptObject.Params.Find('CompanyData').Value = '300-A0003';
MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
 
MsgBox "Outstanding " & lDataSet.FindField("Outstanding").AsString
  //Step 4: Perform Report calculation
MsgBox "Code " & lDataSet.FindField("Code").AsString
  RptObject.CalculateReport();
lDataSet.Next
  lDataSet = RptObject.DataSets.Find('cdsMain');
   Wend
   lDataSet2 = RptObject.DataSets.Find('cdsBranch');
End Function
 
</syntaxhighlight>
  //alert('Count ' + lDataSet.RecordCount);
|}


  //Step 5 Retrieve the output
<div style="float: right;">   [[#top|[top]]]</div>
  lDataSet.First;
  while  (!lDataSet.eof){
    edOutput.value = edOutput.value +
                'Code : ' + lDataSet.FindField('Code').AsString + '\n' +
                'Company Name : ' + lDataSet.FindField('CompanyName').AsString +'\n\n';
lDataSet.Next();
   }
  lDataSet2.First();
  while (!lDataSet2.eof){
  edOutput2.value = edOutput2.value +
                  'Code : '+ lDataSet2.FindField('Code').AsString + '\n' +
  'Branch Name : '+ lDataSet2.FindField('BranchName').AsString + '\n' +
                  'Address 1 : '+ lDataSet2.FindField('Address1').AsString + '\n' +
  'Address 2 : '+ lDataSet2.FindField('Address2').AsString + '\n' +
  'Address 3 : '+ lDataSet2.FindField('Address3').AsString + '\n' +
  'Address 4 : '+ lDataSet2.FindField('Address4').AsString + '\n' +
  'Phone 1 : '+ lDataSet2.FindField('Phone1').AsString  +'\n\n';
  lDataSet2.Next();
    }
}


</script>
====Customer.IV.RO====
</head>
{| class="mw-collapsible mw-collapsed wikitable"
<body>
! Customer.IV.RO Script 
  <table>
|-
    <tr>
|
      <th>Main Table</th>
<syntaxhighlight lang="vb">
      <th>Branch Branch</th>
'Copy below script & paste to notepad & name it as eg Customer.IV.RO.vbs
    </tr>
Call GetData
    <tr>
      <td>
Function CreateSQLAccServer
        <TEXTAREA rows=15 cols=75 name="edOutput"></TEXTAREA>
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  </td>
End Function
      <td>
        <TEXTAREA rows=15 cols=75 name="edOutput2"></TEXTAREA>
Function GetData
  </td>
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
    </tr>
  'Step 1: Create Com Server object
   </table>
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   <table width="83%">
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
<tr>
  END IF
  <td align="center">
<input type='submit' value='Sync Data' name='btnSubmit' onclick='GetCustomerData()'>
  'Step 2: Find and Create the Report Objects
  </td>
  Set RptObject = ComServer.RptObjects.Find("Customer.IV.RO")
</tr>
   </table>
  'Step 3: Spool parameters
</body>
  'RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is true
</html>
   'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
</syntaxhighlight>
  RptObject.Params.Find("AllAgent").Value              = true
|}
   RptObject.Params.Find("AllCompanyCategory").Value    = true
<div style="float: right;">   [[#top|[top]]]</div>
  RptObject.Params.Find("AllArea").Value                = true
 
  RptObject.Params.Find("AllCompany").Value            = true
====Example-Get Next IV Number====
  RptObject.Params.Find("AllCurrency").Value            = true
{| class="mw-collapsible mw-collapsed wikitable"
  RptObject.Params.Find("AllDocument").Value            = false
! Get Next IV Number Script 
  RptObject.Params.Find("AllPaymentMethod").Value      = true
|-
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
|
  'RptObject.Params.Find("CompanyData").Value          = 'Not use if AllCompany is true
<syntaxhighlight lang="javascript">
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
<html>
 
<head>
  lDateFrom = CDate("January 01, 2017")
<title>Add Cash Sales</title>
   lDateTo = CDate("December 31, 2017")
<script language="JScript">
 
var ComServer, lDataSet;
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
 
  RptObject.Params.Find("DateTo").Value                  = lDateTo
function CreateSQLAccServer() {
  RptObject.Params.Find("DocumentData").Value            = "IV-00012"
  ComServer = new ActiveXObject('SQLAcc.BizApp');
   'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
  if (!ComServer.IsLogin) {            /* check whether user has logon */
  RptObject.Params.Find("IncludeCancelled").Value        = true
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
  'RptObject.Params.Find("PaymentMethodData").Value      = 'Not use if AllPaymentMethod is true
/* UserName, Password */
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
   }
  RptObject.Params.Find("SelectDate").Value              = true
}
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = true
  RptObject.Params.Find("SortBy").Value                  = "DocDate;DocNo;Code"
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllItemProject").Value          = true
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("ItemProjectData  ").Value      = 'Not use if AllItemProject is true
   
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
  MsgBox "Count " & lDataSet.RecordCount
  'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
MsgBox "PaymentAmt " & lDataSet.FindField("PaymentAmt").AsString
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
lDataSet2.First
    While (not lDataSet2.eof)
  MsgBox "Account " & lDataSet2.FindField("Account").AsString
  MsgBox "Description " & lDataSet2.FindField("Description").AsString
  MsgBox "Amount " & lDataSet2.FindField("Amount").AsString
  lDataSet2.Next
    Wend
lDataSet.Next
   Wend
End Function
</syntaxhighlight>
|}


function zeroPad(num, places) {
<div style="float: right;"[[#top|[top]]]</div>
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
   /*zeroPad(5, 2); // "05"*/
}


function GetData() {
====Sales.OutstandingSO.RO====
   var lSQL;
{| class="mw-collapsible mw-collapsed wikitable"
   lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A ";
! Sales.OutstandingSO.RO Script 
   lSQL = lSQL + "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) ";
|-
   lSQL = lSQL + "WHERE A.DOCTYPE='IV' ";
|
   lSQL = lSQL + "AND A.DESCRIPTION='Customer Invoice' ";
<syntaxhighlight lang="vb">
   lSQL = lSQL + "AND A.STATESET=1 ";
'Copy below script & paste to notepad & name it as eg Sales.OutstandingSO.RO.vbs
   lDataSet = ComServer.DBManager.NewDataSet(lSQL)
Call GetData
}
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
   'Step 1: Create Com Server object
   Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"  
   END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Sales.OutstandingSO.RO")
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
  'RptObject.Params.Find("LocationData").Value        = 'Not use if AllLocation is true
   'RptObject.Params.Find("StockGroupData").Value      = 'Not use if AllStockGroup is true
  RptObject.Params.Find("AllAgent").Value              = true
   RptObject.Params.Find("AllArea").Value              = true
  RptObject.Params.Find("AllCompany").Value            = true
  RptObject.Params.Find("AllDocument").Value          = false
   RptObject.Params.Find("AllItem").Value              = true
  RptObject.Params.Find("AllItemProject").Value        = true
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
   'RptObject.Params.Find("CompanyData").Value          = 'Not use if AllCompany is true
  RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
  'RptObject.Params.Find("TariffData").Value            = 'Not use if TariffData is true - For Version 776 & above


function ShowNextNo() {
  var Desc, Fmt, NextNo, lResult, lPad;
    
    
   CreateSQLAccServer();
   lDateFrom = CDate("January 01, 2017")
   GetData();
  lDateTo = CDate("December 31, 2017")
 
 
   if (lDataSet.RecordCount > 0) {    
  'RptObject.Params.Find("DateFrom").Value              = lDateFrom
    lDataSet.First;
  'RptObject.Params.Find("DateTo").Value                = lDateTo
     Desc = lDataSet.FindField("Description").AsString;
  'RptObject.Params.Find("DeliveryDateFrom").Value      = lDateFrom
Fmt  = lDataSet.FindField("Format").AsString;
  'RptObject.Params.Find("DeliveryDateTo").Value        = lDateTo
NextNo = lDataSet.FindField("NEXTNUMBER").Value;
  RptObject.Params.Find("DocumentData").Value          = "SO-00007"& vbCRLF & "SO-00009"
    alert(Desc);
  'RptObject.Params.Find("GroupBy").Value              = 'If you wanted to grouping the data
alert(Fmt);
  RptObject.Params.Find("IncludeCancelled").Value      = false
alert(NextNo);
  'RptObject.Params.Find("ItemData").Value              = 'Not use if AllItem is true
  RptObject.Params.Find("PrintFulfilledItem").Value    = true 'Print transfered info
lPad = Fmt.substr(5, 1);
  RptObject.Params.Find("PrintOutstandingItem").Value  = true 'Print untransfer info
lPad = zeroPad(NextNo, lPad)
  'RptObject.Params.Find("ItemProjectData").Value      = 'Not use if AllItemProject is true
Desc = Fmt.substr(0, 3);
  RptObject.Params.Find("SelectDate").Value            = false
alert(Desc + lPad);
  RptObject.Params.Find("SelectDeliveryDate").Value    = false
  }
  RptObject.Params.Find("SortBy").Value                = "DocDate;DocNo;Code"
}
  RptObject.Params.Find("AllDocProject").Value          = true
</script>
  RptObject.Params.Find("AllLocation").Value            = true
</head>
  RptObject.Params.Find("AllCompanyCategory").Value    = true
<body>
  RptObject.Params.Find("AllBatch").Value              = true
<input type="submit" value="Show Next No" name="btnSubmit" onclick="ShowNextNo()">
  RptObject.Params.Find("HasCategory").Value            = false
</body>
  RptObject.Params.Find("AllStockGroup").Value          = true
</html>
  'RptObject.Params.Find("CategoryData").Value          = 'For Internal use only
  'RptObject.Params.Find("CategoryTpl").Value          = 'For Internal use only
   'RptObject.Params.Find("ItemCategoryData").Value      = 'For Internal use only
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
   'RptObject.Params.Find("BatchData").Value            = 'Not use if AllBatch is true
  RptObject.Params.Find("TranferDocFilterDate").Value  = false
 
   
  'Step 4: Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsTransfer")
  MsgBox "Count " & lDataSet.RecordCount
   'Step 5 Retrieve the output
  lDataSet.First
  While (not lDataSet.eof)
     MsgBox "DocKey " & lDataSet.FindField("DocKey").AsString
MsgBox "DtlKey " & lDataSet.FindField("Dtlkey").AsString
MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
MsgBox "Item Code " & lDataSet.FindField("ItemCode").AsString
MsgBox "Org Qty " & lDataSet.FindField("SQty").AsString
MsgBox "Outstanding Qty " & lDataSet.FindField("OutstandingQty").AsString
MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
lDataSet2.First
    While (not lDataSet2.eof)
      MsgBox "FromDocKey " & lDataSet2.FindField("FromDocKey").AsString
  MsgBox "FromDtlKey " & lDataSet2.FindField("FromDtlkey").AsString
  MsgBox "DocType " & lDataSet2.FindField("DocType").AsString
  MsgBox "DocNo " & lDataSet2.FindField("DocNo").AsString
  MsgBox "DocDate " & lDataSet2.FindField("DocDate").AsString
  MsgBox "Transfer Qty " & lDataSet2.FindField("TransferQty").AsString
  lDataSet2.Next
    Wend
lDataSet.Next
  Wend
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
====Example-Customer & Supplier Contra====
 
====Common.PaymentMethod.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer & Supplier Contra Script   
! Common.PaymentMethod.RO Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="vb">
<html>
'Copy below script & paste to notepad & name it as eg Common.PaymentMethod.RO.vbs
<head>
Call GetInfo
<title>Add Customer Invoice</title>
<script language="JScript">
var ComServer;
   
   
function CreateSQLAccServer() {
Function CreateSQLAccServer
   ComServer = new ActiveXObject('SQLAcc.BizApp');
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  if (!ComServer.IsLogin) {            /* check whether user has logon */
End Function
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
   
   
function PostARCT() {
Function GetInfo
   var BizObject, lMain, lKO, V;
Dim ComServer, RptObject, lDataSet1, lDataSet2
   'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
   
   
   CreateSQLAccServer();
   'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.PaymentMethod.RO")  
   
   
  BizObject = ComServer.BizObjects.Find('AR_CT');
  lMain = BizObject.DataSets.Find('MainDataSet');
  lKO = BizObject.DataSets.Find('cdsKnockOff');
  BizObject.New();
   
   
   lMain.FindField('DocKey').value = -1;
   'Step 3: Perform Report calculation
   lMain.FindField('DocNo').value = "--CT Test--";
   RptObject.CalculateReport()
   lMain.FindField('DocDate').value = "01/10/2020";
   Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  lMain.FindField('PostDate').value = "01/10/2020";
   Set lDataSet2 = RptObject.DataSets.Find("cdsPaymentAccount") 'You can link with lDataSet1 using Code to get the description
  lMain.FindField('Code').value = "300-A0002";
  lMain.FindField('Description').value = "Contra";
   lMain.FindField('DocAmt').value = "100.00";
  //lMain.FindField('UnappliedAmt').value = "0";


   v = ComServer.CreateOleVariantArray(2);
   MsgBox "Count " & lDataSet1.RecordCount
   v.SetItem(0, 'IV'); /*Knock Off DocType*/
  v.SetItem(1, 'IV-00021'); /*Knock Off DocNo*/
  'Step 5 Retrieve the output
 
   lDataSet1.First
   if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
  While (not lDataSet1.eof)
          lKO.Edit();
MsgBox "Code : " & lDataSet1.FindField("Code").AsString
          lKO.FindField('DocAmt').value = "100";  
lDataSet1.Next
          lKO.FindField('KnockOff').AsString = 'T';
  Wend   
          lKO.Post(); }
 
   MsgBox "Count " & lDataSet2.RecordCount
 
  lDataSet2.First
  While (not lDataSet2.eof)
MsgBox "Code : " & lDataSet2.FindField("Code").AsString
MsgBox "Description : " & lDataSet2.FindField("Description").AsString
lDataSet2.Next
  Wend   
End Function
</syntaxhighlight>
|}


   /* Save document */ 
<div style="float: right;">   [[#top|[top]]]</div>
    BizObject.Save();
    BizObject.Close();
    alert('Customer Contra - has been saved.');
}


function PostAPST() {
====Common.Agent.RO====
  var BizObject, lMain, lKO, V, lDocNo, lDocKey;
{| class="mw-collapsible mw-collapsed wikitable"
! Common.Agent.RO Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
Call GetInfo
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function GetInfo
Dim ComServer, RptObject, lDataSet1
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB"
  END IF
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO")
   
   
  CreateSQLAccServer();
   
   
   BizObject = ComServer.BizObjects.Find('AP_ST');
   'Step 3: Perform Report calculation
   lMain = BizObject.DataSets.Find('MainDataSet');
   RptObject.CalculateReport()
   lKO = BizObject.DataSets.Find('cdsKnockOff');
   Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
    
    
   lDocNo = "--CT Test--"
   MsgBox "Count " & lDataSet1.RecordCount
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
   
  BizObject.Params.Find("DocKey").Value = lDocKey  
   'Step 5 Retrieve the output
    
   lDataSet1.First
   if (lDocKey != null) {
  While (not lDataSet1.eof)
    BizObject.Open();
MsgBox "Code : " & lDataSet1.FindField("Code").AsString
BizObject.Edit();
MsgBox "Description : " & lDataSet1.FindField("Description").AsString  
lMain.FindField('Code').value = "400-C0001";
lDataSet1.Next
lMain.FindField('DocAmt').value = "100.00";
   Wend     
  //lMain.FindField('UnappliedAmt').value = "0";
End Function
 
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'PI'); /*Knock Off DocType*/
  v.SetItem(1, 'PI-00001'); /*Knock Off DocNo*/
 
    if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
          lKO.Edit();
          lKO.FindField('DocAmt').value = "100";  
          lKO.FindField('KnockOff').AsString = 'T';
          lKO.Post(); }
 
  /* Save document */ 
    BizObject.Save(); 
    BizObject.Close();
    alert('Supplier Contra - has been Updated.');
   }
}
</script>
</head>
<body>
<button onclick="javascript:PostARCT();">PostARCT</button>&nbsp;&nbsp;
<button onclick="javascript:PostAPST();">PostAPST</button>&nbsp;&nbsp;
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
<br />


===Delphi===
====Stock.Item.RO====
The below example is assuming after you had check the login status.
====Example-GL_JE====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_JE Script   
! Stock.Item.RO Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_GL_JEClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg Stock.Item.RO.vbs
var BizApp, lMain, lDtl, lBizObj, lDocKey : Variant;
Call GetInfo
     i : integer;
begin
Function CreateSQLAccServer
   BizApp := CreateOleObject('SQLAcc.BizApp');
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   try
End Function
     lBizObj := BizApp.BizObjects.Find('GL_JE');
     lMain  := lBizObj.DataSets.Find('MainDataSet');
Function GetInfo
     lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
Dim ComServer, RptObject, lDataSet1, lDataSet2, lDateFrom, lDateTo
     lBizObj.New;
  'Step 1 Create Com Server object
    lMain.FindField('DOCKEY').Value        := -1;
  Set ComServer = CreateSQLAccServer 'Create Com Server
     lMain.FindField('DocNo').Value        := '--JE Test--';
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     lMain.FindField('DocDate').Value      := '28 Aug 2017';
     ComServer.Login "ADMIN", "ADMIN", "C\DB\SQLAcc.DCF", "ACC-0002.FDB"
     lMain.FindField('PostDate').Value      := '28 Aug 2017';
  END IF
     lMain.FindField('TAXDATE').Value      := '28 Aug 2017';
     lMain.FindField('Description').Value   := 'Postage';
   'Step 2 Find and Create the Report Objects
     lMain.FindField('Cancelled').Value    := 'F';
  Set RptObject = ComServer.RptObjects.Find("Stock.Item.RO")  
     lMain.FindField('DOCNOSETKEY').Value  := 0;
     lMain.Post;
   'Step 3 Spool parameters
 
     RptObject.Params.Find("AllItem").AsBoolean              = true
    //For Tax Inclusive
     RptObject.Params.Find("AllStockGroup").AsBoolean        = true
     lDtl.Append;
     RptObject.Params.Find("AllCustomerPriceTag").AsBoolean  = true
    lDtl.FindField('DTLKEY').Value      := -1;
     RptObject.Params.Find("AllSupplierPriceTag").AsBoolean  = true
     lDtl.FindField('DOCKEY').Value      := -1;
     'RptObject.Params.Find("CategoryData").AsBlob            = 'Not use
     lDtl.FindField('SEQ').Value         := 1;
     'RptObject.Params.Find("CategoryTpl").AsBlob            = 'Not use
     lDtl.FindField('CODE').Value        := '610-1000';
     'RptObject.Params.Find("CustomerPriceTagData").AsBlob    = 'Not use if AllCustomerPriceTag is True
     lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 1';
     'RptObject.Params.Find("SupplierPriceTagData").AsBlob    = 'Not use if AllSupplierPriceTag is True
     lDtl.FindField('TAX').Value          := 'TX';
//    lDtl.FindField('LOCALTAXAMT').AsFloat := 17.32;//For JE you can't override (i.e. system auto calc)
    lDateFrom = CDate("January 01, 2017")
     lDtl.FindField('TAXINCLUSIVE').Value  := 1;
     lDateTo = CDate("December 31, 2017")
     lDtl.FindField('LocalDR').AsFloat    := 306;//Including GST if TAXINCLUSIVE = 1
    
     lDtl.FindField('DR').AsFloat         := 306;//if wanted DR <> LocalDR
     'RptObject.Params.Find("DateFrom").AsDate                = lDateFrom 'Not use if SelectDate is False
     lDtl.FindField('CHANGED').Value      := 'F';
     'RptObject.Params.Find("DateTo").AsDate                  = lDateTo
     lDtl.Post;
     RptObject.Params.Find("HasAltStockItem").AsBoolean      = false
 
     RptObject.Params.Find("HasBarcode").AsBoolean          = false
    //For Tax Exclusive
     RptObject.Params.Find("HasBOM").AsBoolean              = false
     lDtl.Append;
     RptObject.Params.Find("HasCategory").AsBoolean         = false
    lDtl.FindField('DTLKEY').Value      := -1;
     RptObject.Params.Find("HasCustomerItem").AsBoolean      = false
     lDtl.FindField('DOCKEY').Value       := -1;
     RptObject.Params.Find("HasOpeningBalance").AsBoolean    = false
     lDtl.FindField('SEQ').Value          := 2;
     RptObject.Params.Find("HasPurchasePrice").AsBoolean    = false
     lDtl.FindField('CODE').Value        := '605-200';
    RptObject.Params.Find("HasSellingPrice").AsBoolean      = false
     lDtl.FindField('DESCRIPTION').Value := 'Item Desc 2';
    RptObject.Params.Find("HasSupplierItem").AsBoolean      = false
    lDtl.FindField('TAX').Value          := 'TX';
     'RptObject.Params.Find("ItemData").AsBlob                = 'Not use if AllItem is True
     lDtl.FindField('TAXINCLUSIVE').Value := 0;
     'RptObject.Params.Find("ItemCategoryData").AsBlob        = 'Not use if SelectCategory is False
     lDtl.FindField('LocalCR').AsFloat    := 100;
     RptObject.Params.Find("PrintActive").AsBoolean         = true
     lDtl.FindField('CHANGED').Value      := 'F';
     RptObject.Params.Find("PrintInActive").AsBoolean        = true
     lDtl.Post;
     RptObject.Params.Find("PrintNonStockControl").AsBoolean = true
     RptObject.Params.Find("PrintStockControl").AsBoolean    = true
     RptObject.Params.Find("SelectCategory").AsBoolean       = false
     RptObject.Params.Find("SelectDate").AsBoolean          = false
     RptObject.Params.Find("SortBy").AsString                  = "Code"
     'RptObject.Params.Find("StockGroupData").AsBlob        = 'Not use if AllStockGroup is True 
   
  'Step 4 Perform Report calculation
  RptObject.CalculateReport()
  Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsUOM") ' To link Master Data use Code
  MsgBox "Count " & lDataSet1.RecordCount
  'Step 5 Retrieve the output
  lDataSet1.First
  While (not lDataSet1.eof)
     MsgBox "Code " & lDataSet1.FindField("Code").AsString
     MsgBox "Description " & lDataSet1.FindField("Description").AsString
     MsgBox "Balance Qty " & lDataSet1.FindField("BalSQty").AsString
     lDataSet1.Next
  Wend


    //For No GST
  MsgBox "Count " & lDataSet2.RecordCount
    lDtl.Append;
  lDataSet2.First
     lDtl.FindField('DTLKEY').Value      := -1;
  While (not lDataSet2.eof)
    lDtl.FindField('DOCKEY').Value      := -1;
     MsgBox "Code " & lDataSet2.FindField("Code").AsString
    lDtl.FindField('SEQ').Value          := 3;
MsgBox "UOM " & lDataSet2.FindField("UOM").AsString
    lDtl.FindField('CODE').Value        := '610-002';
MsgBox "Rate " & lDataSet2.FindField("Rate").AsString
    lDtl.FindField('DESCRIPTION').Value := 'Item Desc 3';
MsgBox "RefPrice " & lDataSet2.FindField("RefPrice").AsString
    lDtl.FindField('TAX').Value          := '';
    lDataSet2.Next
    lDtl.FindField('TAXINCLUSIVE').Value  := 0;
  Wend
     lDtl.FindField('LocalCR').AsFloat    := 200;
End Function
    lDtl.FindField('CHANGED').Value      := 'F';
</syntaxhighlight>
    lDtl.Post;
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Stock Item Balance====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Stock Item Balance Script  
|-
|
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg ItemBalance.vbs
Call CheckLogin
Call GetData
 
Dim ComServer
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


    lBizObj.Save;
Function GetData
    MessageDlg('GL_JE-DocNo : ''--JE Test--'' Posted...', mtInformation, [mbOK],0);
Dim lDataSet, lSQL
   finally
  lSQL = "SELECT A.Location, A.Batch, A.ItemCode, B.Description, Sum(A.Qty) Qty FROM ST_TR A "
     lBizObj.Close;
  lSQL = lSQL & "INNER JOIN ST_ITEM B ON (A.ITEMCODE=B.CODE) "
   end;
  lSQL = lSQL & "WHERE B.IsActive='T' "
end;
  lSQL = lSQL & "AND A.PostDate <= '31 Dec 2017' "
  lSQL = lSQL & "AND A.ItemCode= 'ANT' "
  lSQL = lSQL & "GROUP by A.Location, A.Batch, A.ItemCode, B.Description"
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "Location : " & lDataSet.FindField("Location").AsString
    MsgBox "Batch : " & lDataSet.FindField("Batch").AsString
     MsgBox "Item Code : " & lDataSet.FindField("ItemCode").AsString
MsgBox "Item Description : " & lDataSet.FindField("Description").AsString
MsgBox "Balance Qty : " & lDataSet.FindField("Qty").AsString
lDataSet.Next
   Wend
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,146: Line 8,331:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL_PV====
====ST_IS====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_PV Script   
! ST_IS Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_GLPVClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg StockIssue.vbs
var lMain, lDtl, lBizObj, BizApp : Variant;
Call CheckLogin
    lTime : TDateTime;
Call InsertData
begin
  lTime := Now;
  BizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := BizApp.BizObjects.Find('GL_PV');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
    lBizObj.New;
    lMain.FindField('DOCKEY').Value          := -1;
    lMain.FindField('DocNo').AsString        := '--CB PV Test1--';
    lMain.FindField('DocDate').Value          := '18 Aug 2015';
    lMain.FindField('PostDate').Value        := '18 Aug 2015';
    lMain.FindField('TAXDATE').Value          := '18 Aug 2015';
    lMain.FindField('Description').AsString  := 'Compacc System';
    lMain.FindField('PAYMENTMETHOD').AsString := '310-001';
    lMain.FindField('CHEQUENUMBER').AsString  := 'MBB 213245';
    lMain.FindField('DocAmt').AsFloat        := 2019;
    lMain.FindField('Cancelled').AsString    := 'F';
    lMain.FindField('CHANGED').AsString      := 'F';
    lMain.Post;


    lDtl.Append;
Dim ComServer
    lDtl.FindField('DTLKEY').Value        := -1;
    lDtl.FindField('DOCKEY').Value        := -1;
    lDtl.FindField('Code').AsString        := '200-300';
    lDtl.FindField('DESCRIPTION').AsString := 'Maybank - Asus A555LD-xx313H';
    lDtl.FindField('TAX').AsString        := 'TX';
    lDtl.FindField('TAXAMT').AsFloat      := 114.28;
    lDtl.FindField('TAXINCLUSIVE').Value  := 1;
    lDtl.FindField('AMOUNT').AsFloat      := 2019;
    lDtl.FindField('CHANGED').AsString    := 'F';
    lDtl.Post;
    lBizObj.Save;
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


====Example-AR_Customer====
function CheckLogin
{| class="mw-collapsible mw-collapsed wikitable"
  'Step 1: Create Com Server object
! AR_Customer Script 
  Set ComServer = CreateSQLAccServer 'Create Com Server
|-
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
|
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
<syntaxhighlight lang="delphi">
                'UserName, Password, DCF full path, Database filename
procedure TfmMain.dxbb_CustomerClick(Sender: TObject);
   END IF
var lMain, lDtl, lBizObj, lBizApp : Variant;
End Function
    lTime : TDateTime;
begin
   lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');


  lBizObj := lBizApp.BizObjects.Find('AR_Customer');
Function InsertData
  lMain  := lBizObj.DataSets.Find('MainDataSet');
Dim BizObject, lMain, lDetail, lDate
   lDtl    := lBizObj.DataSets.Find('cdsBranch');
   'Step 2: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("ST_IS")  


   try
   'Step 3: Set Dataset
    lBizObj.New;
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
    lMain.FindField('Code').value       := '300-Test';
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
    lMain.FindField('CompanyName').value := 'Testing 123';
 
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString      = "--IS Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Description").AsString = "Stock Issue"
   
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Issue out Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.Post


    lDtl.Edit; //For 1st Branch
  lDetail.Append
    lDtl.FindField('BranchName').AsString := 'BILLING';
  lDetail.FindField("DtlKey").value        = -1
    lDtl.FindField('Address1').AsString  := 'Address1';
  lDetail.FindField("DocKey").value        = -1
    lDtl.FindField('Address2').AsString   := 'Address2';
   lDetail.FindField("ItemCode").AsString   = "E-BAT"
    lDtl.FindField('Address3').AsString   := 'Address3';
   lDetail.FindField("Description").AsString = "Issue out Item A"
    lDtl.FindField('Address4').AsString   := 'Address4';
  lDetail.FindField("Qty").AsFloat          = 4
    lDtl.FindField('Attention').AsString := 'Attention';
  lDetail.Post
    lDtl.FindField('Phone1').AsString    := 'Phone1';
  'Step 6: Save Document
    lDtl.FindField('Fax1').AsString      := 'Fax1';
   BizObject.Save
    lDtl.FindField('Email').AsString      := 'EmailAddress';
   BizObject.Close
    lDtl.Post;
      
 
  ComServer.Logout 'Logout after done
    lDtl.Append; //For 2nd Branch
   MsgBox "Done" 
    lDtl.FindField('BranchName').AsString := 'Branch1';
End Function
    lDtl.FindField('Address1').AsString   := 'DAddress1';
    lDtl.FindField('Address2').AsString  := 'DAddress2';
    lDtl.FindField('Address3').AsString   := 'DAddress3';
    lDtl.FindField('Address4').AsString  := 'DAddress4';
     lDtl.FindField('Attention').AsString  := 'DAttention';
    lDtl.FindField('Phone1').AsString    := 'DPhone1';
    lDtl.FindField('Fax1').AsString      := 'DFax1';
    lDtl.FindField('Email').AsString      := 'DEmailAddress';
    lDtl.Post;
    lBizObj.Save;
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
   finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,259: Line 8,402:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_PM====
====ST_RC====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script   
! ST_RC Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg StockReceived.vbs
var lMain, lKO, lBizApp, lBizObj, V : Variant;
Call CheckLogin
begin
Call InsertData
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lKO    := lBizObj.DataSets.Find('cdsKnockOff');


    lBizObj.New;
Dim ComServer
    lMain.FindField('DOCKEY').Value          := -1;
    lMain.FindField('DocNo').AsString        := '--PM Test--'; //Payment Document Number
    lMain.FindField('CODE').AsString          := '300-A0001';
    lMain.FindField('DocDate').Value          := '28 Aug 2016';
    lMain.FindField('PostDate').Value        := '28 Aug 2016';
    lMain.FindField('Description').AsString  := 'Payment for A/c';
    lMain.FindField('PaymentMethod').AsString := '320-000';
    lMain.FindField('DocAmt').AsFloat        := 1060;
    lMain.FindField('Cancelled').AsString    := 'F';
    lMain.FindField('CHANGED').AsString      := 'F';


    V := lBizApp.CreateOleVariantArray(2);
Function CreateSQLAccServer
    V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    V.SetItem(1, '--IV Test--');  //Invoice Document Number
End Function


     if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
function CheckLogin
       begin
  'Step 1: Create Com Server object
        lKO.Edit;
  Set ComServer = CreateSQLAccServer 'Create Com Server
        lKO.FindField('KOAmt').ASFloat     := 500;
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
         lKO.FindField('KnockOff').AsString := 'T';
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
        lKO.Post;
                'UserName, Password, DCF full path, Database filename
      end;
  END IF
End Function
 
Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_RC")
 
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value        = -1
  lMain.FindField("DocNo").AsString       = "--RC Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Description").AsString = "Stock Received"
      
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Received Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UnitCost").AsFloat    = 25.15
  lDetail.Post


    lBizObj.Save;
  lDetail.Append
    MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
  lDetail.FindField("DtlKey").value        = -1
   finally
  lDetail.FindField("DocKey").value        = -1
     lBizObj.Close;
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
   end;
  lDetail.FindField("Description").AsString = "Received Item A"
end;
  lDetail.FindField("Qty").AsFloat          = 4
  lDetail.FindField("UnitCost").AsFloat    = 54
  lDetail.Post 
  'Step 6: Save Document
  BizObject.Save
   BizObject.Close
      
  ComServer.Logout 'Logout after done
   MsgBox "Done" 
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,309: Line 8,475:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_PM-Edit====
====ST_AJ====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script   
! ST_AJ Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg StockAdjustment.vbs
var lMain, lKO, lBizApp, lBizObj, V : Variant;
Call CheckLogin
begin
Call InsertData
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lKO    := lBizObj.DataSets.Find('cdsKnockOff');


    lDocKey := lBizObj.FindKeyByRef('DocNo', '--PM Test--');
Dim ComServer
    lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);


    If not VarIsNull(lDocKey) Then begin
Function CreateSQLAccServer
      lBizObj.Open;
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
      lBizObj.Edit;
End Function
      lMain.FindField('DOCKEY').Value          := -1;
      lMain.FindField('DocDate').Value          := '28 Aug 2016';
      lMain.FindField('PostDate').Value        := '28 Aug 2016';
      lMain.FindField('Description').AsString   := 'Payment for A/c';
      lMain.FindField('PaymentMethod').AsString := '310-000';
      lMain.FindField('DocAmt').AsFloat        := 800.28;
      lMain.FindField('UnappliedAmt').AsFloat  := 100.28;
      lMain.FindField('Cancelled').AsString    := 'F';
      lMain.FindField('CHANGED').AsString      := 'F';


      V := lBizApp.CreateOleVariantArray(2);
function CheckLogin
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
  'Step 1: Create Com Server object
      V.SetItem(1, '--IV Test--');  //Document Number
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
Function InsertData
        begin
Dim BizObject, lMain, lDetail, lDate
          lKO.Edit;
  'Step 2: Find and Create the Biz Objects
          lKO.FindField('KOAmt').AsFloat    := 700.28; // IV Knock Off/Offset Amount
  Set BizObject = ComServer.BizObjects.Find("ST_AJ")  
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;


      lBizObj.Save;
  'Step 3: Set Dataset
      MessageDlg('AR_PM-DocNo : ''--PM Test--'' Updated...', mtInformation, [mbOK],0);
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
    end;
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
   finally
 
     lBizObj.Close;
  'Step 4 : Insert Data - Master
   end;
  lDate = CDate("January 1, 2017")
end;
  BizObject.New
  lMain.FindField("DocKey").value        = -1
  lMain.FindField("DocNo").AsString      = "--AJ Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Description").AsString = "Stock Adjustment"
   
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Adjust IN Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UnitCost").AsFloat    = 25.15 'Only IN need UnitCost
  lDetail.Post
 
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Description").AsString = "Adjust OUT Item A"
  lDetail.FindField("Qty").AsFloat          = -4
  lDetail.Post 
  'Step 6: Save Document
  BizObject.Save
   BizObject.Close
      
  ComServer.Logout 'Logout after done
   MsgBox "Done" 
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,364: Line 8,547:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-ST_Item====
====ST_XF====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! ST_Item Script   
! ST_XF Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg ST_XF.vbs
var lMain, lDtl, lBizObj, lBizApp : Variant;
Call CheckLogin
    lTime : TDateTime;
Call InsertData
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsUOM');


  try
Dim ComServer
    lBizObj.New;
    lMain.FindField('Code').AsString        := 'Test-1';
    lMain.FindField('Description').AsString := 'Testing - Description';


    lDtl.Edit; //For 1st UOM
Function CreateSQLAccServer
    lDtl.FindField('UOM').AsString    := 'PCS';
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    lDtl.FindField('Rate').AsFloat    := 1;
End Function
    lDtl.FindField('RefCost').AsFloat  := 10.20;
    lDtl.FindField('RefPrice').AsFloat := 25.00;
    lDtl.Post;


    lDtl.Append; //For 2nd UOM
function CheckLogin
    lDtl.FindField('UOM').AsString    := 'CTN';
  'Step 1: Create Com Server object
    lDtl.FindField('Rate').AsFloat    := 12;
  Set ComServer = CreateSQLAccServer 'Create Com Server
     lDtl.FindField('RefCost').AsFloat  := 102.00;
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    lDtl.FindField('RefPrice').AsFloat := 240.00;
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    lDtl.Post;
                'UserName, Password, DCF full path, Database filename
    lBizObj.Save;
  END IF
End Function


    lTime := Now - lTime;
Function InsertData
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
Dim BizObject, lMain, lDetail, lDate
              mtInformation, [mbOk], 0);
  'Step 2: Find and Create the Biz Objects
   finally
   Set BizObject = ComServer.BizObjects.Find("ST_XF")
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}


<div style="float: right;">   [[#top|[top]]]</div>
  'Step 3: Set Dataset
 
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
====Example-ST_Item-Edit====
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
{| class="mw-collapsible mw-collapsed wikitable"
    
! ST_Item Script 
  'Begin Looping yr data
|-
  'Step 4 : Insert Data - Master
|
  lDate = CDate("January 1, 2017")
<syntaxhighlight lang="delphi">
  BizObject.New
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
  lMain.FindField("DocKey").value        = -1
var lMain, lDtl, lBizObj, lBizApp, lDocKey, V : Variant;
  lMain.FindField("DocNo").AsString      = "--XF Test--"
begin
  lMain.FindField("DocDate").value        = lDate
   lBizApp := CreateOleObject('SQLAcc.BizApp');
  lMain.FindField("PostDate").value      = lDate
   lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account - Optional
   lMain  := lBizObj.DataSets.Find('MainDataSet');
  lMain.FindField("CompanyName").AsString = "Cash Sales" 'Optional
   lDtl    := lBizObj.DataSets.Find('cdsUOM');
  lMain.FindField("Description").AsString = "Stock Transfer"
   
  'Step 5: Insert Data - Detail
  lDetail.Append
   lDetail.FindField("DtlKey").value          = -1
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
   lDetail.FindField("Description").AsString  = "Transfer Item A"
  lDetail.FindField("Qty").AsFloat          = 10
  lDetail.FindField("UOM").AsString          = "UNIT"
   lDetail.FindField("FromLocation").AsString = "----"
   lDetail.FindField("ToLocation").AsString  = "BALAKONG"
  lDetail.Post


   lDocKey := lBizObj.FindKeyByRef('Code', '--Stock Item Test--');
   lDetail.Append
   lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);
  lDetail.FindField("DtlKey").value          = -1
   try
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString    = "HFK"
  lDetail.FindField("Description").AsString  = "Transfer Item B"
  lDetail.FindField("Qty").AsFloat          = 5
   lDetail.FindField("UOM").AsString          = "UNIT"
  lDetail.FindField("FromLocation").AsString = "----"
  lDetail.FindField("ToLocation").AsString  = "BALAKONG"
   lDetail.Post


    If not VarIsNull(lDocKey) Then begin
  'Step 6: Save Document
      lBizObj.Open;
  BizObject.Save
      lBizObj.Edit;
  BizObject.Close
      lMain.FindField('Description').value := 'Testing - Description';
 
 
  'Step 7 : Logout after done  
      V := lBizApp.CreateOleVariantArray(2);
  'ComServer.Logout
      V.SetItem(0, 'CTN'); //UOM
    
      V.SetItem(1, '12');  //Rate
   MsgBox "Done" 
 
End Function
      if lDtl.Locate('UOM;Rate', V.AsOleVariant, False, False) then
        begin
          lDtl.Edit;
          lDtl.FindField('RefCost').AsFloat := 10.20;
          lDtl.FindField('RefPrice').AsFloat := 25.00;
          lDtl.Post;
        end;
      lBizObj.Save;
 
      MessageDlg('ST_Item-ItemCode : ''--Stock Item Test--'' Updated...', mtInformation, [mbOK],0);
    end;
   finally
    lBizObj.Close;
   end;
end;
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,459: Line 8,630:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-SL_IV====
====AP_PI-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! SL_IV Script   
! AP_PI Edit Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_SL_IVClick(Sender: TObject);
'Available in Version 5.2018.833.759 & above
var lMain, lDtl, lSN, lBizObj, lBizApp : Variant;
'Copy below script & paste to notepad & name it as eg AP_PI.vbs
    lTime : TDateTime;
Call CheckLogin
begin
Call GetData
  lTime := Now;
Call PostData
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('SL_IV');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
  lSN    := lBizObj.DataSets.Find('cdsSerialNumber');


  try
Dim ComServer, lDataSet
    lBizObj.New;
    lMain.FindField('DOCKEY').Value        := -1;
    lMain.FindField('DocNo').AsString      := '--IV Test--';
    lMain.FindField('CODE').AsString        := '300-A0001';
    lMain.FindField('DocDate').Value        := '28 Aug 2020';
    lMain.FindField('PostDate').Value      := '28 Aug 2020';
    lMain.FindField('TAXDATE').Value        := '28 Aug 2020';
    lMain.FindField('Description').AsString := 'Sales';
    lMain.FindField('Cancelled').AsString  := 'F';
    lMain.Post;


    lDtl.Append; // For Tax Inclusive = True with override Tax Amount
Function CreateSQLAccServer
    lDtl.FindField('DTLKEY').Value        := -1;
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    lDtl.FindField('DOCKEY').Value        := -1;
End Function
    lDtl.FindField('SEQ').Value            := 1;
    lDtl.FindField('ItemCode').AsString    := 'ITEM A';
    lDtl.FindField('ACCOUNT').AsString    := '500-000'; //GL Sales Account
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item A';
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString        := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value   := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 435;//Including GST UnitPrice
    lDtl.FindField('AMOUNT').AsFloat      := 410.37; //Must Excluding GST (Qty * UnitPrice) // Less 0.01
    lDtl.FindField('TAXAMT').AsFloat      := 24.63; //Extra 0.01


    lDtl.DisableControls; //For Tax Inclusive Only where TaxAmt is not as Calc
function CheckLogin
    try
  'Step 1: Create Com Server object
      lDtl.FindField('TAXINCLUSIVE').Value := 1;
  Set ComServer = CreateSQLAccServer 'Create Com Server
    finally
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
      lDtl.EnableControls;
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    end;
                'UserName, Password, DCF full path, Database filename
    lDtl.Post;
  END IF
End Function


    lDtl.Append; // For Tax Inclusive = False with override Tax Amount
Function GetData
    lDtl.FindField('DTLKEY').Value        := -1;
Dim lSQL
    lDtl.FindField('DOCKEY').Value        := -1;
  lSQL = "SELECT Dockey FROM AP_PI "
    lDtl.FindField('SEQ').Value            := 2;
  lSQL = lSQL & "WHERE DocNo='PI-00001' "
    lDtl.FindField('ItemCode').AsString    := 'ITEM B';
  lSQL = lSQL & "AND Code='400-D0001' "
    lDtl.FindField('ACCOUNT').AsString    := '500-000';
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item B';
End Function
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString        := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value   := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 94.43;
    lDtl.FindField('AMOUNT').AsFloat      := 94.43;
    lDtl.FindField('TAXAMT').AsFloat      := 5.66; //Less 0.01
    lDtl.Post;


    lDtl.Append; // For Serial Number
Function PostData
    lDtl.FindField('DTLKEY').Value        := -1;
Dim BizObject, lMain, lDetail
    lDtl.FindField('DOCKEY').Value        := -1;
  'Step 2: Find and Create the Biz Objects
    lDtl.FindField('SEQ').Value            := 3;
  Set BizObject = ComServer.BizObjects.Find("AP_PI")  
    lDtl.FindField('ItemCode').AsString    := 'SN1';
    lDtl.FindField('ACCOUNT').AsString    := '500-000';
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Serial Number Item';


     lSN.Append;
  'Step 3: Set Dataset
     lSN.FindField('SERIALNUMBER').AsString := 'SN-00001';
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
     lSN.Post;
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
 
     lSN.Append;
  'Step 4 : Find Doc Number
     lSN.FindField('SERIALNUMBER').AsString  := 'SN-00002';
  If lDataSet.RecordCount > 0 Then 
     lSN.Post;
lDataSet.First
 
     BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
     lDtl.FindField('QTY').AsFloat        := 2;
 
     lDtl.FindField('TAX').AsString      := 'SR';
 
     lDtl.FindField('TAXINCLUSIVE').Value := 0;
    BizObject.Open
     lDtl.FindField('UNITPRICE').AsFloat  := 94.43;
    BizObject.Edit
     lDtl.FindField('TAXAMT').AsFloat    := 11.33;
     lMain.Edit
     lDtl.Post;
lMain.FindField("Description").AsString = "testing"
 
 
     lBizObj.Save;
  'Step 5: Delete all Detail
 
     While lDetail.RecordCount <> 0
    lTime := Now - lTime;
      lDetail.First
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
  lDetail.Delete
              mtInformation, [mbOk], 0);
    Wend
  finally
  'Step 6: Append Detail
     lBizObj.Close;
     lDetail.Append
     lMain := null;
     lDetail.FindField("DtlKey").value = -1
    lDtl := null;
     lDetail.FindField("Account").value = "610-2000"
    lSN := null;
     lDetail.FindField("Description").value = "Purchase Item A"
    lBizObj := null;
     lDetail.FindField("Tax").value = ""
    lBizApp := null;
     lDetail.FindField("TaxInclusive").value = 0
  end;
     lDetail.FindField("Amount").value = 410.37
end;
     lDetail.FindField("TaxAmt").value = 0
     lDetail.Post
 
  'Step 7: Save Document
     BizObject.Save
    BizObject.Close
 
  'Step 8 : Logout after done 
     'ComServer.Logout 
     MsgBox "Done"
Else
MsgBox "Record Not Found"
  END IF
 
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,567: Line 8,718:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.IV.RO====
====SL_DO to SL_IV====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.IV.RO Report Object Script   
! SL_DO to SL_IV Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_RptObjClick(Sender: TObject);
'Updated 26 Oct 2018
var lBizApp, lRptVar : Variant;
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
    lTime : TDateTime;
Call CheckLogin
    cdsMain, cdsDtl : TClientDataset;
Call InsertData1
begin
Call InsertData2
  lTime := Now;
 
  cdsMain := TClientDataset.Create(nil);
Dim ComServer
  cdsDtl  := TClientDataset.Create(nil);
 
  lBizApp := CreateOleObject('SQLAcc.BizApp');
Function CreateSQLAccServer
  try
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
    lRptVar := null;
End Function
    lRptVar := lBizApp.RptObjects.Find('Customer.IV.RO');
    lRptVar.Params.Find('SelectDate').AsBoolean          := True;
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    lRptVar.Params.Find('AllAgent').AsBoolean            := False;
    lRptVar.Params.Find('AgentData').AsBlob              := '----'#13#10'HALIM'; //Filter by Agent code ---- & HALIM
    lRptVar.Params.Find('AllArea').AsBoolean              := True;
//    lRptVar.Params.Find('AreaData').AsBlob                := ; //Not use if AllArea is True
    lRptVar.Params.Find('AllCompany').AsBoolean          := True;
//    lRptVar.Params.Find('CompanyData').AsBlob            := ; //Not use if AllCompany is True
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := ; //Not use if AllCurrenty is True
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
//    lRptVar.Params.Find('DocProjectData').AsBlob          := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean   := True;
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob    := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
//    lRptVar.Params.Find('DocumentData').AsBlob            := ; //Not use if AllDocument is True
    lRptVar.Params.Find('IncludeCancelled').AsBoolean  := True;
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean := False;
    lRptVar.Params.Find('AllItemProject').AsBoolean    := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean  := True;
    lRptVar.CalculateReport;


    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
function CheckLogin
     cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocDetail').XMLData; //Detail Data - To link Master Data use Dockey field
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
Function InsertData1
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_DO")  


    lTime := Now - lTime;
  'Step 3: Set Dataset
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
              mtInformation, [mbOk], 0);
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
   finally
 
     lRptVar := null;
  'Begin Looping yr data
    cdsMain.Free;
  'Step 4 : Insert Data - Master
     cdsDtl.Free;
  lDate = CDate("January 1, 2017")
   end;
  BizObject.New
end;
  lMain.FindField("DocKey").value        = -1
</syntaxhighlight>
  lMain.FindField("DocNo").AsString      = "--DO Test--"
|}
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  'lMain.FindField("Address1").AsString    = "" 'Optional
  'lMain.FindField("Address2").AsString    = "" 'Optional
  'lMain.FindField("Address3").AsString    = "" 'Optional
  'lMain.FindField("Address4").AsString    = "" 'Optional
  'lMain.FindField("Phone1").AsString      = "" 'Optional
   lMain.FindField("Description").AsString = "Delivery Order"
      
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item A"
  lDetail.FindField("UOM").AsString        = "BOX"
  lDetail.FindField("Qty").AsFloat          = 2
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
   lDetail.FindField("UnitPrice").AsFloat    = 100 
  lDetail.FindField("Amount").AsFloat      = 200
  lDetail.FindField("TaxAmt").AsFloat      = 12
  lDetail.Post


<div style="float: right;">  [[#top|[top]]]</div>
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("ItemCode").AsString    = "COVER"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("UOM").AsString        = "UNIT"
  lDetail.FindField("Qty").AsFloat          = 3
  lDetail.FindField("Tax").AsString        = "SR"
  lDetail.FindField("TaxRate").AsString    = "6%"
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 10 
  lDetail.FindField("Amount").AsFloat      = 30
  lDetail.FindField("TaxAmt").AsFloat      = 1.80
  lDetail.Post 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "DO Posting Done"
End Function


====Example-Stock.Item.RO====
Function InsertData2
{| class="mw-collapsible mw-collapsed wikitable"
Dim BizObject, lMain, lDetail, lDate, lDODtl, lxFer, lSQL, v(2)
! Stock.Item.RO Report Object Script 
  'Step 1: Check Is transtered or not
|-
   lSQL = "SELECT DocKey FROM SL_IVDTL "
|
   lSQL = lSQL & "WHERE FromDockey=(SELECT DocKey FROM SL_DO "
<syntaxhighlight lang="delphi">
   lSQL = lSQL & "WHERE DocNo='--DO Test--') "
procedure TfmMain.dxbb_ST_ITEM_ROClick(Sender: TObject);
   Set lxFer = ComServer.DBManager.NewDataSet(lSQL)
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl, cdsCat : TClientDataset;
    lSQL : string;
begin
   lTime    := Now;
   cdsMain  := TClientDataset.Create(nil);
   cdsDtl  := TClientDataset.Create(nil);
   cdsCat  := TClientDataset.Create(nil);


   lBizApp := CreateOleObject('SQLAcc.BizApp');
   if lxFer.RecordCount = 0 then
    'Step 2: Get DO Information
    lSQL = "SELECT * FROM SL_DODTL "
    lSQL = lSQL & "WHERE Dockey=(SELECT DocKey FROM SL_DO "
    lSQL = lSQL & "WHERE DocNo='--DO Test--') "
    Set lDODtl = ComServer.DBManager.NewDataSet(lSQL)   
'Step 3: Find and Create the Biz Objects
    Set BizObject = ComServer.BizObjects.Find("SL_IV")  


   lSQL := 'SELECT * FROM ST_ITEM_CATEGORY ' +
    'Step 4: Set Dataset
          'WHERE Category IN (''B-MOTOLORA'',''B-MAXIS'')';
    Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
  cdsCat.Data := lBizApp.DBManager.Execute(lSQL); //For filtering Category only
    Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
    
   try
     'Step 5 : Insert Data - Master
     lRptVar := null;
     lDate = CDate("January 1, 2017")
     lRptVar := lBizApp.RptObjects.Find('Stock.Item.RO');
     BizObject.New
     lRptVar.Params.Find('AllItem').AsBoolean              := True;
    lMain.FindField("DocKey").value        = -1
     lRptVar.Params.Find('AllStockGroup').AsBoolean        := True;
     lMain.FindField("DocNo").AsString      = "--IV Test--"
     lRptVar.Params.Find('AllCustomerPriceTag').AsBoolean  := True;
     lMain.FindField("DocDate").value        = lDate
     lRptVar.Params.Find('AllSupplierPriceTag').AsBoolean  := True;
     lMain.FindField("PostDate").value      = lDate
//    lRptVar.Params.Find('CategoryData').AsBlob            := ; //Not use
    lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
//    lRptVar.Params.Find('CategoryTpl').AsBlob            := ; //Not use
    lMain.FindField("CompanyName").AsString = "Cash Sales"
//    lRptVar.Params.Find('CustomerPriceTagData').AsBlob   := ; //Not use if AllCustomerPriceTag is True
    'lMain.FindField("Address1").AsString   = "" 'Optional
//    lRptVar.Params.Find('SupplierPriceTagData').AsBlob   := ; //Not use if AllSupplierPriceTag is True
    'lMain.FindField("Address2").AsString   = "" 'Optional
//    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015'; //Not use if SelectDate is False
    'lMain.FindField("Address3").AsString    = "" 'Optional
//    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    'lMain.FindField("Address4").AsString    = "" 'Optional
     lRptVar.Params.Find('HasAltStockItem').AsBoolean     := False;
     'lMain.FindField("Phone1").AsString     = "" 'Optional
     lRptVar.Params.Find('HasBarcode').AsBoolean          := False;
     lMain.FindField("Description").AsString = "Sales"
    lRptVar.Params.Find('HasBOM').AsBoolean              := False;
   
    lRptVar.Params.Find('HasCategory').AsBoolean          := False;
    'Step 6: Insert Data - Detail
    lRptVar.Params.Find('HasCustomerItem').AsBoolean      := False;
    v(0) = "COVER"
    lRptVar.Params.Find('HasOpeningBalance').AsBoolean   := False;
    v(1) = "UNIT"
    lRptVar.Params.Find('HasPurchasePrice').AsBoolean     := False;
    lRptVar.Params.Find('HasSellingPrice').AsBoolean      := False;
    if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
    lRptVar.Params.Find('HasSupplierItem').AsBoolean      := False;
      lDetail.Append
//    lRptVar.Params.Find('ItemData').AsBlob                := 'ANT 1.0'#13#10'COVER'; //Filter by Item code ANT 1.0 & COVER
      lDetail.FindField("DtlKey").value        = -1
//   lRptVar.Params.Find('ItemCategoryData').AsBlob        := cdsCat.XMLData; //Not use if SelectCategory is False
      lDetail.FindField("DocKey").value        = -1
    lRptVar.Params.Find('PrintActive').AsBoolean          := True;
      lDetail.FindField("Seq").value            = 1
    lRptVar.Params.Find('PrintInActive').AsBoolean        := True;
      lDetail.FindField("ItemCode").AsString   = lDODtl.FindField("ItemCode").AsString
    lRptVar.Params.Find('PrintNonStockControl').AsBoolean := True;
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
    lRptVar.Params.Find('PrintStockControl').AsBoolean    := True;
      'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
    lRptVar.Params.Find('SelectCategory').AsBoolean      := False;
      lDetail.FindField("UOM").AsString        = lDODtl.FindField("UOM").AsString
    lRptVar.Params.Find('SelectDate').AsBoolean          := False;
  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
    lRptVar.Params.Find('SortBy').AsString                 := 'Code';
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
//    lRptVar.Params.Find('StockGroupData').AsBlob       := ; //Not use if AllStockGroup is True
      lDetail.FindField("Tax").AsString        = lDODtl.FindField("Tax").AsString
     lRptVar.CalculateReport;
      lDetail.FindField("TaxRate").AsString    = lDODtl.FindField("TaxRate").AsString
 
      lDetail.FindField("TaxInclusive").value  = lDODtl.FindField("TaxInclusive").Value
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData; //Master Data
      lDetail.FindField("UnitPrice").AsFloat   = lDODtl.FindField("UnitPrice").AsFloat
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsUOM').XMLData;  //Detail Data - To link Master Data use Code field
      lDetail.FindField("Amount").AsFloat      = lDODtl.FindField("Amount").AsFloat
 
      lDetail.FindField("TaxAmt").AsFloat      = lDODtl.FindField("TaxAmt").AsFloat
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
  lDetail.FindField("FromDocType").AsString = "DO"
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
  lDetail.FindField("FromDockey").AsFloat  = lDODtl.FindField("DocKey").AsFloat
 
  lDetail.FindField("FromDtlkey").AsFloat  = lDODtl.FindField("DtlKey").AsFloat
    lTime := Now - lTime;
      lDetail.Post
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
End IF 
              mtInformation, [mbOk], 0);
    v(0) = "ANT"
   finally
    v(1) = "BOX"
     lRptVar := null;
     cdsMain.Free;
    if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
    cdsDtl.Free;
      lDetail.Append
    cdsCat.Free;
      lDetail.FindField("DtlKey").value        = -1
   end;
      lDetail.FindField("DocKey").value        = -1
end;
      lDetail.FindField("Seq").value            = 2
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
      lDetail.FindField("UOM").AsString        = lDODtl.FindField("UOM").AsString
  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString       = lDODtl.FindField("Disc").AsString
      lDetail.FindField("Tax").AsString        = lDODtl.FindField("Tax").AsString
      lDetail.FindField("TaxRate").AsString     = lDODtl.FindField("TaxRate").AsString
      lDetail.FindField("TaxInclusive").value  = lDODtl.FindField("TaxInclusive").Value
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitPrice").AsFloat
      lDetail.FindField("Amount").AsFloat      = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("TaxAmt").AsFloat      = lDODtl.FindField("TaxAmt").AsFloat
  lDetail.FindField("FromDocType").AsString = "DO"
  lDetail.FindField("FromDockey").AsFloat  = lDODtl.FindField("DocKey").AsFloat
  lDetail.FindField("FromDtlkey").AsFloat  = lDODtl.FindField("DtlKey").AsFloat
      lDetail.Post
End IF 
   'Step 7: Save Document
     BizObject.Save
     BizObject.Close
 
  'Step 8 : Logout after done 
  'ComServer.Logout
 
  MsgBox "Posting IV Done"
  else MsgBox "--DO Test-- had been transfered. Posting IV aborted" 
   End IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.Statement.RO====
====SL_IV-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.Statement.RO Report Object Script   
! SL_IV-Edit Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_StatementClick(Sender: TObject);
'Available in Version 5.2018.833.759 & above
var lBizApp, lRptVar : Variant;
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
    lTime : TDateTime;
Call CheckLogin
    cdsMain, cdsDtl : TClientDataset;
Call GetData
    s : string;
Call PostData
begin
 
  lTime := Now;
Dim ComServer, lDataSet
  cdsMain := TClientDataset.Create(nil);
 
  cdsDtl  := TClientDataset.Create(nil);
Function CreateSQLAccServer
  lBizApp := CreateOleObject('SQLAcc.BizApp');
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
End Function
      '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
      '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
      '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
      '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
      '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
      '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
      '</ROWDATA></DATAPACKET>';
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Statement.RO');
//  lRptVar.Params.Find('AgentData').AsBlob              := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString          := s; //Fixed
    lRptVar.Params.Find('AgingOn').AsString            := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean        := False;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob              := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob   := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('CompanyData').AsBlob          := '300-A0001'#13#10'300-C0001'; //Filter by Customer Code 300-A0001 & 300-C0001
//    lRptVar.Params.Find('ControlAccountData').AsBlob    := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob          := ; //Not use if AllCurrency is True
    lRptVar.Params.Find('DateFrom').AsDate              := '01 Aug 2016';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
//    lRptVar.Params.Find('DocProjectData').AsBlob        := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SelectDate').AsBoolean        := True;
    lRptVar.Params.Find('SortBy').AsString              := 'CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount';
    lRptVar.Params.Find('StatementDate').AsDate        := '31 Aug 2016'; // Norm same as DateTo
    lRptVar.Params.Find('StatementType').AsString      := 'O'; //O := Open Item, B := B/F


     lRptVar.CalculateReport;
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
Function GetData
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field
Dim lSQL
  lSQL = "SELECT Dockey FROM SL_IV "
  lSQL = lSQL & "WHERE DocNo='IV-00010' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
Function PostData
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_IV")  


    lTime := Now - lTime;
  'Step 3: Set Dataset
     MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
              mtInformation, [mbOk], 0);
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
   finally
 
     lRptVar := null;
  'Step 4 : Find Doc Number
     cdsMain.Free;
  If lDataSet.RecordCount > 0 Then 
     cdsDtl.Free;
lDataSet.First
   end;
     BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
end;
 
 
    BizObject.Open
    BizObject.Edit
    lMain.Edit
lMain.FindField("Description").AsString = "Sales - Edited"
 
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
  lDetail.Delete
    Wend
  'Step 6: Append Detail
    lDetail.Append
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("Account").value = "500-000"
    lDetail.FindField("Description").value =  "Edited Item A"
    lDetail.FindField("Tax").value =  ""
    lDetail.FindField("TaxInclusive").value =  0
    lDetail.FindField("Amount").value = 410.37
    lDetail.FindField("TaxAmt").value = 0
    lDetail.Post
    
  'Step 7: Save Document
     BizObject.Save
    BizObject.Close
 
  'Step 8 : Logout after done 
     'ComServer.Logout 
     MsgBox "Done"
Else
MsgBox "Record Not Found"
   END IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL Account List For Sales & Purchase 1====
====GL_JE====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL_Acc Object Script   
! GL_JE Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
var BizApp : Variant;
Call InsertGLJE
    lDataSet : TClientDataSet;
     ASQL : String;
Function CreateSQLAccServer
begin
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   //For Debtor List => SpecialAccType = DR
End Function
   //For Creditor List => SpecialAccType = CR
   BizApp := CreateOleObject('SQLAcc.BizApp');
Function InsertGLJE
   lDataSet := TClientDataSet.Create(Self);
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
   try
    ASQL := 'SELECT A.Code, A.Description FROM GL_ACC A '+
  'Step 1: Create Com Server object
            'LEFT OUTER JOIN GL_ACC B ON (A.Dockey=B.Parent) '+
  Set ComServer = CreateSQLAccServer 'Create Com Server
            'WHERE A.Parent<>-1 ' +
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
            'AND B.Dockey IS NULL ' +
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
            'AND A.SpecialAccType = '''' '+
  END IF
            'ORDER BY A.CODE ';
    lDataSet.Data := BizApp.DBManager.Execute(ASQL);
   'Step 2: Find and Create the Biz Objects
    lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
   Set BizObject = ComServer.BizObjects.Find("GL_JE")
   finally
    lDataSet.Free;
   'Step 3: Set Dataset
   end;
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
end;
   Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
</syntaxhighlight>
    
|}
  'Step 4 : Insert Data - Master
 
  lDate = CDate("January 23, 2017")
<div style="float: right;">   [[#top|[top]]]</div>
  BizObject.New
 
  lMainDataSet.FindField("DocKey").value = -1
====Example-GL Account List For Sales & Purchase 2====
  lMainDataSet.FindField("DocNo").value = "--JV Test--"
{| class="mw-collapsible mw-collapsed wikitable"
  lMainDataSet.FindField("DocDate").value = lDate
! GL_Acc Object Script  
  lMainDataSet.FindField("PostDate").value = lDate
|-
  lMainDataSet.FindField("Description").value = "testing desc header"
|
   lMainDataSet.Post
<syntaxhighlight lang="delphi">
    
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
  'Step 5: Insert Data - Detail
var BizApp, BizObj : Variant;
  'For Tax Inclusive
    lDataSet1, lDataSet2 : TClientDataSet;
  lDetailDataSet.Append
    ASQL : String;
  lDetailDataSet.FindField("DtlKey").value = -1
begin
  lDetailDataSet.FindField("DocKey").value = -1
   //For Debtor List => SpecialAccType = DR  
  lDetailDataSet.FindField("SEQ").value = 1
   //For Creditor List => SpecialAccType = CR
   lDetailDataSet.FindField("Code").value = "610-1000"
   BizApp := CreateOleObject('SQLAcc.BizApp');
  lDetailDataSet.FindField("Project").value = "----"
   BizObj := BizApp.BizObjects.Find('GL_Acc');
  lDetailDataSet.FindField("Description").value = "testing desc1"
  lDetailDataSet.FindField("Tax").value = "TX"
  'lDetailDataSet.FindField("LOCALTAXAMT").value = 17.32 //For JE you can't override (i.e. system auto calc)
  lDetailDataSet.FindField("TaxInclusive").Value = 1
   lDetailDataSet.FindField("LocalDR").value = 306 '//Including GST if TAXINCLUSIVE = 1
  lDetailDataSet.FindField("DR").value = 306 '//If wanted DR <> LocalDR
 
   'For Tax Exclusive
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
   lDetailDataSet.FindField("SEQ").value = 2
  lDetailDataSet.FindField("Code").value = "605-200"
  lDetailDataSet.FindField("Project").value = "----"
  lDetailDataSet.FindField("Description").value = "testing desc2"
   lDetailDataSet.FindField("Tax").value = "TX"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("LocalCR").value = 100
  lDetailDataSet.Post


   lDataSet1 := TClientDataSet.Create(Self);
   'For No GST
   lDataSet2 := TClientDataSet.Create(Self);
  lDetailDataSet.Append
  try
  lDetailDataSet.FindField("DtlKey").value = -1
    ASQL :='Parent<>-1 ' +
   lDetailDataSet.FindField("DocKey").value = -1
          'AND (SpecialAccType IS NULL OR SpecialAccType = '''' ' +
  lDetailDataSet.FindField("SEQ").value = 3
          'OR SpecialAccType = '''') ';
  lDetailDataSet.FindField("Code").value = "610-002"
    lDataSet1.XMLData:= BizObj.Select('Dockey,Code,Description', ASQL, 'Code', 'SX', '', '');
  lDetailDataSet.FindField("Project").value = "----"
 
  lDetailDataSet.FindField("Description").value =  "testing desc3"
    lDataSet2.XMLData:= BizObj.Select('Parent', '', 'Code', 'SX', '', '');
  lDetailDataSet.FindField("Tax").value =  ""
 
  lDetailDataSet.FindField("TaxInclusive").value =  0
    lDataset2.First; // Remove Parent Account
  lDetailDataSet.FindField("LocalCR").value = 200
    while not lDataset2.Eof do begin
  lDetailDataSet.Post
      if lDataset1.Locate('Dockey', lDataSet2.FindField('Parent').AsString, []) then
  'Step 6: Save Document
        lDataset1.Delete;
   BizObject.Save
      lDataset2.Next;
  BizObject.Close
    end;
   MsgBox "Done"
    lDataset1.MergeChangeLog;
End Function
    lDataset1.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
   finally
    lDataSet1.Free;
    lDataSet2.Free;
   end;
end;
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 7,860: Line 9,088:
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-Customer.Aging.RO====
====GL_JE-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Aging Report Object Script   
! GL_JE-Edit Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxbb_AgingClick(Sender: TObject);
'Available in Version 5.2018.833.759 & above
var lBizApp, lRptVar : Variant;
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
    lTime : TDateTime;
Call CheckLogin
    cdsMain, cdsDtl : TClientDataset;
Call GetData
    s : string;
Call PostData
begin
 
  lTime := Now;
Dim ComServer, lDataSet
  cdsMain := TClientDataset.Create(nil);
 
  cdsDtl  := TClientDataset.Create(nil);
Function CreateSQLAccServer
   lBizApp := CreateOleObject('SQLAcc.BizApp');
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


   s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
function CheckLogin
      '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
   'Step 1: Create Com Server object
      '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
  Set ComServer = CreateSQLAccServer 'Create Com Server
      '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
      '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
      '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
                'UserName, Password, DCF full path, Database filename
      '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
   END IF
      '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
End Function
      '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
      '</ROWDATA></DATAPACKET>';
   try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Aging.RO');
    lRptVar.Params.Find('ActualGroupBy').AsString      := 'Code;CompanyName'; //Fixed
//    lRptVar.Params.Find('AgentData').AsBlob              := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString          := s;
    lRptVar.Params.Find('AgingDate').AsDate            := '31 Aug 2016';
    lRptVar.Params.Find('AgingOn').AsString            := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean        := True;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob            := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob := ; //Not use if AllCompanyCategory is True
//    lRptVar.Params.Find('CompanyData').AsBlob        := ; //Not use if AllCompany is True
//    lRptVar.Params.Find('ControlAccountData').AsBlob  := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob        := ; //Not use if AllCurrency is True
//    lRptVar.Params.Find('DocProjectData').AsBlob      := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('FilterPostDate').AsBoolean      := True;
//    lRptVar.Params.Find('GroupBy
    lRptVar.Params.Find('IncludePDC').AsBoolean        := False;
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SortBy').AsString              := 'Code;CompanyName';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
    lRptVar.Params.Find('IncludeKnockedOffDetail').AsBoolean := False;


    lRptVar.CalculateReport;
Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_JE "
  lSQL = lSQL & "WHERE DocNo='JV-00002' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
Function PostData
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_JE")  


    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
  'Step 3: Set Dataset
     cdsDtl.SaveToFile('C:\Temp\_ListD.xml'); //Export To XML file
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
 
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
    lTime := Now - lTime;
 
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
  'Step 4 : Find Doc Number
              mtInformation, [mbOk], 0);
  If lDataSet.RecordCount > 0 Then 
   finally
lDataSet.First
     lRptVar := null;
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
     cdsMain.Free;
 
     cdsDtl.Free;
 
   end;
    BizObject.Open
end;
    BizObject.Edit
     lMain.Edit
lMain.FindField("Description").AsString = "Journal - Edited"
 
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
  lDetail.Delete
    Wend
  'Step 6: Append Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("Code").value = "610-000"
  lDetail.FindField("Description").value =  "testing desc1"
  lDetail.FindField("Project").value = "P12W1"
  lDetail.FindField("Tax").value =  ""
  lDetail.FindField("TaxInclusive").value = 0
  lDetail.FindField("LocalDR").value = 200
  lDetail.FindField("DR").value = 200
  lDetail.Post
 
  lDetail.Append
  lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("Code").value = "531-000"
  lDetail.FindField("Description").value =  "testing desc2"
  lDetail.FindField("Project").value = "P13W1"
  lDetail.FindField("Tax").value =  ""
  lDetail.FindField("TaxInclusive").value =  0
  lDetail.FindField("LocalCR").value = 200
   lDetail.FindField("CR").value = 200
  lDetail.Post
 
  'Step 7: Save Document
    BizObject.Save
     BizObject.Close
 
  'Step 8 : Logout after done 
     'ComServer.Logout 
     MsgBox "Done"
Else
MsgBox "Record Not Found"
   END IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-GL.CB.RO====
====GL_JE-Delete====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! GL Cash Book Report Object Script   
! GL_JE-Delete Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TfmMain.dxBB_CBClick(Sender: TObject);
'Available in Version 5.2018.833.759 & above
var lBizApp, lRptVar : Variant;
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
    lTime : TDateTime;
Call CheckLogin
    cdsMain, cdsDtl, cdsTax : TClientDataset;
Call GetData
begin
Call DelData
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  cdsTax  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('GL.CB.RO');
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
    lRptVar.Params.Find('AllItemProject').AsBoolean      := True;
    lRptVar.Params.Find('AllItemArea').AsBoolean          := True;
    lRptVar.Params.Find('AllItemAgent').AsBoolean        := True;
    lRptVar.Params.Find('AllDocAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllDocArea').AsBoolean          := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean    := False;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := 'Not use if AllCurrency is true


//  For Post Date From & Date To'
Dim ComServer, lDataSet
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2017';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2017';


//    lRptVar.Params.Find('DocProjectData').AsBlob          := //'Not use if AllDocProject is true
Function CreateSQLAccServer
//    lRptVar.Params.Find('DocAreaData').AsBlob            := //Not use if AllDocArea is true
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
//    lRptVar.Params.Find('DocAgentData').AsBlob            := //Not use if AllDocAgent is true
End Function
//    lRptVar.Params.Find('ItemAgentData').AsBlob          := //Not use if AllItemAgent is true
    lRptVar.Params.Find('DocType').AsString              := 'PV'; //'PV for Payment Voucher & OR for Official Receipt
//    lRptVar.Params.Find('DocumentData').AsBlob            := //Not use if AllDocument is true
//    lRptVar.Params.Find('GroupBy').AsBlob                := //If you wanted to grouping the data
    lRptVar.Params.Find('IncludeCancelled').AsBoolean    := False;
//    lRptVar.Params.Find('ItemAreaData').AsBlob            := //Not use if AllItemArea is true
//    lRptVar.Params.Find('ItemProjectData').AsBlob        := //Not use if AllItemProject is true
    lRptVar.Params.Find('PaymentMethodData').AsBlob      := '310-001';
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean   := True;
    lRptVar.Params.Find('SelectDate').AsBoolean          := True; //For Post Date
//  lRptVar.Params.Find('SelectDocDate').AsBoolean  := True; 'For Doc Date
    lRptVar.Params.Find('SortBy').AsString                := 'PostDate;DocNo';


     lRptVar.CalculateReport;
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
Function GetData
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDetail').XMLData; //Detail Data - To link Master Data use Dockey field
Dim lSQL
    cdsTax.XMLData  := lRptVar.DataSets.Find('cdsTax').XMLData; //Tax List
  lSQL = "SELECT Dockey FROM GL_JE "
  lSQL = lSQL & "WHERE DocNo='JV-00002' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
Function DelData
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
Dim BizObject
     cdsTax.SaveToFile('C:\Temp\_ListT.xml');  //Export To XML file
  'Step 2: Find and Create the Biz Objects
 
  Set BizObject = ComServer.BizObjects.Find("GL_JE")  
     lTime := Now - lTime;
  'Step 3 : Find Doc Number
     MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
  If lDataSet.RecordCount > 0 Then
              mtInformation, [mbOk], 0);
lDataSet.First
   finally
     BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
    lRptVar := null;
    BizObject.Open
     cdsMain.Free;
     BizObject.Delete
     cdsDtl.Free;
     BizObject.Close
   end;
 
end;
   'Step 4 : Logout after done 
     'ComServer.Logout 
     MsgBox "Done"
Else
MsgBox "Record Not Found"
   END IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


====Example-AR_DP====
====Get Invoice Next Number====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit Script   
! Get Invoice Next Number Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TForm1.Button1Click(Sender: TObject);
'Available in Version 5.2018.833.759 & above
var lMain, lBizObj, lBizApp : Variant;
'Copy below script & paste to notepad & name it as eg GetNextNo.vbs
begin
Call CheckLogin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
Call GetData
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
Call ShowNextNo
 
Dim ComServer, lDataSet


   lBizObj := lBizApp.BizObjects.Find('AR_DP');
Function CreateSQLAccServer
  lMain  := lBizObj.DataSets.Find('MainDataSet');
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


   try
function CheckLogin
    lBizObj.New;
   'Step 1: Create Com Server object
    lMain.FindField('DOCKEY').Value        := -1;
  Set ComServer = CreateSQLAccServer 'Create Com Server
    lMain.FindField('DocNo').AsString      := '--DP Test--';
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    lMain.FindField('CODE').AsString        := '300-C0001';
     ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    lMain.FindField('DocDate').Value        := '28 Oct 2019';
                'UserName, Password, DCF full path, Database filename
    lMain.FindField('PostDate').Value      := '28 Oct 2019';
   END IF
     lMain.FindField('TAXDATE').Value        := '28 Oct 2019';
End Function
    lMain.FindField('DEPOSITACCOUNT').AsString := 'PREPAYMENT';
    lMain.FindField('PaymentMethod').AsString  := '320-000'; //Bank or Cash account
    lMain.FindField('Description').AsString    := 'Deposit For Account';
    lMain.FindField('ChequeNumber').AsString   := '';
    lMain.FindField('BankCharge').AsFloat      := 0;
    lMain.FindField('DocAmt').AsFloat          := 1000.00;
    lMain.FindField('Cancelled').AsString      := 'F';


    try
Function GetData
      lBizObj.Save;
Dim lSQL
    except
  lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A "
      on E: Exception do
  lSQL = lSQL & "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) "
        Memo1.Lines.Append(E.Message);
  lSQL = lSQL & "WHERE A.DOCTYPE='IV' "
    end;
  lSQL = lSQL & "AND A.DESCRIPTION='Customer Invoice' "
    lBizObj.Close;
   lSQL = lSQL & "AND A.STATESET=1 "
    Memo1.Lines.Append('Done');
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
//    MessageDlg('Done', mtInformation, [mbOk], 0);
End Function
   finally
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
   end;
end;
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
Function ShowNextNo
 
Dim Desc, Fmt, NextNo, lResult, sb
====Example-Customer Deposit to Customer Payment====
  set sb = CreateObject("System.Text.StringBuilder")
{| class="mw-collapsible mw-collapsed wikitable"
  'Step 2 : Find Doc Number
! Customer Deposit to Customer Payment Script   
  If lDataSet.RecordCount > 0 Then 
|-
lDataSet.First
|  
    Desc = lDataSet.FindField("Description").AsString
<syntaxhighlight lang="delphi">
Fmt  = lDataSet.FindField("Format").AsString
procedure TForm1.Button2Click(Sender: TObject);
NextNo = lDataSet.FindField("NEXTNUMBER").Value
var lMain, lKO, lBizApp, lBizObj, V : Variant;
    cdsTmp : TClientDataset;
'Convert from IV-%.5d to IV-{0:d5}
    lSQL : String;
sb.Append_3 Fmt
begin
sb.Replace "d", ""
  cdsTmp  := TClientDataset.Create(nil);
sb.Replace "%.","{0:d"
  lBizApp := CreateOleObject('SQLAcc.BizApp');
Fmt = sb.ToString & "}"
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
sb.Length = 0 'clear sb list
sb.AppendFormat Fmt, NextNo
lResult = sb.ToString
    MsgBox Desc
MsgBox Fmt
MsgBox NextNo
MsgBox lResult
Else
MsgBox "Record Not Found"
  END IF   
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Auto Run Doc. Number====
{| class="mw-collapsible mw-collapsed wikitable"
! Sales Order Auto Run Doc Number Script   
|-
|  
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg SL_SO.vbs
'If had prompt Set Default - Just click Yes to avoid keep prompt
Call CheckLogin
Call GetData
Call InsertData


  try
Dim ComServer, lDataSet
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);


    if cdsTmp.RecordCount > 0 then begin
Function CreateSQLAccServer
      lBizObj := lBizApp.BizObjects.Find('AR_PM');
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
      lMain  := lBizObj.DataSets.Find('MainDataSet');
End Function
      lKO    := lBizObj.DataSets.Find('cdsKnockOff');


      lBizObj.New;
function CheckLogin
      lMain.FindField('DOCKEY').Value          := -1;
  'Step 1: Create Com Server object
      lMain.FindField('DocNo').AsString        := '--PM Test--'; //Payment Document Number
  Set ComServer = CreateSQLAccServer 'Create Com Server
      lMain.FindField('CODE').AsString          := '300-C0001';
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
      lMain.FindField('DocDate').Value          := '29 Oct 2019';
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
      lMain.FindField('PostDate').Value        := '29 Oct 2019';
                'UserName, Password, DCF full path, Database filename
      lMain.FindField('Description').AsString  := 'Payment for A/c';
   END IF
      lMain.FindField('PaymentMethod').AsString := 'PREPAYMENT';
End Function
      lMain.FindField('DocAmt').AsFloat        := 200;
      lMain.FindField('FROMDOCTYPE').AsString   := 'DP'; //Transfer from Deposit
      lMain.FindField('FROMDOCKEY').Value      := cdsTmp.FindField('Dockey').AsFloat; //Transfer from Deposit
      lMain.FindField('Cancelled').AsString    := 'F';
      lMain.FindField('CHANGED').AsString      := 'F';


      V := lBizApp.CreateOleVariantArray(2);
Function GetData
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
Dim lSQL
      V.SetItem(1, 'IV-00003');  //Invoice Document Number
  lSQL = "SELECT * FROM SY_DOCNO "
  lSQL = lSQL & "WHERE DESCRIPTION='Customer Sales Order 2' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
        begin
          lKO.Edit;
          lKO.FindField('KOAmt').ASFloat    := 200;
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;


      try
Function InsertData
        lBizObj.Save;
Dim BizObject, lMain, lDetail, lDate
      except
  'Step 2: Find and Create the Biz Objects
        on E: Exception do
  Set BizObject = ComServer.BizObjects.Find("SL_SO")  
          Memo1.Lines.Append(E.Message);
      end;
        lBizObj.Close;
        Memo1.Lines.Append('Done');
      //MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
    end else
      Memo1.Lines.Append('Deposit No. Not found');
  finally
    cdsTmp.Free;
    lBizApp.Logout;
    lMain := Null;
    lBizObj := Null;
    lBizApp := Null;
  end;
end;
</syntaxhighlight>
|}


<div style="float: right;">  [[#top|[top]]]</div>
  'Step 3: Set Dataset
 
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
====Example-AR_DPDTL_REFUND====
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
{| class="mw-collapsible mw-collapsed wikitable"
 
! Customer Deposit Refund Script   
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2019")
  BizObject.New
  lMain.FindField("DocKey").value        = -1
  lMain.FindField("DocNo").AsString      = "<<New>>"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value      = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Sales Order"
  lMain.FindField("DocNoSetKey").value    = lDataSet.FindField("DocKey").value
   
  'Step 5: Insert Data - Detail
  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value        = -1
  lDetail.FindField("DocKey").value        = -1
  lDetail.FindField("Seq").value            = 3
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString        = "UNIT"
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString        = ""
  lDetail.FindField("TaxRate").AsString    = ""
  lDetail.FindField("TaxInclusive").value  = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100 
  lDetail.FindField("Amount").AsFloat      = 200
  lDetail.FindField("TaxAmt").AsFloat      = 0
  lDetail.Post
 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
 
  'Step 7 : Logout after done 
  'ComServer.Logout
 
  MsgBox "Done" 
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL_PV====
{| class="mw-collapsible mw-collapsed wikitable"
! Cash Book PV Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TForm1.Button3Click(Sender: TObject);
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
var lMain, lBizApp, lBizObj : Variant;
Call PostData
    cdsTmp : TClientDataset;
    lSQL : String;
Function CreateSQLAccServer
begin
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
   cdsTmp  := TClientDataset.Create(nil);
End Function
   lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
Function PostData
 
Dim ComServer, BizObject, lIVNo, lDate
   try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
  'Step 1: Create Com Server object
            'WHERE DOCNO=''--DP Test--'' ';
   Set ComServer = CreateSQLAccServer 'Create Com Server
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);
   If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
 
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    if cdsTmp.RecordCount > 0 then begin
   END IF
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_REFUND');
      lMain   := lBizObj.DataSets.Find('MainDataSet');
  'Step 2: Find and Create the Biz Objects
 
  Set BizObject = ComServer.BizObjects.Find("GL_PV")  
      lBizObj.New;
      lMain.FindField('DOCKEY').Value         := cdsTmp.FindField('Dockey').AsFloat;
  'Step 3: Set Dataset
      lMain.FindField('Account').AsString     := '320-000'; //Bank or Cash account
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
      lMain.FindField('DocDate').Value         := '28 Oct 2019';
   Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
      lMain.FindField('PostDate').Value       := '28 Oct 2019';
 
      lMain.FindField('Description').AsString := 'Deposit Refund';
  'Step 4 : Posting
      lMain.FindField('ChequeNumber').AsString := '';
    lDate = CDate("January 23, 2020")
      lMain.FindField('BankCharge').AsFloat    := 0;
    BizObject.New
      lMain.FindField('PAYMENTAMOUNT').AsFloat := 500.00;
    lMain.FindField("DOCKEY").Value           = -1
 
    lMain.FindField("DocNo").AsString         = "--CB PV Test--"
      try
    lMain.FindField("DocDate").Value         = lDate
        lBizObj.Save;
    lMain.FindField("PostDate").Value         = lDate
      except
    lMain.FindField("Description").AsString   = "Compacc System"
        on E: Exception do
    lMain.FindField("PaymentMethod").AsString = "310-001"
          Memo1.Lines.Append(E.Message);
lMain.FindField("CHEQUENUMBER").AsString = "MBB 213245"
      end;
    lMain.FindField("DocAmt").AsFloat         = 2019.57
      lBizObj.Close;
    lMain.FindField("Cancelled").AsString    = "F"
      Memo1.Lines.Append('Done');
lMain.Post
  //     MessageDlg('Done', mtInformation, [mbOk], 0);
 
    end else
    lDetailDataSet.Append
      Memo1.Lines.Append('Deposit No. Not Found');
    lDetailDataSet.FindField("DTLKEY").value = -1
  finally
lDetailDataSet.FindField("DOCKEY").value = -1
    cdsTmp.Free;
lDetailDataSet.FindField("Code").AsString = "200-300"
    lMain := Null;
     lDetailDataSet.FindField("DESCRIPTION").AsString = "Maybank - Asus A555LD-xx313H"
    lBizObj := Null;
lDetailDataSet.FindField("TAX").AsString = ""
     lBizApp.Logout;
lDetailDataSet.FindField("TAXAMT").AsFloat = 0
    lBizApp := Null;
lDetailDataSet.FindField("TAXINCLUSIVE").AsFloat = 0
  end;
lDetailDataSet.FindField("AMOUNT").AsFloat = 2019.57
end;
     lDetailDataSet.Post
</syntaxhighlight>
|}


  'Step 5: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>
 
====ST_Item with Opening====
====Example-AR_DPDTL_FORFEIT====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit Forfeit Script   
! ST_Item with Opening Script   
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
procedure TForm1.Button4Click(Sender: TObject);
'Copy below script & paste to notepad & name it as eg ST_XF.vbs
var lMain, lBizApp, lBizObj : Variant;
Call CheckLogin
    cdsTmp : TClientDataset;
Call InsertData
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');


  try
Dim ComServer
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);


    if cdsTmp.RecordCount > 0 then begin
Function CreateSQLAccServer
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_FORFEIT');
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
      lMain  := lBizObj.DataSets.Find('MainDataSet');
End Function


      lBizObj.New;
function CheckLogin
      lMain.FindField('DOCKEY').Value          := cdsTmp.FindField('Dockey').AsFloat;
  'Step 1: Create Com Server object
      lMain.FindField('Account').AsString      := '532-000'; //Forfeit account
  Set ComServer = CreateSQLAccServer 'Create Com Server
      lMain.FindField('DocDate').Value        := '28 Oct 2019';
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
      lMain.FindField('PostDate').Value        := '28 Oct 2019';
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
      lMain.FindField('Description').AsString := 'Deposit Forfeit';
                'UserName, Password, DCF full path, Database filename
      lMain.FindField('ChequeNumber').AsString := '';
  END IF
      lMain.FindField('BankCharge').AsFloat   := 0;
End Function
      lMain.FindField('Amount').AsFloat       := 150.00;
 
Function InsertData
Dim BizObject, lMain, lDtl, lOpn
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_ITEM")
 
  'Step 3: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDtl = BizObject.DataSets.Find("cdsUOM") 'lDetail contains detail data 
  Set lOpn = BizObject.DataSets.Find("cdsOpeningBalance") 'lDetail contains detail data 
 
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  BizObject.New
  lMain.FindField("CODE").value = "==Test New Item Code=="
  lMain.FindField("DESCRIPTION").value = "Item Description 123"
  lMain.FindField("STOCKGROUP").value = "DEFAULT"
  lMain.FindField("STOCKCONTROL").value = "T"
  lMain.FindField("ISACTIVE").value = "T"
   
  'Step 5: Insert Data - Detail
  lDtl.Edit 'For 1St UOM
  lDtl.FindField("UOM").AsString = "PCS"
  lDtl.FindField("Rate").AsFloat = 1
  lDtl.FindField("RefCost").AsFloat = 10.2
  lDtl.FindField("RefPrice").AsFloat = 25
  lDtl.Post
 
  lDtl.Append 'For 2nd UOM
  lDtl.FindField("UOM").AsString = "CTN"
  lDtl.FindField("Rate").AsFloat = 12
  lDtl.FindField("RefCost").AsFloat = 102
  lDtl.FindField("RefPrice").AsFloat = 240
  lDtl.Post
 
  'Step 6: Insert Data - Opening
  lOpn.Append
  lOpn.FindField("LOCATION").AsString = "----"
  lOpn.FindField("Qty").AsFloat = 10 'in smallest UOM'
  lOpn.FindField("COST").AsFloat = 10.2
  lOpn.Post


      try
  'Step 7: Save Document
        lBizObj.Save;
  BizObject.Save
      except
  BizObject.Close
        on E: Exception do
 
          Memo1.Lines.Append(E.Message);
   'Step 8 : Logout after done 
      end;
  'ComServer.Logout
      lBizObj.Close;
    
      Memo1.Lines.Append('Done');
   MsgBox "Done" 
   //    MessageDlg('Done', mtInformation, [mbOk], 0);
End Function
    end else
      Memo1.Lines.Append('Deposit No. Not Found');
   finally
    cdsTmp.Free;
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
   end;
end;
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


==FAQ==
====GL Stock Value-Insert,Edit & Delete====
===Problem with opening CHM Help files?===
{| class="mw-collapsible mw-collapsed wikitable"
# Right click the chm file & select Properties
! GL Stock Value Insert, Edit & Delete Script 
# At General tab Click Unblock button.
|-
# Click Apply | Ok.
|
<syntaxhighlight lang="vb">
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GLStockValue.vbs
Call CheckLogin
Call GetData
'Call InsertValue
'Call UpdateValue
Call DeleteValue


<div style="float: right;">  [[#top|[top]]]</div>
Dim ComServer, lDataSet


===Still can't open CHM file?===
Function CreateSQLAccServer
# Login SQL Accounting
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
# Click Tools | Options
End Function
# Click Register & follow wizard
# Exit SQL Accounting
# Login SQL Accounting
# Run CHM File


<div style="float: right;">   [[#top|[top]]]</div>
function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
   END IF
End Function


===Why when I compile my program with stated unknown method or unknown identifier?===
Function GetData
:If you compiler had error may try add the '''esfw10.dll''' file under the SQL Accounting\bin folder
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_STOCK "
  lSQL = lSQL & "WHERE BalanceStock='330-000' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


<div style="float: right;">  [[#top|[top]]]</div>
Function InsertValue
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK")


===How to make sure I login to correct database?===
  'Step 3: Set Dataset
* Can use the '''Common.Agent.RO''' Report Objects to get the Profile info.
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
* Then use the cdsProfile Dataset
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
: - CompanyName Field
 
: - Remark Field
  'Step 4 : Find Dockey Record
* Refer to [https://www.estream.com.my/wiki/SDK_Live#Example-Get_Company_Profile Example - Get Company Profile]
  If lDataSet.RecordCount > 0 Then 
 
lDataSet.First
<div style="float: right;">  [[#top|[top]]]</div>
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString 
 
===Why after post to SQL Accounting the Description3 (More Description)/Notes field it show like this "M y  D e s c r i p t i o n" instead of "My Description"?===
    BizObject.Open
:Make sure you use '''.AsString''' in your code (see example below)
    BizObject.Edit
{| class="mw-collapsible mw-collapsed wikitable"
! Description3 Field Script/Code 
    lDetail.Append
|-
    lDetail.FindField("Project").value = "----"
|
lDetail.FindField("SYear").value = 2021
lDetail.FindField("SMonth").value = 4
lDetail.FindField("Amount").value = 423.00
    lDetail.Post
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF
End Function
 
Function UpdateValue
Dim BizObject, lMain, lDetail, v(2)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK")
 
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
  'Step 4 : Find Dockey Record
  If lDataSet.RecordCount > 0 Then 
lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString 
    BizObject.Open
    BizObject.Edit
 
    v(0) = "----" 'Project Code
    v(1) = "2021" 'Year
v(2) = "3" 'Month to update
if (lDetail.Locate("Project;SYear;SMonth", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("Amount").value = 333.12     
      lDetail.Post
End IF
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF
End Function
 
Function DeleteValue
Dim BizObject, lMain, lDetail, v(2)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK")
 
  'Step 3: Set Dataset
  Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
 
  'Step 4 : Find Dockey Record
  If lDataSet.RecordCount > 0 Then 
lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString 
    BizObject.Open
    BizObject.Edit


...
    v(0) = "----" 'Project Code
  lDtl.FindField('DESCRIPTION3').'''AsString'''  := 'Sales Item A More Description'+ #13 + 'I in 2nd line';
    v(1) = "2021" 'Year
...
v(2) = "4" 'Month to update
if (lDetail.Locate("Project;SYear;SMonth", v, false, false)) then
      lDetail.Delete
End IF
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF
End Function
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


===Can I Ignore Doc No Field & let SQL Accounting to Auto Assign?===
====Stock Item Template to SL_IV====
:Yes but we not recommended as you will lost track when user wanted to know which Doc No in SQL Acc is posted.
: To Set Auto Assign set it as below
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! DocNo Field Script/Code  
! Stock Item Template to SL_IV Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
'Updated 03 Sep 2021
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call CheckLogin
Call InsertData1
Call InsertData2
Dim ComServer
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function


...
function CheckLogin
   lMain.FindField('DocNo').'''AsString'''  := '<<New>>';
   'Step 1: Create Com Server object
...
  Set ComServer = CreateSQLAccServer 'Create Com Server
|}
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
                'UserName, Password, DCF full path, Database filename
  END IF
End Function


<div style="float: right;">  [[#top|[top]]]</div>
Function InsertData1
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_ITEM_TPL")


===Can I Auto Login & Logout SQL Accounting when doing & after Posting?===
  'Step 3: Set Dataset
: Yes can below is example script
  Set lMain  = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
: Only work if that PC is no once is using SQL Accounting
  Set lDetail = BizObject.DataSets.Find("cdsItemTplDtl") 'lDetail contains detail data 
{| class="mw-collapsible mw-collapsed wikitable"
 
! C Sharp  
  'Begin Looping yr data
|-
  'Step 4 : Insert Data - Master
|
  BizObject.New
<syntaxhighlight lang="C#">
  lMain.FindField("Code").AsString        = "--TPL Test--"
Int32 lBuildNo;
  lMain.FindField("Description").AsString = "Template formt 1"
dynamic ComServer;
  lMain.FindField("RefPrice").AsFloat     = 299.15
      
public void CheckLogin()
  'Step 5: Insert Data - Detail
{           
  lDetail.Append
    lBizType = Type.GetTypeFromProgID("SQLAcc.BizApp");
  lDetail.FindField("DtlKey").value         = -1
    ComServer = Activator.CreateInstance(lBizType);
  lDetail.FindField("Code").AsString        = "--TPL Test--"
           
  lDetail.FindField("Seq").value            = 1
     if (!ComServer.IsLogin)
  lDetail.FindField("ItemCode").AsString    = "ANT"
     {
  lDetail.FindField("Description").AsString = "Sales Item A"
        try
  lDetail.FindField("UOM").AsString         = "BOX"
         {
  lDetail.FindField("Qty").AsFloat          = 2
            ComServer.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text);
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
            ComServer.Minimize();
  lDetail.FindField("UNITAMOUNT").AsFloat    = 100 
         }
  lDetail.FindField("Amount").AsFloat      = 200
        catch(Exception ex)
  lDetail.FindField("PRINTABLE").AsString  = "T"
        {
  lDetail.Post
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 
            FreeBiz(ComServer);
  lDetail.Append
        }
  lDetail.FindField("DtlKey").value         = -1
    }
  lDetail.FindField("Code").AsString        = "--TPL Test--"
    if (ComServer.IsLogin)
  lDetail.FindField("Seq").value            = 2
    {
  lDetail.FindField("ItemCode").AsString    = "COVER"
         lBuildNo = ComServer.BuildNo;
  lDetail.FindField("Description").AsString = "Sales Item B"
    }
  lDetail.FindField("UOM").AsString        = "UNIT"
}
  lDetail.FindField("Qty").AsFloat          = 3
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
public void FreeBiz(object AbizObj)
  lDetail.FindField("UNITAMOUNT").AsFloat    = 10 
{
  lDetail.FindField("Amount").AsFloat      = 30
    System.Runtime.InteropServices.Marshal.ReleaseComObject(AbizObj);
  lDetail.FindField("PRINTABLE").AsString  = "T"
}
  lDetail.Post 
  'Step 6: Save Document
private void btnExport_Click(object sender, EventArgs e)
  BizObject.Save
{
  BizObject.Close
    dynamic BizObject, lMain, lDocKey;
  MsgBox "Template Posting Done" 
End Function


    CheckLogin();
Function InsertData2
    //'Step 2: Find and Create the Biz Objects
Dim BizObject, lMain, lDetail, lDate, lDODtl, lSQL, v(2)
    BizObject = ComServer.BizObjects.Find("Agent");
  'Step 1: Get Template Information
  lSQL = "SELECT * FROM ST_ITEM_TPLDTL "
  lSQL = lSQL & "WHERE Code='--TPL Test--' "
  Set lDODtl = ComServer.DBManager.NewDataSet(lSQL)


    //Step 3: Set Dataset
  if lDODtl.RecordCount > 0 then
     lMain = BizObject.DataSets.Find("MainDataSet");    //lMain contains master data
'Step 2: Find and Create the Biz Objects
     Set BizObject = ComServer.BizObjects.Find("SL_IV")  


     //Step 4: Search
     'Step 3: Set Dataset
     lDocKey = BizObject.FindKeyByRef("CODE", edCode.Text);
     Set lMain  = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
    try
    Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data 
     {
 
        try
     'Step 4 : Insert Data - Master
        {
    lDate = CDate("January 1, 2021")
            //Step 5 : Insert or Update
    BizObject.New
            if (Convert.IsDBNull(lDocKey))
    lMain.FindField("DocKey").value        = -1
            {
    lMain.FindField("DocNo").AsString      = "--IV Test--"
                BizObject.New();
    lMain.FindField("DocDate").value       = lDate
                lMain.FindField("CODE").value = edCode.Text;
    lMain.FindField("PostDate").value       = lDate
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
    lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
            }
    lMain.FindField("CompanyName").AsString = "Cash Sales"
            else
    'lMain.FindField("Address1").AsString    = "" 'Optional
            {//Edit Data if found
    'lMain.FindField("Address2").AsString    = "" 'Optional
                BizObject.Params.Find("CODE").Value = lDocKey;
    'lMain.FindField("Address3").AsString    = "" 'Optional
                BizObject.Open();
    'lMain.FindField("Address4").AsString    = "" 'Optional
                BizObject.Edit();
    'lMain.FindField("Phone1").AsString      = "" 'Optional
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
    lMain.FindField("Description").AsString = "Sales"
            }
   
            //Step 6: Save & Close
    'Step 6: Insert Data - Detail
            BizObject.Save();
lDODtl.First
            MessageBox.Show("Done", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
    While not lDODtl.Eof
         }
      lDetail.Append
        catch (Exception ex)
      lDetail.FindField("DtlKey").value        = -1
        {
      lDetail.FindField("DocKey").value        = -1
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      lDetail.FindField("Seq").value            = 1
        }
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
    }
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
     finally
      lDetail.FindField("UOM").AsString         = lDODtl.FindField("UOM").AsString
     {
      lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
        BizObject.Close();
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
 
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitAmount").AsFloat
        //Step 7 : Logout after done            
      lDetail.FindField("Amount").AsFloat      = lDODtl.FindField("Amount").AsFloat
        FreeBiz(BizObject);
      lDetail.FindField("PRINTABLE").AsString  = lDODtl.FindField("PRINTABLE").AsString
        ComServer.Logout();
      lDetail.Post
        FreeBiz(ComServer);
  lDODtl.Next
    }           
Wend
}
  'Step 7: Save Document
     BizObject.Save
     BizObject.Close
 
  'Step 8 : Logout after done
  'ComServer.Logout
 
  MsgBox "Posting IV Done"
  else MsgBox "--No Template found. Posting IV aborted" 
  End IF
End Function
</syntaxhighlight>
</syntaxhighlight>
|}
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
====AR_CN====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Delphi  
! AR_CN Script  
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="vb">
....
'Updated 24 Feb 2023
  public
'Copy below script & paste to notepad & name it as eg AR_CN.vbs
    { Public declarations }
Call InsertData
    lBizApp : variant;
  end;
....


procedure TForm1.CheckLogin;
Function CreateSQLAccServer
begin
   Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  lBizApp := null;
End Function
   lBizApp := CreateOleObject('SQLAcc.BizApp');


  if not lBizApp.IsLogin then begin
Function InsertData
    lBizApp.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text); //Login with preset setting
Dim ComServer, BizObject, lDate, lIVNO, v(1)
    lBizApp.Minimize; //Mininise the SQLAccounting
  end;
end;


procedure TForm1.Button2Click(Sender: TObject);
   'Step 1: Create Com Server object
var BizObject, lMain : Variant;
  Set ComServer = CreateSQLAccServer 'Create Com Server
begin
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
   try
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
    //Begin Loop your data
   END IF
    try
      CheckLogin;
      BizObject := lBizApp.BizObjects.Find('Agent');
      lMain    := BizObject.DataSets.Find('MainDataSet');
      BizObject.New;
      lMain.FindField('CODE').AsString := 'HALIM';
      lMain.FindField('Description').AsString := 'HALIM 123';
      BizObject.save;
    except
      on E: Exception do
        MmLog.Lines.Append(E.Message);
    end;
    //
  finally
    BizObject.close;
    BizObject := null;
    lBizApp.Logout;
    lBizApp := null;
   end;
end;
</syntaxhighlight>
|}


  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_CN")
  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data 
  Set lKO = BizObject.DataSets.Find("cdsKnockOff") 'Contains IV/DN to knock off data 
 
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2023")
  BizObject.New
  lMainDataSet.FindField("DocKey").value = -1
  lMainDataSet.FindField("DocNo").value = "--CN Test--"
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Code").value = "300-A0001"
  lMainDataSet.FindField("Description").value = "Credit Note"
   
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "510-2000"
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
  lDetailDataSet.FindField("Tax").value =  "SV"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 410.37
  lDetailDataSet.FindField("TaxAmt").value = 24.63
 
  lDetailDataSet.DisableControls
  lDetailDataSet.FindField("TaxInclusive").value =  1
  lDetailDataSet.EnableControls
 
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
 
  'For Tax Inclusive = False with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "510-2000"
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Tax").value =  "SV"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
  'Step 7: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
    if (lKO.Locate("DocType;DocNo", v, false, false)) then
      lKO.Edit
      lKO.FindField("KOAmt").value = 65.57
      lKO.FindField("KnockOff").AsString = "T"
      lKO.Post
End IF 
  'Step 7: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<br />
===JScript/JavaScript===
This Script only can run using Internet Explorer (till IE 11)
====AR_IV====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! VB Script   
! AR_IV Script   
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="javascript">
'Copy below script & paste to notepad & name it as eg Agent.vbs
<html>
Call PostData
<head>
<title>Add Customer Invoice</title>
<script language="JScript">
var ComServer;
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
   
   
Function CreateSQLAccServer
function AutoInvoice() {
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
  var BizObject, lMainDataSet, lDetailDataSet;
End Function
   
   
Function PostData
  CreateSQLAccServer();
Dim ComServer, BizObject
   
   
   'Step 1: Create Com Server object
   BizObject = ComServer.BizObjects.Find('AR_IV');
  Set ComServer = CreateSQLAccServer 'Create Com Server
   lMainDataSet = BizObject.DataSets.Find('MainDataSet');
 
   lDetailDataSet = BizObject.DataSets.Find('cdsDocDetail');
   Set WScr = CreateObject("WScript.Shell")
   BizObject.New();
  WScript.Sleep 1000 '//Wait 1 second for system loading before proceed
 
  'Step 2: Force Logout to make sure login correct database
   If ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Logout
  END IF
  'Step 3: Login
  ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0015.FDB"
 
  'Step 4: Find and Create the Biz Objects
   Set BizObject = ComServer.BizObjects.Find("Agent")  
   
   
   'Step 5: Set Dataset
   lMainDataSet.FindField('DocKey').value = -1;
   Set lMain = BizObject.DataSets.Find("MainDataSet")   'lMainDataSet contains master data
   lMainDataSet.FindField('DocNo').value = "--IV Test--";
  lMainDataSet.FindField('DocDate').value = "01/10/2016";
  lMainDataSet.FindField('PostDate').value = "01/10/2016";
  lMainDataSet.FindField('Code').value = "300-A0003";
  lMainDataSet.FindField('Description').value = "Sales";


    
   /*For Tax Inclusive = True with override Tax Amount*/
   'Step 6 : Posting
   lDetailDataSet.Append();
    BizObject.New
  lDetailDataSet.FindField('DtlKey').value = -1;
    lMain.FindField("CODE").AsString          = "_Test_"
  lDetailDataSet.FindField('DocKey').value = -1;
    lMain.FindField("Description").AsString   = "Testing 123"
  lDetailDataSet.FindField('Account').value = "500-000";
  lDetailDataSet.FindField('Description').value =  "Sales Item A";
  lDetailDataSet.FindField('Tax').value =  "SR";
  lDetailDataSet.FindField('TaxInclusive').value =  0;
  lDetailDataSet.FindField('Amount').value = 410.37;
  lDetailDataSet.FindField('TaxAmt').value = 24.63;
  lDetailDataSet.DisableControls();
  lDetailDataSet.FindField('TaxInclusive').value =  1;
  lDetailDataSet.EnableControls();
  lDetailDataSet.FindField('Changed').value = "F";
  lDetailDataSet.Post();
 
  /*For Tax Inclusive = False with override Tax Amount*/
  lDetailDataSet.Append();
  lDetailDataSet.FindField('DtlKey').value = -1;
  lDetailDataSet.FindField('DocKey').value = -1;
  lDetailDataSet.FindField('Account').value = "500-000";
  lDetailDataSet.FindField('Description').value =  "Sales Item B";
  lDetailDataSet.FindField('Tax').value =  "SR";
  lDetailDataSet.FindField('TaxInclusive').value =  0;
   lDetailDataSet.FindField('Amount').value = 94.43;
  lDetailDataSet.FindField('TaxAmt').value = 5.66;
  lDetailDataSet.FindField('Changed').value = "F";
  lDetailDataSet.Post();


   'Step 7: Save Document
   /* Save document */ 
     BizObject.Save
     BizObject.Save();
     BizObject.Close
     BizObject.Close();
    alert('Customer Invoice - has been saved.');
  'Step 8: Logout
}
    ComServer.Logout
</script>
MsgBox "Done"
</head>
End Function
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="AutoInvoice()">
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>
<div style="float: right;">  [[#top|[top]]]</div>


===When Post System Prompt Operation aborted Error===
====SL_CS====
: This happen when the Login User ID don't had the to '''Override Sales Min/Max Price''' &
: Use '''Last Price XXX''' (In Tools | Options | Unit Price) &
: 1 of record is below Min Price.
'''Solution'''
: Can try change the Posting Seq like below (UOM then Qty)
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! Sequence Field Script/Code  
! SL_CS Script   
|-
|-
|  
|  
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer;


...
function CreateSQLAccServer() {
    lDetail.Append();
  ComServer = new ActiveXObject('SQLAcc.BizApp');
    lDetail.FindField("DtlKey").value = -1;
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    lDetail.FindField("DocKey").value = -1;
     ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
    lDetail.FindField("Seq").value = 3;
/* UserName, Password */
    lDetail.FindField("ItemCode").AsString = "ANT";
  }
    lDetail.FindField("Description").AsString = "Sales Item B";
}
    //lDetail.FindField("Account").AsString = "500-000"; To override the Sales Account Code
     '''lDetail.FindField("UOM").AsString = "UNIT";'''
    '''lDetail.FindField("Qty").AsFloat = 2;'''
    //lDetail.FindField("DISC").AsString = "5%+3"; //Optional(eg 5% plus 3 Discount)
    lDetail.FindField("Tax").AsString = "SR";
    lDetail.FindField("TaxRate").AsString = "6%";
    lDetail.FindField("TaxInclusive").value = 0;
    lDetail.FindField("UnitPrice").AsFloat = 100;
    lDetail.FindField("Amount").AsFloat = 200;
    lDetail.FindField("TaxAmt").AsFloat = 12;
    lDetail.Post();
...
|}
<div style="float: right;">  [[#top|[top]]]</div>


===How do my system know there is a changes or update in SQLAccounting?===
function InsertData() {
'''Data Entry'''<br>
  var BizObject, lMain, lDetail;
: In all Document it had a field call <span style="color:#0000ff">UPDATECOUNT</span>.
 
: Default is null & each changes will +1.
  CreateSQLAccServer();
: So if you see 2 meaning it had being update 2 times


'''Master Data'''
  /*Step 2: Find and Create the Biz Objects*/
: Only available in
  BizObject = ComServer.BizObjects.Find('SL_CS') ;
:* Version 842.765 & above
:* AP_SUPPLIER (Maintain Supplier)
:* AR_CUSTOMER (Maintain Customer)
:* ST_GROUP (Maintain Stock Group)
:* ST_ITEM (Maintain Stock Item)
:* ST_ITEM_TPL (Maintain Item Template)
:* ST_PRICETAG (Maintain Price Tag)
:* TAX (Maintain Tax)
: In Each table it had a field call <span style="color:#0000ff">LASTMODIFIED</span>.
: The value is '''Epoch Time''' or '''Unix Time'''


You can use below function to get the field
  /*Step 3: Set Dataset*/
{| class="mw-collapsible mw-collapsed wikitable"
  lMain  = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
! vbs 
  lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */ 
|-
 
|
  /*Begin Looping yr data*/
<syntaxhighlight lang="vbs">
  /*Step 4 : Insert Data - Master*/
...
  BizObject.New();
Function GetData
  lMain.FindField('DocKey').value        = -1;
Dim lDataSet, lSQL
  lMain.FindField('DocNo').AsString      = "--IV Test--";
   lSQL = "SELECT DOCNO, UPDATECOUNT FROM SL_CS "
  lMain.FindField('DocDate').value        = "20/12/2017";
   lSQL = lSQL & "WHERE UPDATECOUNT IS NOT NULL "  
  lMain.FindField('PostDate').value      = "20/12/2017";
   lSQL = lSQL & "ORDER BY DOCNO "
  lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
   Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
  lMain.FindField('CompanyName').AsString = "Cash Sales"
  lMain.FindField('Address1').AsString    = ""; /*Optional*/
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
  lMain.FindField('Address4').AsString    = ""; /*Optional*/
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
  lMain.FindField('Description').AsString = "Sales";
   
  /*Step 5: Insert Data - Detail*/
  /*For Tax Inclusive = True with override Tax Amount*/
  lDetail.Append();
  lDetail.FindField('DtlKey').value        = -1;
  lDetail.FindField('DocKey').value        = -1;
  lDetail.FindField('Seq').value            = 1;
  lDetail.FindField('Account').AsString    = "500-000"; /*Sales Account*/
   lDetail.FindField('Description').AsString = "Sales Item A";
  lDetail.FindField('Qty').AsFloat          = 1;
   lDetail.FindField('Tax').AsString        = "SR";
   lDetail.FindField('TaxRate').AsString    = "6%";
  lDetail.FindField('TaxInclusive').value  = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 435;
  lDetail.FindField('Amount').AsFloat      = 410.37; /*Exclding GST Amt*/
  lDetail.FindField('TaxAmt').AsFloat      = 24.63;
 
  lDetail.DisableControls();
   lDetail.FindField('TaxInclusive').value  = 1;
  lDetail.EnableControls();
 
  lDetail.Post();
    
    
   lDataSet.First
   /*For Tax Inclusive = False with override Tax Amount*/
   While (not lDataSet.eof)
  lDetail.Append();
     MsgBox "DocNo : " & lDataSet.FindField("DocNo").AsString
   lDetail.FindField('DtlKey').value        = -1;
     MsgBox "UpdateCount : " & lDataSet.FindField("UPDATECOUNT").AsString
  lDetail.FindField('DocKey').value        = -1;
     lDataSet.Next
  lDetail.FindField('Seq').value            = 2;
   Wend
  lDetail.FindField('Account').AsString     = "500-000";
End Function
  lDetail.FindField('Description').AsString = "Sales Item B";
...
  lDetail.FindField('Qty').AsFloat          = 1;
</syntaxhighlight>
  lDetail.FindField('Tax').AsString        = "SR";
|}
  lDetail.FindField('TaxRate').AsString    = "6%";
 
  lDetail.FindField('TaxInclusive').value  = 0;
{| class="mw-collapsible mw-collapsed wikitable"
  lDetail.FindField('UnitPrice').AsFloat    = 94.43;
! Delphi
  lDetail.FindField('Amount').AsFloat      = 94.43;
  lDetail.FindField('TaxAmt').AsFloat      = 5.66;
  lDetail.Post();
 
  /*For With Item Code*/
  lDetail.Append();
  lDetail.FindField('DtlKey').value        = -1;
  lDetail.FindField('DocKey').value        = -1;
  lDetail.FindField('Seq').value            = 3;
  lDetail.FindField('ItemCode').AsString    = "ANT";
  lDetail.FindField('Description').AsString = "Sales Item B";
  /*lDetail.FindField('Account').AsString     = "500-000"; If you wanted override the Sales Account Code*/
  lDetail.FindField('Qty').AsFloat          = 2;
  lDetail.FindField('UOM').AsString        = "UNIT";
  /*lDetail.FindField('DISC').AsString       = "5%+3"; Optional (eg 5% plus 3 Discount)*/
  lDetail.FindField('Tax').AsString        = "SR";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value  = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 100;
  lDetail.FindField('Amount').AsFloat      = 200;
  lDetail.FindField('TaxAmt').AsFloat      = 12;
   lDetail.Post();
 
  /*Step 6: Save Document*/
  BizObject.Save();
  BizObject.Close();
    alert('Document has been saved.');
}
</script>
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="InsertData()">
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_PM====
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script 
|-
|-
|  
|  
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="javascript">
... 
<html>
procedure TfmMain.dxbb_GetFieldClick(Sender: TObject);
<head>
var BizApp : Variant;
<title>Customer Payment</title>
    lDataSet : TClientDataSet;
<script language="JScript">
    ASQL : String;
<html>
begin
<head>
  BizApp := CreateOleObject('SQLAcc.BizApp');
<title>Add Customer Payment</title>
  lDataSet := TClientDataSet.Create(Self);
<script language="JScript">
  try
var ComServer;
    ASQL := 'SELECT DOCNO, UPDATECOUNT FROM SL_CS ' +
            'WHERE UPDATECOUNT IS NOT NULL ' +
            'ORDER BY DOCNO ';
    lDataSet.Data := BizApp.DBManager.Execute(ASQL);
    lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet.Free;
  end;
end;
...
</syntaxhighlight>
|}
<div style="float: right;">   [[#top|[top]]]</div>


===Can I control my Stock when I link with other Application?===
function CreateSQLAccServer() {
: Yes. We suggest to use Stock Transfer to (eg Location call <span style="color:#0000ff">MOBILE</span>) transfer stock as Reserve to avoid stock over deduct in SQL Accounting
  ComServer = new ActiveXObject("SQLAcc.BizApp");
: When other Application post to SQL Accounting they just need set the Location to the Reserve Location (eg <span style="color:#0000ff">MOBILE</span>)
  if (!ComServer.IsLogin) {            /* check whether user has logon */
: Below is example posting with location
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
{| class="mw-collapsible mw-collapsed wikitable"
/* UserName, Password */
! Post Location Field Script/Code 
  }
|-
}
|


...
function AddPayment() {
   lDtl.FindField('UOM').AsString      := 'CTN';
   var BizObject, lMainDataSet, lKnockOffDataSet, V;
   lDtl.FindField('QTY').AsFloat        := 6;
    
   lDtl.FindField('Location').AsString  := 'MOBILE';
   CreateSQLAccServer();
...
|}


<div style="float: right;">   [[#top|[top]]]</div>
  BizObject = ComServer.BizObjects.Find('AR_PM');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
  BizObject.New();
 
  lMainDataSet.FindField('DocKey').value = -1;
  lMainDataSet.FindField('DocNo').value = "--OR Test--";
  lMainDataSet.FindField('Code').value = "300-C0001";
  lMainDataSet.FindField('DocDate').value = "10/10/2023";
  lMainDataSet.FindField('PostDate').value = "10/10/2023"; 
  lMainDataSet.FindField('Description').value = "Payment for Account";
  lMainDataSet.FindField('PaymentMethod').value = "310-001";
  lMainDataSet.FindField('ChequeNumber').value = "";
  lMainDataSet.FindField('DocAmt').AsFloat = 106.10;
  lMainDataSet.FindField('BankCharge').AsFloat = 0;
  lMainDataSet.FindField('UnappliedAmt').AsFloat = 0;
  lMainDataSet.FindField('Cancelled').value = 'F';
 
   v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType*/
  v.SetItem(1, 'IV-00172'); /*Knock Off DocNo*/


===Where to Check the SQL Accounting DCF Path, FileName & FDB FileName?===
  if (lKnockOffDataSet.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
: In Login Screen Click 3 Dot Button then you can see the information
          lKnockOffDataSet.Edit();
[[File:SDK-FAQ-01.jpg|center]]
          lKnockOffDataSet.FindField('KOAmt').AsFloat = 106.10;  
[[File:SDK-FAQ-02.jpg|554px|center]]
          lKnockOffDataSet.FindField('KnockOff').AsString = 'T';
<div style="float: right;">   [[#top|[top]]]</div>
          lKnockOffDataSet.Post(); }
    /* Save document */ 
    BizObject.Save();
    BizObject.Close();
    alert("Customer Payment - has been saved.");
}
 
function EditPayment(){
  var BizObject, lMainDataSet, lKnockOffDataSet, V, lDocNo, lDocKey;
 
   CreateSQLAccServer();


===How to check & What is the value for Advance Credit Control in Maintain Customer===
  BizObject = ComServer.BizObjects.Find('AR_PM');
: You can use <span style="color:#0000ff">ComServer.DBManager.NewDataSet(lSQL)</span> function to Query the information
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
: lSQL = SELECT * FROM AR_CUSTOMERCRCTRL
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
: You may refer to <span style="color:#0000ff">ControlType</span> column
 
  lDocNo = "--OR Test--"
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
  BizObject.Params.Find('DocKey').Value = lDocKey;
 
  if (lDocKey != null) {
    BizObject.Open();
    BizObject.Edit();
    lMainDataSet.FindField('Description').value = "Payment for Account-Edited";
    lMainDataSet.FindField('PaymentMethod').value = "310-001";
    lMainDataSet.FindField('ChequeNumber').value = "";
    lMainDataSet.FindField('DocAmt').AsFloat = 200.00;
    lMainDataSet.FindField('BankCharge').AsFloat = 0;
    lMainDataSet.FindField('UnappliedAmt').AsFloat = 0;
    lMainDataSet.FindField('Cancelled').value = 'F';
 
    v = ComServer.CreateOleVariantArray(2);
    v.SetItem(0, 'IV'); /*Knock Off DocType*/
    v.SetItem(1, 'IV-00172'); /*Knock Off DocNo*/


{| class="wikitable" style="margin: 1em auto 1em auto;"
    if (lKnockOffDataSet.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){  
|-
          lKnockOffDataSet.Edit();
! ControlType !! Exceed Credit Limit !! Exceed OverDue Limit
          lKnockOffDataSet.FindField('KOAmt').AsFloat = 200;  
|-
          lKnockOffDataSet.FindField('KnockOff').AsString = 'T';
| align="center" | 0 || UnBlock || UnBlock
          lKnockOffDataSet.Post(); }
|-
    /* Save document */  
| align="center" | 1 || UnBlock || Block
      BizObject.Save();
|-
      BizObject.Close();
| align="center" | 2|| UnBlock || Override
      alert("Customer Payment - has been Edited & saved.");
|-
  }
| align="center" | 3|| Block || UnBlock
}
|-
| align="center" | 4|| Block || Block
|-
| align="center" | 5|| Block || Override
|-
| align="center" | 6|| Override || UnBlock
|-
| align="center" | 7|| Override || Block
|-
| align="center" | 8|| Override || Override
|-
| align="center" | 9|| align="center" colspan="2"| Suspended
|}


<div style="float: right;">   [[#top|[top]]]</div>
function DelPayment(){
  var BizObject, lMainDataSet, lKnockOffDataSet, V, lDocNo, lDocKey;
    
  CreateSQLAccServer();


===How to get Error/Exception Message Return from SQL Accounting?===
  BizObject = ComServer.BizObjects.Find('AR_PM');
{| class="mw-collapsible mw-collapsed wikitable"
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
! C Sharp 
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
|-
 
|
  lDocNo = "--OR Test--"
<syntaxhighlight lang="C#">
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
try
  BizObject.Params.Find('DocKey').Value = lDocKey;
{
 
  BizObject.New();
  if (lDocKey != null) {
....
    BizObject.Open();
  BizObject.Save();
    BizObject.Delete();
}
 
catch (Exception ex)
    BizObject.Close();
{
     alert("Customer Payment - has been Deleted.");
     MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  }
}
}
</script>
</head>
<body>
<input type="submit" value="Add Payment" name="btnSubmit" onclick="AddPayment()">
<input type="submit" value="Edit Payment" name="btnSubmit" onclick="EditPayment()">
<input type="submit" value="Delete Payment" name="btnSubmit" onclick="DelPayment()">
</body>
</html>
</syntaxhighlight>
</syntaxhighlight>
|}
|}
<div style="float: right;">  [[#top|[top]]]</div>


====Customer.IV.RO====
{| class="mw-collapsible mw-collapsed wikitable"
{| class="mw-collapsible mw-collapsed wikitable"
! VB.Net  
! Customer.IV.RO Report Object Script  
|-
|-
|  
|  
<syntaxhighlight lang="vb">
<syntaxhighlight lang="javascript">
Try
<html>
   BizObject.[New]
  <head>
...
    <title>Customer.IV.RO</title>
   BizObject.Save
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript">
var ComServer;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject("SQLAcc.BizApp");
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}     
 
function GetData() { 
  var lMain, lDetail, lRptVar, lDateFrom, lDateTo;
 
  elem = document.getElementById('txt1');
 
  CreateSQLAccServer();
 
  lDateFrom = new Date("January 1 2015");
  lDateTo = new Date("December 31, 2015");
 
  lRptVar = ComServer.RptObjects.Find('Customer.IV.RO');
  lRptVar.Params.Find('SelectDate').Value          = true;
  lRptVar.Params.Find('DateFrom').Value            = lDateFrom.valueOf();
  lRptVar.Params.Find('DateTo').Value              = lDateTo.valueOf();
  lRptVar.Params.Find('AllAgent').Value            = false;
  lRptVar.Params.Find('AgentData').Value            = "----\nLF"; /*Filter by Agent code ---- & HALIM */
  lRptVar.Params.Find('AllArea').Value              = true;
  lRptVar.Params.Find('AllCompany').Value          = true;
  lRptVar.Params.Find('AllCurrency').Value          = true;
  lRptVar.Params.Find('AllDocProject').Value        = true;
  lRptVar.Params.Find('AllCompanyCategory').Value  = true;
  lRptVar.Params.Find('AllDocument').Value          = true;
  lRptVar.Params.Find('IncludeCancelled').Value  = false;
  lRptVar.Params.Find('PrintDocumentStyle').Value = false;
  lRptVar.Params.Find('AllItemProject').Value    = true;
  lRptVar.Params.Find('AllPaymentMethod').Value  = true;
  lRptVar.CalculateReport(); 
 
  lMain  = lRptVar.DataSets.Find('cdsMain');
  lDetail = lRptVar.DataSets.Find('cdsDocDetail');
  /*alert("Count -" + lRptVar.DataSets.Find('cdsDocDetail').RecordCount);*/
  elem.innerHTML += 'From Main'+'\n';
   
  lMain.First();
  while (!lMain.eof) {
    elem.innerHTML += lMain.FindField('DocKey').AsString + ' ' +
                  lMain.FindField('DocNo').AsString + ' ' + lMain.FindField('DocDate').AsString + ' '+
                      lMain.FindField('CompanyName').AsString + ' ' + lMain.FindField('DocAmt').AsString + '\n';
lMain.Next(); 
  }
  elem.innerHTML += 'End Main'+'\n\n';
 
  elem.innerHTML += 'From Detail'+'\n';
  lDetail.First();
  while (!lDetail.eof) {
    elem.innerHTML += lDetail.FindField('Dockey').AsString + ' ' + lDetail.FindField('Account').AsString + ' ' +
                  lDetail.FindField('Description').AsString + ' ' + lDetail.FindField('Amount').AsString + '\n';
lDetail.Next(); 
  } 
  elem.innerHTML += 'End Detail'+'\n\n';
}
 
    </script>
  </head>
  <body>
    <form>
      <textarea id="txt1" rows="30" cols="116"></textarea>
      <input type="button" value="Calculate" onclick="GetData()">
    </form>
  </body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Customer.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.RO Report Object Script 
|-
|
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Customer Invoice</title>
<script language='JScript'>
var ComServer;
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
 
function GetCustomerData() {
  var RptObject, lDataSet, lDataSet2;
  edOutput.value = '';
  edOutput2.value = '';
  //Step 1: Create Com Server object
  CreateSQLAccServer();
 
  //Step 2: Find and Create the Report Objects
  RptObject = ComServer.RptObjects.Find('Customer.RO');
 
  //Step 3: Spool parameters
  RptObject.Params.Find('AllAgent').Value = true;
  RptObject.Params.Find('AllArea').Value = true;
  RptObject.Params.Find('AllCompany').Value = true;
  RptObject.Params.Find('AllCompanyCategory').Value = true;
  RptObject.Params.Find('AllCurrency').Value = true;
  RptObject.Params.Find('AllTerms').Value = true;
  RptObject.Params.Find('SelectDate').Value = true;
  RptObject.Params.Find('PrintActive').Value = true;
  RptObject.Params.Find('PrintInactive').Value = false;
  RptObject.Params.Find('PrintPending').Value = false;
  RptObject.Params.Find('PrintProspect').Value = false;
  RptObject.Params.Find('PrintSuspend').Value = false;
  //RptObject.Params.Find('CompanyData').Value = '300-A0003';
 
  //Step 4: Perform Report calculation
  RptObject.CalculateReport();
  lDataSet = RptObject.DataSets.Find('cdsMain');
  lDataSet2 = RptObject.DataSets.Find('cdsBranch');
 
  //alert('Count ' + lDataSet.RecordCount);
 
  //Step 5 Retrieve the output
  lDataSet.First;
  while  (!lDataSet.eof){
    edOutput.value = edOutput.value +
                'Code : ' + lDataSet.FindField('Code').AsString + '\n' +
                'Company Name : ' + lDataSet.FindField('CompanyName').AsString +'\n\n';
lDataSet.Next();
  }
  lDataSet2.First();
  while (!lDataSet2.eof){
  edOutput2.value = edOutput2.value +
                  'Code : '+ lDataSet2.FindField('Code').AsString + '\n' +
  'Branch Name : '+ lDataSet2.FindField('BranchName').AsString + '\n' +
                  'Address 1 : '+ lDataSet2.FindField('Address1').AsString + '\n' +
  'Address 2 : '+ lDataSet2.FindField('Address2').AsString + '\n' +
  'Address 3 : '+ lDataSet2.FindField('Address3').AsString + '\n' +
  'Address 4 : '+ lDataSet2.FindField('Address4').AsString + '\n' +
  'Phone 1 : '+ lDataSet2.FindField('Phone1').AsString  +'\n\n';
  lDataSet2.Next();
    }
}
 
</script>
</head>
<body>
  <table>
    <tr>
      <th>Main Table</th>
      <th>Branch Branch</th>
    </tr>
    <tr>
      <td>
        <TEXTAREA rows=15 cols=75 name="edOutput"></TEXTAREA>
  </td>
      <td>
        <TEXTAREA rows=15 cols=75 name="edOutput2"></TEXTAREA>
  </td>
    </tr>
  </table>
  <table width="83%">
<tr>
  <td align="center">
<input type='submit' value='Sync Data' name='btnSubmit' onclick='GetCustomerData()'>
  </td>
</tr>
  </table>
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Next IV Number====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Next IV Number Script 
|-
|
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer, lDataSet;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
 
function zeroPad(num, places) {
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
  /*zeroPad(5, 2); // "05"*/
}
 
function GetData() {
  var lSQL;
  lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A ";
  lSQL = lSQL + "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) ";
  lSQL = lSQL + "WHERE A.DOCTYPE='IV' ";
  lSQL = lSQL + "AND A.DESCRIPTION='Customer Invoice' ";
  lSQL = lSQL + "AND A.STATESET=1 ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL); 
}
 
function ShowNextNo() {
  var Desc, Fmt, NextNo, lResult, lPad;
 
  CreateSQLAccServer(); 
  GetData();
 
  if (lDataSet.RecordCount > 0) { 
    lDataSet.First;
    Desc = lDataSet.FindField("Description").AsString;
Fmt  = lDataSet.FindField("Format").AsString;
NextNo = lDataSet.FindField("NEXTNUMBER").Value;
    alert(Desc);
alert(Fmt);
alert(NextNo);
lPad = Fmt.substr(5, 1);
lPad = zeroPad(NextNo, lPad)
Desc = Fmt.substr(0, 3);
alert(Desc + lPad);
  }
}
</script>
</head>
<body>
<input type="submit" value="Show Next No" name="btnSubmit" onclick="ShowNextNo()">
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
====Customer & Supplier Contra====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer & Supplier Contra Script 
|-
|
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Customer Invoice</title>
<script language="JScript">
var ComServer;
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
function PostARCT() {
  var BizObject, lMain, lKO, V;
  CreateSQLAccServer();
  BizObject = ComServer.BizObjects.Find('AR_CT');
  lMain = BizObject.DataSets.Find('MainDataSet');
  lKO = BizObject.DataSets.Find('cdsKnockOff');
  BizObject.New();
  lMain.FindField('DocKey').value = -1;
  lMain.FindField('DocNo').value = "--CT Test--";
  lMain.FindField('DocDate').value = "01/10/2020";
  lMain.FindField('PostDate').value = "01/10/2020";
  lMain.FindField('Code').value = "300-A0002";
  lMain.FindField('Description').value = "Contra";
  lMain.FindField('DocAmt').value = "100.00";
  //lMain.FindField('UnappliedAmt').value = "0";
 
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType*/
  v.SetItem(1, 'IV-00021'); /*Knock Off DocNo*/
 
  if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
          lKO.Edit();
          lKO.FindField('DocAmt').value = "100";  
          lKO.FindField('KnockOff').AsString = 'T';
          lKO.Post(); }
 
  /* Save document */ 
    BizObject.Save();
    BizObject.Close();
    alert('Customer Contra - has been saved.');
}
 
function PostAPST() {
  var BizObject, lMain, lKO, V, lDocNo, lDocKey;
  CreateSQLAccServer();
  BizObject = ComServer.BizObjects.Find('AP_ST');
  lMain = BizObject.DataSets.Find('MainDataSet');
  lKO = BizObject.DataSets.Find('cdsKnockOff');
 
  lDocNo = "--CT Test--"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey 
 
  if (lDocKey != null) {
    BizObject.Open();
BizObject.Edit();
lMain.FindField('Code').value = "400-C0001";
lMain.FindField('DocAmt').value = "100.00";
  //lMain.FindField('UnappliedAmt').value = "0";
 
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'PI'); /*Knock Off DocType*/
  v.SetItem(1, 'PI-00001'); /*Knock Off DocNo*/
 
    if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
          lKO.Edit();
          lKO.FindField('DocAmt').value = "100";  
          lKO.FindField('KnockOff').AsString = 'T';
          lKO.Post(); }
 
  /* Save document */ 
    BizObject.Save(); 
    BizObject.Close();
    alert('Supplier Contra - has been Updated.');
  }
}
</script>
</head>
<body>
<button onclick="javascript:PostARCT();">PostARCT</button>&nbsp;&nbsp;
<button onclick="javascript:PostAPST();">PostAPST</button>&nbsp;&nbsp;
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Add Stock Item====
{| class="mw-collapsible mw-collapsed wikitable"
! Add ST_Item Script 
|-
|
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Stock Item</title>
<script language="JScript">
var ComServer;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
 
function InsertData() {
  var BizObject, lMain, lDetail;
 
  CreateSQLAccServer();
 
  /*Step 2: Find and Create the Biz Objects*/
  BizObject = ComServer.BizObjects.Find('ST_ITEM') ;
 
  /*Step 3: Set Dataset*/
  lMain  = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lUOM = BizObject.DataSets.Find('cdsUOM'); /*lDetail contains detail data */ 
 
  /*Begin Looping yr data*/
  /*Step 4 : Insert Data - Master*/
  BizObject.New();
  lMain.FindField('Code').AsString        = "Code JScript";
  lMain.FindField('DESCRIPTION').AsString = "Post from JScript"
  lMain.FindField('STOCKGROUP').AsString    = "DEFAULT"; /*Optional*/
  lMain.FindField('STOCKCONTROL').AsString    = "T"; /*Optional*/
  lMain.FindField('ISACTIVE').AsString    = "T"; /*Optional*/
   
  /*Step 5: Insert Data - UOM*/
  lUOM.Edit(); /*For 1St UOM*/
  lUOM.FindField('UOM').AsString = "PCS";
  lUOM.FindField('Rate').AsFloat = 1;
  lUOM.FindField('RefCost').AsFloat = 10.2;
  lUOM.FindField('RefPrice').AsFloat = 25;
  lUOM.Post();
 
  lUOM.Append(); /*For 2nd UOM*/
  lUOM.FindField('UOM').AsString = "CTN";
  lUOM.FindField('Rate').AsFloat = 12;
  lUOM.FindField('RefCost').AsFloat = 102;
  lUOM.FindField('RefPrice').AsFloat = 240;
  lUOM.Post();
 
  /*Step 6: Save*/
  BizObject.Save();
  BizObject.Close();
    alert('Item has been saved.');
}
</script>
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="InsertData()">
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
====Get Company Profile====
{| class="mw-collapsible mw-collapsed wikitable"
! Get Company Profile Script 
|-
|
<syntaxhighlight lang="javascript">
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer, lDataSet;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
/* UserName, Password */
  }
}
 
function zeroPad(num, places) {
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
  /*zeroPad(5, 2); // "05"*/
}
 
function GetData() {
  var lSQL;
  lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, ";
  lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, ";
  lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL); 
}
 
function ShowCoProfile() {
  var CoName, Rmk, BRN;
 
  CreateSQLAccServer(); 
  GetData();
 
  if (lDataSet.RecordCount > 0) { 
    lDataSet.First;
    CoName = lDataSet.FindField("COMPANYNAME").AsString;
Rmk  = lDataSet.FindField("REMARK").AsString;
BRN = lDataSet.FindField("BRN").Value;
    alert(CoName);
alert(Rmk);
alert(BRN);
  }
}
</script>
</head>
<body>
<input type="submit" value="Show Co Profile" name="btnSubmit" onclick="ShowCoProfile()">
</body>
</html>
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
<br />
 
===Delphi===
The below example is assuming after you had check the login status.
====GL_JE====
{| class="mw-collapsible mw-collapsed wikitable"
! GL_JE Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_GL_JEClick(Sender: TObject);
var BizApp, lMain, lDtl, lBizObj, lDocKey : Variant;
    i : integer;
begin
  BizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := BizApp.BizObjects.Find('GL_JE');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
    lBizObj.New;
    lMain.FindField('DOCKEY').Value        := -1;
    lMain.FindField('DocNo').Value        := '--JE Test--';
    lMain.FindField('DocDate').Value      := '28 Aug 2017';
    lMain.FindField('PostDate').Value      := '28 Aug 2017';
    lMain.FindField('TAXDATE').Value      := '28 Aug 2017';
    lMain.FindField('Description').Value  := 'Postage';
    lMain.FindField('Cancelled').Value    := 'F';
    lMain.FindField('DOCNOSETKEY').Value  := 0;
    lMain.Post;
 
    //For Tax Inclusive
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value      := -1;
    lDtl.FindField('DOCKEY').Value      := -1;
    lDtl.FindField('SEQ').Value          := 1;
    lDtl.FindField('CODE').Value        := '610-1000';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 1';
    lDtl.FindField('TAX').Value          := 'TX';
//    lDtl.FindField('LOCALTAXAMT').AsFloat := 17.32;//For JE you can't override (i.e. system auto calc)
    lDtl.FindField('TAXINCLUSIVE').Value  := 1;
    lDtl.FindField('LocalDR').AsFloat    := 306;//Including GST if TAXINCLUSIVE = 1
    lDtl.FindField('DR').AsFloat          := 306;//if wanted DR <> LocalDR
    lDtl.FindField('CHANGED').Value      := 'F';
    lDtl.Post;
 
    //For Tax Exclusive
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value      := -1;
    lDtl.FindField('DOCKEY').Value      := -1;
    lDtl.FindField('SEQ').Value          := 2;
    lDtl.FindField('CODE').Value        := '605-200';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 2';
    lDtl.FindField('TAX').Value          := 'TX';
    lDtl.FindField('TAXINCLUSIVE').Value := 0;
    lDtl.FindField('LocalCR').AsFloat    := 100;
    lDtl.FindField('CHANGED').Value      := 'F';
    lDtl.Post;
 
    //For No GST
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value      := -1;
    lDtl.FindField('DOCKEY').Value      := -1;
    lDtl.FindField('SEQ').Value          := 3;
    lDtl.FindField('CODE').Value        := '610-002';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 3';
    lDtl.FindField('TAX').Value          := '';
    lDtl.FindField('TAXINCLUSIVE').Value  := 0;
    lDtl.FindField('LocalCR').AsFloat    := 200;
    lDtl.FindField('CHANGED').Value      := 'F';
    lDtl.Post;
 
    lBizObj.Save;
    MessageDlg('GL_JE-DocNo : ''--JE Test--'' Posted...', mtInformation, [mbOK],0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL_PV====
{| class="mw-collapsible mw-collapsed wikitable"
! GL_PV Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_GLPVClick(Sender: TObject);
var lMain, lDtl, lBizObj, BizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  BizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := BizApp.BizObjects.Find('GL_PV');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
    lBizObj.New;
    lMain.FindField('DOCKEY').Value          := -1;
    lMain.FindField('DocNo').AsString        := '--CB PV Test1--';
    lMain.FindField('DocDate').Value          := '18 Aug 2015';
    lMain.FindField('PostDate').Value        := '18 Aug 2015';
    lMain.FindField('TAXDATE').Value          := '18 Aug 2015';
    lMain.FindField('Description').AsString  := 'Compacc System';
    lMain.FindField('PAYMENTMETHOD').AsString := '310-001';
    lMain.FindField('CHEQUENUMBER').AsString  := 'MBB 213245';
    lMain.FindField('DocAmt').AsFloat        := 2019;
    lMain.FindField('Cancelled').AsString    := 'F';
    lMain.FindField('CHANGED').AsString      := 'F';
    lMain.Post;
 
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value        := -1;
    lDtl.FindField('DOCKEY').Value        := -1;
    lDtl.FindField('Code').AsString        := '200-300';
    lDtl.FindField('DESCRIPTION').AsString := 'Maybank - Asus A555LD-xx313H';
    lDtl.FindField('TAX').AsString        := 'TX';
    lDtl.FindField('TAXAMT').AsFloat      := 114.28;
    lDtl.FindField('TAXINCLUSIVE').Value  := 1;
    lDtl.FindField('AMOUNT').AsFloat      := 2019;
    lDtl.FindField('CHANGED').AsString    := 'F';
    lDtl.Post;
    lBizObj.Save;
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_Customer====
{| class="mw-collapsible mw-collapsed wikitable"
! AR_Customer Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_CustomerClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
 
  lBizObj := lBizApp.BizObjects.Find('AR_Customer');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsBranch');
 
  try
    lBizObj.New;
    lMain.FindField('Code').value        := '300-Test';
    lMain.FindField('CompanyName').value := 'Testing 123';
 
    lDtl.Edit; //For 1st Branch
    lDtl.FindField('BranchName').AsString := 'BILLING';
    lDtl.FindField('Address1').AsString  := 'Address1';
    lDtl.FindField('Address2').AsString  := 'Address2';
    lDtl.FindField('Address3').AsString  := 'Address3';
    lDtl.FindField('Address4').AsString  := 'Address4';
    lDtl.FindField('Attention').AsString  := 'Attention';
    lDtl.FindField('Phone1').AsString    := 'Phone1';
    lDtl.FindField('Fax1').AsString      := 'Fax1';
    lDtl.FindField('Email').AsString      := 'EmailAddress';
    lDtl.Post;
 
    lDtl.Append; //For 2nd Branch
    lDtl.FindField('BranchName').AsString := 'Branch1';
    lDtl.FindField('Address1').AsString  := 'DAddress1';
    lDtl.FindField('Address2').AsString  := 'DAddress2';
    lDtl.FindField('Address3').AsString  := 'DAddress3';
    lDtl.FindField('Address4').AsString  := 'DAddress4';
    lDtl.FindField('Attention').AsString  := 'DAttention';
    lDtl.FindField('Phone1').AsString    := 'DPhone1';
    lDtl.FindField('Fax1').AsString      := 'DFax1';
    lDtl.FindField('Email').AsString      := 'DEmailAddress';
    lDtl.Post;
    lBizObj.Save;
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_PM====
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lKO    := lBizObj.DataSets.Find('cdsKnockOff');
 
    lBizObj.New;
    lMain.FindField('DOCKEY').Value          := -1;
    lMain.FindField('DocNo').AsString        := '--PM Test--'; //Payment Document Number
    lMain.FindField('CODE').AsString          := '300-A0001';
    lMain.FindField('DocDate').Value          := '28 Aug 2016';
    lMain.FindField('PostDate').Value        := '28 Aug 2016';
    lMain.FindField('Description').AsString  := 'Payment for A/c';
    lMain.FindField('PaymentMethod').AsString := '320-000';
    lMain.FindField('DocAmt').AsFloat        := 1060;
    lMain.FindField('Cancelled').AsString    := 'F';
 
    V := lBizApp.CreateOleVariantArray(2);
    V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
    V.SetItem(1, '--IV Test--');  //Invoice Document Number
 
    if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
      begin
        lKO.Edit;
        lKO.FindField('KOAmt').ASFloat    := 500;
        lKO.FindField('KnockOff').AsString := 'T';
        lKO.Post;
      end;
 
    lBizObj.Save;
    MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_PM-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
! AR_PM Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain  := lBizObj.DataSets.Find('MainDataSet');
    lKO    := lBizObj.DataSets.Find('cdsKnockOff');
 
    lDocKey := lBizObj.FindKeyByRef('DocNo', '--PM Test--');
    lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);
 
    If not VarIsNull(lDocKey) Then begin
      lBizObj.Open;
      lBizObj.Edit;
      lMain.FindField('DOCKEY').Value          := -1;
      lMain.FindField('DocDate').Value          := '28 Aug 2016';
      lMain.FindField('PostDate').Value        := '28 Aug 2016';
      lMain.FindField('Description').AsString  := 'Payment for A/c';
      lMain.FindField('PaymentMethod').AsString := '310-000';
      lMain.FindField('DocAmt').AsFloat        := 800.28;
      lMain.FindField('UnappliedAmt').AsFloat  := 100.28;
      lMain.FindField('Cancelled').AsString    := 'F';
      lMain.FindField('CHANGED').AsString      := 'F';
 
      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
      V.SetItem(1, '--IV Test--');  //Document Number
 
      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
        begin
          lKO.Edit;
          lKO.FindField('KOAmt').AsFloat    := 700.28; // IV Knock Off/Offset Amount
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;
 
      lBizObj.Save;
      MessageDlg('AR_PM-DocNo : ''--PM Test--'' Updated...', mtInformation, [mbOK],0);
    end;
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====ST_Item====
{| class="mw-collapsible mw-collapsed wikitable"
! ST_Item Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsUOM');
 
  try
    lBizObj.New;
    lMain.FindField('Code').AsString        := 'Test-1';
    lMain.FindField('Description').AsString := 'Testing - Description';
 
    lDtl.Edit; //For 1st UOM
    lDtl.FindField('UOM').AsString    := 'PCS';
    lDtl.FindField('Rate').AsFloat    := 1;
    lDtl.FindField('RefCost').AsFloat  := 10.20;
    lDtl.FindField('RefPrice').AsFloat := 25.00;
    lDtl.Post;
 
    lDtl.Append; //For 2nd UOM
    lDtl.FindField('UOM').AsString    := 'CTN';
    lDtl.FindField('Rate').AsFloat    := 12;
    lDtl.FindField('RefCost').AsFloat  := 102.00;
    lDtl.FindField('RefPrice').AsFloat := 240.00;
    lDtl.Post;
    lBizObj.Save;
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====ST_Item-Edit====
{| class="mw-collapsible mw-collapsed wikitable"
! ST_Item Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp, lDocKey, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsUOM');
 
  lDocKey := lBizObj.FindKeyByRef('Code', '--Stock Item Test--');
  lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);
  try
 
    If not VarIsNull(lDocKey) Then begin
      lBizObj.Open;
      lBizObj.Edit;
      lMain.FindField('Description').value := 'Testing - Description';
 
      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'CTN'); //UOM
      V.SetItem(1, '12');  //Rate
 
      if lDtl.Locate('UOM;Rate', V.AsOleVariant, False, False) then
        begin
          lDtl.Edit;
          lDtl.FindField('RefCost').AsFloat  := 10.20;
          lDtl.FindField('RefPrice').AsFloat := 25.00;
          lDtl.Post;
        end;
      lBizObj.Save;
 
      MessageDlg('ST_Item-ItemCode : ''--Stock Item Test--'' Updated...', mtInformation, [mbOK],0);
    end;
  finally
    lBizObj.Close;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====SL_IV====
{| class="mw-collapsible mw-collapsed wikitable"
! SL_IV Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_SL_IVClick(Sender: TObject);
var lMain, lDtl, lSN, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('SL_IV');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
  lSN    := lBizObj.DataSets.Find('cdsSerialNumber');
 
  try
    lBizObj.New;
    lMain.FindField('DOCKEY').Value        := -1;
    lMain.FindField('DocNo').AsString      := '--IV Test--';
    lMain.FindField('CODE').AsString        := '300-A0001';
    lMain.FindField('DocDate').Value        := '28 Aug 2020';
    lMain.FindField('PostDate').Value      := '28 Aug 2020';
    lMain.FindField('TAXDATE').Value        := '28 Aug 2020';
    lMain.FindField('Description').AsString := 'Sales';
    lMain.FindField('Cancelled').AsString  := 'F';
    lMain.Post;
 
    lDtl.Append; // For Tax Inclusive = True with override Tax Amount
    lDtl.FindField('DTLKEY').Value        := -1;
    lDtl.FindField('DOCKEY').Value        := -1;
    lDtl.FindField('SEQ').Value            := 1;
    lDtl.FindField('ItemCode').AsString    := 'ITEM A';
    lDtl.FindField('ACCOUNT').AsString    := '500-000'; //GL Sales Account
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item A';
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString        := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value  := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 435;//Including GST UnitPrice
    lDtl.FindField('AMOUNT').AsFloat      := 410.37; //Must Excluding GST (Qty * UnitPrice) // Less 0.01
    lDtl.FindField('TAXAMT').AsFloat      := 24.63; //Extra 0.01
 
    lDtl.DisableControls; //For Tax Inclusive Only where TaxAmt is not as Calc
    try
      lDtl.FindField('TAXINCLUSIVE').Value := 1;
    finally
      lDtl.EnableControls;
    end;
    lDtl.Post;
 
    lDtl.Append; // For Tax Inclusive = False with override Tax Amount
    lDtl.FindField('DTLKEY').Value        := -1;
    lDtl.FindField('DOCKEY').Value        := -1;
    lDtl.FindField('SEQ').Value            := 2;
    lDtl.FindField('ItemCode').AsString    := 'ITEM B';
    lDtl.FindField('ACCOUNT').AsString    := '500-000';
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item B';
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString        := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value  := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 94.43;
    lDtl.FindField('AMOUNT').AsFloat      := 94.43;
    lDtl.FindField('TAXAMT').AsFloat      := 5.66; //Less 0.01
    lDtl.Post;
 
    lDtl.Append; // For Serial Number
    lDtl.FindField('DTLKEY').Value        := -1;
    lDtl.FindField('DOCKEY').Value        := -1;
    lDtl.FindField('SEQ').Value            := 3;
    lDtl.FindField('ItemCode').AsString    := 'SN1';
    lDtl.FindField('ACCOUNT').AsString    := '500-000';
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Serial Number Item';
 
    lSN.Append;
    lSN.FindField('SERIALNUMBER').AsString  := 'SN-00001';
    lSN.Post;
 
    lSN.Append;
    lSN.FindField('SERIALNUMBER').AsString  := 'SN-00002';
    lSN.Post;
 
    lDtl.FindField('QTY').AsFloat        := 2;
    lDtl.FindField('TAX').AsString      := 'SR';
    lDtl.FindField('TAXINCLUSIVE').Value := 0;
    lDtl.FindField('UNITPRICE').AsFloat  := 94.43;
    lDtl.FindField('TAXAMT').AsFloat    := 11.33;
    lDtl.Post;
 
    lBizObj.Save;
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
    lMain := null;
    lDtl := null;
    lSN := null;
    lBizObj := null;
    lBizApp := null;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Customer.IV.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.IV.RO Report Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_RptObjClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.IV.RO');
    lRptVar.Params.Find('SelectDate').AsBoolean          := True;
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    lRptVar.Params.Find('AllAgent').AsBoolean            := False;
    lRptVar.Params.Find('AgentData').AsBlob              := '----'#13#10'HALIM'; //Filter by Agent code ---- & HALIM
    lRptVar.Params.Find('AllArea').AsBoolean              := True;
//    lRptVar.Params.Find('AreaData').AsBlob                := ; //Not use if AllArea is True
    lRptVar.Params.Find('AllCompany').AsBoolean          := True;
//    lRptVar.Params.Find('CompanyData').AsBlob            := ; //Not use if AllCompany is True
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := ; //Not use if AllCurrenty is True
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
//    lRptVar.Params.Find('DocProjectData').AsBlob          := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean  := True;
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob    := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
//    lRptVar.Params.Find('DocumentData').AsBlob            := ; //Not use if AllDocument is True
    lRptVar.Params.Find('IncludeCancelled').AsBoolean  := True;
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean := False;
    lRptVar.Params.Find('AllItemProject').AsBoolean    := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean  := True;
    lRptVar.CalculateReport;
 
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocDetail').XMLData; //Detail Data - To link Master Data use Dockey field
 
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Stock.Item.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! Stock.Item.RO Report Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_ST_ITEM_ROClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl, cdsCat : TClientDataset;
    lSQL : string;
begin
  lTime    := Now;
  cdsMain  := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  cdsCat  := TClientDataset.Create(nil);
 
  lBizApp := CreateOleObject('SQLAcc.BizApp');
 
  lSQL := 'SELECT * FROM ST_ITEM_CATEGORY ' +
          'WHERE Category IN (''B-MOTOLORA'',''B-MAXIS'')';
  cdsCat.Data := lBizApp.DBManager.Execute(lSQL); //For filtering Category only
 
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Stock.Item.RO');
    lRptVar.Params.Find('AllItem').AsBoolean              := True;
    lRptVar.Params.Find('AllStockGroup').AsBoolean        := True;
    lRptVar.Params.Find('AllCustomerPriceTag').AsBoolean  := True;
    lRptVar.Params.Find('AllSupplierPriceTag').AsBoolean  := True;
//    lRptVar.Params.Find('CategoryData').AsBlob            := ; //Not use
//    lRptVar.Params.Find('CategoryTpl').AsBlob            := ; //Not use
//    lRptVar.Params.Find('CustomerPriceTagData').AsBlob    := ; //Not use if AllCustomerPriceTag is True
//    lRptVar.Params.Find('SupplierPriceTagData').AsBlob    := ; //Not use if AllSupplierPriceTag is True
//    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015'; //Not use if SelectDate is False
//    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    lRptVar.Params.Find('HasAltStockItem').AsBoolean      := False;
    lRptVar.Params.Find('HasBarcode').AsBoolean          := False;
    lRptVar.Params.Find('HasBOM').AsBoolean              := False;
    lRptVar.Params.Find('HasCategory').AsBoolean          := False;
    lRptVar.Params.Find('HasCustomerItem').AsBoolean      := False;
    lRptVar.Params.Find('HasOpeningBalance').AsBoolean    := False;
    lRptVar.Params.Find('HasPurchasePrice').AsBoolean    := False;
    lRptVar.Params.Find('HasSellingPrice').AsBoolean      := False;
    lRptVar.Params.Find('HasSupplierItem').AsBoolean      := False;
//    lRptVar.Params.Find('ItemData').AsBlob                := 'ANT 1.0'#13#10'COVER'; //Filter by Item code ANT 1.0 & COVER
//    lRptVar.Params.Find('ItemCategoryData').AsBlob        := cdsCat.XMLData; //Not use if SelectCategory is False
    lRptVar.Params.Find('PrintActive').AsBoolean          := True;
    lRptVar.Params.Find('PrintInActive').AsBoolean        := True;
    lRptVar.Params.Find('PrintNonStockControl').AsBoolean := True;
    lRptVar.Params.Find('PrintStockControl').AsBoolean    := True;
    lRptVar.Params.Find('SelectCategory').AsBoolean      := False;
    lRptVar.Params.Find('SelectDate').AsBoolean          := False;
    lRptVar.Params.Find('SortBy').AsString                  := 'Code';
//    lRptVar.Params.Find('StockGroupData').AsBlob        := ; //Not use if AllStockGroup is True
    lRptVar.CalculateReport;
 
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData; //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsUOM').XMLData;  //Detail Data - To link Master Data use Code field
 
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
    cdsCat.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Customer.Statement.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer.Statement.RO Report Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_StatementClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
    s : string;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
      '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
      '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
      '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
      '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
      '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
      '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
      '</ROWDATA></DATAPACKET>';
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Statement.RO');
//  lRptVar.Params.Find('AgentData').AsBlob              := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString          := s; //Fixed
    lRptVar.Params.Find('AgingOn').AsString            := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean        := False;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob              := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob  := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('CompanyData').AsBlob          := '300-A0001'#13#10'300-C0001'; //Filter by Customer Code 300-A0001 & 300-C0001
//    lRptVar.Params.Find('ControlAccountData').AsBlob    := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob          := ; //Not use if AllCurrency is True
    lRptVar.Params.Find('DateFrom').AsDate              := '01 Aug 2016';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
//    lRptVar.Params.Find('DocProjectData').AsBlob        := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SelectDate').AsBoolean        := True;
    lRptVar.Params.Find('SortBy').AsString              := 'CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount';
    lRptVar.Params.Find('StatementDate').AsDate        := '31 Aug 2016'; // Norm same as DateTo
    lRptVar.Params.Find('StatementType').AsString      := 'O'; //O := Open Item, B := B/F
 
    lRptVar.CalculateReport;
 
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field
 
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL Account List For Sales & Purchase 1====
{| class="mw-collapsible mw-collapsed wikitable"
! GL_Acc Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
var BizApp : Variant;
    lDataSet : TClientDataSet;
    ASQL : String;
begin
  //For Debtor List => SpecialAccType = DR
  //For Creditor List => SpecialAccType = CR
  BizApp := CreateOleObject('SQLAcc.BizApp');
  lDataSet := TClientDataSet.Create(Self);
  try
    ASQL := 'SELECT A.Code, A.Description FROM GL_ACC A '+
            'LEFT OUTER JOIN GL_ACC B ON (A.Dockey=B.Parent) '+
            'WHERE A.Parent<>-1 ' +
            'AND B.Dockey IS NULL ' +
            'AND A.SpecialAccType = '''' '+
            'ORDER BY A.CODE ';
    lDataSet.Data := BizApp.DBManager.Execute(ASQL);
    lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL Account List For Sales & Purchase 2====
{| class="mw-collapsible mw-collapsed wikitable"
! GL_Acc Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
var BizApp, BizObj : Variant;
    lDataSet1, lDataSet2 : TClientDataSet;
    ASQL : String;
begin
  //For Debtor List => SpecialAccType = DR
  //For Creditor List => SpecialAccType = CR
  BizApp := CreateOleObject('SQLAcc.BizApp');
  BizObj := BizApp.BizObjects.Find('GL_Acc');
 
  lDataSet1 := TClientDataSet.Create(Self);
  lDataSet2 := TClientDataSet.Create(Self);
  try
    ASQL :='Parent<>-1 ' +
          'AND (SpecialAccType IS NULL OR SpecialAccType = '''' ' +
          'OR SpecialAccType = '''') ';
    lDataSet1.XMLData:= BizObj.Select('Dockey,Code,Description', ASQL, 'Code', 'SX', '', '');
 
    lDataSet2.XMLData:= BizObj.Select('Parent', '', 'Code', 'SX', '', '');
 
    lDataset2.First; // Remove Parent Account
    while not lDataset2.Eof do begin
      if lDataset1.Locate('Dockey', lDataSet2.FindField('Parent').AsString, []) then
        lDataset1.Delete;
      lDataset2.Next;
    end;
    lDataset1.MergeChangeLog;
    lDataset1.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet1.Free;
    lDataSet2.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Customer.Aging.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Aging Report Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxbb_AgingClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
    s : string;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
 
  s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
      '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
      '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
      '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
      '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
      '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
      '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
      '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
      '</ROWDATA></DATAPACKET>';
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Aging.RO');
    lRptVar.Params.Find('ActualGroupBy').AsString      := 'Code;CompanyName'; //Fixed
//    lRptVar.Params.Find('AgentData').AsBlob              := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString          := s;
    lRptVar.Params.Find('AgingDate').AsDate            := '31 Aug 2016';
    lRptVar.Params.Find('AgingOn').AsString            := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean        := True;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob            := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob := ; //Not use if AllCompanyCategory is True
//    lRptVar.Params.Find('CompanyData').AsBlob        := ; //Not use if AllCompany is True
//    lRptVar.Params.Find('ControlAccountData').AsBlob  := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob        := ; //Not use if AllCurrency is True
//    lRptVar.Params.Find('DocProjectData').AsBlob      := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('FilterPostDate').AsBoolean      := True;
//    lRptVar.Params.Find('GroupBy
    lRptVar.Params.Find('IncludePDC').AsBoolean        := False;
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SortBy').AsString              := 'Code;CompanyName';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
    lRptVar.Params.Find('IncludeKnockedOffDetail').AsBoolean := False;
 
    lRptVar.CalculateReport;
 
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field
 
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====GL.CB.RO====
{| class="mw-collapsible mw-collapsed wikitable"
! GL Cash Book Report Object Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TfmMain.dxBB_CBClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl, cdsTax : TClientDataset;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  cdsTax  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('GL.CB.RO');
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
    lRptVar.Params.Find('AllItemProject').AsBoolean      := True;
    lRptVar.Params.Find('AllItemArea').AsBoolean          := True;
    lRptVar.Params.Find('AllItemAgent').AsBoolean        := True;
    lRptVar.Params.Find('AllDocAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllDocArea').AsBoolean          := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean    := False;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := 'Not use if AllCurrency is true
 
//  For Post Date From & Date To'
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2017';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2017';
 
//    lRptVar.Params.Find('DocProjectData').AsBlob          := //'Not use if AllDocProject is true
//    lRptVar.Params.Find('DocAreaData').AsBlob            := //Not use if AllDocArea is true
//    lRptVar.Params.Find('DocAgentData').AsBlob            := //Not use if AllDocAgent is true
//    lRptVar.Params.Find('ItemAgentData').AsBlob          := //Not use if AllItemAgent is true
    lRptVar.Params.Find('DocType').AsString              := 'PV'; //'PV for Payment Voucher & OR for Official Receipt
//    lRptVar.Params.Find('DocumentData').AsBlob            := //Not use if AllDocument is true
//    lRptVar.Params.Find('GroupBy').AsBlob                := //If you wanted to grouping the data
    lRptVar.Params.Find('IncludeCancelled').AsBoolean    := False;
//    lRptVar.Params.Find('ItemAreaData').AsBlob            := //Not use if AllItemArea is true
//    lRptVar.Params.Find('ItemProjectData').AsBlob        := //Not use if AllItemProject is true
    lRptVar.Params.Find('PaymentMethodData').AsBlob      := '310-001';
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean  := True;
    lRptVar.Params.Find('SelectDate').AsBoolean          := True; //For Post Date
//  lRptVar.Params.Find('SelectDocDate').AsBoolean  := True; 'For Doc Date
    lRptVar.Params.Find('SortBy').AsString                := 'PostDate;DocNo';
 
    lRptVar.CalculateReport;
 
    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDetail').XMLData; //Detail Data - To link Master Data use Dockey field
    cdsTax.XMLData  := lRptVar.DataSets.Find('cdsTax').XMLData; //Tax List
 
    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
    cdsTax.SaveToFile('C:\Temp\_ListT.xml');  //Export To XML file
 
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
              mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_DP====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TForm1.Button1Click(Sender: TObject);
var lMain, lBizObj, lBizApp : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
 
  lBizObj := lBizApp.BizObjects.Find('AR_DP');
  lMain  := lBizObj.DataSets.Find('MainDataSet');
 
  try
    lBizObj.New;
    lMain.FindField('DOCKEY').Value        := -1;
    lMain.FindField('DocNo').AsString      := '--DP Test--';
    lMain.FindField('CODE').AsString        := '300-C0001';
    lMain.FindField('DocDate').Value        := '28 Oct 2019';
    lMain.FindField('PostDate').Value      := '28 Oct 2019';
    lMain.FindField('TAXDATE').Value        := '28 Oct 2019';
    lMain.FindField('DEPOSITACCOUNT').AsString := 'PREPAYMENT';
    lMain.FindField('PaymentMethod').AsString  := '320-000'; //Bank or Cash account
    lMain.FindField('Description').AsString    := 'Deposit For Account';
    lMain.FindField('ChequeNumber').AsString  := '';
    lMain.FindField('BankCharge').AsFloat      := 0;
    lMain.FindField('DocAmt').AsFloat          := 1000.00;
    lMain.FindField('Cancelled').AsString      := 'F';
 
    try
      lBizObj.Save;
    except
      on E: Exception do
        Memo1.Lines.Append(E.Message);
    end;
    lBizObj.Close;
    Memo1.Lines.Append('Done');
//    MessageDlg('Done', mtInformation, [mbOk], 0);
  finally
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====Customer Deposit to Customer Payment====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit to Customer Payment Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TForm1.Button2Click(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
 
  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);
 
    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_PM');
      lMain  := lBizObj.DataSets.Find('MainDataSet');
      lKO    := lBizObj.DataSets.Find('cdsKnockOff');
 
      lBizObj.New;
      lMain.FindField('DOCKEY').Value          := -1;
      lMain.FindField('DocNo').AsString        := '--PM Test--'; //Payment Document Number
      lMain.FindField('CODE').AsString          := '300-C0001';
      lMain.FindField('DocDate').Value          := '29 Oct 2019';
      lMain.FindField('PostDate').Value        := '29 Oct 2019';
      lMain.FindField('Description').AsString  := 'Payment for A/c';
      lMain.FindField('PaymentMethod').AsString := 'PREPAYMENT';
      lMain.FindField('DocAmt').AsFloat        := 200;
      lMain.FindField('FROMDOCTYPE').AsString  := 'DP'; //Transfer from Deposit
      lMain.FindField('FROMDOCKEY').Value      := cdsTmp.FindField('Dockey').AsFloat; //Transfer from Deposit
      lMain.FindField('Cancelled').AsString    := 'F';
      lMain.FindField('CHANGED').AsString      := 'F';
 
      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
      V.SetItem(1, 'IV-00003');  //Invoice Document Number
 
      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
        begin
          lKO.Edit;
          lKO.FindField('KOAmt').ASFloat    := 200;
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;
 
      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
        lBizObj.Close;
        Memo1.Lines.Append('Done');
      //MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
    end else
      Memo1.Lines.Append('Deposit No. Not found');
  finally
    cdsTmp.Free;
    lBizApp.Logout;
    lMain := Null;
    lBizObj := Null;
    lBizApp := Null;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_DPDTL_REFUND====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit Refund Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TForm1.Button3Click(Sender: TObject);
var lMain, lBizApp, lBizObj : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
 
  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);
 
    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_REFUND');
      lMain  := lBizObj.DataSets.Find('MainDataSet');
 
      lBizObj.New;
      lMain.FindField('DOCKEY').Value          := cdsTmp.FindField('Dockey').AsFloat;
      lMain.FindField('Account').AsString      := '320-000'; //Bank or Cash account
      lMain.FindField('DocDate').Value        := '28 Oct 2019';
      lMain.FindField('PostDate').Value        := '28 Oct 2019';
      lMain.FindField('Description').AsString  := 'Deposit Refund';
      lMain.FindField('ChequeNumber').AsString := '';
      lMain.FindField('BankCharge').AsFloat    := 0;
      lMain.FindField('PAYMENTAMOUNT').AsFloat := 500.00;
 
      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
      lBizObj.Close;
      Memo1.Lines.Append('Done');
  //    MessageDlg('Done', mtInformation, [mbOk], 0);
    end else
      Memo1.Lines.Append('Deposit No. Not Found');
  finally
    cdsTmp.Free;
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
====AR_DPDTL_FORFEIT====
{| class="mw-collapsible mw-collapsed wikitable"
! Customer Deposit Forfeit Script 
|-
|
<syntaxhighlight lang="delphi">
procedure TForm1.Button4Click(Sender: TObject);
var lMain, lBizApp, lBizObj : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');
 
  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);
 
    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_FORFEIT');
      lMain  := lBizObj.DataSets.Find('MainDataSet');
 
      lBizObj.New;
      lMain.FindField('DOCKEY').Value          := cdsTmp.FindField('Dockey').AsFloat;
      lMain.FindField('Account').AsString      := '532-000'; //Forfeit account
      lMain.FindField('DocDate').Value        := '28 Oct 2019';
      lMain.FindField('PostDate').Value        := '28 Oct 2019';
      lMain.FindField('Description').AsString  := 'Deposit Forfeit';
      lMain.FindField('Amount').AsFloat        := 150.00;
 
      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
      lBizObj.Close;
      Memo1.Lines.Append('Done');
  //    MessageDlg('Done', mtInformation, [mbOk], 0);
    end else
      Memo1.Lines.Append('Deposit No. Not Found');
  finally
    cdsTmp.Free;
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
==FAQ==
===Problem with opening CHM Help files?===
# Right click the chm file & select Properties
# At General tab Click Unblock button.
# Click Apply | Ok.
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Still can't open CHM file?===
# Login SQL Accounting
# Click Tools | Options
# Click Register & follow wizard
# Exit SQL Accounting
# Login SQL Accounting
# Run CHM File
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Why when I compile my program with stated unknown method or unknown identifier?===
:If you compiler had error may try add the '''esfw10.dll''' file under the SQL Accounting\bin folder
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to make sure I login to correct database?===
* Can use the '''Common.Agent.RO''' Report Objects to get the Profile info.
* Then use the cdsProfile Dataset
: - CompanyName Field
: - Remark Field
* Refer to [https://wiki.sql.com.my/wiki/SDK_Live#Get_Company_Profile Get Company Profile]
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Why after post to SQL Accounting the Description3 (More Description)/Notes field it show like this "M y  D e s c r i p t i o n" instead of "My Description"?===
:Make sure you use '''.AsString''' in your code (see example below)
{| class="mw-collapsible mw-collapsed wikitable"
! Description3 Field Script/Code 
|-
|
 
...
  lDtl.FindField('DESCRIPTION3').'''AsString'''  := 'Sales Item A More Description'+ #13 + 'I in 2nd line';
...
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Can I Ignore Doc No Field & let SQL Accounting to Auto Assign?===
:Yes but we not recommended as you will lost track when user wanted to know which Doc No in SQL Acc is posted.
: To Set Auto Assign set it as below
{| class="mw-collapsible mw-collapsed wikitable"
! DocNo Field Script/Code 
|-
|
 
...
  lMain.FindField('DocNo').'''AsString'''  := '<<New>>';
...
lDocNo := lMain.FindField('DocNo').AsString; //To Get docno after post
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Can I Auto Login & Logout SQL Accounting when doing & after Posting?===
: Yes can below is example script
: Only work if that PC is no once is using SQL Accounting
{| class="mw-collapsible mw-collapsed wikitable"
! C Sharp 
|-
|
<syntaxhighlight lang="C#">
Int32 lBuildNo;
dynamic ComServer;
public void CheckLogin()
{           
    lBizType = Type.GetTypeFromProgID("SQLAcc.BizApp");
    ComServer = Activator.CreateInstance(lBizType);
           
    if (!ComServer.IsLogin)
    {
        try
        {
            ComServer.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text);
            ComServer.Minimize();
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            FreeBiz(ComServer);
        }
    }
    if (ComServer.IsLogin)
    {
        lBuildNo = ComServer.BuildNo;
    }
}
public void FreeBiz(object AbizObj)
{
    System.Runtime.InteropServices.Marshal.ReleaseComObject(AbizObj);
}
private void btnExport_Click(object sender, EventArgs e)
{
    dynamic BizObject, lMain, lDocKey;
 
    CheckLogin();
    //'Step 2: Find and Create the Biz Objects
    BizObject = ComServer.BizObjects.Find("Agent");
 
    //Step 3: Set Dataset
    lMain = BizObject.DataSets.Find("MainDataSet");    //lMain contains master data
 
    //Step 4: Search
    lDocKey = BizObject.FindKeyByRef("CODE", edCode.Text);
    try
    {
        try
        {
            //Step 5 : Insert or Update
            if (Convert.IsDBNull(lDocKey))
            {
                BizObject.New();
                lMain.FindField("CODE").value = edCode.Text;
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
            }
            else
            {//Edit Data if found
                BizObject.Params.Find("CODE").Value = lDocKey;
                BizObject.Open();
                BizObject.Edit();
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
            }
            //Step 6: Save & Close
            BizObject.Save();
            MessageBox.Show("Done", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
    }
    finally
    {
        BizObject.Close();
 
        //Step 7 : Logout after done           
        FreeBiz(BizObject);
        ComServer.Logout();
        FreeBiz(ComServer);
    }           
}
</syntaxhighlight>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! Delphi 
|-
|
<syntaxhighlight lang="delphi">
....
  public
    { Public declarations }
    lBizApp : variant;
  end;
....
 
procedure TForm1.CheckLogin;
begin
  lBizApp := null;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
 
  if not lBizApp.IsLogin then begin
    lBizApp.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text); //Login with preset setting
    lBizApp.Minimize; //Mininise the SQLAccounting
  end;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var BizObject, lMain : Variant;
begin
  try
    //Begin Loop your data
    try
      CheckLogin;
      BizObject := lBizApp.BizObjects.Find('Agent');
      lMain    := BizObject.DataSets.Find('MainDataSet');
      BizObject.New;
      lMain.FindField('CODE').AsString := 'HALIM';
      lMain.FindField('Description').AsString := 'HALIM 123';
      BizObject.save;
    except
      on E: Exception do
        MmLog.Lines.Append(E.Message);
    end;
    //
  finally
    BizObject.close;
    BizObject := null;
    lBizApp.Logout;
    lBizApp := null;
  end;
end;
</syntaxhighlight>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! VB Script 
|-
|
<syntaxhighlight lang="vb">
'Copy below script & paste to notepad & name it as eg Agent.vbs
Call PostData
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
Function PostData
Dim ComServer, BizObject
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
 
  Set WScr = CreateObject("WScript.Shell")
  WScript.Sleep 1000 '//Wait 1 second for system loading before proceed
 
  'Step 2: Force Logout to make sure login correct database
  If ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Logout
  END IF
  'Step 3: Login
  ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0015.FDB"
 
  'Step 4: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("Agent")
  'Step 5: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
 
 
  'Step 6 : Posting
    BizObject.New
    lMain.FindField("CODE").AsString          = "_Test_"
    lMain.FindField("Description").AsString  = "Testing 123"
 
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  'Step 8: Logout
    ComServer.Logout
MsgBox "Done"
End Function
</syntaxhighlight>
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===When Post System Prompt Operation aborted Error===
: This happen when the Login User ID don't had the to '''Override Sales Min/Max Price''' &
: Use '''Last Price XXX''' (In Tools | Options | Unit Price) &
: 1 of record is below Min Price.
'''Solution'''
: Can try change the Posting Seq like below (UOM then Qty)
{| class="mw-collapsible mw-collapsed wikitable"
! Sequence Field Script/Code 
|-
|
 
...
    lDetail.Append();
    lDetail.FindField("DtlKey").value = -1;
    lDetail.FindField("DocKey").value = -1;
    lDetail.FindField("Seq").value = 3;
    lDetail.FindField("ItemCode").AsString = "ANT";
    lDetail.FindField("Description").AsString = "Sales Item B";
    //lDetail.FindField("Account").AsString = "500-000"; To override the Sales Account Code
    '''lDetail.FindField("UOM").AsString = "UNIT";'''
    '''lDetail.FindField("Qty").AsFloat = 2;'''
    //lDetail.FindField("DISC").AsString = "5%+3"; //Optional(eg 5% plus 3 Discount)
    lDetail.FindField("Tax").AsString = "SR";
    lDetail.FindField("TaxRate").AsString = "6%";
    lDetail.FindField("TaxInclusive").value = 0;
    lDetail.FindField("UnitPrice").AsFloat = 100;
    lDetail.FindField("Amount").AsFloat = 200;
    lDetail.FindField("TaxAmt").AsFloat = 12;
    lDetail.Post();
...
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
===How do my system know there is a changes or update in SQLAccounting?===
'''Data Entry'''<br>
: In all Document it had a field call <span style="color:#0000ff">UPDATECOUNT</span>.
: Default is null & each changes will +1.
: So if you see 2 meaning it had being update 2 times
 
'''Master Data'''
: Only available in
:* Version 842.765 & above
:* AP_SUPPLIER (Maintain Supplier)
:* AR_CUSTOMER (Maintain Customer)
:* ST_GROUP (Maintain Stock Group)
:* ST_ITEM (Maintain Stock Item)
:* ST_ITEM_TPL (Maintain Item Template)
:* ST_PRICETAG (Maintain Price Tag)
:* TAX (Maintain Tax)
: In Each table it had a field call <span style="color:#0000ff">LASTMODIFIED</span>.
: The value is '''Epoch Time''' or '''Unix Time'''
 
You can use below function to get the field
{| class="mw-collapsible mw-collapsed wikitable"
! vbs 
|-
|
<syntaxhighlight lang="vbs">
...
Function GetData
Dim lDataSet, lSQL
  lSQL = "SELECT DOCNO, UPDATECOUNT FROM SL_CS "
  lSQL = lSQL & "WHERE UPDATECOUNT IS NOT NULL "
  lSQL = lSQL & "ORDER BY DOCNO "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocNo : " & lDataSet.FindField("DocNo").AsString
    MsgBox "UpdateCount : " & lDataSet.FindField("UPDATECOUNT").AsString
    lDataSet.Next
  Wend
End Function
...
</syntaxhighlight>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! Delphi
|-
|
<syntaxhighlight lang="delphi">
... 
procedure TfmMain.dxbb_GetFieldClick(Sender: TObject);
var BizApp : Variant;
    lDataSet : TClientDataSet;
    ASQL : String;
begin
  BizApp := CreateOleObject('SQLAcc.BizApp');
  lDataSet := TClientDataSet.Create(Self);
  try
    ASQL := 'SELECT DOCNO, UPDATECOUNT FROM SL_CS ' +
            'WHERE UPDATECOUNT IS NOT NULL ' +
            'ORDER BY DOCNO ';
    lDataSet.Data := BizApp.DBManager.Execute(ASQL);
    lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet.Free;
  end;
end;
...
</syntaxhighlight>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
===Can I control my Stock when I link with other Application?===
: Yes. We suggest to use Stock Transfer to (eg Location call <span style="color:#0000ff">MOBILE</span>) transfer stock as Reserve to avoid stock over deduct in SQL Accounting
: When other Application post to SQL Accounting they just need set the Location to the Reserve Location (eg <span style="color:#0000ff">MOBILE</span>)
: Below is example posting with location
{| class="mw-collapsible mw-collapsed wikitable"
! Post Location Field Script/Code 
|-
|
 
...
  lDtl.FindField('UOM').AsString      := 'CTN';
  lDtl.FindField('QTY').AsFloat        := 6;
  lDtl.FindField('Location').AsString  := 'MOBILE';
...
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Where to Check the SQL Accounting DCF Path, FileName & FDB FileName?===
: In Login Screen Click 3 Dot Button then you can see the information
: For SQL Accounting Version 5.2023.957.831 and below
[[File:SDK-FAQ-01.jpg|center]]
: For SQL Accounting Version 5.2023.958.832 and above
[[File:SDK-FAQ-03.jpg|800px|center]]
[[File:SDK-FAQ-02.jpg|554px|center]]
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to check & What is the value for Advance Credit Control in Maintain Customer===
: You can use <span style="color:#0000ff">ComServer.DBManager.NewDataSet(lSQL)</span> function to Query the information
: lSQL = SELECT * FROM AR_CUSTOMERCRCTRL
: You may refer to <span style="color:#0000ff">ControlType</span> column
 
{| class="wikitable" style="margin: 1em auto 1em auto;"
|-
! ControlType !! Exceed Credit Limit !! Exceed OverDue Limit
|-
| align="center" | 0 || UnBlock || UnBlock
|-
| align="center" | 1 || UnBlock || Block
|-
| align="center" | 2|| UnBlock || Override
|-
| align="center" |  3|| Block || UnBlock
|-
| align="center" | 4|| Block || Block
|-
| align="center" | 5|| Block || Override
|-
| align="center" | 6|| Override || UnBlock
|-
| align="center" | 7|| Override || Block
|-
| align="center" | 8|| Override || Override
|-
| align="center" | 9|| align="center" colspan="2"| Suspended
|}
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to get Error/Exception Message Return from SQL Accounting?===
{| class="mw-collapsible mw-collapsed wikitable"
! C Sharp 
|-
|
<syntaxhighlight lang="C#">
try
{
  BizObject.New();
....
  BizObject.Save();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
</syntaxhighlight>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! Python 
|-
|
    try:
        BizObject.Save()         
    except Exception as e:
        print("Oops!", e) 
 
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! VB.Net 
|-
|
<syntaxhighlight lang="vb">
Try
   BizObject.[New]
...
   BizObject.Save
Catch ex As Exception
Catch ex As Exception
   MsgBox(ex.Message, MsgBoxStyle.Exclamation)
   MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Try
</syntaxhighlight>
</syntaxhighlight>
|}
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! Delphi
|-
|
<syntaxhighlight lang="delphi">
try
  lBizObj.New;
....
  lBizObj.Save;
except
  on E: Exception do
    Memo1.Lines.Text := E.Message;
end;
</syntaxhighlight>
|}
 
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Why Post to SQL Accounting sometime prompt Catastrophic failure Error?===
'''Possible Problem 1'''
: Make sure you code don't cross over Call action during posting
: Eg Posing SL_SO Header partly then suddenly call other object example Check Customer Code Validity
: Summary action (Correct Steps)
::01. Do Verify 1st (eg Check Customer Code Validity & etc)
::02. Post Transactions
 
'''Possible Problem 2'''
:Keep Login & Logout till windows not enough time to response
: Summary action (Correct Steps)
::01. Pull Data from Your application/web
::02. Login SQL Accounting 1 time (Auto Login)
::03. Do all your requirement actions (eg. verify, query & posting)
<pre>
    eg Posting Cash Sales & Customer Payment
begin looping
  BizObject = ComServer.BizObjects.Find("SL_CS")
  ....
  BizObject.Save
  BizObject.Close
  FreeBiz(BizObject)
 
  BizObject = ComServer.BizObjects.Find("AR_PM")
  ....
  BizObject.Save
  BizObject.Close
  FreeBiz(BizObject)
 
  Next Record
End looping
</pre>
::04. Logout SQL Accounting 1 time (Auto Logout)
::05. Push Data to Your application/web (if any)
 
'''Possible Problem 3'''
: Company Profile Logo format had problem.
: Solution
::01. Click File | Company Profile
::02. Export out the Logo by right Click the Company Logo
::03. Open the Exported Logo with Photo Editor
::04. Just Click File | Save again as jpg.
::05. Load Back the Save Logo by right Click the Company Logo
::06. Click Save
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to Get the GL Account List for Sales & Purchase?===
: You can use the function <span style="color:#0000ff">ComServer.DBManager.NewDataSet(lSQL)</span> with the following SQL
<pre>
SELECT  Code, Description, Description2 FROM GL_ACC A
WHERE (A.Parent<>-1
AND NOT (EXISTS (SELECT Parent FROM GL_ACC B
                WHERE A.DocKey=B.Parent))
AND (A.SpecialAccType IS NULL OR A.SpecialAccType IN ('', 'AD')))
ORDER BY Code
</pre>
<div style="float: right;">  [[#top|[top]]]</div>
 
===Can I setup a testing/Staging environment for SQL Accounting?===
:Yes can, you can self setup or we can help you to setup.
:There are 4 types of Testing/Staging
:01. Install the Testing SQL Accounting version & Testing Database in the developer PC
:02. Install the Live SQL Accounting version & User Backup Database in the developer PC
::- Require User Permission for Backup
:03. Setup at User PC/Server & using User Backup Database
::- Require User Permission for Backup & PC/Server setup
:04. Setup at User PC/Server & using Testing Database
::- Require User Permission for PC/Server setup
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to Loop & post SQL Accounting?===
:Below summary how to loop
:01. Call ComServer
:02. Check Login
:03. Call BizObject (eg SL_CS)
:04. Begin Loop you data
:05. Call Close BizObject (eg BizObject.Close)
:06. Continue Call other BizObject (eg AR_PM)
:07. Repeat Steps 4 & 5
:08. Call Logout
:09. Free ComServer
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to post Description3 with Unicode?===
:You have to convert it to rtf format before set to Description3 field
 
{| class="mw-collapsible mw-collapsed wikitable"
! C Sharp 
|-
|
<pre>
private static string FormatAsRTF(string DirtyText)
{
    System.Windows.Forms.RichTextBox rtf = new System.Windows.Forms.RichTextBox();
    rtf.Text = DirtyText;
    return rtf.Rtf;
}
 
....
lDtl.FindField("DESCRIPTION3").AsString  = FormatAsRTF("ANTENNA ???");
...
</pre>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! VB.Net 
|-
|
<pre>
Private Shared Function FormatAsRTF(ByVal DirtyText As String) As String
    Dim rtf As System.Windows.Forms.RichTextBox = New System.Windows.Forms.RichTextBox()
    rtf.Text = DirtyText
    Return rtf.Rtf
End Function
 
....
lDtl.FindField("DESCRIPTION3").AsString  = FormatAsRTF("ANTENNA ???")
...
</pre>
|}
 
{| class="mw-collapsible mw-collapsed wikitable"
! Delphi
|-
|
<pre>
function TfmMain.PlainTxtToRTF(const AValue:String):String;
var R:TRichEdit;
    M : TStringStream;
begin
  R := TRichEdit.CreateParented(HWND_MESSAGE);
  M := TStringStream.Create('');
  try
    R.WordWrap := False;
    R.Lines.Add(AValue);
    R.Lines.SaveToStream(M);
    Result := M.DataString;
  finally
    R.Free;
    M.Free;
  end;
end;
 
....
lDtl.FindField('DESCRIPTION3').AsString  := PlainTxtToRTF('ANTENNA ???');
...
</pre>
|}
 
:or Can use our build in Utility function (only available from 5.2022.941.822 & above)
<pre>
....
lDtl.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("ANTENNA ??? ??")
...
</pre>
 
{| class="mw-collapsible mw-collapsed wikitable"
! PHP 
|-
|
<pre>
<!DOCTYPE html>
<html>
<body>
 
<h1>SQL Acc SDK in PHP page</h1>
 
<?php
echo "Updated 14 Sep 2022<br>";
#This action to show & post Description3 with unicode
 
$ComServer = null;
 
function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();
 
    if ($status == true)
    {
        #$ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
   
}
 
function GetData(){
    global $ComServer;
    $lSQL = "SELECT Description3 FROM ST_ITEM
    WHERE Code='ANT' ";
    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);
 
    if ($lDataSet->RecordCount > 0) {
$lDataSet->First();
$rtf = $lDataSet->FindField('Description3')->AsString();
        echo $rtf;
echo "<br>== <br>";
echo "<br>Result after RTF: <br>";
$txt = $ComServer->Utility->RichTextToPlainText($rtf);
echo "<TEXTAREA rows=10 cols=80 id='edResult1' >".$txt. "</TEXTAREA>";
echo "<br>== <br>";
echo "??? ??";
}else {
    echo "Record Not Found";
    }
}
 
function PostData(){
global $ComServer;
$BizObject = $ComServer->BizObjects->Find("ST_AJ");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail");
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "<<New>>";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Adjustment";
    #Insert Data - Detail - Increase Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
    #Insert Data - Detail - Reduce Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER  ???";
$lDetail->FindField("Description3")->AsString = $ComServer->Utility->PlainTextToRichText("NOKIA CHARGER ??? ??");
    $lDetail->FindField("Qty")->AsFloat = -5;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
    $BizObject->Save();
    $BizObject->Close();
try{
        $BizObject->Save();
        $BizObject->Close();
}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}
 
if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
echo "<br>";
        echo date("d M Y h:i:s A")." - Done";
PostData();
echo "<br>";
        echo date("d M Y h:i:s A")." - Done ST_AJ";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}
 
?>
    <form method="post">         
        <input type="submit" name="BtnData"
                value="Get RTF n Post RTF"/>
    </form>
</body>
</html>
</pre>
|}
<div style="float: right;">  [[#top|[top]]]</div>
 
==See also==
* [[SQL Accounting Linking]]
* [[SQL XML Import]]
* [[SQL Text Import]]
* [[SQL Acc XLS n MDB Import]]
* Others [[Customisation]]


{| class="mw-collapsible mw-collapsed wikitable"
* <big>Need assistance? May email to '''support@sql.com.my'''</big>
! Delphi
|-
|
<syntaxhighlight lang="delphi">
try
  lBizObj.New;
....
  lBizObj.Save;
except
  on E: Exception do
    Memo1.Lines.Text := E.Message;
end;
</syntaxhighlight>
|}
 
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===Why Post to SQL Accounting sometime prompt Catastrophic failure Error?===
'''Possible Problem 1'''
: Make sure you code don't cross over Call action during posting
: Eg Posing SL_SO Header partly then suddenly call other object example Check Customer Code Validity
: Summary action (Correct Steps)
::01. Do Verify 1st (eg Check Customer Code Validity & etc)
::02. Post Transactions
 
'''Possible Problem 2'''
: Company Profile Logo format had problem.
: Solution
::01. Click File | Company Profile
::02. Export out the Logo by right Click the Company Logo
::03. Open the Exported Logo with Photo Editor
::04. Just Click File | Save again as jpg.
::05. Load Back the Save Logo by right Click the Company Logo
::06. Click Save
 
<div style="float: right;">  [[#top|[top]]]</div>
 
===How to Get the GL Account List for Sales & Purchase?===
: You can use the function <span style="color:#0000ff">ComServer.DBManager.NewDataSet(lSQL)</span> with the following SQL
<pre>
SELECT  Code, Description, Description2 FROM GL_ACC A
WHERE (A.Parent<>-1
AND NOT (EXISTS (SELECT Parent FROM GL_ACC B
                WHERE A.DocKey=B.Parent))
AND (A.SpecialAccType IS NULL OR A.SpecialAccType IN ('', 'AD')))
ORDER BY Code
</pre>
<div style="float: right;">  [[#top|[top]]]</div>
 
==See also==
* [[SQL Accounting Linking]]
* [[SQL XML Import]]
* [[SQL Text Import]]
* [[SQL Acc XLS n MDB Import]]
* Others [[Customisation]]

Latest revision as of 08:44, 19 February 2024

Introduction

This is the "Bridge" direct live linking between External Program with SQL Accounting

Pros

  1. Can Live or Batch Update.
  2. Can do action such as New, Edit & Delete.
  3. About 95% of modules is covered.
  4. Can direct Retrieve/Get Information From Connected Database.
  5. Able to do Automation (i.e. auto login & update data).
  6. Support GST & SST.
  7. Free of Charge (Freeware) for End User on SDK Linking.

Cons

  1. Must had programming knowledge.
  2. Must had SQL Accounting installed & running.
  3. Must self do checking else error prompt will unable to “capture”.
  4. Only supported in IE for JScript

Requirement

  • Microsoft Windows 8.1 and above (recommended with 64 bits windows)
  • Intel i5, i7 and above computer.
  • 8 GB of RAM (recommended 12 GB and above).
  • Firebird (For Automatic Login & Logout Only)
  • SQL Accounting
  • Windows Scheduler (For Automatic Login & Logout Only)

Documentation

Linking Flow

  • Highlight in Yellow Color is the Windows base Application/Function you need to Develop/Create.

Example 1 - POS System

LinkFlow-Example01.jpg

Example 2 - Cloud/Mobile System

LinkFlow-Example02.jpg
  • The SDK can be build in in your system or a Standalone windows Application(Middle Application).
  • If you build in your system then it can be sync anytime either by a special interface with parameter (eg Date From, Date To & etc) or each transaction after post(not recommended)
  • If you create a Standalone windows Application(Middle Application) you can make use the Windows Schedule to sync or call from you system to execute/run the Standalone windows Application(Middle Application).

Steps

CHM File

  1. Install SQL Accounting Click here
  2. Create Sample Data
  3. Login (username & password is Admin)
  4. Double click the SQLSDK.chm file
  5. Click Application Object | Business Objects
  6. Click the word "here"
  7. Click Yes
  8. In the list Look for (example)
- AR_IV -> Customer Invoice
- AR_CN -> Customer Credit Note
- AP_PI -> Supplier Invoice
- SL_IV -> Sales Invoice
- PH_PI -> Purchase Invoice
- ST_AJ -> Stock Adjustment

External Application Linking

  1. Login SQL Accounting
  2. Login External Application
  3. Click Post to SQL Accounting button or Click Save button from External Application.
----------------------------------------------------------------------------------------------------------------------------------------------------
Template.Tips-01.jpg
Can try start with Add Agent under the SDK file to make sure you
Application can communicate with SQL Accounting
----------------------------------------------------------------------------------------------------------------------------------------------------

Available Programming Language

Example External Program

VB. Net

C Sharp

Steps (C Sharp & VB.Net Only)

The example video is how to

01. Open DCF in D:\Happy\DB\Default.DCF
02. Datatabase is ACC-0008.FDB
03. Click Complete Post button
04. Where to check in SQL accounting after Post (Steps-2.gif)

Available Function

- Complete Post - SL_CS, SL_CN, AR_PM, AR_CN & AR_CF
- Batch Post - Cash Sales - SL_CS
- Batch Post...2 DB
- Batch Post...2 DCF
- Add Stock Assembly with Override Raw Materials - ST_AS
- Add Stock Job Order to Stock Assembly with Override Raw Materials - PD_JO & ST_AS
- Add Agent - Agent
- Get Agent Description
- Add Journal Voucher - Add GL JE
- Edit GL Journal Voucher - Edit GL_JE
- Edit Sales Cash Sales - SL_CS
- Delete Cash Sales - Del SL CS - SL_CS
- Customer Aging - Customer.Aging.RO
- Get Sales Invoice Listing - Sales.IV.RO
- Stock Item List
- Add SKU with Edit SKU - ST_ITEM
- Del SKU - ST_ITEM
- Get DCF Database List
- Month End - FIFO
- Month End - WA (Weighted Average)
- Get Options...(Perform Tax / Local Amount Rounding, 5 Cents Rounding (Sales Invoice) & 5 Cents Rounding (Cash Sales)
- Get Next Invoice No.
- Is Valid ST_Item
- Is Valid GL_Acc
- Outstanding SO - Sales.OutstandingSO.RO
- Read RTF n Picture Data...
- Get Customer List - AR_Customer
- Add Customer with Edit Customer - AR_Customer
- Del Customer - AR_Customer
- Add GL Payment Voucher - Add GL_PV
- Transfer Document - DO to SL_IV
- Get Transfer Info. 1 - At Invoice Find DO Number & Date
- Get Transfer Info. 2 - At DO Find Invoice Number & Date
- GL Ledger
- Add Stock Transfer - Add ST XF
- Add Stock Adjustment - Add ST AJ
- Get Serial Number Balance - Serial No. Bal.
- Add Customer Deposit - Deposit
- Transfer Customer Deposit to Payment - Deposit to PM
- Refund Deposit - Deposit Refund
- Forfeit Deposit - Deposit Forfeit
- Enable Support DocNo Format with Month & Year Format
- Add AR IV
- Add AR CN
- Add AR PM Bounce Chq
- Add GL Ledger RO
- AR Statement
- Add Add/Edit AR PM
- Add LogInOut (For Testing purpose)

History - C Sharp & VB.Net

19 Aug 2023...
- Add Add/Edit AR PM
- Add LogInOut (For Testing purpose)
14 Jun 2022
- Add AR Statement
- Fix Error when click 2nd time for Report.
27 Apr 2022
- Add/Edit Location
- Rename Caption for Add Customer to Add/Edit Cust
- Rename Caption for Add Agent to Add/Edit Agent
- Add Reconnect
- Add/Edit ST_Batch
- Fix bug on KillApp should Sleep 2 seconds after run the KillApp
18 Mar 2021
- Enable Support DocNo Format with Month & Year Format
- Add AR IV
- Add AR CN
- Add AR PM Bounce Chq
- Add GL Ledger RO
22 May 2020
- Fix Complete Post Action cause SQLAcc still not exit after logout
- Add/Edit Customer Contra
28 Mar 2020
- SL DO to SL IV button - Check Transfer Status should excluded Cancelled
- Add Get Transfer Info. 1 - At Invoice Find DO Number & Date
- Add Get Transfer Info. 2 - At DO Find Invoice Number & Date
04 Mar 2020
- Add Post with Serial Number for Complete Post
- Fix Posting Seq Error on Complete Post
- Add GL JE
- Add GL_PV
- Add Additional Note for Outstanding SO button
05 Feb 2020
- Add Customer Deposit
- Add Customer Deposit to PM
- Add Customer Deposit Refund
- Add Customer Deposit Forfeit
- Add SL DO to SL IV
- Add 12 Months Aging Parameter for Customer.Aging.RO
- Add Add ST AJ - Stock Adjustment
- Add Add ST XF - Stock Transfer
22 Oct 2019
- Add GL Ledger function
- Add Cust. IV Listing function
- Add Serial No. Bal function
- Fixed Error on Auto Logout Error when using ComServer.DBManager.NewDataSet(lSQL)
23 Aug 2019
- Add Del SKU function
- Add Customer List... function
- Add Add Customer function
- Add Del Customer function
- Add Del SL CS function
31 Jul 2019
- Add Read RTF n Picture Data... function.
10 Jul 2019
- Fixed KillApp function not working in some situation.
11 Jun 2019
- Fixed Auto Logout Prompt Error.
- Fixed SQLAcc not Fully Exit when Call Auto Logout.
- Fixed Batch Post 2 DB error for CSharp
06 Jun 2019
- Fixed unable to Update Stock Item for Add SKU.
- Add Update UOM for Add SKU.
- Add C Sharp Coding
23 May 2019
- Update Complete Post - Add Description3 (More Description)
- Fixed Batch Post.. keep login when looping
- Add Get Outstanding SO - Sales.OutstandingSO.RO
05 May 2019
- Add Condition for Stock Item List only filter if edCode is not empty
- Add Prompt Message If Login Fail
- Add SQLAcc Build No Condition for Get Sales Invoice Listing to support version 776 & above
- Add SKU - ST_ITEM



ASP.Net C Sharp

01. Make sure Enabled the following function in IIS Manager - Sites - YourSiteName - Authentication

- Anonymous Authentication
- ASP.Net Impersonation (Make sure set Specific user (Windows Login User & Password))

02 Make sure the Windows user set in ASP.Net Impersonation is Login

Available Function

- Get Agent Description
- New & Update Customer/Supplier Info.
- Edit Cash Sales
- Edit Purchase Invoice
- Complete Post
- GL PV
- Add Add/Edit Agent
- Add Add/Edit Terms
- Add Add/Edit ST Item
- Delete Cash Sales
- Add SL SO

History

16 Aug 2021
- Add SL SO
19 Feb 2021
- Delete Cash Sales
16 Sep 2020
- Add Add/Edit ST Item
- Fix some comment note error
23 Jun 2020
- Add Add/Edit Agent
- Add Add/Edit Terms
22 May 2020
- Add Edit Purchase Invoice
- Add Complete Post
- Add GL PV
06 Dec 2019
- Add Edit Cash Sales
- Enable Run Time Set User Name, Password, DCF & FDB


Python

Module Require in Python
- pypiwin32 (Mandatory) -> pip install pypiwin32
- Pillow (Optional for Picture) -> pip install Pillow

Common

  • Common.py file for example code
Common Function
#Updated 03 Oct 2023
import win32com.client
import Common
import os
from time import sleep

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def KillApp():
    os.system('cmd /c "taskkill /IM "SQLACC.exe" /F"')
    sleep(2) #sleep 2 sec


def CheckLogin():
    global ComServer
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
        KillApp()
 
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    try:    
        ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                        "D:\\Happy\\DB\\Default.DCF",
                        #"C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                        "ACC-0015.FDB") #Database Name
    except Exception as e:
        print("Oops !", e)


def ShowResult(ADataset):
    if ADataset.RecordCount > 0:
        while not ADataset.eof:
            fc = ADataset.Fields.Count
            for x in range(fc):
                fn = ADataset.Fields.Items(x).FieldName
                fv = ADataset.FindField(fn).AsString
                lresult = "Index : "+ str(x) + " FieldName : " + fn + " Value : " + fv
                print (lresult)
            print("====")
            ADataset.Next()
    else:
        print ("Record Not Found")
        
        
def QuotedStr(ACode):
    return "'" + ACode.replace("'", "''") + "'"

Agent

Agent Script
#Updated 22 Jul 2023
import Common
       
def GetListData():
    lSQL = "SELECT * FROM AGENT "
    lSQL = lSQL + "WHERE ISACTIVE='T' "
    lSQL = lSQL + "ORDER BY CODE "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("Agent")
    lMain = BizObject.DataSets.Find("MainDataSet")    
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("CODE").value = "FAIRY"
        lMain.FindField("DESCRIPTION").value = "FAIRY TAIL"

    else:
        BizObject.Params.Find("Code").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.FindField("DESCRIPTION").value = "FAIRY TAIL WIZARD"
            
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("Agent")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")

    ComServer.Logout()
finally:
    ComServer = None
    Common.KillApp()

Get Company Profile

Get Company Profile
#Updated 22 Jul 2023
import Common

def GetData():
    lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, "
    lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, "
    lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    Common.ShowResult(lDataSet)
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer       
    GetData()
    ComServer.Logout()
finally:
    ComServer = None
    Common.KillApp()

Complete Post

SL_CS, AR_PM, SL_CN & AR_CN Script
#Updated 19 Jul 2023
#This will doing following posting
#01. Cash Sales
#02. Sales Credit Note
#03. Customer Payment With Knock off
#04. Edit Credit Note Posted in Step 02 & Knock Off
#05. Customer Refund to Knock off Credit Note
import Common
import datetime

def PostDataCS():    
    BizObject = ComServer.BizObjects.Find("SL_CS")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    BizObject.New();
    lMain.FindField("DocNo").AsString = "--IV Test--"
    lMain.FindField("DocDate").value = lDate
    lMain.FindField("PostDate").value = lDate
    lMain.FindField("Code").AsString = "300-C0001" #Customer Account
    lMain.FindField("CompanyName").AsString = "Cash Sales"
    lMain.FindField("Address1").AsString = "" #Optional
    lMain.FindField("Address2").AsString = "" #Optional
    lMain.FindField("Address3").AsString = "" #Optional
    lMain.FindField("Address4").AsString = "" #Optional
    lMain.FindField("Phone1").AsString = ""   #Optional
    lMain.FindField("Description").AsString = "Sales"

    #Insert Data - Detail
    #For Tax Inclusive = True with override Tax Amount
    lDetail.Append()
    lDetail.FindField("Seq").value = 1
    lDetail.FindField("Account").AsString = "500-000" #Sales Account
    lDetail.FindField("Description").AsString = "Sales Item A"
    lDetail.FindField("Description3").AsString = ("Item A Line 1" + ("\r" + "Item A Line 2"))
    lDetail.FindField("Qty").AsFloat = 1
    lDetail.FindField("Tax").AsString = "SV"
    lDetail.FindField("TaxRate").AsString = "6%"
    lDetail.FindField("TaxInclusive").value = 0
    lDetail.FindField("UnitPrice").AsFloat = 435
    lDetail.FindField("Amount").AsFloat = 410.37 #Exclding GST Amt
    lDetail.FindField("TaxAmt").AsFloat = 24.63

    lDetail.DisableControls()
    lDetail.FindField("TaxInclusive").value = 1
    lDetail.EnableControls()
    
    lDetail.Post()

    #For Tax Inclusive = False with override Tax Amount
    lDetail.Append()
    lDetail.FindField("Seq").value = 2
    lDetail.FindField("Account").AsString = "500-000"
    lDetail.FindField("Description").AsString = "Sales Item B"
    lDetail.FindField("Qty").AsFloat = 1
    lDetail.FindField("Tax").AsString = "SV"
    lDetail.FindField("TaxRate").AsString = "6%"
    lDetail.FindField("TaxInclusive").value = 0
    lDetail.FindField("UnitPrice").AsFloat = 94.43
    lDetail.FindField("Amount").AsFloat = 94.43
    lDetail.FindField("TaxAmt").AsFloat = 5.66
    lDetail.Post()
    
    #For With Item Code
    lDetail.Append()
    lDetail.FindField("Seq").value = 3
    lDetail.FindField("ItemCode").AsString = "ANT"
    lDetail.FindField("Description").AsString = "Sales Item B"
    #lDetail.FindField("Account").AsString     = "500-000" #If you wanted override the Sales Account Code
    lDetail.FindField("Qty").AsFloat = 2
    lDetail.FindField("UOM").AsString = "UNIT"
    #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
    lDetail.FindField("Tax").AsString = "SV"
    lDetail.FindField("TaxRate").AsString = "6%"
    lDetail.FindField("TaxInclusive").value = 0
    lDetail.FindField("UnitPrice").AsFloat = 100
    lDetail.FindField("Amount").AsFloat = 200
    lDetail.FindField("TaxAmt").AsFloat = 12
    lDetail.Post()    
    
    BizObject.Save()
    BizObject.Close()

def PostDataPM():       
    BizObject = ComServer.BizObjects.Find("AR_PM")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    BizObject.New()
    lMain.FindField("DocNo").AsString = "--PM Test--"
    lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
    lMain.FindField("DocDate").Value = lDate
    lMain.FindField("PostDate").Value = lDate
    lMain.FindField("Description").AsString = "Payment for A/c"
    lMain.FindField("PaymentMethod").AsString = "320-000" #Bank or Cash Account
    lMain.FindField("ChequeNumber").AsString = ""
    lMain.FindField("BankCharge").AsFloat = 0
    lMain.FindField("DocAmt").AsFloat = 200.00
    lMain.FindField("Cancelled").AsString = "F"    
    
    #Knock Off IV  
    V = ["IV", "--IV Test--"]  #DocType, DocNo
    
    if (lDetail.Locate("DocType;DocNo", V, False, False)) :
        lDetail.Edit()
        lDetail.FindField("KOAmt").AsFloat = 147.09 #Partial Knock off
        lDetail.FindField("KnockOff").AsString = "T"
        lDetail.Post()
        
    BizObject.Save()
    BizObject.Close()
    
def PostDataCN():   
    BizObject = ComServer.BizObjects.Find("SL_CN")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    BizObject.New()
    lMain.FindField("DocNo").AsString = "--CN Test--"
    lMain.FindField("DocDate").value = lDate
    lMain.FindField("PostDate").value = lDate
    lMain.FindField("Code").AsString = "300-C0001"
    lMain.FindField("CompanyName").AsString = "Cash Sales"
    lMain.FindField("Address1").AsString = ""
    lMain.FindField("Address2").AsString = ""
    lMain.FindField("Address3").AsString = ""
    lMain.FindField("Address4").AsString = ""
    lMain.FindField("Phone1").AsString = ""
    lMain.FindField("Description").AsString = "Sales Returned"

    #For With Item Code
    lDetail.Append()
    lDetail.FindField("ItemCode").AsString = "ANT"
    lDetail.FindField("Description").AsString = "Sales Item B"
    lDetail.FindField("Description2").AsString = "Product Spoil" #Reason
    lDetail.FindField("Remark1").AsString = "--IV Test--"   #Invoice No
    lDetail.FindField("Remark2").AsString = "01 Jan 2017"   #Invoice Date
    lDetail.FindField("Qty").AsFloat = 1
    lDetail.FindField("Tax").AsString = "SV"
    lDetail.FindField("TaxRate").AsString = "6%"
    lDetail.FindField("TaxInclusive").value = 0
    lDetail.FindField("UnitPrice").AsFloat = 100
    lDetail.FindField("Amount").AsFloat = 100
    lDetail.FindField("TaxAmt").AsFloat = 6
    lDetail.Post()

    #Save Document
    BizObject.Save()
    BizObject.Close()    
    
def PostKnockIVCN():
    BizObject = ComServer.BizObjects.Find("AR_CN")
    lMain = BizObject.DataSets.Find("MainDataSet")
    lDetail = BizObject.DataSets.Find("cdsKnockOff")
    
    #Find CN Number
    lDocNo = "--CN Test--"
    lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
    BizObject.Params.Find("DocKey").Value = lDocKey
    
    if lDocKey is not None:
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        
        #Knock Off IV        
        V = ["IV", "--IV Test--"]  #DocType, DocNo
        
        if (lDetail.Locate("DocType;DocNo", V, False, False)) :
            lDetail.Edit()
            lDetail.FindField("KOAmt").AsFloat = 100 #Partial Knock off
            lDetail.FindField("KnockOff").AsString = "T"
            lDetail.Post()
        
    BizObject.Save()
    BizObject.Close()        

def PostDataCF():       
    BizObject = ComServer.BizObjects.Find("AR_CF")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    BizObject.New()
    lMain.FindField("DocNo").AsString = "--CF Test--"
    lMain.FindField("CODE").AsString = "300-C0001" #Customer Account
    lMain.FindField("DocDate").Value = lDate
    lMain.FindField("PostDate").Value = lDate
    lMain.FindField("Description").AsString = "Payment for A/c"
    lMain.FindField("PaymentMethod").AsString = "320-000" #Bank or Cash Account
    lMain.FindField("ChequeNumber").AsString = ""
    lMain.FindField("BankCharge").AsFloat = 0
    lMain.FindField("DocAmt").AsFloat = 6
    lMain.FindField("Cancelled").AsString = "F"    
    
    #Knock Off Credit Note  
    V = ["CN", "--CN Test--"]  #DocType, DocNo
    
    if (lDetail.Locate("DocType;DocNo", V, False, False)) :
        lDetail.Edit()
        lDetail.FindField("KOAmt").AsFloat = 4 #Partial Knock off
        lDetail.FindField("KnockOff").AsString = "T"
        lDetail.Post()
        
    BizObject.Save()
    BizObject.Close()

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    print ("Posting Cash Sales")
    PostDataCS()
    print ("Posting Payment")
    PostDataPM()
    print ("Posting Sales CN")
    PostDataCN()
    print ("Posting Knock Off CN")
    PostKnockIVCN()
    print ("Posting Customer Refund")
    PostDataCF()
    print ("Done")
    ComServer.Logout()
finally:
    ComServer = None
    Common.KillApp()

Get Picture & Description3(Rich Text)

Get Picture & Description3(Rich Text) Script
#Updated 02 Aug 2023
import os, sys
import Common
from io import BytesIO
from PIL import Image

def GetData():
    lSQL = "SELECT Description3, Picture FROM ST_ITEM "
    lSQL = lSQL + "WHERE Code='ANT' "
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)

    imgdata = BytesIO(lDataSet.FindField('Picture').Value)
    dt = Image.open(imgdata)
    dt.save("test.jpg")
    print ("Done Export Picture file...")
    #print (lDataSet.FindField('Picture').Value)
    
    rtf = lDataSet.FindField('Description3').AsString
    print (rtf)
    
    with open('out.rtf', 'w') as output:
        output.write(rtf)
        output.close()
    print ("Done Export RTF file...")
    
    txt = ComServer.Utility.RichTextToPlainText(rtf)
    print (txt)
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer    
    GetData()
    ComServer.Logout()
finally:    
    ComServer = None
    Common.KillApp()

Get Invoice Next Number

Get Invoice Next Number Script
#Updated 19 Jul 2023
import Common

def GetData():
    lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A "
    lSQL = lSQL + "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) "
    lSQL = lSQL + "WHERE A.DOCTYPE='IV' "
    lSQL = lSQL + "AND A.DESCRIPTION='Customer Invoice' "
    lSQL = lSQL + "AND A.STATESET=1 "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    fmt = lDataSet.FindField('Format').AsString
    NextNo = lDataSet.FindField('NEXTNUMBER').AsFloat
    print (fmt % NextNo)
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer       
    GetData()
    ComServer.Logout()
finally:
    ComServer = None
    Common.KillApp()

Stock Item

Stock Item Script
#Updated 21 Dec 2023
import Common
       
def GetListData():
    lSQL = "SELECT A.*, B.UOM, B.RATE, B.REFCOST, B.REFPRICE, B.ISBASE FROM ST_ITEM A "
    lSQL = lSQL + "INNER JOIN ST_ITEM_UOM B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.ISACTIVE='T' "
    lSQL = lSQL + "ORDER BY A.CODE, B.RATE" 
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("ST_ITEM")
    lMain = BizObject.DataSets.Find("MainDataSet")
    lDtl = BizObject.DataSets.Find("cdsUOM")
    LBar = BizObject.DataSets.Find("cdsBarcode")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("CODE").value = "FAIRY"
        lMain.FindField("DESCRIPTION").value = "FAIRY TAIL"
        lMain.FindField("STOCKGROUP").value = "DEFAULT";
        lMain.FindField("STOCKCONTROL").value = "T";
        lMain.FindField("ISACTIVE").value = "T";

        lDtl.Edit() #For 1St UOM
        lDtl.FindField("UOM").AsString = "PCS"
        lDtl.FindField("Rate").AsFloat = 1
        lDtl.FindField("RefCost").AsFloat = 10.2
        lDtl.FindField("RefPrice").AsFloat = 25
        lDtl.Post()

        lDtl.Append() #For 2nd UOM
        lDtl.FindField("UOM").AsString = "CTN"
        lDtl.FindField("Rate").AsFloat = 12
        lDtl.FindField("RefCost").AsFloat = 102
        lDtl.FindField("RefPrice").AsFloat = 240
        lDtl.Post()
        
        LBar.Append() #For 1St UOM Barcode
        LBar.FindField("Barcode").AsString = "123456"
        LBar.FindField("UOM").AsString = "PCS"
        LBar.Post()

        LBar.Append() #For 2nd UOM Barcode
        LBar.FindField("Barcode").AsString = "7890123"
        LBar.FindField("UOM").AsString = "CTN"
        LBar.Post()
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.FindField("DESCRIPTION").value = "FAIRY TAIL WIZARD"
        
        while lDtl.RecordCount > 0:
            lDtl.First()
            lDtl.Delete()

        #Insert back with new Price
        lDtl.Append() #For 1St UOM
        lDtl.FindField("UOM").AsString = "PCS" #Make sure this always same as b4 delete data
        lDtl.FindField("Rate").AsFloat = 1     #Make sure this always same as b4 delete data
        lDtl.FindField("RefCost").AsFloat = 22.3
        lDtl.FindField("RefPrice").AsFloat = 52
        lDtl.FindField("ISBASE").AsFloat = 1 
        lDtl.Post();

        lDtl.Append()  #For 2nd UOM
        lDtl.FindField("UOM").AsString = "CTN" #Make sure this always same as b4 delete data
        lDtl.FindField("Rate").AsFloat = 12    #Make sure this always same as b4 delete data
        lDtl.FindField("RefCost").AsFloat = 102.5
        lDtl.FindField("RefPrice").AsFloat = 260.45
        lDtl.FindField("ISBASE").AsFloat = 0 
        lDtl.Post()
    
        while LBar.RecordCount > 0:
            LBar.First()
            LBar.Delete()    

        LBar.Append() #For 1St UOM Barcode
        LBar.FindField("Barcode").AsString = "888888"
        LBar.FindField("UOM").AsString = "PCS"
        LBar.Post()

        LBar.Append() #For 2nd UOM Barcode
        LBar.FindField("Barcode").AsString = "999999"
        LBar.FindField("UOM").AsString = "CTN"
        LBar.Post()
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("ST_ITEM")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
    ComServer.Logout()
finally:
    ComServer = None
    Common.KillApp()

AR_Customer

AR_Customer Script
#Updated 22 Jul 2023
import Common
       
def GetListData():
    lSQL = "SELECT A.*, B.BRANCHTYPE, B.BRANCHNAME, B.ADDRESS1, B.ADDRESS2, B.ADDRESS3, B.ADDRESS4, "
    lSQL = lSQL + "B.GEOLAT, B.GEOLONG, B.ATTENTION, B.PHONE1, B.PHONE2, B.MOBILE, B.FAX1, B.FAX2, B.EMAIL "
    lSQL = lSQL + "FROM AR_CUSTOMER A "
    lSQL = lSQL + "INNER JOIN AR_CUSTOMERBRANCH B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.STATUS='A' "
    lSQL = lSQL + "ORDER BY A.CODE, B.BRANCHTYPE "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("AR_CUSTOMER")
    lMain = BizObject.DataSets.Find("MainDataSet")
    lDtl = BizObject.DataSets.Find("cdsBranch")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("CODE").value = "FAIRY"
        lMain.FindField("CompanyName").value = "FAIRY TAIL"

        lDtl.Edit() #For 1St Branch
        lDtl.FindField("BranchName").AsString  = "BILLING"
        lDtl.FindField("Address1").AsString    = "Address1"
        lDtl.FindField("Address2").AsString    = "Address2"
        lDtl.FindField("Address3").AsString    = "Address3"
        lDtl.FindField("Address4").AsString    = "Address4"  
        lDtl.FindField("Attention").AsString   = "Attention"  
        lDtl.FindField("Phone1").AsString      = "Phone1"
        lDtl.FindField("Fax1").AsString        = "Fax1"
        lDtl.FindField("Email").AsString       = "EmailAddress"
        lDtl.Post()

        lDtl.Append() #For 2nd Branch
        lDtl.FindField("BranchName").AsString  = "Branch1"
        lDtl.FindField("Address1").AsString    = "DAddress1"
        lDtl.FindField("Address2").AsString    = "DAddress2"
        lDtl.FindField("Address3").AsString    = "DAddress3"
        lDtl.FindField("Address4").AsString    = "DAddress4"  
        lDtl.FindField("Attention").AsString   = "DAttention"  
        lDtl.FindField("Phone1").AsString      = "DPhone1"
        lDtl.FindField("Fax1").AsString        = "DFax1"
        lDtl.FindField("Email").AsString       = "DEmailAddress"
        lDtl.Post()
    else:
        BizObject.Params.Find("Code").Value = "FAIRY"
        BizObject.Open()
        BizObject.Edit()
        lMain.FindField("CompanyName").value = "FAIRY TAIL WIZARD"
        
        while lDtl.RecordCount > 0:
            lDtl.First()
            lDtl.Delete()

        #Insert back with new Information
        lDtl.Append() #For 1St Branch
        lDtl.FindField("BranchType").AsString  = "B" 
        lDtl.FindField("BranchName").AsString  = "BILLING" #Make sure this always same as b4 delete data
        lDtl.FindField("Address1").AsString    = "New Address1"
        lDtl.FindField("Address2").AsString    = "New Address2"
        lDtl.FindField("Address3").AsString    = "New Address3"
        lDtl.FindField("Address4").AsString    = "New Address4"  
        lDtl.FindField("Attention").AsString   = "New Attention"  
        lDtl.FindField("Phone1").AsString      = "New Phone1"
        lDtl.FindField("Fax1").AsString        = "New Fax1"
        lDtl.FindField("Email").AsString       = "New EmailAddress"
        lDtl.Post()

        lDtl.Append() #For 2nd Branch
        lDtl.FindField("BranchType").AsString  = "D" 
        lDtl.FindField("BranchName").AsString  = "Branch1" #Make sure this always same as b4 delete data
        lDtl.FindField("Address1").AsString    = "New DAddress1"
        lDtl.FindField("Address2").AsString    = "New DAddress2"
        lDtl.FindField("Address3").AsString    = "New DAddress3"
        lDtl.FindField("Address4").AsString    = "New DAddress4"  
        lDtl.FindField("Attention").AsString   = "New DAttention"  
        lDtl.FindField("Phone1").AsString      = "New DPhone1"
        lDtl.FindField("Fax1").AsString        = "New DFax1"
        lDtl.FindField("Email").AsString       = "New DEmailAddress"
        lDtl.Post()
    
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("AR_CUSTOMER")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "FAIRY")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input") 
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Sales Invoice

SL_IV
#Updated 08 Jan 2024
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM SL_IV A "
    lSQL = lSQL + "INNER JOIN SL_IVDTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("SL_IV")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--IV Test--")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--IV Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("CompanyName").AsString = "Cash Sales"
        lMain.FindField("Address1").AsString = "" #Optional
        lMain.FindField("Address2").AsString = "" #Optional
        lMain.FindField("Address3").AsString = "" #Optional
        lMain.FindField("Address4").AsString = "" #Optional
        lMain.FindField("Phone1").AsString = ""   #Optional
        lMain.FindField("Description").AsString = "Sales"

        #Insert Data - Detail
        #For Tax Inclusive = True with override Tax Amount
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("Account").AsString = "500-000" #Sales Account
        lDetail.FindField("Description").AsString = "Sales Item A"
        lDetail.FindField("Description3").AsString = ("Item A Line 1" + ("\r" + "Item A Line 2"))
        lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 435
        lDetail.FindField("Amount").AsFloat = 410.37 #Exclding GST Amt
        lDetail.FindField("TaxAmt").AsFloat = 24.63

        lDetail.DisableControls()
        lDetail.FindField("TaxInclusive").value = 1
        lDetail.EnableControls()
    
        lDetail.Post()

        #For Tax Inclusive = False with override Tax Amount
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("Account").AsString = "500-000"
        lDetail.FindField("Description").AsString = "Sales Item B"
        lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 94.43
        lDetail.FindField("Amount").AsFloat = 94.43
        lDetail.FindField("TaxAmt").AsFloat = 5.66
        lDetail.Post()
    
        #For With Item Code
        lDetail.Append()
        lDetail.FindField("Seq").value = 3
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Sales Item B"
        #lDetail.FindField("Account").AsString     = "500-000" #If you wanted override the Sales Account Code
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 200
        lDetail.FindField("TaxAmt").AsFloat = 12
        lDetail.Post()
    
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"

        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
            
        #Append Detail
        lDetail.Append()
        #lDetail.FindField("Account").value = "500-000"
        lDetail.FindField("Description").AsString = "Item A  的第一"
        lDetail.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("More description  的第一 🐱")
        lDetail.FindField("Tax").value = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("Amount").value = 410.37
        lDetail.FindField("TaxAmt").value = 0
        lDetail.Post()
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never not knock off by Payment or Credit Note
    BizObject = ComServer.BizObjects.Find("SL_IV")
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--IV Test--")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Purchase Invoice

PH_PI
#Updated 08 Jan 2024
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM PH_PI A "
    lSQL = lSQL + "INNER JOIN PH_PIDTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='400-L0001' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("PH_PI")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    V = ["--PI Test--", "400-W0001"]  #DocNo, Code
    
    lDocKey = BizObject.FindKeyByRef("DocNo;Code", V)
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--PI Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "400-W0001" #Supplier Account
        lMain.FindField("CompanyName").AsString = "WORLDLINE COMMUNICATION SDN BHD"
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""   #Optional
        lMain.FindField("Description").AsString = "Purchase Invoice"

        #Insert Data - Detail    
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Item B"
        #lDetail.FindField("Account").AsString     = "600-000" #If you wanted override the Purchase Account Code
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = ""
        lDetail.FindField("TaxRate").AsString = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 80
        lDetail.FindField("Amount").AsFloat = 160
        lDetail.FindField("TaxAmt").AsFloat = 0
        lDetail.Post()
        
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("ItemCode").AsString = "HFK"
        lDetail.FindField("Description").AsString = "HANDS FREE KITS"
        #lDetail.FindField("Account").AsString     = "600-000" #If you wanted override the Purchase Account Code
        lDetail.FindField("Qty").AsFloat = 3
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = ""
        lDetail.FindField("TaxRate").AsString = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 50
        lDetail.FindField("Amount").AsFloat = 150
        lDetail.FindField("TaxAmt").AsFloat = 0
        lDetail.Post()        
    
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"

        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
            
        #Append Detail
        lDetail.Append()
        #lDetail.FindField("Account").value = "600-000"
        lDetail.FindField("Description").AsString = "Item A  的第一"
        lDetail.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("More description  的第一 🐱")
        lDetail.FindField("Tax").value = ""
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("Amount").value = 410.37
        lDetail.FindField("TaxAmt").value = 0
        lDetail.Post()
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never not knock off by Payment or Credit Note
    BizObject = ComServer.BizObjects.Find("PH_PI")
    
    V = ["--PI Test--", "400-W0001"]  #DocNo, Code
    
    lDocKey = BizObject.FindKeyByRef("DocNo;Code", V)    
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

GL Ledger

GL Ledger Script
#Updated 24 Jul 2023
import Common

def GetData():
    lSQL = "SELECT A.CODE, B.DESCRIPTION ACCDESC, A.DOCDATE, A.POSTDATE, A.DESCRIPTION, A.DESCRIPTION2,  "
    lSQL = lSQL + "A.LOCALDR, A.LOCALCR, A.REF1, A.REF2 FROM GL_TRANS A "
    lSQL = lSQL + "INNER JOIN GL_ACC B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.CANCELLED='F' "
    lSQL = lSQL + "AND A.POSTDATE BETWEEN '01 JAN 2023'  "
    lSQL = lSQL + "AND '31 DEC 2023' "
    lSQL = lSQL + "AND A.CODE='310-000' "
    lSQL = lSQL + "ORDER BY A.CODE, A.POSTDATE "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    Common.ShowResult(lDataSet)
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer       
    GetData()
    ComServer.Logout()
finally:    
    ComServer = None
    Common.KillApp()

GL Trial Balance

GL Trial Balance Script
#Updated 25 Jul 2023
import Common
import datetime

def GetData():
    RptObject = ComServer.RptObjects.Find('GL.TrialBalance.RO')
    
    RptObject.Params.Find("AllProject").Value      = True
    RptObject.Params.Find("AllAgent").Value        = True
    RptObject.Params.Find("AllArea").Value         = True
    RptObject.Params.Find("LedgerType").Value      = "G" #G = Legder, S = Debtor, P = Supplier
    #RptObject.Params.Find("ProjectData").Value    = #Not use if AllArea is true
    RptObject.Params.Find("ShowZeroBalance").Value = False
    RptObject.Params.Find("SortBy").Value          = "PostDate;DocNo" 
    RptObject.Params.Find("UseDescription2").Value = False
    
    lDateFrom = datetime.datetime(2018, 1, 1, 13, 0)
    lDateFrom.strftime('%m/%d/%Y')
    lDateTo = datetime.datetime(2018, 12, 31, 13, 0)
    lDateTo.strftime('%m/%d/%Y')
    
    RptObject.Params.Find("DateFrom").Value       = lDateFrom
    RptObject.Params.Find("DateTo").Value         = lDateTo

    #RptObject.Params.Find("AgentData").Value      = 'Not use if AllAgent is true
    #RptObject.Params.Find("AreaData").Value       = 'Not use if AllArea is true
  
    RptObject.Params.Find("SortBy").Value          = "Code;Description"
    RptObject.CalculateReport()

    lDataSet = RptObject.DataSets.Find("cdsMain")
    lDataSet2 = RptObject.DataSets.Find("cdsGLAccount") #For Account List
    
    if lDataSet2.RecordCount > 0:
        while not lDataSet2.eof:
            print(lDataSet2.FindField('CODE').AsString)
            print(lDataSet2.FindField('DESCRIPTION').AsString)
            print("===")
            lDataSet2.Next()
            
    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            print("Month To Date")
            print(lDataSet.FindField('CODE').AsString)
            print(lDataSet.FindField('MTDDR').AsString)            
            print(lDataSet.FindField('MTDCR').AsString)
            print("Year To Date")
            print(lDataSet.FindField('CODE').AsString)
            print(lDataSet.FindField('YTDDR').AsString)
            print(lDataSet.FindField('YTDCR').AsString)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer       
    GetData()
    ComServer.Logout()
finally:    
    ComServer = None
    Common.KillApp()

Terms

Terms
#Updated 25 Jul 2023
import Common
       
def GetListData():
    lSQL = "SELECT * FROM TERMS "
    lSQL = lSQL + "WHERE ISACTIVE='T' "
    lSQL = lSQL + "ORDER BY CODE "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("Terms")
    lMain = BizObject.DataSets.Find("MainDataSet")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "90 Days")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("CODE").value = "90 Days"
        lMain.FindField("DESCRIPTION").value = "Net 90 Days"
        lMain.FindField("TermDay").value = 90
        lMain.FindField("ISACTIVE").value = "T"
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.FindField("DESCRIPTION").value = "Net 90 Days - Edited"
        lMain.FindField("ISACTIVE").value = "F"
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never use in other document
    BizObject = ComServer.BizObjects.Find("Terms")
    
    lDocKey = BizObject.FindKeyByRef("CODE", "90 Days")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("CODE").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Stock Adjustment

ST_SJ
#Updated 08 Jan 2024
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AUTHBY, A.REASON, A.REMARK, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITCOST, "
    lSQL = lSQL + "B.AMOUNT, B.REMARK1, B.REMARK2 "
    lSQL = lSQL + "FROM ST_AJ A "
    lSQL = lSQL + "INNER JOIN ST_AJDTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.DocDate='20 Apr 2013' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("ST_AJ")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
        
    lDocKey = BizObject.FindKeyByRef("DocNo", "--AJ Test--")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--AJ Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Description").AsString = "Stock Adjustment"

        #Insert Data - Detail - Increase Stock Qty   
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "ANTENA"
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "PCS"
        lDetail.FindField("UnitCOST").AsFloat = 80
        lDetail.FindField("Amount").AsFloat = 160
        lDetail.Post()
        
        #Insert Data - Detail - Reduce Stock Qty
        lDetail.Append()
        lDetail.FindField("Seq").value = 2
        lDetail.FindField("ItemCode").AsString = "HFK"
        lDetail.FindField("Description").AsString = "HANDS FREE KITS"
        lDetail.FindField("Qty").AsFloat = -3
        lDetail.FindField("UOM").AsString = "UNIT"
        lDetail.Post()        
    
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"

        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
            
        #Append Detail
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "BOM"
        lDetail.FindField("Description").AsString = "Bill Of Material"        
        lDetail.FindField("Qty").AsFloat = -1
        lDetail.FindField("UOM").AsString = "UNIT"
        lDetail.Post()
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    BizObject = ComServer.BizObjects.Find("ST_AJ")
        
    lDocKey = BizObject.FindKeyByRef("DocNo", "--AJ Test--")    
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Sales Order

Sales Order
#Updated 08 Jan 2024
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, A.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, "
    lSQL = lSQL + "B.ITEMCODE, B.DESCRIPTION ITEMDESC, B.QTY, B.UOM, B.UNITPRICE, B.DISC,  "
    lSQL = lSQL + "B.TAX, B.TAXRATE, B.TAXAMT, B.TAXINCLUSIVE, B.AMOUNT "
    lSQL = lSQL + "FROM SL_SO A "
    lSQL = lSQL + "INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("SL_SO")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--SO Test--")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--SO Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("CompanyName").AsString = "Cash Sales"
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""   #Optional
        lMain.FindField("Description").AsString = "Sales Order"

        #Insert Data - Detail    
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "ANT"
        lDetail.FindField("Description").AsString = "Sales Item B"
        lDetail.FindField("Qty").AsFloat = 2
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 200
        lDetail.FindField("TaxAmt").AsFloat = 12
        lDetail.Post()
    
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Description 123 的第一 🐱"

        #Delete all Detail
        while lDetail.RecordCount != 0:
            lDetail.Last()
            lDetail.Delete()
            
        #Append Detail
        lDetail.Append()
        lDetail.FindField("Seq").value = 1
        lDetail.FindField("ItemCode").AsString = "BOM"
        lDetail.FindField("Description").AsString = "Sales Item BOM"
        lDetail.FindField("Qty").AsFloat = 1
        lDetail.FindField("UOM").AsString = "UNIT"
        #lDetail.FindField("DISC").AsString        = "5%+3" #Optional(eg 5% plus 3 Discount)
        lDetail.FindField("Tax").AsString = "SV"
        lDetail.FindField("TaxRate").AsString = "6%"
        lDetail.FindField("TaxInclusive").value = 0
        lDetail.FindField("UnitPrice").AsFloat = 100
        lDetail.FindField("Amount").AsFloat = 100
        lDetail.FindField("TaxAmt").AsFloat = 6
        lDetail.Post()
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    BizObject = ComServer.BizObjects.Find("SL_SO")
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--SO Test--")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Sales.PriceHistory.RO

Sales.PriceHistory.RO Script
#Updated 01 Apr 2021
import win32com.client
import datetime

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name

def GetData():
    RptObject = ComServer.RptObjects.Find('Sales.PriceHistory.RO')
    
    #RptObject.Params.Find("AgentData").Value            = #Not use if AllAgent is true
    #RptObject.Params.Find("TaxData").Value              = #Not use if AllTax is true
    #RptObject.Params.Find("CompanyCategoryData").Value  = #Not use if AllCompanyCategory is true
    RptObject.Params.Find("AllAgent").Value              = True
    RptObject.Params.Find("AllTax").Value                = True
    RptObject.Params.Find("AllShipper").Value            = True
    RptObject.Params.Find("AllArea").Value               = True
    RptObject.Params.Find("AllCompany").Value            = True
    RptObject.Params.Find("AllDocProject").Value         = True
    RptObject.Params.Find("AllItem").Value               = False
    RptObject.Params.Find("AllItemProject").Value        = True
    RptObject.Params.Find("AllLocation").Value           = True
    RptObject.Params.Find("AllCompanyCategory").Value    = True
    RptObject.Params.Find("AllBatch").Value              = True
    RptObject.Params.Find("AllTariff").Value             = True
    RptObject.Params.Find("AllStockGroup").Value         = True
    #RptObject.Params.Find("AreaData").Value             = #Not use if AllArea is true
    #RptObject.Params.Find("CategoryData").Value         = #Not use if AllTax is true
    #RptObject.Params.Find("CategoryTpl").Value          = #Not use if AllTax is true
    #RptObject.Params.Find("CompanyData").Value          = #Not use if AllTax is true
       
    lDateFrom = datetime.datetime(2021, 3, 1, 13, 0)
    lDateFrom.strftime('%m/%d/%Y')
    lDateTo = datetime.datetime(2021, 3, 31, 13, 0)
    lDateTo.strftime('%m/%d/%Y')
    
    RptObject.Params.Find("DateFrom").Value         = lDateFrom
    RptObject.Params.Find("DateTo").Value           = lDateTo

    RptObject.Params.Find("DoCN_SC").Value          = False #Include Credit Note
    #RptObject.Params.Find("DocProjectData").Value  = #Not use if AllDocProject is true
    RptObject.Params.Find("DoCS_CP").Value          = True #Include Cash Sales
    RptObject.Params.Find("DoDN_SD").Value          = False #Include Debit Note
    RptObject.Params.Find("DoDO_GR").Value          = False #Include Delivery Order
    RptObject.Params.Find("DoED_EG").Value          = False #Include Extra Delivery Order
    RptObject.Params.Find("DoIV_PI").Value          = False #Include Invoice
    RptObject.Params.Find("DoQT_PQ").Value          = False #Include Quotation
    RptObject.Params.Find("DoSO_PO").Value          = False #Include Sales Order
    #RptObject.Params.Find("ItemCode").Value        = #For Internal use only
    RptObject.Params.Find("ItemData").Value         = "ANT" + "\r" + "BOM"
    #RptObject.Params.Find("ItemProjectData").Value  = #Not use if AllItemProject is true
    #RptObject.Params.Find("LocationData").Value     = #Not use if AllLocation is true
    #RptObject.Params.Find("MaxRecords").Value       = #Not use if SelectMaxRecords is False
    RptObject.Params.Find("SelectDate").Value        = True
    RptObject.Params.Find("SelectMaxRecords").Value  = False
    #RptObject.Params.Find("GroupBy").Value          = #Only use if wanted to grouping
    RptObject.Params.Find("HasCategory").Value       = False
    #RptObject.Params.Find("ItemCategoryData").Value = #Not use if HasCategory is False
    #RptObject.Params.Find("BatchData").Value        = #Not use if AllBatch is true
    #RptObject.Params.Find("TariffData").Value       = #Not use if AllTariff is true
    #RptObject.Params.Find("ShipperData").Value      = #Not use if AllShipper is true
    RptObject.Params.Find("SortBy").Value            = "DocDate;DocNo"
    #RptObject.Params.Find("StockGroupData").Value   = #Not use if AllStockGroup is true
    #RptObject.Params.Find("SummaryInterval  
    
    RptObject.CalculateReport()

    lDataSet = RptObject.DataSets.Find("cdsMain")
        
    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            for idx in range(lDataSet.Fields.Count):
                LFld = lDataSet.Fields.Items(idx).FieldName 
                print(LFld + " :"+ lDataSet.FindField(LFld).AsString)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")
    
try:
    CheckLogin()      
    GetData()
finally:
    ComServer.Logout()
    ComServer = None

Get Edited Sales Invoice List

Get Edited Sales Invoice List Script
#Updated 19 Jul 2021
import win32com.client

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("ADMIN", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0081.FDB") #Database Name

def GetData():
    lSQL = "SELECT REFERENCE FROM AUDIT "
    lSQL = lSQL + "WHERE REF LIKE 'SL_IV%' "
    lSQL = lSQL + "AND UPDATEKIND='E' "
    lSQL = lSQL + "AND CAST(DOCDATETIME AS DATE) = '10 JUN 2021' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)

    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            DocNo = lDataSet.FindField('REFERENCE').AsString
            DocNo = DocNo.split(',')[0]
            DocNo = DocNo.split(':')[1]
    
            print(DocNo)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")


    
try:
    CheckLogin()      
    GetData()
finally:
    ComServer.Logout()
    ComServer = None

SO to DO

Get Outstanding SO by SO Number transfer to DO Script
#Updated 29 Nov 2021
import win32com.client
import datetime

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "D:\\Happy\\DB\\Default.DCF",
                   # "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0011.FDB") #Database Name

def PostData():
    lSQL = "SELECT Dockey, DocNo,Code, CompanyName, DocProject, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount, DtlProject, "
    lSQL = lSQL + "Tax, TaxRate, TaxInclusive, TaxAmt, COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM ( "
    lSQL = lSQL + "SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName, A.Project DocProject, "
    lSQL = lSQL + "B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount, "
    lSQL = lSQL + "B.Tax, B.TaxRate, B.TaxInclusive, B.TaxAmt, B.Project DtlProject, C.Qty XFQty FROM SL_SO A "
    lSQL = lSQL + "INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY) "
    lSQL = lSQL + "LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY "
    lSQL = lSQL + "                          AND C.FROMDOCTYPE='SO') "
    lSQL = lSQL + "WHERE A.DOCNO='SO-00044') "
    lSQL = lSQL + "GROUP BY Dockey, DocNo, Code, CompanyName, DocProject, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, "
    lSQL = lSQL +" Amount, DtlProject, Tax, TaxRate, TaxInclusive, TaxAmt "
    lSQL = lSQL + "HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0 "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL) #Get Outstanding Qty for each itemcode
    #print("==="+ str(lDataSet.RecordCount))
    if lDataSet.RecordCount > 0:
        BizObject = ComServer.BizObjects.Find("SL_DO")
        lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
        lDetail = BizObject.DataSets.Find("cdsDocDetail") #lDetail contains detail data
    
        lDate = datetime.datetime(2021, 11, 29, 13, 0)
        lDate.strftime('%m/%d/%Y')
    
        BizObject.New();
        lMain.FindField("DocKey").value = -1
        lMain.FindField("DocNo").AsString = "--DO Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = lDataSet.FindField("Code").AsString #Customer Account
        lMain.FindField("CompanyName").AsString = lDataSet.FindField("CompanyName").AsString
        #lMain.FindField("Address1").AsString = "" #Optional
        #lMain.FindField("Address2").AsString = "" #Optional
        #lMain.FindField("Address3").AsString = "" #Optional
        #lMain.FindField("Address4").AsString = "" #Optional
        #lMain.FindField("Phone1").AsString = ""   #Optional
        lMain.FindField("Project").AsString = lDataSet.FindField("DocProject").AsString
        lMain.FindField("Description").AsString = "Delivery Order"

        #Insert Data - Detail
        while not lDataSet.eof:
            lDetail.Append()
            lDetail.FindField("DtlKey").value = -1
            lDetail.FindField("DocKey").value = -1
            lDetail.FindField("Seq").value = lDataSet.FindField("Seq").Value
            lDetail.FindField("ItemCode").AsString = lDataSet.FindField("ItemCode").AsString
            lDetail.FindField("UOM").AsString = lDataSet.FindField("UOM").AsString
            lDetail.FindField("Qty").AsFloat = lDataSet.FindField("OSQty").AsFloat # Transfer all balance Qty
            lDetail.FindField("DISC").AsString = lDataSet.FindField("DISC").AsString
            lDetail.FindField("Tax").AsString = lDataSet.FindField("Tax").AsString
            lDetail.FindField("TaxRate").AsString = lDataSet.FindField("TaxRate").AsString
            lDetail.FindField("TaxInclusive").value = lDataSet.FindField("TaxInclusive").value 
            lDetail.FindField("UnitPrice").AsFloat = lDataSet.FindField("UnitPrice").AsFloat 
            lDetail.FindField("Amount").AsFloat = lDataSet.FindField("Amount").AsFloat 
            lDetail.FindField("TaxAmt").AsFloat = lDataSet.FindField("TaxAmt").AsFloat
            lDetail.FindField("Project").AsString = lDataSet.FindField("DtlProject").AsString
            lDetail.FindField("FromDocType").AsString = "SO"; #From Document Type
            lDetail.FindField("FromDockey").AsFloat = lDataSet.FindField("Dockey").AsFloat;
            lDetail.FindField("FromDtlkey").AsFloat = lDataSet.FindField("DtlKey").AsFloat;
            lDetail.Post()
            lDataSet.Next()
    
        BizObject.Save()
        BizObject.Close()
    else :
        print ("Record Not Found")
try:
    CheckLogin()
    print ("Posting SO to DO")
    PostData()
    print ("Done")
finally:
    ComServer.Logout()
    ComServer = None

Stock Month End - Weighted Average

Stock Month End - Weighted Average Script
#Updated 30 Nov 2021
import win32com.client
import datetime

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "D:\\Happy\\DB\\Default.DCF",
                   # "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0011.FDB") #Database Name

def GetData():
    #Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
    lSQL = "SELECT A.ItemCode, A.Location, A.Batch,  MAX(B.Seq) AS Seq, 2 AS CostingMethod "
    lSQL = lSQL + "FROM ST_TR A INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) "
    lSQL = lSQL + "WHERE A.PostDate<='31 Jul 2020' "
    lSQL = lSQL + "GROUP BY A.ItemCode, A.Location, A.Batch "
    
    lDataSet1 = ComServer.DBManager.NewDataSet(lSQL) 

    if lDataSet1.RecordCount > 0:
        lDataSet1.First()
        while not lDataSet1.eof:
            lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.UTDQty, B.UTDCost FROM ST_TR A "
            lSQL = lSQL + "INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) "
            lSQL = lSQL + "WHERE A.ITEMCODE= '" + lDataSet1.FindField("ItemCode").AsString + "' "
            lSQL = lSQL + "AND B.SEQ= " + lDataSet1.FindField("Seq").AsString
            lSQL = lSQL + " AND A.LOCATION='" + lDataSet1.FindField("Location").AsString + "' "
            lSQL = lSQL + " AND A.BATCH='" + lDataSet1.FindField("Batch").AsString + "' "
            lSQL = lSQL + "AND B.UTDQty<>0 "
            lSQL = lSQL + "ORDER BY A.ItemCode, A.Location, A.Batch "
            
            #print(lSQL)
            lDataSet2 = ComServer.DBManager.NewDataSet(lSQL)
            if lDataSet2.RecordCount > 0:
                lDataSet2.First()
                print("ITEMCODE = "+lDataSet2.FindField("ITEMCODE").AsString)
                print("LOCATION = "+lDataSet2.FindField("LOCATION").AsString)
                print("BATCH = "+lDataSet2.FindField("BATCH").AsString)
                print("UTDQTY = "+lDataSet2.FindField("UTDQTY").AsString)
                print("UTDCOST = "+lDataSet2.FindField("UTDCOST").AsString)
                print("=====")
            else :
                print ("Detail Record Not Found")
            lDataSet1.Next()
            
    else :
        print ("Record Not Found")
try:
    CheckLogin()
    print ("Month End - WA")
    GetData()
    print ("Done")
finally:
    ComServer.Logout()
    ComServer = None

Stock Month End - FIFO

Stock Month End - FIFO Script
#Updated 15 Feb 2022
import win32com.client
import datetime

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin():
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                    "ACC-0011.FDB") #Database Name

def GetData():
    #Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting        

    lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.QTY, B.COST FROM ST_TR A "
    lSQL = lSQL + "INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO) "
    lSQL = lSQL + "WHERE B.COSTTYPE='U' "
    lSQL = lSQL + "AND A.PostDate<='31 Jul 2022' "
    lSQL = lSQL + "AND A.ITEMCODE ='ANT' "
    lSQL = lSQL + "AND B.Qty<>0 "
    lSQL = lSQL + "AND EXISTS (SELECT MAX(D.Seq) FROM ST_TR C "
    lSQL = lSQL + "            INNER JOIN ST_TR_FIFO D ON (C.TRANSNO=D.TRANSNO) "
    lSQL = lSQL + "            WHERE C.PostDate<='31 Jul 2022' "
    lSQL = lSQL + "            AND C.ItemCode ='ANT' "
    lSQL = lSQL + "            GROUP BY C.ItemCode, C.Location, C.Batch "
    lSQL = lSQL + "            HAVING B.SEQ=MAX(D.Seq) "
    lSQL = lSQL + "            ) "
    lSQL = lSQL + "ORDER BY A.ItemCode, A.Location, A.BATCH, A.TRANSNO "
    print(lSQL)
    lDataSet2 = ComServer.DBManager.NewDataSet(lSQL)
            
    if lDataSet2.RecordCount > 0: #Total Qty & Cost
        lDataSet2.First()
        while not lDataSet2.eof:
            print(" ")
            print("TRANSNO = "+lDataSet2.FindField("TRANSNO").AsString)
            print("ITEMCODE = "+lDataSet2.FindField("ITEMCODE").AsString)
            print("LOCATION = "+lDataSet2.FindField("LOCATION").AsString)
            print("BATCH = "+lDataSet2.FindField("BATCH").AsString)
            print("QTY = "+lDataSet2.FindField("QTY").AsString)
            print("COST = "+lDataSet2.FindField("COST").AsString)
            print("=====")
            print(" ")
            print("===Detail Cost===")
            lSQL = "SELECT TRANSNO, ITEMCODE, COSTSEQ, QTY, COST FROM ST_TR_FIFO "
            lSQL = lSQL + "WHERE ITEMCODE = '" + lDataSet2.FindField("ITEMCODE").AsString
            lSQL = lSQL + "' AND COSTTYPE='B' "
            lSQL = lSQL + "AND TRANSNO="+lDataSet2.FindField("TRANSNO").AsString
            lSQL = lSQL + " ORDER BY COSTSEQ"
                    
            lDataSet3 = ComServer.DBManager.NewDataSet(lSQL)

            if lDataSet3.RecordCount > 0: #Detail Cost
                lDataSet3.First()
                while not lDataSet3.eof:
                    print("TRANSNO = "+lDataSet3.FindField("TRANSNO").AsString)
                    print("ITEMCODE = "+lDataSet3.FindField("ITEMCODE").AsString)
                    print("COSTSEQ = "+lDataSet3.FindField("COSTSEQ").AsString)
                    print("QTY = "+lDataSet3.FindField("QTY").AsString)
                    print("COST = "+lDataSet3.FindField("COST").AsString)
                    print("D=====")
                    lDataSet3.Next()
            lDataSet2.Next()
    else :
        print("Detail Record Not Found")
                
try:
    CheckLogin()
    print ("Month End - FIFO")
    GetData()
    print ("Done")
finally:
    #ComServer.Logout()
    ComServer = None

Login 2 Database

Login 2 Database
#Updated 17 Mar 2022
import win32com.client
import datetime

ComServer = win32com.client.Dispatch("SQLAcc.BizApp")

def CheckLogin1():
    ComServer = None
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0024.FDB") #Database Name


def CheckLogin2():
    ComServer = None
    ComServer = win32com.client.Dispatch("SQLAcc.BizApp")
    B = ComServer.IsLogin
    if B == True:
        ComServer.Logout()
    ComServer.Login("FAUNG", "ADMIN", #UserName, Password
                    "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                    "ACC-0015.FDB") #Database Name
        
def GetData():    
    lSQL = "SELECT COUNT(*) Nos FROM AR_CUSTOMER A WHERE A.CODE LIKE '%300%' "
    
    try:
        lDataSet1 = ComServer.DBManager.NewDataSet(lSQL) 
        Seq = 0
        if lDataSet1.RecordCount > 0:
            lDataSet1.First()
            Seq = lDataSet1.FindField("Nos").Value
            print(Seq)
        else :
            print ("Record Not Found")
        
    finally:
        lDataSet1 = None

    
try:
    print ("Login 1st DB")
    CheckLogin1()
    GetData()
    print ("Done 1st DB")
    print ("Login 2nd DB")
    CheckLogin2()
    GetData()
    print ("Done 2nd DB")    
finally:
    ComServer.Logout()
    ComServer = None
    print ("Done...")

Get Stock Qty Balance

Get Stock Qty Balance
#Updated 18 Jan 2024
import Common

def GetData():
    lSQL = "SELECT  ItemCode, Location, Batch, Sum(Qty) Qty  FROM ST_TR   "
    lSQL = lSQL + "WHERE PostDate<='31 Dec 2019' "
    lSQL = lSQL + "AND ITEMCODE ='ANT' "
    lSQL = lSQL + "GROUP BY ItemCode, Location, Batch "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    
    if lDataSet.RecordCount > 0:
        while not lDataSet.eof:
            print(lDataSet.FindField('ItemCode').AsString)
            print(lDataSet.FindField('Location').AsString)
            print(lDataSet.FindField('Batch').AsString)
            print(lDataSet.FindField('Qty').AsString)
            print("===")
            lDataSet.Next()
    else:
        print ("Record Not Found")
    
try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer      
    GetData()
finally:
    ComServer = None
    Common.KillApp()

Maintain Asset Item

Maintain Asset Item
#Updated 03 Oct 2023
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNOEX, A.ACQUIREDATE, A.CODE, A.DESCRIPTION, A.ASSETGROUP, "
    lSQL = lSQL + "A.AGENT, A.AREA, A.COST, A.USEFULLIFE, A.DEPRRATE, A.RESIDUAL, "
    lSQL = lSQL + "B.POSTDATE, B.DESCRIPTION HISTORYDESC "
    lSQL = lSQL + "FROM FA_ITEM A "
    lSQL = lSQL + "INNER JOIN FA_ITEM_HISTORY B ON (A.Code=B.Code) "
    lSQL = lSQL + "WHERE A.STATUS=1 " #1 = Active 2 = InActive    
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def GetAutoKey(ACode):
    lSQL = "SELECT AUTOKEY FROM FA_ITEM "
    lSQL = lSQL + "WHERE Code= ' + Common.QuotedStr(ACode)
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
    return lDataSet.FindField("AutoKey").AsFloat

def PostData():
    BizObject = ComServer.BizObjects.Find("FA.Item.OPF")
    lMain = BizObject.DataSets.Find("Main") #lMain contains master data
    lProj = BizObject.DataSets.Find("Project") #lProj contains Project data
    lDepr = BizObject.DataSets.Find("DeprSche") #lDepr contains Depreciation Scheduler data
    lHist = BizObject.DataSets.Find("History") #lHist contains History data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    lDocKey = GetAutoKey("--FA Test--")
        
    if lDocKey == 0:
        BizObject.New()
        lMain.FindField("Code").AsString = "--FA Test--"
        lMain.FindField("Description").AsString = "5ft Banquet Table"
        lMain.FindField("AcquireDate").value = lDate
        lMain.FindField("AssetGroup").AsString = "Default"
        lMain.FindField("Cost").AsFloat = 6190.50
        lMain.FindField("UsefulLife").AsFloat = 3
        lMain.FindField("Residual").AsFloat = 1
        lMain.FindField("DocNoEx").AsString = "IV-321578"
        lMain.FindField("Qty").AsFloat = 100

        #Insert Data - Depreciation Schedule
        lDate = datetime.datetime(2024, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')
        
        lDepr.Append()
        lDepr.FindField("SCHEDATE").value       = lDate
        lDepr.FindField("Description").AsString = "Depreciation 1/3"
        lDepr.FindField("AMOUNT").AsFloat       = 2063.17
        lDepr.Post()

        lDate = datetime.datetime(2025, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')
        
        lDepr.Append()
        lDepr.FindField("SCHEDATE").value       = lDate
        lDepr.FindField("Description").AsString = "Depreciation 2/3"
        lDepr.FindField("AMOUNT").AsFloat       = 2063.17
        lDepr.Post()

        lDate = datetime.datetime(2026, 9, 3, 13, 0)
        lDate.strftime('%m/%d/%Y')

        lDepr.Append()
        lDepr.FindField("SCHEDATE").value       = lDate
        lDepr.FindField("Description").AsString = "Depreciation 3/3"
        lDepr.FindField("AMOUNT").AsFloat       = 2063.16
        lDepr.Post()        

        #Insert Data - Hisory   
        lDate = datetime.datetime(2023, 1, 20, 13, 0)
        lDate.strftime('%m/%d/%Y')
        
        lHist.Append()
        lHist.FindField("PostDate").value = lDate
        lHist.FindField("Description").AsString = "Supplier ABC 4 Units"
        lHist.Post()
        
        lDate = datetime.datetime(2023, 2, 22, 13, 0)
        lDate.strftime('%m/%d/%Y')
        
        lHist.Append()
        lHist.FindField("PostDate").value = lDate
        lHist.FindField("Description").AsString = "Supplier XYZ Sdn Bhd 6 Units"
        lHist.Post()
        
        #Insert Data - Project
        lProj.Edit()
        lProj.FindField("Project").AsString = "KL"
        lProj.FindField("Rate").AsFloat = 40.00
        lProj.Post()
        
        lProj.Append()
        lProj.FindField("Project").AsString = "JB"
        lProj.FindField("Rate").AsFloat = 60.00
        lProj.Post()           
    else:
        BizObject.Params.Find("Autokey").AsString = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited 5ft Banquet Tables"

        #Delete all Project
        while lProj.RecordCount != 0:
            lProj.First()
            lProj.Delete()
            
        lProj.Append()
        lProj.FindField("Project").AsString = "----"
        lProj.FindField("Rate").AsFloat = 10.00
        lProj.Post()
        
        lProj.Append()
        lProj.FindField("Project").AsString = "KL"
        lProj.FindField("Rate").AsFloat = 40.00
        lProj.Post()

        lProj.Append()
        lProj.FindField("Project").AsString = "JB"
        lProj.FindField("Rate").AsFloat = 50.00
        lProj.Post()      
        
        #Insert Data - Hisory   
        lDate = datetime.datetime(2023, 2, 10, 13, 0)
        lDate.strftime('%m/%d/%Y')
        
        lHist.Append()
        lHist.FindField("PostDate").value = lDate
        lHist.FindField("Description").AsString = "1 of table leg broken"
        lHist.Post()        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    BizObject = ComServer.BizObjects.Find("FA.Item.OPF")
    
    lDocKey = GetAutoKey("--FA Test--")
        
    if lDocKey == 0:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Autokey").AsString = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()

Customer Payment

AR_PM
#Updated 04 Dec 2023
import Common
import datetime
       
def GetListData():
    lSQL = "SELECT A.DOCNO, A.DOCDATE, A.CODE, B.COMPANYNAME, A.DESCRIPTION, A.DOCAMT, "
    lSQL = lSQL + "A.AGENT, A.AREA, A.PAYMENTMETHOD "
    lSQL = lSQL + "FROM AR_PM A "
    lSQL = lSQL + "INNER JOIN AR_CUSTOMER B ON (A.CODE=B.CODE) "
    lSQL = lSQL + "WHERE A.CODE='300-A0002' "
    lSQL = lSQL + "AND A.CANCELLED='F' "
    
    lDataSet = ComServer.DBManager.NewDataSet(lSQL)
        
    Common.ShowResult(lDataSet)

def PostData():
    BizObject = ComServer.BizObjects.Find("AR_PM")
    lMain = BizObject.DataSets.Find("MainDataSet") #lMain contains master data
    lDetail = BizObject.DataSets.Find("cdsKnockOff") #lDetail contains detail data
    
    lDate = datetime.datetime(2023, 2, 22, 13, 0)
    lDate.strftime('%m/%d/%Y')
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--PM Test--")
        
    if lDocKey is None:
        BizObject.New()
        lMain.FindField("DocNo").AsString = "--PM Test--"
        lMain.FindField("DocDate").value = lDate
        lMain.FindField("PostDate").value = lDate
        lMain.FindField("Code").AsString = "300-C0001" #Customer Account
        lMain.FindField("Description").AsString = "Payment for A/c"
        lMain.FindField("PaymentMethod").AsString = "325-000" #Bank or Cash Account
        lMain.FindField("ChequeNumber").AsString = ""
        lMain.FindField("BankCharge").AsFloat = 0
        lMain.FindField("DocAmt").AsFloat = 10000.00
        lMain.FindField("Cancelled").AsString = "F"    

        #Knock Off IV  
        V = ["IV", "--IV Test--"]  #DocType, DocNo
        if (lDetail.Locate("DocType;DocNo", V, False, False)) :
            lDetail.Edit()
            lDetail.FindField("KOAmt").AsFloat = 147.09 #Partial Knock off
            lDetail.FindField("KnockOff").AsString = "T"
            lDetail.Post()
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Edit()
        lMain.Edit()
        lMain.FindField("Description").AsString = "Edited Payment for A/c 的第一 🐱"

        #Knock Off IV  
        V = ["IV", "--IV Test--"]  #DocType, DocNo
        if (lDetail.Locate("DocType;DocNo", V, False, False)) :
            lDetail.Edit()
            lDetail.FindField("KOAmt").AsFloat = 200.09 #Partial Knock off
            lDetail.FindField("KnockOff").AsString = "T"
            lDetail.Post()
        
    try:
        BizObject.Save()          
    except Exception as e:
        print("Oops!", e)    
    BizObject.Close()
    print ("Posting/Update Done")

def DelData():
    #Deleting only work if the record never not knock off by Refund
    BizObject = ComServer.BizObjects.Find("AR_PM")
    
    lDocKey = BizObject.FindKeyByRef("DocNo", "--PM Test--")
        
    if lDocKey is None:
        print ("Record Not Found")
    else:
        BizObject.Params.Find("Dockey").Value = lDocKey
        BizObject.Open()
        BizObject.Delete()        
        print ("Deleting Done")

try:
    Common.CheckLogin()
    global ComServer
    ComServer = Common.ComServer
    GetListData()
    PostData()
    
    answer = input("Continue To delete?")
    if answer.lower() in ["y","yes"]:
        DelData()
    elif answer.lower() in ["n","no"]:
        print ("Deleting Aborted")
    else:
       print ("Invalid Input")
       
    ComServer.Logout()   
finally:
    ComServer = None
    Common.KillApp()


PHP

  • Tested PHP Version : 7.4.3/8.1.10
  • Add this in ..\xampp\php\php.ini
 [PHP_COM_DOTNET]
 extension=php_com_dotnet.dll
  • Grid.css file for example code
Grid.css file
body 
{
  margin: 10;
}
table {
  font-family: arial, sans-serif;
  border: 1px solid black;
  border-collapse: collapse;
  table-layout: auto;
}

td, th {
  border: 1px solid black;
  text-align: left;
  padding: 8px;
  white-space: nowrap;
}

tr:nth-child(even) {
  background-color: #dddddd;
}

Get Agent

Get Agent Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 May 2020<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function GetData()
{
    global $ComServer;

    $lSQL = "SELECT * FROM AGENT 
	         WHERE CODE='HALIM'";

    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0)
    {
        echo "Result : ";
        echo $lDataSet->FindField('Description')->AsString() . "<br>";
    }
    else
    {
        echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A") . " - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?>
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Agent"/> 
    </form> 
</body>
</html>

Add & Edit Agent

Add & Edit Agent Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 May 2020<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("Agent");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
	
	if ($lDocKey == null){
        $BizObject->New();
        $lMain->FindField("CODE")->value = "FAIRY";
        $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL";
	} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Edit();
        $lMain->FindField("DESCRIPTION")->value = "FAIRY TAIL WIZARD";
	}
	try{
		$BizObject->Save();
		echo "Posting Done <br>";
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}
	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        PostData();
        echo date("d M Y h:i:s A") . " - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?>
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Add/Edit Agent"/> 
    </form> 
</body>
</html>

Delete Agent

Delete Agent Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 May 2020<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("Agent");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
	
	if ($lDocKey == null){
        echo "Record Not Found";
	} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Delete();
        echo "Delete Done<br>";
	}	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        PostData();
        echo date("d M Y h:i:s A") . " - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?>
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Delete Agent"/> 
    </form> 
</body>
</html>

Complete Post

SL_CS, AR_PM, SL_CN & AR_CN Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 May 2020<br>";
#This will doing following posting
#01. Cash Sales - SL_CS
#02. Sales Credit Note - SL_CN
#03. Customer Payment With Knock off - AR_PM
#04. Edit Credit Note Posted in Step 02 & Knock Off - AR_CN
#05. Customer Refund to Knock off Credit Note - AR_CF

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function PostDataCS(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("SL_CS");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--CS Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
    $lMain->FindField("Address1")->AsString = ""; #Optional
    $lMain->FindField("Address2")->AsString = ""; #Optional
    $lMain->FindField("Address3")->AsString = ""; #Optional
    $lMain->FindField("Address4")->AsString = ""; #Optional
    $lMain->FindField("Phone1")->AsString = "";   #Optional
    $lMain->FindField("Description")->AsString = "Sales";
	
    #Insert Data - Detail
    #For Tax Inclusive = True with override Tax Amount
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
    $lDetail->FindField("Description")->AsString = "Sales Item A";
	
	$txt = <<<EOT
           Item A Line 1
           Item A Line 2
           EOT;
	
    $lDetail->FindField("Description3")->AsString = $txt;
    $lDetail->FindField("Qty")->AsFloat = 1;
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 435;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
    $lDetail->FindField("TaxAmt")->AsFloat = 24.63;

    $lDetail->DisableControls();
    $lDetail->FindField("TaxInclusive")->value = 1;
    $lDetail->EnableControls();    
    $lDetail->Post();
	
    #For Tax Inclusive = False with override Tax Amount
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("Account")->AsString = "500-000";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 1;
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 94.43;
    $lDetail->FindField("Amount")->AsFloat = 94.43;
    $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
    $lDetail->Post();
	
    #For With Item Code
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 3;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    #$lDetail->FindField("Account")->AsString = "500-000"; #If you wanted override the Sales Account Code
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->FindField("Qty")->AsFloat = 2;
    #$lDetail->FindField("DISC")->AsString = "5%+3"; #Optional(eg 5% plus 3 Discount)
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 100;
    $lDetail->FindField("Amount")->AsFloat = 200;
    $lDetail->FindField("TaxAmt")->AsFloat = 12;
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();	
}

function PostDataPM(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("AR_PM");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
	
    $BizObject->New();
    $lMain->FindField("DOCKEY")->Value = -1;
    $lMain->FindField("DocNo")->AsString = "--PM Test--";
    $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Payment for A/c";
    $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
    $lMain->FindField("ChequeNumber")->AsString = "";
    $lMain->FindField("BankCharge")->AsFloat = 0;
    $lMain->FindField("DocAmt")->AsFloat = 200.00;
    $lMain->FindField("Cancelled")->AsString = "F";

    #Knock Off IV  
    $V = array("IV", "--CS Test--");  #DocType, DocNo
    
    if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
        $lDetail->Edit();
        $lDetail->FindField("KOAmt")->AsFloat = 147.09; #Partial Knock off
        $lDetail->FindField("KnockOff")->AsString = "T";
        $lDetail->Post();
	}	
    $BizObject->Save();
    $BizObject->Close();
}

function PostDataCN(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("SL_CN");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--CN Test--";
    $lMain->FindField("DocDate")->value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001";
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
    $lMain->FindField("Address1")->AsString = "";
    $lMain->FindField("Address2")->AsString = "";
    $lMain->FindField("Address3")->AsString = "";
    $lMain->FindField("Address4")->AsString = "";
    $lMain->FindField("Phone1")->AsString = "";
    $lMain->FindField("Description")->AsString = "Sales Returned";
	
    #For With Item Code
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Description2")->AsString = "Product Spoil"; #Reason
    $lDetail->FindField("Remark1")->AsString = "--CS Test--";   #Invoice No
    $lDetail->FindField("Remark2")->AsString = "20 Apr 2020";   #Invoice Date
    $lDetail->FindField("Qty")->AsFloat = 1;
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("UnitPrice")->AsFloat = 100;
    $lDetail->FindField("Amount")->AsFloat = 100;
    $lDetail->FindField("TaxAmt")->AsFloat = 6;
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();	
}

function PostKnockIVCN(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("AR_CN");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff");
	
    #Find CN Number
    $lDocNo = "--CN Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
    $BizObject->Params->Find("DocKey")->AsString = $lDocKey;
	
	if ($lDocKey != null){
        $BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
        
        #Knock Off IV        
        $V = array("IV", "--CS Test--");  #DocType, DocNo
        
        if ($lDetail->Locate("DocType;DocNo", $V, False, False)){
            $lDetail->Edit();
            $lDetail->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
            $lDetail->FindField("KnockOff")->AsString = "T";
            $lDetail->Post();
		}
        $BizObject->Save();
        $BizObject->Close();		
	}
}

function PostDataCF(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("AR_CF");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsKnockOff"); #lDetail contains detail data
	
    $BizObject->New();
    $lMain->FindField("DOCKEY")->Value = -1;
    $lMain->FindField("DocNo")->AsString = "--CF Test--";
    $lMain->FindField("CODE")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("DocDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->Value = "04/23/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Payment for A/c";
    $lMain->FindField("PaymentMethod")->AsString = "320-000"; #Bank or Cash Account
    $lMain->FindField("ChequeNumber")->AsString = "";
    $lMain->FindField("BankCharge")->AsFloat = 0;
    $lMain->FindField("DocAmt")->AsFloat = 6;
    $lMain->FindField("Cancelled")->AsString = "F";

    #Knock Off CN 
    $V = array("CN", "--CN Test--");  #DocType, DocNo
    
    if ($lDetail->Locate("DocType;DocNo", $V, False, False)) {
        $lDetail->Edit();
        $lDetail->FindField("KOAmt")->AsFloat = 4; #Partial Knock off
        $lDetail->FindField("KnockOff")->AsString = "T";
        $lDetail->Post();
	}	
    $BizObject->Save();
    $BizObject->Close();
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Posting Cash Sales<br>";
        PostDataCS();
        echo date("d M Y h:i:s A")." - Posting Customer Payment<br>";
        PostDataPM();
        echo date("d M Y h:i:s A")." - Posting Sales Credit Note<br>";
        PostDataCN();
        echo date("d M Y h:i:s A")." - Posting Knock Off Sales Credit Note<br>";
        PostKnockIVCN();
        echo date("d M Y h:i:s A")." - Posting Customer Refund<br>";
        PostDataCF();
        echo date("d M Y h:i:s A")." - Posting Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Complete Post"/> 
    </form> 
</body>
</html>

Get Invoice Next Number

Get Invoice Next Number Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 May 2020<br>";
#This action to Get Next Number for Customer Invoice

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function GetData(){
	global $ComServer;
	
    $lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A 
	         INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY)
			 WHERE A.DOCTYPE='IV'
			 AND A.DESCRIPTION='Customer Invoice'
			 AND A.STATESET=1
			 ";
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
		$lDataSet->First();
        $fmt = $lDataSet->FindField('Format')->AsString();
        $NextNo = $lDataSet->FindField('NEXTNUMBER')->AsFloat();
		
        echo date("d M Y h:i:s A")." Format in SQLAcc : " . str_ireplace("d","s", $fmt)."<br>";
        $fmt= str_ireplace(".","'0", $fmt);
        echo date("d M Y h:i:s A")." Format in PHP : " . str_ireplace("d","s", $fmt)."<br>";
		echo date("d M Y h:i:s A")." Output in PHP : " .sprintf($fmt,$NextNo)."<br>";
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Doc Number"/> 
    </form> 
</body>
</html>

Add & Edit AR_Customer

Add & Edit AR_Customer Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 11 Jun 2020<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\\eStream\\SQLAccounting\\Share\\Default.DCF", #DCF File 
                      "ACC-0035.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
    $BizObject = $ComServer->BizObjects->Find("AR_Customer");
    $lMain = $BizObject->DataSets->Find("MainDataSet");
	$lDtl  = $BizObject->DataSets->Find("cdsBranch");
    
    $lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY");
	
	if ($lDocKey == null){
        $BizObject->New();
        $lMain->FindField("CODE")->value = "FAIRY";
        $lMain->FindField("CompanyName")->value = "FAIRY TAIL";
		
        $lDtl->Edit(); #For 1St Branch
        $lDtl->FindField("BranchName")->AsString  = "BILLING";
        $lDtl->FindField("Address1")->AsString    = "Address1";
        $lDtl->FindField("Address2")->AsString    = "Address2";
        $lDtl->FindField("Address3")->AsString    = "Address3";
        $lDtl->FindField("Address4")->AsString    = "Address4"; 
        $lDtl->FindField("Attention")->AsString   = "Attention"; 
        $lDtl->FindField("Phone1")->AsString      = "Phone1";
        $lDtl->FindField("Fax1")->AsString        = "Fax1";
        $lDtl->FindField("Email")->AsString       = "EmailAddress";
        $lDtl->Post();

        $lDtl->Append(); #For 2nd Branch
        $lDtl->FindField("BranchName")->AsString  = "Branch1";
        $lDtl->FindField("Address1")->AsString    = "DAddress1";
        $lDtl->FindField("Address2")->AsString    = "DAddress2";
        $lDtl->FindField("Address3")->AsString    = "DAddress3";
        $lDtl->FindField("Address4")->AsString    = "DAddress4";  
        $lDtl->FindField("Attention")->AsString   = "DAttention";  
        $lDtl->FindField("Phone1")->AsString      = "DPhone1";
        $lDtl->FindField("Fax1")->AsString        = "DFax1";
        $lDtl->FindField("Email")->AsString       = "DEmailAddress";
        $lDtl->Post();	
	} else{
        $BizObject->Params->Find("CODE")->Value = $lDocKey;
        $BizObject->Open();
        $BizObject->Edit();
        $lMain->FindField("CompanyName")->value = "FAIRY TAIL WIZARD";
		
		$r = $lDtl->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lDtl->First();
            $lDtl->Delete();
			$x++;
		}
		
        #Insert back with new Information
        $lDtl->Edit(); #For 1St Branch
        $lDtl->FindField("BranchName")->AsString  = "BILLING"; #Make sure this always same as b4 delete data
        $lDtl->FindField("Address1")->AsString    = "New Address1";
        $lDtl->FindField("Address2")->AsString    = "New Address2";
        $lDtl->FindField("Address3")->AsString    = "New Address3";
        $lDtl->FindField("Address4")->AsString    = "New Address4";  
        $lDtl->FindField("Attention")->AsString   = "New Attention";  
        $lDtl->FindField("Phone1")->AsString      = "New Phone1";
        $lDtl->FindField("Fax1")->AsString        = "New Fax1";
        $lDtl->FindField("Email")->AsString       = "New EmailAddress";
        $lDtl->Post();

        $lDtl->Append(); #For 2nd Branch
        $lDtl->FindField("BranchName")->AsString  = "Branch1"; #Make sure this always same as b4 delete data
        $lDtl->FindField("Address1")->AsString    = "New DAddress1";
        $lDtl->FindField("Address2")->AsString    = "New DAddress2";
        $lDtl->FindField("Address3")->AsString    = "New DAddress3";
        $lDtl->FindField("Address4")->AsString    = "New DAddress4"; 
        $lDtl->FindField("Attention")->AsString   = "New DAttention";  
        $lDtl->FindField("Phone1")->AsString      = "New DPhone1";
        $lDtl->FindField("Fax1")->AsString        = "New DFax1";
        $lDtl->FindField("Email")->AsString       = "New DEmailAddress";
        $lDtl->Post();	
	
	}
	try{
		$BizObject->Save();
		echo "Posting Done <br>";
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}
	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        PostData();
        echo date("d M Y h:i:s A") . " - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?>
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Add/Edit AR Customer"/> 
    </form> 
</body>
</html>

Get Stock List

Get Stock List Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 22 Jun 2020<br>";
#This action to Get Stock Item List

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function GetData(){
	global $ComServer;
	
    $lSQL = "SELECT A.*, B.UOM, B.RATE, B.REFCOST, B.REFPRICE, B.ISBASE FROM ST_ITEM A 
	         INNER JOIN ST_ITEM_UOM B ON (A.CODE=B.CODE) 
			 WHERE A.ISACTIVE='T'
			 ";
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
		$lDataSet->First();
		$fc = $lDataSet->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Stock list"/> 
    </form> 
</body>
</html>

AR_IV

AR_IV Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 24 Jun 2020<br>";
#This action to Post Customer Invoice

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0070.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("AR_IV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--IV Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("Description")->AsString = "Sales";
	
    #Insert Data - Detail
    #For Tax Inclusive = True with override Tax Amount
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("Account")->AsString = "500-000"; #Sales Account
    $lDetail->FindField("Description")->AsString = "Sales Item A";
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
    $lDetail->FindField("TaxAmt")->AsFloat = 24.63;

    $lDetail->DisableControls();
    $lDetail->FindField("TaxInclusive")->value = 1;
    $lDetail->EnableControls();    
    $lDetail->Post();
	
    #For Tax Inclusive = False with override Tax Amount
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("Account")->AsString = "500-000";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Tax")->AsString = "SV";
    $lDetail->FindField("TaxRate")->AsString = "6%";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 94.43;
    $lDetail->FindField("TaxAmt")->AsFloat = 5.66;
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
		PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Post Customer Invoice"/> 
    </form> 
</body>
</html>

Get Outstanding Invoice List

Get Outstanding Invoice List Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 24 Jun 2020<br>";
#This action to Get Outstanding Invoice List

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function GetData(){
	global $ComServer;
	
    $lSQL = "SELECT A.*, B.COMPANYNAME, (A.DOCAMT-A.PAYMENTAMT) OUTSTANDING  FROM AR_IV A
	         INNER JOIN AR_CUSTOMER B ON (A.CODE=B.CODE) 
			 WHERE (A.DOCAMT-A.PAYMENTAMT)<>0
			 AND CANCELLED='F'
			 ";
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
		$lDataSet->First();
		$fc = $lDataSet->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Outstanding Invoice List"/> 
    </form> 
</body>
</html>

Stock Month End - Weighted Average

Stock Month End - Weighted Average Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 01 Dec 2021<br>";


$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function GetData(){
	#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
	global $ComServer;
	
    $lSQL = "SELECT A.ItemCode, A.Location, A.Batch,  MAX(B.Seq) AS Seq, 2 AS CostingMethod
	         FROM ST_TR A INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) 
			 WHERE A.PostDate<='31 Jul 2020'
			 AND A.ITEMCODE='Adj_Voucher'
			 GROUP BY A.ItemCode, A.Location, A.Batch
			 ";
	
	$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
	
	$Seq = "";
	$lDataSet1->First();
	while (! $lDataSet1->Eof()){
		$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
		$lDataSet1->Next();
	}

    $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.UTDQty, B.UTDCost FROM ST_TR A
	         INNER JOIN ST_TR_WMA B ON (A.TRANSNO=B.TRANSNO) 
			 WHERE A.PostDate<='31 Jul 2020'
			 AND A.ITEMCODE='Adj_Voucher'
			 AND B.SEQ IN (".substr_replace($Seq ,"",-1).") 
			 AND B.UTDQty<>0 
			 ORDER BY A.ItemCode, A.Location, A.Batch
			 ";
		 
	$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);		 
			 
    if ($lDataSet2->RecordCount > 0) {
		$lDataSet2->First();
		$fc = $lDataSet2->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet2->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet2->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet2->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Month End - WA"/> 
    </form> 
</body>
</html>

Stock Month End - FIFO

Stock Month End - FIFO Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 16 Jul 2020<br>";
#This action to Get Outstanding Invoice List

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function GetData(){
	#Accuracy : 90% - Due to the figure is base on last run Costing in SQL Accounting
	global $ComServer;
	
    $lSQL = "SELECT  A.ItemCode, A.Location, A.Batch, MAX(B.Seq) AS Seq, 1 AS CostingMethod 
	         FROM ST_TR A INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO) 
			 WHERE A.PostDate<='31 Jul 2020'
			 AND A.ItemCode IN ('ANT', 'COVER', 'BOM')
			 GROUP BY A.ItemCode, A.Location, A.Batch
			 ";
	
	$lDataSet1 = $ComServer->DBManager->NewDataSet($lSQL);
	
	$Seq = "";
	$lDataSet1->First();
	while (! $lDataSet1->Eof()){
		$Seq = $Seq.$lDataSet1->FindField("SEQ")->AsString .",";
		$lDataSet1->Next();
	}

    $lSQL = "SELECT A.TRANSNO, A.ItemCode, A.Location, A.Batch, B.QTY, B.COST FROM ST_TR A 
	         INNER JOIN ST_TR_FIFO B ON (A.TRANSNO=B.TRANSNO) 
			 WHERE B.COSTTYPE='U' 
			 AND A.PostDate<='31 Jul 2020'
			 AND B.SEQ IN (".substr_replace($Seq ,"",-1).") 
			 AND A.ItemCode IN ('ANT1.0', 'COVER', 'BOM')
			 AND B.Qty<>0 
			 ORDER BY A.ItemCode, A.Location, A.Batch
			 ";
	 
	$lDataSet2 = $ComServer->DBManager->NewDataSet($lSQL);		 
			 
    if ($lDataSet2->RecordCount > 0) {
		$lDataSet2->First();
		$fc = $lDataSet2->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet2->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet2->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet2->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet2->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet2->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
	
	#FIFO Detail Key to link with $lDataSet2 & $lDataSet3 is TRANSNO
	$Seq = "";
	$lDataSet2->First();
	while (! $lDataSet2->Eof()){
		$Seq = $Seq.$lDataSet2->FindField("TRANSNO")->AsString .",";
		$lDataSet2->Next();
	}

    $lSQL = "SELECT  TransNo, Cost, SUM(Qty) AS Qty, MIN(CostSeq) AS Seq FROM ST_TR_FIFO 
	         WHERE CostType='B' 
			 AND TRANSNO IN (".substr_replace($Seq ,"",-1).") 
			 GROUP BY TransNo, Cost
			 ";
	 
	$lDataSet3 = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet3->RecordCount > 0) {
		$lDataSet3->First();
		$fc = $lDataSet3->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet3->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet3->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet3->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet3->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet3->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        #$ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Month End - FIFO"/> 
    </form> 
</body>
</html>

Add & Edit Stock Item

Add & Edit Stock Item Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 05 Aug 2020<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("ST_ITEM");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); 
    $lUOM  = $BizObject->DataSets->Find("cdsUOM"); 
	$lBarcode = $BizObject->DataSets->Find("cdsBarcode"); 
	
	$lDocKey = $BizObject->FindKeyByRef("CODE", "FAIRY-PHP");

	if ($lDocKey == null){
        $BizObject->New();
        $lMain->FindField("CODE")->AsString = "FAIRY-PHP";
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL";
        $lMain->FindField("STOCKGROUP")->AsString = "DEFAULT";
        $lMain->FindField("STOCKCONTROL")->AsString = "T";
        $lMain->FindField("ISACTIVE")->AsString = "T";

        $lUOM->Edit(); #For 1St UOM
        $lUOM->FindField("UOM")->AsString = "PCS";
        $lUOM->FindField("Rate")->AsFloat = 1;
        $lUOM->FindField("RefCost")->AsFloat = 10.2;
        $lUOM->FindField("RefPrice")->AsFloat = 25;
        $lUOM->Post();

        $lUOM->Append(); #For 2nd UOM
        $lUOM->FindField("UOM")->AsString = "CTN";
        $lUOM->FindField("Rate")->AsFloat = 12;
        $lUOM->FindField("RefCost")->AsFloat = 102;
        $lUOM->FindField("RefPrice")->AsFloat = 240;
        $lUOM->Post();

        $lBarcode->Append(); #For 1st UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "123456789";
		$lBarcode->FindField("UOM")->AsString = "PCS";
        $lBarcode->Post();
		
        $lBarcode->Append(); #For 2nd UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "987654321";
		$lBarcode->FindField("UOM")->AsString = "CTN";
        $lBarcode->Post();		
	} else{
        $BizObject->Params->Find("Dockey")->AsString = $lDocKey;
        $BizObject->Open();
        $BizObject->Edit();
        $lMain->FindField("DESCRIPTION")->AsString = "FAIRY TAIL WIZARD";
		
		$r = $lUOM->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lUOM->First();
            $lUOM->Delete();
			$x++;
		}
		
		$r = $lBarcode->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lBarcode->First();
            $lBarcode->Delete();
			$x++;
		}
		
        $lUOM->Append(); #For 1St UOM
        $lUOM->FindField("UOM")->AsString = "PCS"; #Make sure this always same as b4 delete data
        $lUOM->FindField("Rate")->AsFloat = 1; #Make sure this always same as b4 delete data
        $lUOM->FindField("RefCost")->AsFloat = 22.3;
        $lUOM->FindField("RefPrice")->AsFloat = 52;
        $lUOM->Post();

        $lUOM->Append(); #For 2nd UOM
        $lUOM->FindField("UOM")->AsString = "CTN"; #Make sure this always same as b4 delete data
        $lUOM->FindField("Rate")->AsFloat = 12; #Make sure this always same as b4 delete data
        $lUOM->FindField("RefCost")->AsFloat = 102.5;
        $lUOM->FindField("RefPrice")->AsFloat = 260.45;
        $lUOM->Post();	
		
        $lBarcode->Append(); #For 1st UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "456321789";
		$lBarcode->FindField("UOM")->AsString = "PCS";
        $lBarcode->Post();
		
        $lBarcode->Append(); #For 2nd UOM Barcode
        $lBarcode->FindField("BARCODE")->AsString = "321456987";
		$lBarcode->FindField("UOM")->AsString = "CTN";
        $lBarcode->Post();			
	}
	
	try{
        $BizObject->Save();
        $BizObject->Close();
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }	
}


if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting Stock Item<br>";
        PostData();
		echo date("d M Y h:i:s A")." - Done<br>";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Add & Edit Stock Item"/> 
    </form> 
</body>
</html>

Add Stock Issue

Add Stock Issue Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 21 Oct 2020<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function CheckLogin1()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("ST_IS");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); 
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); 
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--IS Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Issue";
	
    #Insert Data - Detail	
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("UOM")->AsString = "BOX";
    $lDetail->Post();

    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("ItemCode")->AsString = "N-CHARGER";
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER";
    $lDetail->FindField("Qty")->AsFloat = 5;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();
	
	try{
        $BizObject->Save();
        $BizObject->Close();
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }	
}


if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin1();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostData();
		echo date("d M Y h:i:s A")." - Done<br>";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Add Stock Issue"/> 
    </form> 
</body>
</html>

Add Points

Add Points Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 30 Oct 2020<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("Sales.Points.OPF");
    $lMain = $BizObject->DataSets->Find("Main"); #lMain contains master data
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--Point Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("CompanyName")->AsString = "Cash Sales";
	$lMain->FindField("DESCRIPTION")->AsString = "Points Earn";
    $lMain->FindField("FromDocType")->AsString = "CS";
	$lMain->FindField("FromDocNo")->AsString = "CS-01234";
	$lMain->FindField("FROMDOCAMT")->AsFloat = 100.10;
	$lMain->FindField("Points")->AsFloat = 10;
	
	try{
		$BizObject->Save();
	}catch (Exception $e) {
		echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}


if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Posting Point<br>";
        PostData();
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Post Point"/> 
    </form> 
</body>
</html>

AR_CN

AR_CN Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 12 Dec 2020<br>";
#This action to Post Customer Credit Note

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0040.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("AR_CN");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	$lKO = $BizObject->DataSets->Find("cdsKnockOff");
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--CN Test1--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
    $lMain->FindField("Description")->AsString = "Sales";
	
    #Insert Data - Detail
    #For Tax Inclusive = True with override Tax Amount
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("Account")->AsString = "510-000"; #Sales Return Account
    $lDetail->FindField("Description")->AsString = "Return Item A";
    $lDetail->FindField("Tax")->AsString = "";
    $lDetail->FindField("TaxRate")->AsString = "";
    $lDetail->FindField("TaxInclusive")->value = 0;
    $lDetail->FindField("Amount")->AsFloat = 410.37; #Exclding GST Amt
    $lDetail->FindField("TaxAmt")->AsFloat = 0;
	$lDetail->Post();

    $V = array("IV", "IV-00003");  #DocType, DocNo
        
    if ($lKO->Locate("DocType;DocNo", $V, False, False)){
        $lKO->Edit();
        $lKO->FindField("KOAmt")->AsFloat = 100; #Partial Knock off
        $lKO->FindField("KnockOff")->AsString = "T";
        $lKO->Post();
	}	
    $BizObject->Save();
    $BizObject->Close();	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
		PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Post Customer Credit Note"/> 
    </form> 
</body>
</html>

SO to DO

SO to DO Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 15 Jan 2021<br>";
#This action to 
#01. Get Oustanding SO
#02. Post To DO

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
    $lSQL = "SELECT Dockey, DocNo,Code, CompanyName, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount, 
             COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM (
             SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName,
             B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount, 
             C.Qty XFQty FROM SL_SO A
             INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY)
             LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY
                                       AND C.FROMDOCTYPE='SO')
             WHERE A.DOCNO='SO-00140')
             GROUP BY Dockey, DocNo, Code, CompanyName, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount
			 HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0
			 ";	
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL); #Get Oustanding SO Qty

    if ($lDataSet->RecordCount > 0) {
		$BizObject = $ComServer->BizObjects->Find("SL_DO");
        $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
        $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data	
		
		$lDataSet->First();
		$BizObject->New();
		$lMain->FindField("DocKey")->value = -1;
		$lMain->FindField("DocNo")->AsString = "--DO Test--";
		$lMain->FindField("DocDate")->value = "01/20/2021"; #MM/DD/YYYY
		$lMain->FindField("PostDate")->value = "01/20/2021"; #MM/DD/YYYY
		$lMain->FindField("Code")->AsString = $lDataSet->FindField("Code")->AsString;
		$lMain->FindField("CompanyName")->AsString = $lDataSet->FindField("CompanyName")->AsString;
		$lMain->FindField("Description")->AsString = "Delivery Order";		

		while (! $lDataSet->Eof()){
    		$lDetail->Append();
    		$lDetail->FindField("DtlKey")->value = -1;
    		$lDetail->FindField("DocKey")->value = -1;
    		$lDetail->FindField("ItemCode")->AsString = $lDataSet->FindField("ItemCode")->AsString;
    		$lDetail->FindField("UOM")->AsString = $lDataSet->FindField("UOM")->AsString;
		$lDetail->FindField("Qty")->AsFloat = $lDataSet->FindField("OSQty")->AsFloat;
    		$lDetail->FindField("DISC")->value = $lDataSet->FindField("DISC")->value;
    		$lDetail->FindField("Tax")->AsString = "";
    		$lDetail->FindField("TaxRate")->AsString = "";
    		$lDetail->FindField("TaxInclusive")->value = 0;
    		$lDetail->FindField("UnitPrice")->AsFloat = $lDataSet->FindField("UnitPrice")->AsFloat;
    		$lDetail->FindField("Amount")->AsFloat = $lDataSet->FindField("Amount")->AsFloat;
    		$lDetail->FindField("TaxAmt")->AsFloat = 0;
		$lDetail->FindField("FromDocType")->AsString = "SO";
		$lDetail->FindField("FromDockey")->AsFloat = $lDataSet->FindField("Dockey")->AsFloat;
		$lDetail->FindField("FromDtlkey")->AsFloat = $lDataSet->FindField("DtlKey")->AsFloat;
    		$lDetail->Post();
		$lDataSet->Next();

		}
        $BizObject->Save();
        $BizObject->Close();			
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
		PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Post SO to DO"/> 
    </form> 
</body>
</html>

ST_AJ

ST_AJ Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 08 Feb 2021<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0100.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("ST_AJ");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); 
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); 
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "--AJ Test--";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Adjustment";
	
    #Insert Data - Detail - Increase Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "ANTENA";
    $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("UOM")->AsString = "BOX";
    $lDetail->Post();
    #Insert Data - Detail - Reduce Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("ItemCode")->AsString = "N-CHARGER";
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER";
    $lDetail->FindField("Qty")->AsFloat = -5;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();
	
	try{
        $BizObject->Save();
        $BizObject->Close();
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
		PostData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Post ST_AJ"/> 
    </form> 
</body>
</html>

Get Stock Serial Number balance

Get Stock Serial Number Balance List Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 21 May 2021<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF",  #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0024.FDB"); #Database Name
    
}

function GetData(){
	global $ComServer;
	
    $lSQL = "SELECT ItemCode, Location, Batch, SerialNumber, SUM(Qty) Qty  FROM ST_TR_SN  
	         GROUP BY ItemCode, Location, Batch, SerialNumber 
			 HAVING SUM(Qty) > 0
			 ";
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
		$lDataSet->First();
		$fc = $lDataSet->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
		GetData();
        echo date("d M Y h:i:s A")." - Done";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get SN Balance"/> 
    </form> 
</body>
</html>

SL_IV-Add, Edit & Delete

Insert, Edit & Delete Invoice Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 14 Mar 2022<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0015.FDB"); #Database Name
    
}

function PostDataIV(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("SL_IV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    #Find IV Number
    $lDocNo = "--IV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
	    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("CompanyName")->AsString = "Cash Sales-Edited";
        $lMain->FindField("Address1")->AsString = ""; #Optional
        $lMain->FindField("Address2")->AsString = ""; #Optional
        $lMain->FindField("Address3")->AsString = ""; #Optional
        $lMain->FindField("Address4")->AsString = ""; #Optional
        $lMain->FindField("Phone1")->AsString = "";   #Optional
        $lMain->FindField("Description")->AsString = "Sales - Edited";

		$r = $lDetail->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lDetail->First();
            $lDetail->Delete();
			$x++;
		}
        $lDetail->Append();
        $lDetail->FindField("ItemCode")->AsString = "COVER";
        $lDetail->FindField("Description")->AsString = "Sales Item Cover";
	    $lDetail->FindField("UOM")->AsString = "UNIT";
        $lDetail->FindField("Qty")->AsFloat = 3;
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("UnitPrice")->AsFloat = 5.60;
        $lDetail->FindField("Amount")->AsFloat = 16.80;
        $lDetail->FindField("TaxAmt")->AsFloat = 0;
        $lDetail->Post();		
	} else {
      echo "New Invoice<br>";
	  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
	  $lMain->FindField("Code")->AsString = "300-C0001"; #Customer Account
	  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("CompanyName")->AsString = "Cash Sales";
      $lMain->FindField("Address1")->AsString = ""; #Optional
      $lMain->FindField("Address2")->AsString = ""; #Optional
      $lMain->FindField("Address3")->AsString = ""; #Optional
      $lMain->FindField("Address4")->AsString = ""; #Optional
      $lMain->FindField("Phone1")->AsString = "";   #Optional
      $lMain->FindField("Description")->AsString = "Sales";
	  #$lMain->FindField('DocAmt')->value = $Amt;
	
      $lDetail->Append();
      $lDetail->FindField("ItemCode")->AsString = "ANT";
      $lDetail->FindField("Description")->AsString = "Sales Item ANT";
	  $lDetail->FindField("UOM")->AsString = "UNIT";
      $lDetail->FindField("Qty")->AsFloat = 1;
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("UnitPrice")->AsFloat = 100;
      $lDetail->FindField("Amount")->AsFloat = 100;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();


      $lDetail->Append();
      $lDetail->FindField("ItemCode")->AsString = "BOM";
      $lDetail->FindField("Description")->AsString = "Sales Item BOM";
	  $lDetail->FindField("UOM")->AsString = "UNIT";
      $lDetail->FindField("Qty")->AsFloat = 2;
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("UnitPrice")->AsFloat = 150;
      $lDetail->FindField("Amount")->AsFloat = 300;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();
	}
    $BizObject->Save();
	
	echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();	
}

function PostDelIV(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("SL_IV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
	
    #Find IV Number
    $lDocNo = "--IV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Delete();
		echo date("d M Y h:i:s A")." - Record deleted<br>";
	} else {
		echo date("d M Y h:i:s A")." - Document Not Found<br>";
	}		
}
if (isset($_POST['BtnPost']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostDataIV();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

if (isset($_POST['BtnDel']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
        PostDelIV();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnPost"
                value="Post Sales IV"/> 
        <input type="submit" name="BtnDel"
                value="Post Delete IV"/>
    </form> 
</body>
</html>

GL_PV-Add, Edit & Delete

Insert, Edit & Delete Invoice Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 15 Mar 2022<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "D:\Happy\DB\Default.DCF", #"C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0015.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("GL_PV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    #Find PV Number
    $lDocNo = "--PV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
	    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("Description")->AsString = "Tenaga Malaysia - Edited";
		$lMain->FindField("PaymentMethod")->AsString = "310-001"; #GL Bank/Cash account code
		$lMain->FindField("CHEQUENUMBER")->AsString = "MBB 123456"; #Optional
		$lMain->FindField("Cancelled")->AsString = "F";

		$r = $lDetail->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lDetail->First();
            $lDetail->Delete();
			$x++;
		}
        $lDetail->Append();
        $lDetail->FindField("Code")->AsString = "907-000";
        $lDetail->FindField("Description")->AsString = "TNB Bill for Feb 2022 - Edited";
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("Amount")->AsFloat = 168.80;
        $lDetail->FindField("TaxAmt")->AsFloat = 0;
        $lDetail->Post();		
	} else {
      echo "New PV<br>";
	  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
	  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("Description")->AsString = "Tenaga Malaysia";
	  $lMain->FindField("PaymentMethod")->AsString = "310-001"; #GL Bank/Cash account code
	  $lMain->FindField("CHEQUENUMBER")->AsString = "MBB 123456"; #Optional
	  $lMain->FindField("Cancelled")->AsString = "F";
		
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "907-000"; #GL Account
      $lDetail->FindField("Description")->AsString = "TNB Bill for Jan 2022";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("Amount")->AsFloat = 100.80;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();

      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "907-000";
      $lDetail->FindField("Description")->AsString = "TNB Bill for Feb 2022";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("Amount")->AsFloat = 68.00;
      $lDetail->FindField("TaxAmt")->AsFloat = 0;
      $lDetail->Post();
	}
    $BizObject->Save();
	
	echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();	
}

function DelData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("GL_PV");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
	
    #Find PV Number
    $lDocNo = "--PV Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Delete();
		echo date("d M Y h:i:s A")." - Record deleted<br>";
	} else {
		echo date("d M Y h:i:s A")." - Document Not Found<br>";
	}		
}
if (isset($_POST['BtnPost']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostData();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

if (isset($_POST['BtnDel']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
        DelData();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnPost"
                value="Post GL PV"/> 
        <input type="submit" name="BtnDel"
                value="Delete PV"/>
    </form> 
</body>
</html>

GL_JE-Add, Edit & Delete

Insert, Edit & Delete Invoice Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 15 Mar 2022<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0015.FDB"); #Database Name
    
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("GL_JE");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); #lDetail contains detail data
	
    #Find JE Number
    $lDocNo = "--JE Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Edit();
        $lMain->Edit();
	    $lMain->FindField("DocDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("PostDate")->value = "02/20/2022"; #MM/DD/YYYY
        $lMain->FindField("Description")->AsString = "Credit Card Charges - Edited";
		$lMain->FindField("Cancelled")->AsString = "F";

		$r = $lDetail->RecordCount();
		$x = 1;
		while ($x <= $r ){
			$lDetail->First();
            $lDetail->Delete();
			$x++;
		}
        $lDetail->Append();
        $lDetail->FindField("Code")->AsString = "902-000";
        $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges - Edited";
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("LocalDR")->AsFloat = 78.88;
		$lDetail->FindField("DR")->AsFloat = 78.88; #If Wanted DR <> LocalDR
        $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
        $lDetail->Post();
		
        $lDetail->Append();
        $lDetail->FindField("Code")->AsString = "310-001";
        $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges - Edited";
        $lDetail->FindField("Tax")->AsString = "";
        $lDetail->FindField("TaxRate")->AsString = "";
        $lDetail->FindField("TaxInclusive")->value = 0;
        $lDetail->FindField("LocalCR")->AsFloat = 78.88;
		$lDetail->FindField("CR")->AsFloat = 78.88; #If Wanted CR <> LocalCR
        $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
        $lDetail->Post();			
	} else {
      echo "New JE<br>";
	  $BizObject->New();
      $lMain->FindField("DocKey")->value = -1;
      $lMain->FindField("DocNo")->AsString = $lDocNo;
	  $lMain->FindField("DocDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("PostDate")->value = "02/18/2022"; #MM/DD/YYYY
      $lMain->FindField("Description")->AsString = "Credit Card Charges";
	  $lMain->FindField("Cancelled")->AsString = "F";
		
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "902-000";
      $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("LocalDR")->AsFloat = 88.88;
	  $lDetail->FindField("DR")->AsFloat = 88.88; #If Wanted DR <> LocalDR
      $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
      $lDetail->Post();
		
      $lDetail->Append();
      $lDetail->FindField("Code")->AsString = "310-001";
      $lDetail->FindField("Description")->AsString = "MBB Credit Card Charges";
      $lDetail->FindField("Tax")->AsString = "";
      $lDetail->FindField("TaxRate")->AsString = "";
      $lDetail->FindField("TaxInclusive")->value = 0;
      $lDetail->FindField("LocalCR")->AsFloat = 88.88;
	  $lDetail->FindField("CR")->AsFloat = 88.88; #If Wanted CR <> LocalCR
      $lDetail->FindField("LocalTaxAmt")->AsFloat = 0;
      $lDetail->Post();
	}
    $BizObject->Save();
	
	echo date("d M Y h:i:s A")." - Posting Done<br>";
    $BizObject->Close();	
}

function DelData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("GL_JE");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); #lMain contains master data
	
    #Find JE Number
    $lDocNo = "--JE Test--";
    $lDocKey = $BizObject->FindKeyByRef("DocNo", $lDocNo);
	
	if ($lDocKey != null){
        echo "Dockey = ".$lDocKey."<br>";
		$BizObject->Params->Find("DocKey")->AsString = $lDocKey;
		$BizObject->Open();
        $BizObject->Delete();
		echo date("d M Y h:i:s A")." - Record deleted<br>";
	} else {
		echo date("d M Y h:i:s A")." - Document Not Found<br>";
	}		
}
if (isset($_POST['BtnPost']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Posting<br>";
        PostData();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

if (isset($_POST['BtnDel']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Begin Delete<br>";
        DelData();	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnPost"
                value="Post GL JE"/> 
        <input type="submit" name="BtnDel"
                value="Delete JE"/>
    </form> 
</body>
</html>

Get Outstanding SO List

Get Outstanding SO List Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 09 Jun 2022<br>";
$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp") or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0015.FDB"); #Database Name
    
}

function GetData(){
	global $ComServer;
	
    $lSQL = "SELECT Dockey, DocNo,Code, CompanyName, Seq, DtlKey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount, 
             COALESCE(Sum(XFQty),0) XFQty, COALESCE((Qty-Sum(XFQty)), Qty) OSQty FROM (
             SELECT A.Dockey, A.DocNo, A.Code, A.CompanyName,
             B.DtlKey, B.Seq, B.ItemCode, B.Qty, B.UOM, B.UnitPrice, B.Disc, B.Amount, 
             C.Qty XFQty FROM SL_SO A
             INNER JOIN SL_SODTL B ON (A.DOCKEY=B.DOCKEY)
             LEFT JOIN ST_XTRANS C ON (A.DOCKEY=C.FROMDOCKEY AND B.DTLKEY=C.FROMDTLKEY
                                       AND C.FROMDOCTYPE='SO')
             WHERE A.Cancelled='F')
             GROUP BY Dockey, DocNo, Code, CompanyName, Seq, Dtlkey, ItemCode, Qty, UOM, UnitPrice, Disc, Amount
             HAVING COALESCE((Qty-Sum(XFQty)), Qty) >0
			 ";
	
	$lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
		$lDataSet->First();
		$fc = $lDataSet->Fields->Count-1;
		echo "<table>";
		echo "<tr>";
		for ($x = 0; $x <= $fc; $x++) {
			#Insert Header
			echo "<td>".$lDataSet->Fields->Items($x)->FieldName()."</td>"; 
		}
		echo "</tr>";
		
		#Looping Dataset
		while (! $lDataSet->Eof()){
			echo "<tr>";
		    for ($x = 0; $x <= $fc; $x++) {
				$lFN = $lDataSet->Fields->Items($x)->FieldName();
			    echo "<td>".$lDataSet->FindField($lFN)->AsString()."</td>"; 
		    }
		    echo "</tr>";
			$lDataSet->Next();
		}	
		echo "</table>"."<br>";		
	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        echo date("d M Y h:i:s A")." - Get Data<br>";
        GetData();
		echo date("d M Y h:i:s A")." - Done<br>";
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Outstanding SO List"/> 
    </form> 
</body>
</html>

Get Stock Item Picture

Get Stock Item Picture Script
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 14 Sep 2022<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        $ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function GetData(){
    global $ComServer;
	
    $lSQL = "SELECT Picture FROM ST_ITEM 
             WHERE Code='ANT' ";
	
    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
	$lDataSet->First();
		
	$raw = $lDataSet->FindField('Picture')->Value();
	
        $b = [];
        foreach($raw as $p) {
            array_push($b, chr($p));
        }

	echo '<img src=data:image/*;base64,'.base64_encode(implode($b)).' alt="My Picture" style="width:128px;height:128px">';

	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
	echo "<br>";
        echo date("d M Y h:i:s A")." - Done";	
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get Item Picture"/> 
    </form> 
</body>
</html>

Customer.Aging.RO

Customer.Aging.RO Script
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/Grid.css" />
</head>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 26 Sep 2022<br>";

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        #$ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function SetGrid($DataSet){
	echo "<table>";
	echo "<tr>";	
    $DataSet->First();
	$fc = $DataSet->Fields->Count-1;
	for ($x = 0; $x <= $fc; $x++) {
		#Insert Header
		echo "<td>".$DataSet->Fields->Items($x)->FieldName()."</td>"; 
	}
	echo "</tr>";
		
	#Looping Dataset
	while (! $DataSet->Eof()){
		echo "<tr>";
	    for ($x = 0; $x <= $fc; $x++) {
			$lFN = $DataSet->Fields->Items($x)->FieldName();
		    echo "<td>".$DataSet->FindField($lFN)->AsString()."</td>"; 
	    }
	    echo "</tr>";
		$DataSet->Next();
	}
    echo "</table>"."<br>";		
}

function GetData(){
	global $ComServer;
	
    $lSQL = '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>
	         <FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>
             <FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>
             <FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>
             </FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>
             <ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>
             <ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>
             <ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>
             <ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>
             <ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>
             <ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>
             </ROWDATA></DATAPACKET>';
	
	$lRptVar = $ComServer->RptObjects->Find('Customer.Aging.RO');
	$lRptVar->Params->Find('ActualGroupBy')->AsString = 'Code;CompanyName'; #Fixed
#	$lRptVar->Params->Find('AgentData')->AsBlob               = ; #Not use if AllAgent is True
    $lRptVar->Params->Find('AgingData')->AsString           = $lSQL;
    $lRptVar->Params->Find('AgingDate')->AsDate             = '23 Sep 2022';
    $lRptVar->Params->Find('AgingOn')->AsString             = 'I'; #Fixed
    $lRptVar->Params->Find('AllAgent')->AsBoolean           = True;
    $lRptVar->Params->Find('AllArea')->AsBoolean            = True;
    $lRptVar->Params->Find('AllCompany')->AsBoolean         = True;
    $lRptVar->Params->Find('AllCompanyCategory')->AsBoolean = True;
    $lRptVar->Params->Find('AllControlAccount')->AsBoolean  = True;
    $lRptVar->Params->Find('AllCurrency')->AsBoolean        = True;
    $lRptVar->Params->Find('AllDocProject')->AsBoolean      = True;
#    $lRptVar->Params->Find('AreaData')->AsBlob            = ; #Not use if AllArea is True
#    $lRptVar->Params->Find('CompanyCategoryData')->AsBlob = ; #Not use if AllCompanyCategory is True
#    $lRptVar->Params->Find('CompanyData')->AsBlob         = ; #Not use if AllCompany is True
#    $lRptVar->Params->Find('ControlAccountData')->AsBlob  = ; #Not use if AllControlAccount is True
#    $lRptVar->Params->Find('CurrencyData')->AsBlob        = ; #Not use if AllCurrency is True
#    $lRptVar->Params->Find('DocProjectData')->AsBlob      = ; #Not use if AllDocProject is True
    $lRptVar->Params->Find('FilterPostDate')->AsBoolean      = True;
#    $lRptVar->Params->Find('GroupBy
    $lRptVar->Params->Find('IncludePDC')->AsBoolean         = False;
    $lRptVar->Params->Find('IncludeZeroBalance')->AsBoolean = False;
    $lRptVar->Params->Find('SortBy')->AsString              = 'Code;CompanyName';
    $lRptVar->Params->Find('DateTo')->AsDate                = '23 Sep 2022';
    $lRptVar->Params->Find('IncludeKnockedOffDetail')->AsBoolean = False;
	
	$lRptVar->CalculateReport();
	$lDataSetHdr = $lRptVar->DataSets->Find('cdsAgingHeader');
	$lDataSet = $lRptVar->DataSets->Find('cdsMain');
	$lDataSet2 = $lRptVar->DataSets->Find('cdsDocument');
	$lDataSetCO = $lRptVar->DataSets->Find('cdsCompany');

    if ($lDataSet->RecordCount > 0) {
		echo "Header"."<br>";	
		SetGrid($lDataSetHdr);
						
		echo "Main Data"."<br>";
		SetGrid($lDataSet);
		
		echo "Detail Invoice"."<br>";
		SetGrid($lDataSet2);

		echo "Company Information"."<br>";
		SetGrid($lDataSetCO);

	}else {
    echo "Record Not Found";
    }
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
		echo "<br>";
        echo date("d M Y h:i:s A")." - Done";	
    }
    finally
    {
        #$ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get AR Aging"/> 
    </form> 
</body>
</html>


Node JS

Module Require in Node JS
- Winax (Mandatory) -> npm install winax

Common

  • Common.js file for example code
Common Function
/* Updated 31 Jul 2023 */
var winax = require('C:\\node_js\\node_modules\\winax'); /* Path where you install winax */
var cp = require('child_process'); 

exports.KillApp = function KillApp(){
	cp.exec('start cmd.exe /C "taskkill /IM "SQLACC.exe" /F"');
}

exports.CreateSQLAccServer = function CreateSQLAccServer() {  
  var ComServer;
  ComServer = new winax.Object('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {           /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', /* UserName, Password */
	/* 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', */
	'D:\\Happy\\DB\\DEFAULT.DCF', /* DCF File */
	'ACC-0024.FDB'); /* FDB Name */
  }
  return ComServer;
}

exports.ShowResult = function ShowResult(ADataset){
  var fc, fn, fv, lresult;
  ADataset.First;
  while (!ADataset.Eof){
	  fc = ADataset.Fields.Count;
	  for (let i = 0; i < fc; i++) {
		  fn = ADataset.Fields.Items(i).FieldName;
          fv = ADataset.FindField(fn).AsString;
		  lresult =  "Index : "+ i + " FieldName : " + fn + " Value : " + fv;
		  console.log(lresult);
      }
	  console.log("====");
      ADataset.Next();	  
  }
}

exports.ShowMsg = function ShowMsgShowMsg(AMsg){
    try {
        var WSH = new winax.Object('WScript.Shell');
        WSH.popup(AMsg);
    } catch (e) {
        console.log(e);
    }	
}

Get Company Profile

Get Company Profile
/* Updated 22 Jul 2023 */
var Common = require('./Common'); 
var ComServer, lDataSet;

function GetData() {
  var lSQL;
  lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, ";
  lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, ";
  lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);  
  
  Common.ShowResult(lDataSet);
}

try{
	ComServer = Common.CreateSQLAccServer();
	GetData();
	ComServer.Logout();
} catch(e){
	console.error(e.message)
} finally {
	Common.KillApp();
}

Complete Post

Complete Post
/* Updated 22 Jul 2023 
This will doing following posting
01. Cash Sales
02. Sales Credit Note
03. Customer Payment With Knock off
04. Edit Credit Note Posted in Step 02 & Knock Off
05. Customer Refund to Knock off Credit Note
*/
var Common = require('./Common'); 
var ComServer;

function PostDataCS() {
  var BizObject, lMain, lDetail;
  BizObject = ComServer.BizObjects.Find('SL_CS') ;

  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */ 

  /*Begin Looping yr data*/
  /*Insert Data - Master*/ 
  BizObject.New();
  lMain.FindField('DocNo').AsString       = "--CS Test--";
  lMain.FindField('DocDate').value        = "20/12/2022";
  lMain.FindField('PostDate').value       = "20/12/2022";
  lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
  lMain.FindField('CompanyName').AsString = "Cash Sales"
  lMain.FindField('Address1').AsString    = ""; /*Optional*/
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
  lMain.FindField('Address4').AsString    = ""; /*Optional*/
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
  lMain.FindField('Description').AsString = "Sales";
  
  /*Insert Data - Detail*/
  /*For Tax Inclusive = True with override Tax Amount*/
  lDetail.Append();
  lDetail.FindField('Seq').value            = 1;
  lDetail.FindField('Account').AsString     = "500-000"; /*Sales Account*/
  lDetail.FindField('Description').AsString = "Sales Item A";
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('Tax').AsString         = "SV";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 435;
  lDetail.FindField('Amount').AsFloat       = 410.37; /*Exclding Tax Amt*/
  lDetail.FindField('TaxAmt').AsFloat       = 24.63;
  
  lDetail.DisableControls();
  lDetail.FindField('TaxInclusive').value   = 1;
  lDetail.EnableControls();
  
  lDetail.Post();
  
  /*For Tax Inclusive = False with override Tax Amount*/
  lDetail.Append();
  lDetail.FindField('Seq').value            = 2;
  lDetail.FindField('Account').AsString     = "500-000";
  lDetail.FindField('Description').AsString = "Sales Item B";
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('Tax').AsString         = "SV";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 94.43;
  lDetail.FindField('Amount').AsFloat       = 94.43;
  lDetail.FindField('TaxAmt').AsFloat       = 5.66;
  lDetail.Post();  
  
  /*For With Item Code*/
  lDetail.Append();
  lDetail.FindField('Seq').value            = 3;
  lDetail.FindField('ItemCode').AsString    = "ANT";
  lDetail.FindField('Description').AsString = "Sales Item B";
  /*lDetail.FindField('Account').AsString     = "500-000"; If you wanted override the Sales Account Code*/
  lDetail.FindField('Qty').AsFloat          = 2;
  lDetail.FindField('UOM').AsString         = "UNIT";
  /*lDetail.FindField('DISC').AsString        = "5%+3"; Optional (eg 5% plus 3 Discount)*/
  lDetail.FindField('Tax').AsString         = "SV";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 100;
  lDetail.FindField('Amount').AsFloat       = 200;
  lDetail.FindField('TaxAmt').AsFloat       = 12;
  lDetail.Post();
  
  /*Save Document*/
  BizObject.Save();
  BizObject.Close();  
}

function PostDataPM() {
  var BizObject, lMain, lDetail, v;
    
  BizObject = ComServer.BizObjects.Find('AR_PM') ;

  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
  
  BizObject.New();
  
  lMain.FindField('DocNo').AsString         = "--PM Test--";
  lMain.FindField('Code').AsString          = "300-C0001";
  lMain.FindField('DocDate').value          = "20/12/2022";
  lMain.FindField('PostDate').value         = "20/12/2022";
  lMain.FindField('Description').AsString   = "Payment for A/";
  lMain.FindField('PaymentMethod').AsString = "320-000"; /*Bank or Cash Account*/
  lMain.FindField('ChequeNumber').AsString  = "";
  lMain.FindField('BankCharge').AsFloat     = 0;
  lMain.FindField('DocAmt').AsFloat         = 200.00;
  lMain.FindField('Cancelled').AsString     = "F";
  
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType IV or DN*/
  v.SetItem(1, '--CS Test--'); /*Knock Off DocNo*/ 
  
  if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
      lDetail.Edit();
      lDetail.FindField('KOAmt').AsFloat     = "147.09";	/*Partial Knock Off*/	  
      lDetail.FindField('KnockOff').AsString = 'T';
      lDetail.Post();
	  }
    /* Save document */  
  BizObject.Save();
  BizObject.Close();
}

function PostDataCN() {
  var BizObject, lMain, lDetail;
  BizObject = ComServer.BizObjects.Find('SL_CN') ;

  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */ 

  /*Begin Looping yr data*/
  /*Insert Data - Master*/ 
  BizObject.New();
  lMain.FindField('DocNo').AsString       = "--CN Test--";
  lMain.FindField('DocDate').value        = "21/12/2022";
  lMain.FindField('PostDate').value       = "21/12/2022";
  lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
  lMain.FindField('CompanyName').AsString = "Cash Sales"
  lMain.FindField('Address1').AsString    = ""; /*Optional*/
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
  lMain.FindField('Address4').AsString    = ""; /*Optional*/
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
  lMain.FindField('Description').AsString = "Sales Returned";
  
  /*Insert Data - Detail*/  
  /*For With Item Code*/
  lDetail.Append();
  lDetail.FindField('Seq').value             = 1;
  lDetail.FindField('ItemCode').AsString     = "ANT";
  lDetail.FindField('Description').AsString  = "Sales Item B";
  lDetail.FindField('Description2').AsString = "Product Spoil"; /*Reason*/
  lDetail.FindField('Remark1').AsString      = "--IV Test--"; /*Invoice No*/
  lDetail.FindField('Remark2').AsString      = "20 Dec 2022"; /*Invoide Date*/
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('UOM').AsString         = "UNIT";
  lDetail.FindField('Tax').AsString         = "SV";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 100;
  lDetail.FindField('Amount').AsFloat       = 100;
  lDetail.FindField('TaxAmt').AsFloat       = 6;
  lDetail.Post();
  
  /*Save Document*/
  BizObject.Save();
  BizObject.Close();  
}

function PostKnockIVCN() {
  var BizObject, lMain, lDetail, v, lDocNo, lDocKey;
    
  BizObject = ComServer.BizObjects.Find('AR_CN') ;

  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
  
  /* Find CN Number */
  lDocNo = "--CN Test--"
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
  BizObject.Params.Find('DocKey').Value = lDocKey;
  
  if (lDocKey != null) {
	  BizObject.Open();
	  BizObject.Edit();
	  lMain.Edit();
	  
	  v = ComServer.CreateOleVariantArray(2);
	  v.SetItem(0, 'IV'); /*Knock Off DocType IV or DN*/
	  v.SetItem(1, '--CS Test--'); /*Knock Off DocNo*/ 
  
	  if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
		  lDetail.Edit();
	      lDetail.FindField('KOAmt').AsFloat     = "100";	/*Partial Knock Off*/	  
	      lDetail.FindField('KnockOff').AsString = 'T';
	      lDetail.Post();
	  }
    /* Save document */  
	  BizObject.Save();
	  BizObject.Close();
  }
}

function PostDataCF() {
  var BizObject, lMain, lDetail, v;
    
  BizObject = ComServer.BizObjects.Find('AR_CF') ;

  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsKnockOff'); /*lDetail contains detail data */
  
  BizObject.New();
  
  lMain.FindField('DocNo').AsString         = "--CF Test--";
  lMain.FindField('Code').AsString          = "300-C0001";
  lMain.FindField('DocDate').value          = "24/12/2022";
  lMain.FindField('PostDate').value         = "24/12/2022";
  lMain.FindField('Description').AsString   = "Payment for A/";
  lMain.FindField('PaymentMethod').AsString = "320-000"; /*Bank or Cash Account*/
  lMain.FindField('ChequeNumber').AsString  = "";
  lMain.FindField('BankCharge').AsFloat     = 0;
  lMain.FindField('DocAmt').AsFloat         = 6.00;
  lMain.FindField('Cancelled').AsString     = "F";
  
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'CN'); /*Knock Off DocType*/
  v.SetItem(1, '--CN Test--'); /*Knock Off DocNo*/ 
  
  if (lDetail.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){
      lDetail.Edit();
      lDetail.FindField('KOAmt').AsFloat     = "4";	/*Partial Knock Off*/	  
      lDetail.FindField('KnockOff').AsString = 'T';
      lDetail.Post();
	  }
    /* Save document */  
  BizObject.Save();
  BizObject.Close();
}

try{
	ComServer = Common.CreateSQLAccServer();
	console.log("Posting Cash Sales");
    PostDataCS();
    console.log("Posting Payment");
    PostDataPM();
    console.log("Posting Sales CN");
    PostDataCN();
    console.log("Posting Knock Off CN");
    PostKnockIVCN();
    console.log("Posting Customer Refund");
    PostDataCF();
    console.log("Done");
	ComServer.Logout();
} catch(e){
	console.error(e.message)
} finally {
	Common.KillApp();
}

Get Picture & Description3(Rich Text)

Get Picture & Description3(Rich Text) Script
/* Updated 31 Jul 2023 */
var Common = require('./Common'); 
var ComServer, lDataSet;
const fs = require('fs');

function saveImage(filename, data){
  var myBuffer = new Buffer.alloc(data.length);
  for (var i = 0; i < data.length; i++) {
      myBuffer[i] = data[i];
  }
  fs.writeFile(filename, myBuffer, function(err) {
      if(err) {
          console.log(err);
      } else {
          console.log("The Image file was saved!");
      }
  });
}

function ExpFile(AFName, AData){
	const FN = new console.Console(fs.createWriteStream(AFName));
    FN.log(AData);
}

function GetData() {
  var lSQL, txt, rtf;
  lSQL = "SELECT Description3, Picture FROM ST_ITEM ";
  lSQL = lSQL + "WHERE Code='ANT' ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);  
  
  lDataSet.First;
  rtf = lDataSet.FindField('Description3').AsString;
  console.log(rtf);
  
  ExpFile('./output.rtf', rtf);
  
  txt = ComServer.Utility.RichTextToPlainText(rtf);
  Common.ShowMsg(txt);
  /* console.log(txt); <= Not support Unicode */
  
  ExpFile('./output.txt', txt);  
  console.log('Done Export');
  
  saveImage("./Pic.jpg", lDataSet.FindField('Picture').Value);
}

try{
	ComServer = Common.CreateSQLAccServer();
	GetData();
	ComServer.Logout();
} catch(e){
	console.error(e.message)
} finally {
	Common.KillApp();
}

Get Stock Qty Balance

Get Picture & Description3(Rich Text) Script
/* Updated 18 Jan 2024 */
var Common = require('./Common'); 
var ComServer;

function GetListData() {
  var lSQL, lDataSet;
  lSQL = "SELECT  ItemCode, Location, Batch, Sum(Qty) Qty  FROM ST_TR   ";
  lSQL = lSQL + "WHERE PostDate<='31 Dec 2019' ";
  lSQL = lSQL + "AND ITEMCODE ='ANT' ";
  lSQL = lSQL + "GROUP BY ItemCode, Location, Batch ";
  
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);
  
  Common.ShowResult(lDataSet);
}

try{
	ComServer = Common.CreateSQLAccServer();
	GetListData();
	ComServer.Logout();
} catch(e){
	console.error(e.message)
} finally {
	Common.KillApp();
}


VB Script

Get Company Profile

Company Profile Script
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
Call GetCoInfo
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetCoInfo
Dim ComServer, RptObject, lDataSet
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO") 
 
 
  'Step 3: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsProfile")

  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
	MsgBox "Company Name : " & lDataSet.FindField("CompanyName").AsString 
	
	MsgBox "Remark : " & lDataSet.FindField("Remark").AsString

	MsgBox "ROC No : " & lDataSet.FindField("RegisterNo").AsString

	MsgBox "GST No : " & lDataSet.FindField("GSTNo").AsString
	
	MsgBox "Address 1 : " & lDataSet.FindField("Address1").AsString
	
	MsgBox "Address 2 : " & lDataSet.FindField("Address2").AsString
	
	MsgBox "Address 3 : " & lDataSet.FindField("Address3").AsString
	
	MsgBox "Address 4 : " & lDataSet.FindField("Address4").AsString
	
	MsgBox "Attention : " & lDataSet.FindField("Attention").AsString
	
	MsgBox "Phone : " & lDataSet.FindField("Phone1").AsString
	
	MsgBox "Fax : " & lDataSet.FindField("Fax1").AsString
	
	MsgBox "E-Mail : " & lDataSet.FindField("EMail").AsString
	lDataSet.Next
  Wend

  'Step 6 : Logout after done  
  ComServer.Logout    
End Function

Complete Post

SL_CS, AR_PM, SL_CN & AR_CN Script
'Updated 13 Sep 2018
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
'This will doing following posting
'01. Cash Sales
'02. Sales Credit Note
'03. Customer Payment With Knock off
'04. Edit Credit Note Posted in Step 02 & Knock Off
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_CS") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--IV Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Sales"
    
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 1
  lDetail.FindField("Account").AsString     = "500-000" 'Sales Account
  lDetail.FindField("Description").AsString = "Sales Item A"
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 435
  lDetail.FindField("Amount").AsFloat       = 410.37 'Exclding GST Amt
  lDetail.FindField("TaxAmt").AsFloat       = 24.63
  
  lDetail.DisableControls
  lDetail.FindField("TaxInclusive").value   = 1
  lDetail.EnableControls
  
  lDetail.Post
  
  'For Tax Inclusive = False with override Tax Amount
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("Account").AsString     = "500-000"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 1
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 94.43
  lDetail.FindField("Amount").AsFloat       = 94.43
  lDetail.FindField("TaxAmt").AsFloat       = 5.66
  lDetail.Post

  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 3
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item B"
  'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString         = "UNIT"
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100  
  lDetail.FindField("Amount").AsFloat       = 200
  lDetail.FindField("TaxAmt").AsFloat       = 12
  lDetail.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  
  'Step 7: Payment
  Call InsertARPM
  
  'Step 8: Credit Note
  Call InsertSLCN
  'End Looping yr data

  'Step 9 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Done"  
End Function

Function InsertARPM
Dim BizObject, lMain, lDetail, lDate, v(1)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_PM") 
 
  'Step 3: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")   'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains detail data  
  
  'Step 4 : Posting
    lDate = CDate("January 23, 2017")
    BizObject.New
    lMain.FindField("DOCKEY").Value           = -1
    lMain.FindField("DocNo").AsString         = "--PM Test--" 
    lMain.FindField("CODE").AsString          = "300-C0001" 'Customer Account
    lMain.FindField("DocDate").Value          = lDate
    lMain.FindField("PostDate").Value         = lDate
    lMain.FindField("Description").AsString   = "Payment for A/c"
    lMain.FindField("PaymentMethod").AsString = "320-000" 'Bank or Cash Account
	lMain.FindField("ChequeNumber").AsString  = ""
	lMain.FindField("BankCharge").AsFloat     = 0
    lMain.FindField("DocAmt").AsFloat         = 200.00
    lMain.FindField("Cancelled").AsString     = "F"
  'Step 5: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
	
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("KOAmt").AsFloat     = 147.09 'Partial Knock off
      lDetail.FindField("KnockOff").AsString = "T"
      lDetail.Post
	End IF  
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
End Function

Function InsertSLCN
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_CN") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 24, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--CN Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Code").AsString        = "300-C0001"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = ""
  lMain.FindField("Address2").AsString    = ""
  lMain.FindField("Address3").AsString    = ""
  lMain.FindField("Address4").AsString    = ""
  lMain.FindField("Phone1").AsString      = ""  
  lMain.FindField("Description").AsString = "Sales Returned"
    
  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value          = -1
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString     = "ANT"
  lDetail.FindField("Description").AsString  = "Sales Item B"
  lDetail.FindField("Description2").AsString = "Product Spoil" 'Reason
  lDetail.FindField("Remark1").AsString      = "--IV Test--"   'Invoice No
  lDetail.FindField("Remark2").AsString      = "01 Jan 2017"   'Invoice Date
  lDetail.FindField("Qty").AsFloat           = 1
  lDetail.FindField("Tax").AsString          = "SR"
  lDetail.FindField("TaxRate").AsString      = "6%"
  lDetail.FindField("TaxInclusive").value    = 0
  lDetail.FindField("UnitPrice").AsFloat     = 100
  lDetail.FindField("Amount").AsFloat        = 100
  lDetail.FindField("TaxAmt").AsFloat        = 6  
  lDetail.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  
  'Step 7: Knock Off Invoice
  Call KnockIV
End Function

Function KnockIV
Dim BizObject, lMain, lDetail, lDate, v(1)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_CN") 
 
  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet") 'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsKnockOff") 'lDetail contains Knock off data  
  
  'Step 4 : Find CN Number
  lDocNo = "--CN Test--"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey
  
  If not IsNull(lDocKey) Then 
    BizObject.Open
    BizObject.Edit
    lMain.Edit
  'Step 5: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
	
    if (lDetail.Locate("DocType;DocNo", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("KOAmt").AsFloat     = 106 'Fully Knock off
      lDetail.FindField("KnockOff").AsString = "T"
      lDetail.Post
	End IF    
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
  END IF	
End Function

AR_IV

AR_IV Script
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call InsertARIV

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function InsertARIV
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate

  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF

  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_IV") 

  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2016")
  BizObject.New
  lMainDataSet.FindField("DocKey").value = -1
  lMainDataSet.FindField("DocNo").value = "--IV Test--"
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Code").value = "300-A0003"
  lMainDataSet.FindField("Description").value = "Sales"
    
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "500-000"
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 410.37
  lDetailDataSet.FindField("TaxAmt").value = 24.63
  
  lDetailDataSet.DisableControls
  lDetailDataSet.FindField("TaxInclusive").value =  1
  lDetailDataSet.EnableControls
  
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
  
  'For Tax Inclusive = False with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "500-000"
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function

AR_IV-Edit

AR_IV Edit Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call CheckLogin
Call GetData
Call PostData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM AR_IV "
  lSQL = lSQL & "WHERE DocNo='IV-00002' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function PostData
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_IV") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Doc Number
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
  
  
    BizObject.Open
    BizObject.Edit
    lMain.Edit
	lMain.FindField("Description").AsString = "Sales - Edited" 
  
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
	  lDetail.Delete
    Wend
  'Step 6: Append Detail
  lDetail.Append  
  lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("Account").value = "500-000"
  lDetail.FindField("Description").value =  "Sales Item A - Edited"
  lDetail.FindField("Tax").value =  "SR"
  lDetail.FindField("TaxRate").value =  "6%"
  lDetail.FindField("TaxInclusive").value =  0
  lDetail.FindField("Amount").value = 100
  lDetail.FindField("TaxAmt").value = 6
  
  lDetail.DisableControls
  lDetail.FindField("TaxInclusive").value =  1
  lDetail.EnableControls
  
  lDetail.FindField("Changed").value = "F"
  lDetail.Post
  
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
    'ComServer.Logout  
    MsgBox "Done" 
	Else
	MsgBox "Record Not Found" 
  END IF 
End Function

AR_PM

AR_PM Script
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
Call PostData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function PostData
Dim ComServer, BizObject, lIVNo, v(1), lDate
 
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF
 
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_PM") 
 
  'Step 3: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data  
  
  'Step 4 : Posting
    lDate = CDate("January 23, 2017")
    BizObject.New
    lMain.FindField("DOCKEY").Value           = -1
    lMain.FindField("DocNo").AsString         = "--PM Test--" 
    lMain.FindField("CODE").AsString          = "300-C0001"
    lMain.FindField("DocDate").Value          = lDate
    lMain.FindField("PostDate").Value         = lDate
    lMain.FindField("Description").AsString   = "Payment for A/c"
    lMain.FindField("PaymentMethod").AsString = "310-000"
    lMain.FindField("DocAmt").AsFloat         = 65.57
    lMain.FindField("Cancelled").AsString     = "F"
  'Step 5: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
	
    if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
      lDetailDataSet.Edit
      lDetailDataSet.FindField("KOAmt").value = 65.57
      lDetailDataSet.FindField("KnockOff").AsString = "T"
      lDetailDataSet.Post
	End IF  
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  'END IF
End Function

AR_PM-Edit

AR_PM Edit Script
'Copy below script & paste to notepad & name it as eg AR_IV.vbs
Call EditARPM
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function EditARPM
Dim ComServer, BizObject, lDataSet, lDataSet2, lDocKey, lDocNo, lIVNo, v(1)
 
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF
 
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_PM") 
 
  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsKnockOff") 'lDetailDataSet contains detail data  
  
  'Step 4 : Find OR Number
  lDocNo = "OR-00022"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey
  
  If not IsNull(lDocKey) Then 
    BizObject.Open
    BizObject.Edit
    lMainDataSet.Edit
	lMainDataSet.FindField("Description").AsString = "testing"
  'Step 5: Knock Off IV
    lIVNO = "IV-00006"
    v(0) = "IV"
    v(1) = lIVNO
	
    if (lDetailDataSet.Locate("DocType;DocNo", v, false, false)) then
      lDetailDataSet.Edit
      lDetailDataSet.FindField("KOAmt").value = 50.12
      lDetailDataSet.FindField("KnockOff").AsString = "T"
      lDetailDataSet.Post
	  MsgBox "yes"
	End IF  
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF
End Function

Customer.RO

Customer.RO Report Object Script
'Copy below script & paste to notepad & name it as eg customer_ro.vbs
Call GetCustomerData

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function GetCustomerData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF

  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.RO") 

  'Step 3: Spool parameters
  RptObject.Params.Find("AllAgent").Value = true
  RptObject.Params.Find("AllArea").Value = true
  RptObject.Params.Find("AllCompany").Value = false
  RptObject.Params.Find("AllCompanyCategory").Value = true
  RptObject.Params.Find("AllCurrency").Value = true
  RptObject.Params.Find("AllTerms").Value = true
  RptObject.Params.Find("SelectDate").Value = true
  RptObject.Params.Find("PrintActive").Value = true
  RptObject.Params.Find("PrintInactive").Value = false
  RptObject.Params.Find("PrintPending").Value = false
  RptObject.Params.Find("PrintProspect").Value = false
  RptObject.Params.Find("PrintSuspend").Value = false
  lDateFrom = CDate("January 1, 2000")
  lDateTo = CDate("December 31, 2014")

  RptObject.Params.Find("DateFrom").Value = lDateFrom
  RptObject.Params.Find("DateTo").Value = lDateTo
  RptObject.Params.Find("CompanyData").Value = "300-A0003"
  
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsBranch")
  MsgBox "Count " & lDataSet.RecordCount

  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("Address1").AsString
	  lDataSet2.Next
    Wend
	lDataSet.Next
  Wend
End Function

Customer.Statement.RO

Customer.Statement.RO Report Object Script
'Copy below script & paste to notepad & name it as eg customer_statement_ro.vbs
Call GetCustStatementData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function GetCustStatementData
Const Quote = """"
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF

  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.Statement.RO") 
 
  'Step 3: Spool parameters
  lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
       "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
       "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
       "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
       "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
       "</ROWDATA></DATAPACKET>"
'  RptObject.Params.Find("AgentData").Value            =  'Not use if AllAgent is True
  RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed
  RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
  RptObject.Params.Find("AllAgent").Value             = true
  RptObject.Params.Find("AllArea").Value              = true
  RptObject.Params.Find("AllCompany").Value           = false
  RptObject.Params.Find("AllCompanyCategory").Value   = true
  RptObject.Params.Find("AllControlAccount").Value    = true
  RptObject.Params.Find("AllCurrency").Value          = true
  RptObject.Params.Find("AllDocProject").Value        = true
'  RptObject.Params.Find("AreaData").Value             =  'Not use if AllArea is True
'  RptObject.Params.Find("CompanyCategoryData").Value  =  'Not use if AllCompanyCategory is True
  RptObject.Params.Find("CompanyData").Value          = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
'  RptObject.Params.Find("ControlAccountData").Value   =  'Not use if AllControlAccount is True
'  RptObject.Params.Find("CurrencyData").Value         =  'Not use if AllCurrency is True
  lDateFrom = CDate("August 1, 2016")
  lDateTo = CDate("August 31, 2016")
  RptObject.Params.Find("DateFrom").Value             = lDateFrom
  RptObject.Params.Find("DateTo").Value               = lDateTo
'  RptObject.Params.Find("DocProjectData").Value       =  'Not use if AllDocProject is True
  RptObject.Params.Find("IncludeZeroBalance").Value   = false
  RptObject.Params.Find("SelectDate").Value           = true
  RptObject.Params.Find("SortBy").Value               = "CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount"
  RptObject.Params.Find("StatementDate").Value        = lDateTo ' Norm same as DateTo
  RptObject.Params.Find("StatementType").Value        = "O" 'O = Open Item, B = B/F
 
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
  MsgBox "Count " & lDataSet.RecordCount

  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("Balance").AsString
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("DocNo").AsString
	  lDataSet2.Next
    Wend
	lDataSet.Next
  Wend
End Function

GL.CB.RO

GL.CB.RO Report Object Script
'Copy below script & paste to notepad & name it as eg GL.CB.RO.vbs
Call GetCLCBData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetCLCBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("GL.CB.RO") 
 
  'Step 3: Spool parameters
  RptObject.Params.Find("AllCurrency").Value    = true
  RptObject.Params.Find("AllDocProject").Value  = true
  RptObject.Params.Find("AllDocument").Value    = true
  RptObject.Params.Find("AllItemProject").Value = true
  RptObject.Params.Find("AllItemArea").Value    = true
  RptObject.Params.Find("AllItemAgent").Value   = true
  RptObject.Params.Find("AllDocAgent").Value    = true
  RptObject.Params.Find("AllDocArea").Value     = true
  RptObject.Params.Find("AllPaymentMethod").Value = false
  'RptObject.Params.Find("CurrencyData").Value    = 'Not use if AllCurrency is true
  
  lDateFrom = CDate("January 01, 2017")
  lDateTo = CDate("December 31, 2017")
 
  'For Post Date From & Date To'
  RptObject.Params.Find("DateFrom").Value = lDateFrom 
  RptObject.Params.Find("DateTo").Value   = lDateTo
  
  'RptObject.Params.Find("DocProjectData").Value  = 'Not use if AllDocProject is true
  'RptObject.Params.Find("DocAreaData").Value     = 'Not use if AllDocArea is true
  'RptObject.Params.Find("DocAgentData").Value    = 'Not use if AllDocAgent is true
  'RptObject.Params.Find("ItemAgentData").Value   = 'Not use if AllItemAgent is true
  RptObject.Params.Find("DocType").Value          = "PV" 'PV for Payment Voucher & OR for Official Receipt
  'RptObject.Params.Find("DocumentData").Value    = 'Not use if AllDocument is true
  'RptObject.Params.Find("GroupBy").Value         = 'If you wanted to grouping the data
  RptObject.Params.Find("IncludeCancelled").Value = false
  'RptObject.Params.Find("ItemAreaData").Value    = 'Not use if AllItemArea is true
  'RptObject.Params.Find("ItemProjectData").Value = 'Not use if AllItemProject is true
  RptObject.Params.Find("PaymentMethodData").Value  = "310-001"
  RptObject.Params.Find("PrintDocumentStyle").Value = false
  RptObject.Params.Find("SelectDate").Value         = true 'For Post Date
  'RptObject.Params.Find("SelectDocDate").Value     = 'For Doc Date
  RptObject.Params.Find("SortBy").Value             = "PostDate;DocNo" 
 
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
  Set lDataSet3 = RptObject.DataSets.Find("cdsTax")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
	  lDataSet2.Next
    Wend
	lDataSet.Next
  Wend
  'For GST List
  MsgBox "GST Code Count " & lDataSet3.RecordCount
  lDataSet3.First
  While (not lDataSet3.eof)
    MsgBox lDataSet3.FindField("Code").AsString
	lDataSet3.Next
  Wend
End Function

AR_Customer

AR_Customer - Script
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_Customer") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsBranch") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  BizObject.New
  lMain.FindField("Code").AsString       = "300-Test"
  lMain.FindField("CompanyName").AsString = "Cash Sales"
    
  'Step 5: Insert Data - Detail
  'For 1st Branch
  lDetail.Edit
  lDetail.FindField("BranchName").AsString  = "BILLING"
  lDetail.FindField("Address1").AsString    = "Address1"
  lDetail.FindField("Address2").AsString    = "Address2"
  lDetail.FindField("Address3").AsString    = "Address3"
  lDetail.FindField("Address4").AsString    = "Address4"  
  lDetail.FindField("Attention").AsString   = "Attention"  
  lDetail.FindField("Phone1").AsString      = "Phone1"
  lDetail.FindField("Fax1").AsString        = "Fax1"
  lDetail.FindField("Email").AsString       = "EmailAddress"
  lDetail.Post
  
  'For 2nd Branch
  lDetail.Append
  lDetail.FindField("BranchName").AsString  = "Branch1"
  lDetail.FindField("Address1").AsString    = "DAddress1"
  lDetail.FindField("Address2").AsString    = "DAddress2"
  lDetail.FindField("Address3").AsString    = "DAddress3"
  lDetail.FindField("Address4").AsString    = "DAddress4"  
  lDetail.FindField("Attention").AsString   = "DAttention"  
  lDetail.FindField("Phone1").AsString      = "DPhone1"
  lDetail.FindField("Fax1").AsString        = "DFax1"
  lDetail.FindField("Email").AsString       = "DEmailAddress"
  lDetail.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
 
  'End Looping yr data

  'Step 7 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Done"  
End Function

AR_Customer-Edit

AR_Customer - Edit Script
'Copy below script & paste to notepad & name it as eg AR_Customer.vbs
Call EditARCustomer
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function EditARCustomer
Dim ComServer, BizObject, lDataSet, lDataSet2
 
  'Step 1 Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF
 
  'Step 2 Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_Customer") 
 
  'Step 3 Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet") 'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsBranch") 'lDetailDataSet contains detail data  
  
  'Step 4 Find Customer Code
  BizObject.Params.Find("Code").Value = "300-Test"
  
  BizObject.Open
  BizObject.Edit
  lMainDataSet.Edit
  lMainDataSet.FindField("CompanyName").value = "Testing 123-Changed"
 
  'Step 5 For 1st Branch
    v = "BILLING"
 
    if (lDetailDataSet.Locate("BranchName", v, false, false)) then
	  lDetailDataSet.Edit 
      lDetailDataSet.FindField("Address1").AsString   = "Address1-Changed"
      lDetailDataSet.FindField("Address2").AsString   = "Address2-Changed"
      lDetailDataSet.FindField("Address3").AsString   = "Address3-Changed"
      lDetailDataSet.FindField("Address4").AsString   = "Address4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "Attention-Changed"
      lDetailDataSet.FindField("Phone1").AsString     = "Phone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString       = "Fax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "EmailAddress-Changed"
      lDetailDataSet.Post
	end if
 'Step 5 For 2nd Branch
    v = "Branch1"
 
    if (lDetailDataSet.Locate("BranchName", v, false, false)) then 
      lDetailDataSet.Edit
      lDetailDataSet.FindField("Address1").AsString   = "DAddress1-Changed"
      lDetailDataSet.FindField("Address2").AsString   = "DAddress2-Changed"
      lDetailDataSet.FindField("Address3").AsString   = "DAddress3-Changed"
      lDetailDataSet.FindField("Address4").AsString   = "DAddress4-Changed"
      lDetailDataSet.FindField("Attention").AsString  = "DAttention-Changed"
      lDetailDataSet.FindField("Phone1").AsString     = "DPhone1-Changed"
      lDetailDataSet.FindField("Fax1").AsString       = "DFax1-Changed"
      lDetailDataSet.FindField("Email").AsString      = "DEmailAddress-Changed"
      lDetailDataSet.Post  
   end IF 
  'Step 6 Save Customer
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function

GL.TrialBalance.RO

GL Trial Balance Report Object Script
'Copy below script & paste to notepad & name it as eg GL.TrialBalance.RO.vbs
Call GetGLTBData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetGLTBData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("GL.TrialBalance.RO") 
 
  'Step 3: Spool parameters
  RptObject.Params.Find("AllProject").Value      = true
  RptObject.Params.Find("AllAgent").Value        = true
  RptObject.Params.Find("AllArea").Value         = true
  RptObject.Params.Find("LedgerType").Value      = "G" 'G = Legder, S = Debtor, P = Supplier
  'RptObject.Params.Find("ProjectData").Value    = 'Not use if AllArea is true
  RptObject.Params.Find("ShowZeroBalance").Value = false
  RptObject.Params.Find("SortBy").Value          = "PostDate;DocNo" 
  RptObject.Params.Find("UseDescription2").Value = false
   
  lDateFrom = CDate("October 27, 2016")
  lDateTo = CDate("December 31, 2016")
 
  'For Post Date From & Date To'
  RptObject.Params.Find("DateFrom").Value       = lDateFrom 
  RptObject.Params.Find("DateTo").Value         = lDateTo

  'RptObject.Params.Find("AgentData").Value      = 'Not use if AllAgent is true
  'RptObject.Params.Find("AreaData").Value       = 'Not use if AllArea is true
  
  RptObject.Params.Find("SortBy").Value          = "Code;Description" 
 
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsGLAccount")

  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "Month To Date"
	MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("MTDDR").AsString & " CR=>" &	lDataSet.FindField("MTDCR").AsString
	
	MsgBox "Year To Date"
	MsgBox lDataSet.FindField("Code").AsString & " DR=>" & lDataSet.FindField("YTDDR").AsString & " CR=>" &	lDataSet.FindField("YTDCR").AsString
	lDataSet.Next
  Wend
  
  'For Account List
  lDataSet2.First
  While (not lDataSet2.eof)
	MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
	lDataSet2.Next
  Wend
  
End Function

Customer.Aging.RO

Customer Aging Report Object Script
'Copy below script & paste to notepad & name it as eg customer_aging_ro.vbs
Call GetCustStatementData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function GetCustStatementData
Const Quote = """"
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo, lAgeData
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF

  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.Aging.RO") 
 
  'Step 3: Spool parameters
  lAgeData = "<?xml version=" & Quote & "1.0" & Quote & " standalone=" & Quote & "yes" & Quote & "?>  <DATAPACKET Version=" & Quote & "2.0" & Quote & "><METADATA><FIELDS>" &_
       "<FIELD attrname=" & Quote & "ColumnNo" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "ColumnType" & Quote & " fieldtype=" & Quote & "string" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
       "<FIELD attrname=" & Quote & "Param1" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/><FIELD attrname=" & Quote & "Param2" & Quote & " fieldtype=" & Quote & "i4" & Quote & " required=" & Quote & "true" & Quote & "/>" &_
       "<FIELD attrname=" & Quote & "IsLocal" & Quote & " fieldtype=" & Quote & "boolean" & Quote & "/><FIELD attrname=" & Quote & "HeaderScript" & Quote & " fieldtype=" & Quote & "bin.hex" & Quote & " SUBTYPE=" & Quote & "Text" & Quote & " WIDTH=" & Quote & "1" & Quote & "/>" &_
       "</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo=" & Quote & "0" & Quote & " ColumnType=" & Quote & "" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "1" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "0" & Quote & " Param2=" & Quote & "0" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "2" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-1" & Quote & " Param2=" & Quote & "-1" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "3" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-2" & Quote & " Param2=" & Quote & "-2" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "4" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-3" & Quote & " Param2=" & Quote & "-3" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "5" & Quote & " ColumnType=" & Quote & "A" & Quote & " Param1=" & Quote & "-4" & Quote & " Param2=" & Quote & "-4" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;" & Quote & "/>" &_
       "<ROW ColumnNo=" & Quote & "6" & Quote & " ColumnType=" & Quote & "B" & Quote & " Param1=" & Quote & "-999999" & Quote & " Param2=" & Quote & "-5" & Quote & " IsLocal=" & Quote & "FALSE" & Quote & " HeaderScript=" & Quote & "ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;" & Quote & "/>" &_
       "</ROWDATA></DATAPACKET>"
  RptObject.Params.Find("ActualGroupBy").Value         = "Code;CompanyName" 'Fixed
'  RptObject.Params.Find("AgentData").Value            =  'Not use if AllAgent is True
  RptObject.Params.Find("AgingData").Value            = lAgeData 'Fixed

  lDateTo = CDate("August 31, 2016")
  RptObject.Params.Find("AgingDate").Value            = lDateTo  

  RptObject.Params.Find("AgingOn").Value              = "I" 'Fixed
  RptObject.Params.Find("AllAgent").Value             = true
  RptObject.Params.Find("AllArea").Value              = true
  RptObject.Params.Find("AllCompany").Value           = false
  RptObject.Params.Find("AllCompanyCategory").Value   = true
  RptObject.Params.Find("AllControlAccount").Value    = true
  RptObject.Params.Find("AllCurrency").Value          = true
  RptObject.Params.Find("AllDocProject").Value        = true
'  RptObject.Params.Find("AreaData").Value             =  'Not use if AllArea is True
'  RptObject.Params.Find("CompanyCategoryData").Value  =  'Not use if AllCompanyCategory is True
  RptObject.Params.Find("CompanyData").Value          = "300-A0001"& vbCRLF & "300-C0001" 'Filter by Customer Code 300-A0001 & 300-C0001
'  RptObject.Params.Find("ControlAccountData").Value   =  'Not use if AllControlAccount is True
'  RptObject.Params.Find("CurrencyData").Value         =  'Not use if AllCurrency is True
'  RptObject.Params.Find("DocProjectData").Value       =  'Not use if AllDocProject is True
  RptObject.Params.Find("FilterPostDate").Value        = false
'  RptObject.Params.Find("GroupBy").Value               = 'Not use 
  RptObject.Params.Find("IncludePDC").Value        = false
  RptObject.Params.Find("IncludeZeroBalance").Value   = false
  RptObject.Params.Find("SortBy").Value               = "Code;CompanyName"
  RptObject.Params.Find("DateTo").Value               = lDateTo

 
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocument")
  MsgBox "Count " & lDataSet.RecordCount

  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("Code").AsString & " " & lDataSet.FindField("CompanyName").AsString & " " & lDataSet.FindField("C1").AsString
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("C1").AsString
	  lDataSet2.Next
    Wend
	lDataSet.Next
  Wend
End Function

GL.JE.RO

GL Journal Voucher Report Object Script
'Copy below script & paste to notepad & name it as eg GLJE_ro.vbs
Call GetCustomerData

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function GetCustomerData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF

  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("GL.JE.RO") 

  'Step 3: Spool parameters
  RptObject.Params.Find("AllCurrency").Value = true
  RptObject.Params.Find("AllDocProject").Value = true
  RptObject.Params.Find("AllDocument").Value = true
  RptObject.Params.Find("AllItemProject").Value = true
  RptObject.Params.Find("AllItemArea").Value = true
  RptObject.Params.Find("AllItemAgent").Value = true
  RptObject.Params.Find("AllDocAgent").Value = true
  RptObject.Params.Find("AllDocArea").Value = true
  RptObject.Params.Find("AllPaymentMethod").Value = true

  lDateFrom = CDate("December 1, 2017")
  lDateTo = CDate("December 31, 2017")

  RptObject.Params.Find("DateFrom").Value = lDateFrom
  RptObject.Params.Find("DocDateFrom").Value = lDateFrom
  RptObject.Params.Find("DateTo").Value = lDateTo
  RptObject.Params.Find("DocDateTo").Value = lDateTo
  RptObject.Params.Find("IncludeCancelled").Value = false
  RptObject.Params.Find("PrintDocumentStyle").Value = false
  RptObject.Params.Find("SelectDate").Value = true 'Post Date
  RptObject.Params.Find("SelectDocDate").Value = false 'Doc Date
  
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDetail")
  MsgBox "Count " & lDataSet.RecordCount

  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Description").AsString
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("Code").AsString & " " & lDataSet2.FindField("Description").AsString
	  lDataSet2.Next
    Wend
	lDataSet.Next
  Wend
End Function

SL_CS

SL_CS Script
'Copy below script & paste to notepad & name it as eg SL_CS.vbs
Call InsertData

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function InsertData
Dim ComServer, BizObject, lDate

  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF

  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_CS") 

  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2016")
  BizObject.New
  lMainDataSet.FindField("DocKey").value = -1
  lMainDataSet.FindField("DocNo").value = "--IV Test--"
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Code").value = "300-C0001" 'Customer Code
  lMainDataSet.FindField("Description").value = "Sales"
    
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "500-000" 'Sales Account Code  & can ignore if had itemcode
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
  lDetailDataSet.FindField("Qty").value =  1
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("UnitPrice").value = 410.37
  lDetailDataSet.FindField("Amount").value = 410.37
  lDetailDataSet.FindField("TaxAmt").value = 24.63
  
  lDetailDataSet.DisableControls
  lDetailDataSet.FindField("TaxInclusive").value =  1
  lDetailDataSet.EnableControls
  
  lDetailDataSet.Post
  
  'For Tax Inclusive = False with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "500-000"
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Qty").value =  1
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("UnitPrice").value = 94.43
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.Post

  'For With Item Code
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("ItemCode").value = "ANT"
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Qty").value =  2
  lDetailDataSet.FindField("Tax").value =  "SR"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("UnitPrice").value = 100
  lDetailDataSet.FindField("Amount").value = 200
  lDetailDataSet.FindField("TaxAmt").value = 12
  lDetailDataSet.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  ComServer.Logout
  MsgBox "Done"
End Function

Customer.PM.RO

Customer.PM.RO Script
'Copy below script & paste to notepad & name it as eg Customer.PM.RO.vbs
Call GetARPMData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetARPMData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.PM.RO") 
 
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value               = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value     = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("AllAgent").Value                = true
  RptObject.Params.Find("AllCompanyCategory").Value      = true
  RptObject.Params.Find("AllArea").Value                 = true
  RptObject.Params.Find("AllCompany").Value              = true
  RptObject.Params.Find("AllCurrency").Value             = true
  RptObject.Params.Find("AllDocument").Value             = false
  RptObject.Params.Find("AllPaymentMethod").Value        = true
  'RptObject.Params.Find("AreaData").Value                = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyData").Value             = 'Not use if AllCompany is true
  'RptObject.Params.Find("CurrencyData").Value            = 'Not use if AllCurrency is true

  lDateFrom = CDate("January 01, 2017")
  lDateTo = CDate("December 31, 2017")
  
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
  RptObject.Params.Find("DateTo").Value                  = lDateTo
  RptObject.Params.Find("DocumentData").Value            = "VCOR-00049"
  'RptObject.Params.Find("GroupBy").Value                 = 'If you wanted to grouping the data
  RptObject.Params.Find("IncludeCancelled").Value        = false
  'RptObject.Params.Find("PaymentMethodData").Value       = 'Not use if AllPaymentMethod is true
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
  RptObject.Params.Find("SelectDate").Value              = true
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = false
  RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
  RptObject.Params.Find("AllDocProject").Value           = true
  RptObject.Params.Find("AllItemProject").Value          = true
  'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
  'RptObject.Params.Find("ItemProjectData").Value         = 'Not use if AllItemProject is true  
  
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsKnockOff")
  Set lDataSet3 = RptObject.DataSets.Find("cdsKnockOffDetail")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
	MsgBox "cdsKnockOff Count " & lDataSet2.RecordCount
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("FromDocKey").AsString & " " & lDataSet2.FindField("DocNo").AsString & " " & lDataSet2.FindField("KOAmt").AsString
	  lDataSet2.Next
    Wend
    MsgBox "cdsKnockOffDetail Count " & lDataSet3.RecordCount
	lDataSet3.First
    While (not lDataSet3.eof)
      MsgBox lDataSet3.FindField("FromDocKey").AsString & " " & lDataSet3.FindField("DocNo").AsString & " " & lDataSet3.FindField("KOAmt").AsString
  	  lDataSet3.Next
    Wend	
	lDataSet.Next
  Wend
End Function

Sales.IV.RO

Sales.IV.RO Script
'Copy below script & paste to notepad & name it as eg Sales.IV.RO.vbs
Call GetSalesIVData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetSalesIVData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Sales.IV.RO") 
 
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  RptObject.Params.Find("AllAgent").Value               = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value             = false
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllDocument").Value            = true
  RptObject.Params.Find("AllItem").Value                = true
  RptObject.Params.Find("AllItemProject").Value         = true
  RptObject.Params.Find("AllLocation").Value            = true
  RptObject.Params.Find("AllStockGroup").Value          = true
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllBatch").Value               = true
  RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
  'RptObject.Params.Find("TariffData").Value             = 'Not use if TariffData is true - For Version 776 & above
  'RptObject.Params.Find("AreaData").Value               = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyCategoryData").Value    = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-C0001"
  'RptObject.Params.Find("CurrencyData").Value           = 'Not use if AllCurrency is true

  lDateFrom = CDate("January 01, 2017")
  lDateTo = CDate("December 31, 2017")
  
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
  RptObject.Params.Find("DateTo").Value                  = lDateTo
  'RptObject.Params.Find("DocProjectData").Value          = 'Not use if AllDocProject is true
  'RptObject.Params.Find("DocumentData").Value            = 'Not use if AllDocument is true
  'RptObject.Params.Find("GroupBy").Value                 = 'If you wanted to grouping the data
  'RptObject.Params.Find("CategoryData").Value            = 'Not use if HasCategory is false
  'RptObject.Params.Find("CategoryTpl").Value             = 'For Internal use only
  RptObject.Params.Find("IncludeCancelled").Value        = false
  RptObject.Params.Find("HasCategory").Value             = false
  'RptObject.Params.Find("ItemData").Value                = 'Not use if AllItem is true
  'RptObject.Params.Find("ItemProjectData").Value         = 'Not use if AllItemProject is true
  'RptObject.Params.Find("LocationData").Value            = 'Not use if AllLocation is true
  'RptObject.Params.Find("ItemCategoryData").Value        = 'For Internal use only
  'RptObject.Params.Find("BatchData").Value               = 'Not use if AllBatch is true
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
  RptObject.Params.Find("SelectDate").Value              = true
  RptObject.Params.Find("SortBy").Value                  = "PostDate;DocNo;Code"
  'RptObject.Params.Find("StockGroupData").Value          = 'Not use if AllStockGroup is true
  
  
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox lDataSet.FindField("DocKey").AsString & " " &  lDataSet.FindField("DocNo").AsString & " " & lDataSet.FindField("Code").AsString
	MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox lDataSet2.FindField("DocKey").AsString & " " & lDataSet2.FindField("ItemCode").AsString & " " & lDataSet2.FindField("Amount").AsString
	  lDataSet2.Next
    Wend	
	lDataSet.Next
  Wend
End Function

Customer.DueDocument.RO

Customer.DueDocument.RO Script
'Copy below script & paste to notepad & name it as eg Customer.DueDocument.RO.vbs
Call GetData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetData
Dim ComServer, RptObject, lDataSet, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.DueDocument.RO") 
 
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value              = 'Not use if AllAgent is true
  RptObject.Params.Find("AllAgent").Value               = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value             = false
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllItemProject").Value         = true
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyCategoryData").Value   = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("CompanyData").Value            = "300-A0003"
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("GroupBy").Value               = 'If you wanted to grouping the data
  'RptObject.Params.Find("ItemProjectData").Value       = 'Not use if AllItemProject is true
  RptObject.Params.Find("PrintContra").Value            = true
  RptObject.Params.Find("PrintCreditNote").Value        = true
  RptObject.Params.Find("PrintDebitNote").Value         = true
  RptObject.Params.Find("PrintInvoice").Value           = true
  RptObject.Params.Find("PrintOverDue").Value           = true
  RptObject.Params.Find("PrintUnDue").Value             = true
  RptObject.Params.Find("ShowForeignCurrency").Value    = true
  RptObject.Params.Find("ShowLocalCurrency").Value      = true
  RptObject.Params.Find("SortBy").Value                 = "PostDate;DocNo;Code"
  
  lDateTo = CDate("April 12, 2018")
  
  RptObject.Params.Find("DateTo").Value                 = lDateTo
  RptObject.Params.Find("IncludePDCheque").Value        = true  
    
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "Dockey " & lDataSet.FindField("DocKey").AsString 
	MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString 
	MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
	MsgBox "Outstanding " & lDataSet.FindField("Outstanding").AsString
	MsgBox "Code " & lDataSet.FindField("Code").AsString
	lDataSet.Next
  Wend
End Function

Customer.IV.RO

Customer.IV.RO Script
'Copy below script & paste to notepad & name it as eg Customer.IV.RO.vbs
Call GetData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Customer.IV.RO") 
 
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value             = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value   = 'Not use if AllCompanyCategory is true
  RptObject.Params.Find("AllAgent").Value               = true
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllArea").Value                = true
  RptObject.Params.Find("AllCompany").Value             = true
  RptObject.Params.Find("AllCurrency").Value            = true
  RptObject.Params.Find("AllDocument").Value            = false
  RptObject.Params.Find("AllPaymentMethod").Value       = true
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyData").Value           = 'Not use if AllCompany is true
  'RptObject.Params.Find("CurrencyData").Value          = 'Not use if AllCurrency is true
  
  lDateFrom = CDate("January 01, 2017")
  lDateTo = CDate("December 31, 2017")
  
  RptObject.Params.Find("DateFrom").Value                = lDateFrom
  RptObject.Params.Find("DateTo").Value                  = lDateTo
  RptObject.Params.Find("DocumentData").Value            =  "IV-00012"
  'RptObject.Params.Find("GroupBy").Value                = 'If you wanted to grouping the data
  RptObject.Params.Find("IncludeCancelled").Value        = true
  'RptObject.Params.Find("PaymentMethodData").Value      = 'Not use if AllPaymentMethod is true
  RptObject.Params.Find("PrintDocumentStyle").Value      = false
  RptObject.Params.Find("SelectDate").Value              = true
  RptObject.Params.Find("ShowUnappliedAmountOnly").Value = true
  RptObject.Params.Find("SortBy").Value                  = "DocDate;DocNo;Code"
  RptObject.Params.Find("AllDocProject").Value           = true
  RptObject.Params.Find("AllItemProject").Value          = true
  'RptObject.Params.Find("DocProjectData").Value         = 'Not use if AllDocProject is true
  'RptObject.Params.Find("ItemProjectData  ").Value      = 'Not use if AllItemProject is true
    
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsDocDetail")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
	MsgBox "DocAmt " & lDataSet.FindField("DocAmt").AsString
	MsgBox "PaymentAmt " & lDataSet.FindField("PaymentAmt").AsString
	
	MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
	lDataSet2.First
    While (not lDataSet2.eof)
	  MsgBox "Account " & lDataSet2.FindField("Account").AsString
	  MsgBox "Description " & lDataSet2.FindField("Description").AsString
	  MsgBox "Amount " & lDataSet2.FindField("Amount").AsString
	  lDataSet2.Next
    Wend	
	lDataSet.Next
  Wend
End Function

Sales.OutstandingSO.RO

Sales.OutstandingSO.RO Script
'Copy below script & paste to notepad & name it as eg Sales.OutstandingSO.RO.vbs
Call GetData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetData
Dim ComServer, RptObject, lDataSet, lDataSet2, lDataSet3, lDateFrom, lDateTo
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Sales.OutstandingSO.RO") 
 
  'Step 3: Spool parameters
  'RptObject.Params.Find("AgentData").Value            = 'Not use if AllAgent is true
  'RptObject.Params.Find("CompanyCategoryData").Value  = 'Not use if AllCompanyCategory is true
  'RptObject.Params.Find("LocationData").Value         = 'Not use if AllLocation is true
  'RptObject.Params.Find("StockGroupData").Value       = 'Not use if AllStockGroup is true
  RptObject.Params.Find("AllAgent").Value              = true
  RptObject.Params.Find("AllArea").Value               = true
  RptObject.Params.Find("AllCompany").Value            = true
  RptObject.Params.Find("AllDocument").Value           = false
  RptObject.Params.Find("AllItem").Value               = true
  RptObject.Params.Find("AllItemProject").Value        = true
  'RptObject.Params.Find("AreaData").Value              = 'Not use if AllArea is true
  'RptObject.Params.Find("CompanyData").Value           = 'Not use if AllCompany is true
  RptObject.Params.Find("AllTariff").Value              = true 'For Version 776 & above
  'RptObject.Params.Find("TariffData").Value             = 'Not use if TariffData is true - For Version 776 & above

  
  lDateFrom = CDate("January 01, 2017")
  lDateTo = CDate("December 31, 2017") 
  
  'RptObject.Params.Find("DateFrom").Value              = lDateFrom
  'RptObject.Params.Find("DateTo").Value                = lDateTo
  'RptObject.Params.Find("DeliveryDateFrom").Value      = lDateFrom
  'RptObject.Params.Find("DeliveryDateTo").Value        = lDateTo
  RptObject.Params.Find("DocumentData").Value           = "SO-00007"& vbCRLF & "SO-00009"
  'RptObject.Params.Find("GroupBy").Value               = 'If you wanted to grouping the data
  RptObject.Params.Find("IncludeCancelled").Value       = false
  'RptObject.Params.Find("ItemData").Value               = 'Not use if AllItem is true
  RptObject.Params.Find("PrintFulfilledItem").Value     = true 'Print transfered info
  RptObject.Params.Find("PrintOutstandingItem").Value   = true 'Print untransfer info
  'RptObject.Params.Find("ItemProjectData").Value       = 'Not use if AllItemProject is true
  RptObject.Params.Find("SelectDate").Value             = false
  RptObject.Params.Find("SelectDeliveryDate").Value     = false
  RptObject.Params.Find("SortBy").Value                 = "DocDate;DocNo;Code"
  RptObject.Params.Find("AllDocProject").Value          = true
  RptObject.Params.Find("AllLocation").Value            = true
  RptObject.Params.Find("AllCompanyCategory").Value     = true
  RptObject.Params.Find("AllBatch").Value               = true
  RptObject.Params.Find("HasCategory").Value            = false
  RptObject.Params.Find("AllStockGroup").Value          = true
  'RptObject.Params.Find("CategoryData").Value          = 'For Internal use only
  'RptObject.Params.Find("CategoryTpl").Value           = 'For Internal use only
  'RptObject.Params.Find("ItemCategoryData").Value      = 'For Internal use only
  'RptObject.Params.Find("DocProjectData").Value        = 'Not use if AllDocProject is true
  'RptObject.Params.Find("BatchData").Value             = 'Not use if AllBatch is true
  RptObject.Params.Find("TranferDocFilterDate").Value   = false
   
    
  'Step 4: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsTransfer")
  MsgBox "Count " & lDataSet.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocKey " & lDataSet.FindField("DocKey").AsString
	MsgBox "DtlKey " & lDataSet.FindField("Dtlkey").AsString
	MsgBox "DocNo " & lDataSet.FindField("DocNo").AsString
	MsgBox "Item Code " & lDataSet.FindField("ItemCode").AsString
	MsgBox "Org Qty " & lDataSet.FindField("SQty").AsString
	MsgBox "Outstanding Qty " & lDataSet.FindField("OutstandingQty").AsString
	
	MsgBox "cdsDocDetail Count " & lDataSet2.RecordCount
	lDataSet2.First
    While (not lDataSet2.eof)
      MsgBox "FromDocKey " & lDataSet2.FindField("FromDocKey").AsString
	  MsgBox "FromDtlKey " & lDataSet2.FindField("FromDtlkey").AsString
	  MsgBox "DocType " & lDataSet2.FindField("DocType").AsString
	  MsgBox "DocNo " & lDataSet2.FindField("DocNo").AsString
	  MsgBox "DocDate " & lDataSet2.FindField("DocDate").AsString
	  MsgBox "Transfer Qty " & lDataSet2.FindField("TransferQty").AsString
	  lDataSet2.Next
    Wend	
	lDataSet.Next
  Wend
End Function

Common.PaymentMethod.RO

Common.PaymentMethod.RO Script
'Copy below script & paste to notepad & name it as eg Common.PaymentMethod.RO.vbs
Call GetInfo
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetInfo
Dim ComServer, RptObject, lDataSet1, lDataSet2
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.PaymentMethod.RO") 
 
 
  'Step 3: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsPaymentAccount") 'You can link with lDataSet1 using Code to get the description

  MsgBox "Count " & lDataSet1.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet1.First
  While (not lDataSet1.eof)
	MsgBox "Code : " & lDataSet1.FindField("Code").AsString 
	lDataSet1.Next
  Wend    
  
  MsgBox "Count " & lDataSet2.RecordCount
  
  lDataSet2.First
  While (not lDataSet2.eof)
	MsgBox "Code : " & lDataSet2.FindField("Code").AsString 
	MsgBox "Description : " & lDataSet2.FindField("Description").AsString
	lDataSet2.Next
  Wend    
End Function

Common.Agent.RO

Common.Agent.RO Script
'Copy below script & paste to notepad & name it as eg Common.Agent.RO.vbs
Call GetInfo
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetInfo
Dim ComServer, RptObject, lDataSet1
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2: Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Common.Agent.RO") 
 
 
  'Step 3: Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  
  MsgBox "Count " & lDataSet1.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet1.First
  While (not lDataSet1.eof)
	MsgBox "Code : " & lDataSet1.FindField("Code").AsString 
	MsgBox "Description : " & lDataSet1.FindField("Description").AsString 
	lDataSet1.Next
  Wend      
End Function

Stock.Item.RO

Stock.Item.RO Script
'Copy below script & paste to notepad & name it as eg Stock.Item.RO.vbs
Call GetInfo
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function GetInfo
Dim ComServer, RptObject, lDataSet1, lDataSet2, lDateFrom, lDateTo
  'Step 1 Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C\DB\SQLAcc.DCF", "ACC-0002.FDB" 
  END IF
 
  'Step 2 Find and Create the Report Objects
  Set RptObject = ComServer.RptObjects.Find("Stock.Item.RO") 
 
  'Step 3 Spool parameters
    RptObject.Params.Find("AllItem").AsBoolean              = true
    RptObject.Params.Find("AllStockGroup").AsBoolean        = true
    RptObject.Params.Find("AllCustomerPriceTag").AsBoolean  = true
    RptObject.Params.Find("AllSupplierPriceTag").AsBoolean  = true
    'RptObject.Params.Find("CategoryData").AsBlob            =  'Not use
    'RptObject.Params.Find("CategoryTpl").AsBlob             =  'Not use
    'RptObject.Params.Find("CustomerPriceTagData").AsBlob    =  'Not use if AllCustomerPriceTag is True
    'RptObject.Params.Find("SupplierPriceTagData").AsBlob    =  'Not use if AllSupplierPriceTag is True
	
    lDateFrom = CDate("January 01, 2017")
    lDateTo = CDate("December 31, 2017")
  
    'RptObject.Params.Find("DateFrom").AsDate                = lDateFrom 'Not use if SelectDate is False
    'RptObject.Params.Find("DateTo").AsDate                  = lDateTo
    RptObject.Params.Find("HasAltStockItem").AsBoolean      = false
    RptObject.Params.Find("HasBarcode").AsBoolean           = false
    RptObject.Params.Find("HasBOM").AsBoolean               = false
    RptObject.Params.Find("HasCategory").AsBoolean          = false
    RptObject.Params.Find("HasCustomerItem").AsBoolean      = false
    RptObject.Params.Find("HasOpeningBalance").AsBoolean    = false
    RptObject.Params.Find("HasPurchasePrice").AsBoolean     = false
    RptObject.Params.Find("HasSellingPrice").AsBoolean      = false
    RptObject.Params.Find("HasSupplierItem").AsBoolean      = false
    'RptObject.Params.Find("ItemData").AsBlob                = 'Not use if AllItem is True
    'RptObject.Params.Find("ItemCategoryData").AsBlob        = 'Not use if SelectCategory is False
    RptObject.Params.Find("PrintActive").AsBoolean          = true
    RptObject.Params.Find("PrintInActive").AsBoolean        = true
    RptObject.Params.Find("PrintNonStockControl").AsBoolean = true
    RptObject.Params.Find("PrintStockControl").AsBoolean    = true
    RptObject.Params.Find("SelectCategory").AsBoolean       = false
    RptObject.Params.Find("SelectDate").AsBoolean           = false
    RptObject.Params.Find("SortBy").AsString                  = "Code"
    'RptObject.Params.Find("StockGroupData").AsBlob        =  'Not use if AllStockGroup is True  
    
  'Step 4 Perform Report calculation 
  RptObject.CalculateReport()
  Set lDataSet1 = RptObject.DataSets.Find("cdsMain")
  Set lDataSet2 = RptObject.DataSets.Find("cdsUOM") ' To link Master Data use Code
  MsgBox "Count " & lDataSet1.RecordCount
 
  'Step 5 Retrieve the output 
  lDataSet1.First
  While (not lDataSet1.eof)
    MsgBox "Code " & lDataSet1.FindField("Code").AsString 
    MsgBox "Description " & lDataSet1.FindField("Description").AsString 
    MsgBox "Balance Qty " & lDataSet1.FindField("BalSQty").AsString 
    lDataSet1.Next
  Wend

  MsgBox "Count " & lDataSet2.RecordCount
  lDataSet2.First
  While (not lDataSet2.eof)
    MsgBox "Code " & lDataSet2.FindField("Code").AsString 
	MsgBox "UOM " & lDataSet2.FindField("UOM").AsString 
	MsgBox "Rate " & lDataSet2.FindField("Rate").AsString 
	MsgBox "RefPrice " & lDataSet2.FindField("RefPrice").AsString
    lDataSet2.Next
  Wend	
End Function

Stock Item Balance

Get Stock Item Balance Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg ItemBalance.vbs
Call CheckLogin
Call GetData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lDataSet, lSQL
  lSQL = "SELECT A.Location, A.Batch, A.ItemCode, B.Description, Sum(A.Qty) Qty FROM ST_TR A "
  lSQL = lSQL & "INNER JOIN ST_ITEM B ON (A.ITEMCODE=B.CODE) " 
  lSQL = lSQL & "WHERE B.IsActive='T' "
  lSQL = lSQL & "AND A.PostDate <= '31 Dec 2017' "
  lSQL = lSQL & "AND A.ItemCode= 'ANT' "
  lSQL = lSQL & "GROUP by A.Location, A.Batch, A.ItemCode, B.Description"
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
  
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "Location : " & lDataSet.FindField("Location").AsString
    MsgBox "Batch : " & lDataSet.FindField("Batch").AsString
    MsgBox "Item Code : " & lDataSet.FindField("ItemCode").AsString
	MsgBox "Item Description : " & lDataSet.FindField("Description").AsString
	MsgBox "Balance Qty : " & lDataSet.FindField("Qty").AsString
	lDataSet.Next
  Wend
End Function

ST_IS

ST_IS Script
'Copy below script & paste to notepad & name it as eg StockIssue.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_IS") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--IS Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Description").AsString = "Stock Issue"
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Issue out Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Description").AsString = "Issue out Item A"
  lDetail.FindField("Qty").AsFloat          = 4
  lDetail.Post  
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
    
  ComServer.Logout 'Logout after done
  MsgBox "Done"  
End Function

ST_RC

ST_RC Script
'Copy below script & paste to notepad & name it as eg StockReceived.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_RC") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--RC Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Description").AsString = "Stock Received"
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Received Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UnitCost").AsFloat     = 25.15
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Description").AsString = "Received Item A"
  lDetail.FindField("Qty").AsFloat          = 4
  lDetail.FindField("UnitCost").AsFloat     = 54
  lDetail.Post  
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
    
  ComServer.Logout 'Logout after done
  MsgBox "Done"  
End Function

ST_AJ

ST_AJ Script
'Copy below script & paste to notepad & name it as eg StockAdjustment.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_AJ") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--AJ Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Description").AsString = "Stock Adjustment"
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Adjust IN Item A"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UnitCost").AsFloat     = 25.15 'Only IN need UnitCost
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("ItemCode").AsString    = "E-BAT"
  lDetail.FindField("Description").AsString = "Adjust OUT Item A"
  lDetail.FindField("Qty").AsFloat          = -4
  lDetail.Post  
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
    
  ComServer.Logout 'Logout after done
  MsgBox "Done"  
End Function

ST_XF

ST_XF Script
'Copy below script & paste to notepad & name it as eg ST_XF.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_XF") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--XF Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account - Optional
  lMain.FindField("CompanyName").AsString = "Cash Sales" 'Optional
  lMain.FindField("Description").AsString = "Stock Transfer"
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value          = -1
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString     = "ANT"
  lDetail.FindField("Description").AsString  = "Transfer Item A"
  lDetail.FindField("Qty").AsFloat           = 10
  lDetail.FindField("UOM").AsString          = "UNIT"
  lDetail.FindField("FromLocation").AsString = "----"
  lDetail.FindField("ToLocation").AsString   = "BALAKONG"
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value          = -1
  lDetail.FindField("DocKey").value          = -1
  lDetail.FindField("ItemCode").AsString     = "HFK"
  lDetail.FindField("Description").AsString  = "Transfer Item B"
  lDetail.FindField("Qty").AsFloat           = 5
  lDetail.FindField("UOM").AsString          = "UNIT"
  lDetail.FindField("FromLocation").AsString = "----"
  lDetail.FindField("ToLocation").AsString   = "BALAKONG"
  lDetail.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  
  'Step 7 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Done"  
End Function

AP_PI-Edit

AP_PI Edit Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg AP_PI.vbs
Call CheckLogin
Call GetData
Call PostData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM AP_PI "
  lSQL = lSQL & "WHERE DocNo='PI-00001' "
  lSQL = lSQL & "AND Code='400-D0001' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function PostData
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AP_PI") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Doc Number
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
  
  
    BizObject.Open
    BizObject.Edit
    lMain.Edit
	lMain.FindField("Description").AsString = "testing" 
  
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
	  lDetail.Delete
    Wend
  'Step 6: Append Detail
    lDetail.Append
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("Account").value = "610-2000"
    lDetail.FindField("Description").value =  "Purchase Item A"
    lDetail.FindField("Tax").value =  ""
    lDetail.FindField("TaxInclusive").value =  0
    lDetail.FindField("Amount").value = 410.37
    lDetail.FindField("TaxAmt").value = 0
    lDetail.Post
  
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
    'ComServer.Logout  
    MsgBox "Done" 
	Else
	MsgBox "Record Not Found" 
  END IF 
   
End Function

SL_DO to SL_IV

SL_DO to SL_IV Script
'Updated 26 Oct 2018
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call CheckLogin
Call InsertData1
Call InsertData2

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData1
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_DO") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2017")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "--DO Test--"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  'lMain.FindField("Address1").AsString    = "" 'Optional
  'lMain.FindField("Address2").AsString    = "" 'Optional
  'lMain.FindField("Address3").AsString    = "" 'Optional
  'lMain.FindField("Address4").AsString    = "" 'Optional
  'lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Delivery Order"
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item A"
  lDetail.FindField("UOM").AsString         = "BOX"
  lDetail.FindField("Qty").AsFloat          = 2
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100  
  lDetail.FindField("Amount").AsFloat       = 200
  lDetail.FindField("TaxAmt").AsFloat       = 12
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("ItemCode").AsString    = "COVER"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("UOM").AsString         = "UNIT"
  lDetail.FindField("Qty").AsFloat          = 3
  lDetail.FindField("Tax").AsString         = "SR"
  lDetail.FindField("TaxRate").AsString     = "6%"
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 10  
  lDetail.FindField("Amount").AsFloat       = 30
  lDetail.FindField("TaxAmt").AsFloat       = 1.80
  lDetail.Post  
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "DO Posting Done"  
End Function

Function InsertData2
Dim BizObject, lMain, lDetail, lDate, lDODtl, lxFer, lSQL, v(2)
  'Step 1: Check Is transtered or not
  lSQL = "SELECT DocKey FROM SL_IVDTL "
  lSQL = lSQL & "WHERE FromDockey=(SELECT DocKey FROM SL_DO " 
  lSQL = lSQL & "WHERE DocNo='--DO Test--') "
  Set lxFer = ComServer.DBManager.NewDataSet(lSQL)

  if lxFer.RecordCount = 0 then
    'Step 2: Get DO Information
    lSQL = "SELECT * FROM SL_DODTL "
    lSQL = lSQL & "WHERE Dockey=(SELECT DocKey FROM SL_DO " 
    lSQL = lSQL & "WHERE DocNo='--DO Test--') "
    Set lDODtl = ComServer.DBManager.NewDataSet(lSQL)    
	
	'Step 3: Find and Create the Biz Objects
    Set BizObject = ComServer.BizObjects.Find("SL_IV") 

    'Step 4: Set Dataset
    Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
    Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
    'Step 5 : Insert Data - Master
    lDate = CDate("January 1, 2017")
    BizObject.New
    lMain.FindField("DocKey").value         = -1
    lMain.FindField("DocNo").AsString       = "--IV Test--"
    lMain.FindField("DocDate").value        = lDate
    lMain.FindField("PostDate").value       = lDate
    lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
    lMain.FindField("CompanyName").AsString = "Cash Sales"
    'lMain.FindField("Address1").AsString    = "" 'Optional
    'lMain.FindField("Address2").AsString    = "" 'Optional
    'lMain.FindField("Address3").AsString    = "" 'Optional
    'lMain.FindField("Address4").AsString    = "" 'Optional
    'lMain.FindField("Phone1").AsString      = "" 'Optional
    lMain.FindField("Description").AsString = "Sales"
    
    'Step 6: Insert Data - Detail	
    v(0) = "COVER"
    v(1) = "UNIT"
	
    if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
      lDetail.Append
      lDetail.FindField("DtlKey").value         = -1
      lDetail.FindField("DocKey").value         = -1
      lDetail.FindField("Seq").value            = 1
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
      lDetail.FindField("UOM").AsString         = lDODtl.FindField("UOM").AsString
	  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
      lDetail.FindField("Tax").AsString         = lDODtl.FindField("Tax").AsString
      lDetail.FindField("TaxRate").AsString     = lDODtl.FindField("TaxRate").AsString
      lDetail.FindField("TaxInclusive").value   = lDODtl.FindField("TaxInclusive").Value
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitPrice").AsFloat
      lDetail.FindField("Amount").AsFloat       = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("TaxAmt").AsFloat       = lDODtl.FindField("TaxAmt").AsFloat
	  lDetail.FindField("FromDocType").AsString = "DO"
	  lDetail.FindField("FromDockey").AsFloat   = lDODtl.FindField("DocKey").AsFloat
	  lDetail.FindField("FromDtlkey").AsFloat   = lDODtl.FindField("DtlKey").AsFloat
      lDetail.Post
	End IF  
    v(0) = "ANT"
    v(1) = "BOX"
	
    if (lDODtl.Locate("ItemCode;UOM", v, false, false)) then
      lDetail.Append
      lDetail.FindField("DtlKey").value         = -1
      lDetail.FindField("DocKey").value         = -1
      lDetail.FindField("Seq").value            = 2
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      'lDetail.FindField("Account").AsString     = "500-000" 'If you wanted override the Sales Account Code
      lDetail.FindField("UOM").AsString         = lDODtl.FindField("UOM").AsString
	  lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
      lDetail.FindField("Tax").AsString         = lDODtl.FindField("Tax").AsString
      lDetail.FindField("TaxRate").AsString     = lDODtl.FindField("TaxRate").AsString
      lDetail.FindField("TaxInclusive").value   = lDODtl.FindField("TaxInclusive").Value
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitPrice").AsFloat
      lDetail.FindField("Amount").AsFloat       = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("TaxAmt").AsFloat       = lDODtl.FindField("TaxAmt").AsFloat
	  lDetail.FindField("FromDocType").AsString = "DO"
	  lDetail.FindField("FromDockey").AsFloat   = lDODtl.FindField("DocKey").AsFloat
	  lDetail.FindField("FromDtlkey").AsFloat   = lDODtl.FindField("DtlKey").AsFloat
      lDetail.Post
	End IF  
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Posting IV Done"
  else MsgBox "--DO Test-- had been transfered. Posting IV aborted"  
  End IF
End Function

SL_IV-Edit

SL_IV-Edit Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call CheckLogin
Call GetData
Call PostData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM SL_IV "
  lSQL = lSQL & "WHERE DocNo='IV-00010' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function PostData
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_IV") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Doc Number
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
  
  
    BizObject.Open
    BizObject.Edit
    lMain.Edit
	lMain.FindField("Description").AsString = "Sales - Edited" 
  
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
	  lDetail.Delete
    Wend
  'Step 6: Append Detail
    lDetail.Append
    lDetail.FindField("DtlKey").value = -1
    lDetail.FindField("Account").value = "500-000"
    lDetail.FindField("Description").value =  "Edited Item A"
    lDetail.FindField("Tax").value =  ""
    lDetail.FindField("TaxInclusive").value =  0
    lDetail.FindField("Amount").value = 410.37
    lDetail.FindField("TaxAmt").value = 0
    lDetail.Post
  
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
    'ComServer.Logout  
    MsgBox "Done" 
	Else
	MsgBox "Record Not Found" 
  END IF 
End Function

GL_JE

GL_JE Script
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
Call InsertGLJE
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function InsertGLJE
Dim ComServer, BizObject, lDataSet, lDataSet2, lDate
 
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF
 
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_JE") 
 
  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 23, 2017")
  BizObject.New
  lMainDataSet.FindField("DocKey").value = -1
  lMainDataSet.FindField("DocNo").value = "--JV Test--"
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Description").value = "testing desc header"
  lMainDataSet.Post
  
  'Step 5: Insert Data - Detail
  'For Tax Inclusive
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("SEQ").value = 1
  lDetailDataSet.FindField("Code").value = "610-1000"
  lDetailDataSet.FindField("Project").value = "----"
  lDetailDataSet.FindField("Description").value =  "testing desc1"
  lDetailDataSet.FindField("Tax").value =  "TX"
  'lDetailDataSet.FindField("LOCALTAXAMT").value = 17.32 //For JE you can't override (i.e. system auto calc)
  lDetailDataSet.FindField("TaxInclusive").Value = 1
  lDetailDataSet.FindField("LocalDR").value = 306 '//Including GST if TAXINCLUSIVE = 1
  lDetailDataSet.FindField("DR").value = 306 '//If wanted DR <> LocalDR
  
  'For Tax Exclusive 
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("SEQ").value = 2
  lDetailDataSet.FindField("Code").value = "605-200"
  lDetailDataSet.FindField("Project").value = "----"
  lDetailDataSet.FindField("Description").value = "testing desc2"
  lDetailDataSet.FindField("Tax").value =  "TX"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("LocalCR").value = 100
  lDetailDataSet.Post 

  'For No GST
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("SEQ").value = 3
  lDetailDataSet.FindField("Code").value = "610-002"
  lDetailDataSet.FindField("Project").value = "----"
  lDetailDataSet.FindField("Description").value =  "testing desc3"
  lDetailDataSet.FindField("Tax").value =  ""
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("LocalCR").value = 200
  lDetailDataSet.Post 
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function

GL_JE-Edit

GL_JE-Edit Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
Call CheckLogin
Call GetData
Call PostData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_JE "
  lSQL = lSQL & "WHERE DocNo='JV-00002' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function PostData
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_JE") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Doc Number
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
  
  
    BizObject.Open
    BizObject.Edit
    lMain.Edit
	lMain.FindField("Description").AsString = "Journal - Edited" 
  
  'Step 5: Delete all Detail
    While lDetail.RecordCount <> 0
      lDetail.First
	  lDetail.Delete
    Wend
  'Step 6: Append Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("Code").value = "610-000"
  lDetail.FindField("Description").value =  "testing desc1"
  lDetail.FindField("Project").value = "P12W1"
  lDetail.FindField("Tax").value =  ""
  lDetail.FindField("TaxInclusive").value =  0
  lDetail.FindField("LocalDR").value = 200
  lDetail.FindField("DR").value = 200
  lDetail.Post 

  lDetail.Append
  lDetail.FindField("DtlKey").value = -1
  lDetail.FindField("Code").value = "531-000"
  lDetail.FindField("Description").value =  "testing desc2"
  lDetail.FindField("Project").value = "P13W1"
  lDetail.FindField("Tax").value =  ""
  lDetail.FindField("TaxInclusive").value =  0
  lDetail.FindField("LocalCR").value = 200
  lDetail.FindField("CR").value = 200
  lDetail.Post 
  
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
    'ComServer.Logout  
    MsgBox "Done" 
	Else
	MsgBox "Record Not Found" 
  END IF 
End Function

GL_JE-Delete

GL_JE-Delete Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GL_JE.vbs
Call CheckLogin
Call GetData
Call DelData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_JE "
  lSQL = lSQL & "WHERE DocNo='JV-00002' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function DelData
Dim BizObject
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_JE") 
  'Step 3 : Find Doc Number
  If lDataSet.RecordCount > 0 Then 
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString
    BizObject.Open
    BizObject.Delete
    BizObject.Close
  
  'Step 4 : Logout after done  
    'ComServer.Logout  
    MsgBox "Done" 
	Else
	MsgBox "Record Not Found" 
  END IF 	
End Function

Get Invoice Next Number

Get Invoice Next Number Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GetNextNo.vbs
Call CheckLogin
Call GetData
Call ShowNextNo

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A "
  lSQL = lSQL & "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) "
  lSQL = lSQL & "WHERE A.DOCTYPE='IV' "
  lSQL = lSQL & "AND A.DESCRIPTION='Customer Invoice' "
  lSQL = lSQL & "AND A.STATESET=1 "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function ShowNextNo 
Dim Desc, Fmt, NextNo, lResult, sb
  set sb = CreateObject("System.Text.StringBuilder")
  'Step 2 : Find Doc Number
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    Desc = lDataSet.FindField("Description").AsString
	Fmt  = lDataSet.FindField("Format").AsString
	NextNo = lDataSet.FindField("NEXTNUMBER").Value
	
	'Convert from IV-%.5d to IV-{0:d5}
	sb.Append_3 Fmt
	sb.Replace "d", ""
	sb.Replace "%.","{0:d"
	Fmt = sb.ToString & "}"
	
	sb.Length = 0 'clear sb list
	sb.AppendFormat Fmt, NextNo
	
	lResult = sb.ToString
    MsgBox Desc
	MsgBox Fmt
	MsgBox NextNo
	MsgBox lResult
	Else
	MsgBox "Record Not Found" 
  END IF    
End Function

Auto Run Doc. Number

Sales Order Auto Run Doc Number Script
'Copy below script & paste to notepad & name it as eg SL_SO.vbs
'If had prompt Set Default - Just click Yes to avoid keep prompt
Call CheckLogin
Call GetData
Call InsertData

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT * FROM SY_DOCNO "
  lSQL = lSQL & "WHERE DESCRIPTION='Customer Sales Order 2' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function


Function InsertData
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("SL_SO") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2019")
  BizObject.New
  lMain.FindField("DocKey").value         = -1
  lMain.FindField("DocNo").AsString       = "<<New>>"
  lMain.FindField("DocDate").value        = lDate
  lMain.FindField("PostDate").value       = lDate
  lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
  lMain.FindField("CompanyName").AsString = "Cash Sales"
  lMain.FindField("Address1").AsString    = "" 'Optional
  lMain.FindField("Address2").AsString    = "" 'Optional
  lMain.FindField("Address3").AsString    = "" 'Optional
  lMain.FindField("Address4").AsString    = "" 'Optional
  lMain.FindField("Phone1").AsString      = "" 'Optional
  lMain.FindField("Description").AsString = "Sales Order"
  lMain.FindField("DocNoSetKey").value    = lDataSet.FindField("DocKey").value
    
  'Step 5: Insert Data - Detail
  'For With Item Code
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("DocKey").value         = -1
  lDetail.FindField("Seq").value            = 3
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("Qty").AsFloat          = 2
  lDetail.FindField("UOM").AsString         = "UNIT"
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("Tax").AsString         = ""
  lDetail.FindField("TaxRate").AsString     = ""
  lDetail.FindField("TaxInclusive").value   = 0
  lDetail.FindField("UnitPrice").AsFloat    = 100  
  lDetail.FindField("Amount").AsFloat       = 200
  lDetail.FindField("TaxAmt").AsFloat       = 0
  lDetail.Post

  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  
  'Step 7 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Done"  
End Function

GL_PV

Cash Book PV Script
'Copy below script & paste to notepad & name it as eg AR_PM.vbs
Call PostData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function PostData
Dim ComServer, BizObject, lIVNo, lDate
 
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF
 
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_PV") 
 
  'Step 3: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data  
  
  'Step 4 : Posting
    lDate = CDate("January 23, 2020")
    BizObject.New
    lMain.FindField("DOCKEY").Value           = -1
    lMain.FindField("DocNo").AsString         = "--CB PV Test--" 
    lMain.FindField("DocDate").Value          = lDate
    lMain.FindField("PostDate").Value         = lDate
    lMain.FindField("Description").AsString   = "Compacc System"
    lMain.FindField("PaymentMethod").AsString = "310-001"
	lMain.FindField("CHEQUENUMBER").AsString = "MBB 213245"
    lMain.FindField("DocAmt").AsFloat         = 2019.57
    lMain.FindField("Cancelled").AsString     = "F"
	lMain.Post
  
    lDetailDataSet.Append
    lDetailDataSet.FindField("DTLKEY").value = -1
	lDetailDataSet.FindField("DOCKEY").value = -1
	lDetailDataSet.FindField("Code").AsString = "200-300"
    lDetailDataSet.FindField("DESCRIPTION").AsString = "Maybank - Asus A555LD-xx313H"
	lDetailDataSet.FindField("TAX").AsString = ""
	lDetailDataSet.FindField("TAXAMT").AsFloat = 0
	lDetailDataSet.FindField("TAXINCLUSIVE").AsFloat = 0
	lDetailDataSet.FindField("AMOUNT").AsFloat = 2019.57
    lDetailDataSet.Post

  'Step 5: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
End Function

ST_Item with Opening

ST_Item with Opening Script
'Copy below script & paste to notepad & name it as eg ST_XF.vbs
Call CheckLogin
Call InsertData

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData
Dim BizObject, lMain, lDtl, lOpn
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_ITEM") 

  'Step 3: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDtl = BizObject.DataSets.Find("cdsUOM") 'lDetail contains detail data  
  Set lOpn = BizObject.DataSets.Find("cdsOpeningBalance") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  BizObject.New
  lMain.FindField("CODE").value = "==Test New Item Code=="
  lMain.FindField("DESCRIPTION").value = "Item Description 123"
  lMain.FindField("STOCKGROUP").value = "DEFAULT"
  lMain.FindField("STOCKCONTROL").value = "T"
  lMain.FindField("ISACTIVE").value = "T"
			    
  'Step 5: Insert Data - Detail
  lDtl.Edit 'For 1St UOM
  lDtl.FindField("UOM").AsString = "PCS"
  lDtl.FindField("Rate").AsFloat = 1
  lDtl.FindField("RefCost").AsFloat = 10.2
  lDtl.FindField("RefPrice").AsFloat = 25
  lDtl.Post

  lDtl.Append 'For 2nd UOM
  lDtl.FindField("UOM").AsString = "CTN"
  lDtl.FindField("Rate").AsFloat = 12
  lDtl.FindField("RefCost").AsFloat = 102
  lDtl.FindField("RefPrice").AsFloat = 240
  lDtl.Post
  
  'Step 6: Insert Data - Opening
  lOpn.Append 
  lOpn.FindField("LOCATION").AsString = "----"
  lOpn.FindField("Qty").AsFloat = 10 'in smallest UOM'
  lOpn.FindField("COST").AsFloat = 10.2
  lOpn.Post

  'Step 7: Save Document
  BizObject.Save
  BizObject.Close
  
  'Step 8 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Done"  
End Function

GL Stock Value-Insert,Edit & Delete

GL Stock Value Insert, Edit & Delete Script
'Available in Version 5.2018.833.759 & above
'Copy below script & paste to notepad & name it as eg GLStockValue.vbs
Call CheckLogin
Call GetData
'Call InsertValue
'Call UpdateValue
Call DeleteValue

Dim ComServer, lDataSet

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function GetData
Dim lSQL
  lSQL = "SELECT Dockey FROM GL_STOCK "
  lSQL = lSQL & "WHERE BalanceStock='330-000' "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
End Function

Function InsertValue
Dim BizObject, lMain, lDetail
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Dockey Record
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString  
	
    BizObject.Open
    BizObject.Edit
	
    lDetail.Append
    lDetail.FindField("Project").value = "----"
	lDetail.FindField("SYear").value = 2021
	lDetail.FindField("SMonth").value = 4
	lDetail.FindField("Amount").value = 423.00
    lDetail.Post
	
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF	
End Function

Function UpdateValue
Dim BizObject, lMain, lDetail, v(2)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Dockey Record
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString  
	
    BizObject.Open
    BizObject.Edit

    v(0) = "----" 'Project Code
    v(1) = "2021" 'Year
	v(2) = "3" 'Month to update
	
	if (lDetail.Locate("Project;SYear;SMonth", v, false, false)) then
      lDetail.Edit
      lDetail.FindField("Amount").value = 333.12      
      lDetail.Post
	End IF 
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF	
End Function

Function DeleteValue
Dim BizObject, lMain, lDetail, v(2)
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("GL_STOCK") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
  'Step 4 : Find Dockey Record
  If lDataSet.RecordCount > 0 Then   
	lDataSet.First
    BizObject.Params.Find("DocKey").Value = lDataSet.FindField("DocKey").AsString  
	
    BizObject.Open
    BizObject.Edit

    v(0) = "----" 'Project Code
    v(1) = "2021" 'Year
	v(2) = "4" 'Month to update
	
	if (lDetail.Locate("Project;SYear;SMonth", v, false, false)) then
      lDetail.Delete
	End IF 
  'Step 6: Save Document
    BizObject.Save
    BizObject.Close
    MsgBox "Done"
  END IF	
End Function

Stock Item Template to SL_IV

Stock Item Template to SL_IV Script
'Updated 03 Sep 2021
'Copy below script & paste to notepad & name it as eg SL_IV.vbs
Call CheckLogin
Call InsertData1
Call InsertData2

Dim ComServer

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

function CheckLogin
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB"
	                'UserName, Password, DCF full path, Database filename
  END IF
End Function

Function InsertData1
Dim BizObject, lMain, lDetail, lDate
  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("ST_ITEM_TPL") 

  'Step 3: Set Dataset
  Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
  Set lDetail = BizObject.DataSets.Find("cdsItemTplDtl") 'lDetail contains detail data  
  
  'Begin Looping yr data
  'Step 4 : Insert Data - Master
  BizObject.New
  lMain.FindField("Code").AsString        = "--TPL Test--"
  lMain.FindField("Description").AsString = "Template formt 1"
  lMain.FindField("RefPrice").AsFloat     = 299.15
    
  'Step 5: Insert Data - Detail
  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("Code").AsString        = "--TPL Test--"
  lDetail.FindField("Seq").value            = 1
  lDetail.FindField("ItemCode").AsString    = "ANT"
  lDetail.FindField("Description").AsString = "Sales Item A"
  lDetail.FindField("UOM").AsString         = "BOX"
  lDetail.FindField("Qty").AsFloat          = 2
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("UNITAMOUNT").AsFloat    = 100  
  lDetail.FindField("Amount").AsFloat       = 200
  lDetail.FindField("PRINTABLE").AsString   = "T"
  lDetail.Post

  lDetail.Append
  lDetail.FindField("DtlKey").value         = -1
  lDetail.FindField("Code").AsString        = "--TPL Test--" 
  lDetail.FindField("Seq").value            = 2
  lDetail.FindField("ItemCode").AsString    = "COVER"
  lDetail.FindField("Description").AsString = "Sales Item B"
  lDetail.FindField("UOM").AsString         = "UNIT"
  lDetail.FindField("Qty").AsFloat          = 3
  'lDetail.FindField("DISC").AsString        = "5%+3" 'Optional (eg 5% plus 3 Discount)
  lDetail.FindField("UNITAMOUNT").AsFloat    = 10  
  lDetail.FindField("Amount").AsFloat       = 30
  lDetail.FindField("PRINTABLE").AsString   = "T"
  lDetail.Post  
  'Step 6: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "Template Posting Done"  
End Function

Function InsertData2
Dim BizObject, lMain, lDetail, lDate, lDODtl, lSQL, v(2)
  'Step 1: Get Template Information
  lSQL = "SELECT * FROM ST_ITEM_TPLDTL "
  lSQL = lSQL & "WHERE Code='--TPL Test--' "
  Set lDODtl = ComServer.DBManager.NewDataSet(lSQL)

  if lDODtl.RecordCount > 0 then	
	'Step 2: Find and Create the Biz Objects
    Set BizObject = ComServer.BizObjects.Find("SL_IV") 

    'Step 3: Set Dataset
    Set lMain   = BizObject.DataSets.Find("MainDataSet")  'lMain contains master data
    Set lDetail = BizObject.DataSets.Find("cdsDocDetail") 'lDetail contains detail data  
  
    'Step 4 : Insert Data - Master
    lDate = CDate("January 1, 2021")
    BizObject.New
    lMain.FindField("DocKey").value         = -1
    lMain.FindField("DocNo").AsString       = "--IV Test--"
    lMain.FindField("DocDate").value        = lDate
    lMain.FindField("PostDate").value       = lDate
    lMain.FindField("Code").AsString        = "300-C0001" 'Customer Account
    lMain.FindField("CompanyName").AsString = "Cash Sales"
    'lMain.FindField("Address1").AsString    = "" 'Optional
    'lMain.FindField("Address2").AsString    = "" 'Optional
    'lMain.FindField("Address3").AsString    = "" 'Optional
    'lMain.FindField("Address4").AsString    = "" 'Optional
    'lMain.FindField("Phone1").AsString      = "" 'Optional
    lMain.FindField("Description").AsString = "Sales"
    
    'Step 6: Insert Data - Detail	
	lDODtl.First
    While not lDODtl.Eof
      lDetail.Append
      lDetail.FindField("DtlKey").value         = -1
      lDetail.FindField("DocKey").value         = -1
      lDetail.FindField("Seq").value            = 1
      lDetail.FindField("ItemCode").AsString    = lDODtl.FindField("ItemCode").AsString
      lDetail.FindField("Description").AsString = lDODtl.FindField("Description").AsString
      lDetail.FindField("UOM").AsString         = lDODtl.FindField("UOM").AsString
      lDetail.FindField("Qty").AsFloat          = lDODtl.FindField("Qty").AsFloat
      lDetail.FindField("DISC").AsString        = lDODtl.FindField("Disc").AsString
      lDetail.FindField("UnitPrice").AsFloat    = lDODtl.FindField("UnitAmount").AsFloat
      lDetail.FindField("Amount").AsFloat       = lDODtl.FindField("Amount").AsFloat
      lDetail.FindField("PRINTABLE").AsString   = lDODtl.FindField("PRINTABLE").AsString
      lDetail.Post
	  lDODtl.Next
	Wend
  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
  
  'Step 8 : Logout after done  
  'ComServer.Logout
  
  MsgBox "Posting IV Done"
  else MsgBox "--No Template found. Posting IV aborted"  
  End IF
End Function

AR_CN

AR_CN Script
'Updated 24 Feb 2023
'Copy below script & paste to notepad & name it as eg AR_CN.vbs
Call InsertData

Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function

Function InsertData
Dim ComServer, BizObject, lDate, lIVNO, v(1)

  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  If not ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0020.FDB" 
  END IF

  'Step 2: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("AR_CN") 

  'Step 3: Set Dataset
  Set lMainDataSet = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data
  Set lDetailDataSet = BizObject.DataSets.Find("cdsDocDetail") 'lDetailDataSet contains detail data  
  Set lKO = BizObject.DataSets.Find("cdsKnockOff") 'Contains IV/DN to knock off data  
  
  'Step 4 : Insert Data - Master
  lDate = CDate("January 1, 2023")
  BizObject.New
  lMainDataSet.FindField("DocKey").value = -1
  lMainDataSet.FindField("DocNo").value = "--CN Test--"
  lMainDataSet.FindField("DocDate").value = lDate
  lMainDataSet.FindField("PostDate").value = lDate
  lMainDataSet.FindField("Code").value = "300-A0001"
  lMainDataSet.FindField("Description").value = "Credit Note"
    
  'Step 5: Insert Data - Detail
  'For Tax Inclusive = True with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "510-2000"
  lDetailDataSet.FindField("Description").value =  "Sales Item A"
  lDetailDataSet.FindField("Tax").value =  "SV"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 410.37
  lDetailDataSet.FindField("TaxAmt").value = 24.63
  
  lDetailDataSet.DisableControls
  lDetailDataSet.FindField("TaxInclusive").value =  1
  lDetailDataSet.EnableControls
  
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post
  
  'For Tax Inclusive = False with override Tax Amount
  lDetailDataSet.Append
  lDetailDataSet.FindField("DtlKey").value = -1
  lDetailDataSet.FindField("DocKey").value = -1
  lDetailDataSet.FindField("Account").value = "510-2000"
  lDetailDataSet.FindField("Description").value =  "Sales Item B"
  lDetailDataSet.FindField("Tax").value =  "SV"
  lDetailDataSet.FindField("TaxInclusive").value =  0
  lDetailDataSet.FindField("Amount").value = 94.43
  lDetailDataSet.FindField("TaxAmt").value = 5.66
  lDetailDataSet.FindField("Changed").value = "F"
  lDetailDataSet.Post

  'Step 7: Knock Off IV
    lIVNO = "--IV Test--"
    v(0) = "IV"
    v(1) = lIVNO
	
    if (lKO.Locate("DocType;DocNo", v, false, false)) then
      lKO.Edit
      lKO.FindField("KOAmt").value = 65.57
      lKO.FindField("KnockOff").AsString = "T"
      lKO.Post
	End IF  

  'Step 7: Save Document
  BizObject.Save
  BizObject.Close
  MsgBox "Done"
End Function


JScript/JavaScript

This Script only can run using Internet Explorer (till IE 11)

AR_IV

AR_IV Script
<html>
<head>
<title>Add Customer Invoice</title>
<script language="JScript">
var ComServer;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}
 
function AutoInvoice() {
  var BizObject, lMainDataSet, lDetailDataSet;
 
  CreateSQLAccServer();
 
  BizObject = ComServer.BizObjects.Find('AR_IV');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
  lDetailDataSet = BizObject.DataSets.Find('cdsDocDetail');
  BizObject.New();
 
  lMainDataSet.FindField('DocKey').value = -1;
  lMainDataSet.FindField('DocNo').value = "--IV Test--";
  lMainDataSet.FindField('DocDate').value = "01/10/2016";
  lMainDataSet.FindField('PostDate').value = "01/10/2016";
  lMainDataSet.FindField('Code').value = "300-A0003";
  lMainDataSet.FindField('Description').value = "Sales";

  /*For Tax Inclusive = True with override Tax Amount*/
  lDetailDataSet.Append();
  lDetailDataSet.FindField('DtlKey').value = -1;
  lDetailDataSet.FindField('DocKey').value = -1;
  lDetailDataSet.FindField('Account').value = "500-000";
  lDetailDataSet.FindField('Description').value =  "Sales Item A";
  lDetailDataSet.FindField('Tax').value =  "SR";
  lDetailDataSet.FindField('TaxInclusive').value =  0;
  lDetailDataSet.FindField('Amount').value = 410.37;
  lDetailDataSet.FindField('TaxAmt').value = 24.63;
 
  lDetailDataSet.DisableControls();
  lDetailDataSet.FindField('TaxInclusive').value =  1;
  lDetailDataSet.EnableControls();
 
  lDetailDataSet.FindField('Changed').value = "F";
  lDetailDataSet.Post();

  /*For Tax Inclusive = False with override Tax Amount*/
  lDetailDataSet.Append();
  lDetailDataSet.FindField('DtlKey').value = -1;
  lDetailDataSet.FindField('DocKey').value = -1;
  lDetailDataSet.FindField('Account').value = "500-000";
  lDetailDataSet.FindField('Description').value =  "Sales Item B";
  lDetailDataSet.FindField('Tax').value =  "SR";
  lDetailDataSet.FindField('TaxInclusive').value =  0;
  lDetailDataSet.FindField('Amount').value = 94.43;
  lDetailDataSet.FindField('TaxAmt').value = 5.66;
  lDetailDataSet.FindField('Changed').value = "F";
  lDetailDataSet.Post();

  /* Save document */  
    BizObject.Save();
    BizObject.Close();
    alert('Customer Invoice - has been saved.');
}
</script>
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="AutoInvoice()">
</body>
</html>

SL_CS

SL_CS Script
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function InsertData() {
  var BizObject, lMain, lDetail;
  
  CreateSQLAccServer();

  /*Step 2: Find and Create the Biz Objects*/
  BizObject = ComServer.BizObjects.Find('SL_CS') ;

  /*Step 3: Set Dataset*/
  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lDetail = BizObject.DataSets.Find('cdsDocDetail'); /*lDetail contains detail data */  
  
  /*Begin Looping yr data*/
  /*Step 4 : Insert Data - Master*/
  BizObject.New();
  lMain.FindField('DocKey').value         = -1;
  lMain.FindField('DocNo').AsString       = "--IV Test--";
  lMain.FindField('DocDate').value        = "20/12/2017";
  lMain.FindField('PostDate').value       = "20/12/2017";
  lMain.FindField('Code').AsString        = "300-C0001"; /*Customer Account*/
  lMain.FindField('CompanyName').AsString = "Cash Sales"
  lMain.FindField('Address1').AsString    = ""; /*Optional*/
  lMain.FindField('Address2').AsString    = ""; /*Optional*/
  lMain.FindField('Address3').AsString    = ""; /*Optional*/
  lMain.FindField('Address4').AsString    = ""; /*Optional*/
  lMain.FindField('Phone1').AsString      = ""; /*Optional*/
  lMain.FindField('Description').AsString = "Sales";
    
  /*Step 5: Insert Data - Detail*/
  /*For Tax Inclusive = True with override Tax Amount*/
  lDetail.Append();
  lDetail.FindField('DtlKey').value         = -1;
  lDetail.FindField('DocKey').value         = -1;
  lDetail.FindField('Seq').value            = 1;
  lDetail.FindField('Account').AsString     = "500-000"; /*Sales Account*/
  lDetail.FindField('Description').AsString = "Sales Item A";
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('Tax').AsString         = "SR";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 435;
  lDetail.FindField('Amount').AsFloat       = 410.37; /*Exclding GST Amt*/
  lDetail.FindField('TaxAmt').AsFloat       = 24.63;
  
  lDetail.DisableControls();
  lDetail.FindField('TaxInclusive').value   = 1;
  lDetail.EnableControls();
  
  lDetail.Post();
  
  /*For Tax Inclusive = False with override Tax Amount*/
  lDetail.Append();
  lDetail.FindField('DtlKey').value         = -1;
  lDetail.FindField('DocKey').value         = -1;
  lDetail.FindField('Seq').value            = 2;
  lDetail.FindField('Account').AsString     = "500-000";
  lDetail.FindField('Description').AsString = "Sales Item B";
  lDetail.FindField('Qty').AsFloat          = 1;
  lDetail.FindField('Tax').AsString         = "SR";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 94.43;
  lDetail.FindField('Amount').AsFloat       = 94.43;
  lDetail.FindField('TaxAmt').AsFloat       = 5.66;
  lDetail.Post();

  /*For With Item Code*/
  lDetail.Append();
  lDetail.FindField('DtlKey').value         = -1;
  lDetail.FindField('DocKey').value         = -1;
  lDetail.FindField('Seq').value            = 3;
  lDetail.FindField('ItemCode').AsString    = "ANT";
  lDetail.FindField('Description').AsString = "Sales Item B";
  /*lDetail.FindField('Account').AsString     = "500-000"; If you wanted override the Sales Account Code*/
  lDetail.FindField('Qty').AsFloat          = 2;
  lDetail.FindField('UOM').AsString         = "UNIT";
  /*lDetail.FindField('DISC').AsString        = "5%+3"; Optional (eg 5% plus 3 Discount)*/
  lDetail.FindField('Tax').AsString         = "SR";
  lDetail.FindField('TaxRate').AsString     = "6%";
  lDetail.FindField('TaxInclusive').value   = 0;
  lDetail.FindField('UnitPrice').AsFloat    = 100;
  lDetail.FindField('Amount').AsFloat       = 200;
  lDetail.FindField('TaxAmt').AsFloat       = 12;
  lDetail.Post();

  /*Step 6: Save Document*/
  BizObject.Save();
  BizObject.Close();
    alert('Document has been saved.');
}
</script>
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="InsertData()">
</body>
</html>

AR_PM

AR_PM Script
<html>
<head>
<title>Customer Payment</title>
<script language="JScript">
<html>
<head>
<title>Add Customer Payment</title>
<script language="JScript">
var ComServer;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject("SQLAcc.BizApp");
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function AddPayment() {
  var BizObject, lMainDataSet, lKnockOffDataSet, V;
  
  CreateSQLAccServer();

  BizObject = ComServer.BizObjects.Find('AR_PM');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
  BizObject.New();
  
  lMainDataSet.FindField('DocKey').value = -1;
  lMainDataSet.FindField('DocNo').value = "--OR Test--";
  lMainDataSet.FindField('Code').value = "300-C0001";
  lMainDataSet.FindField('DocDate').value = "10/10/2023";
  lMainDataSet.FindField('PostDate').value = "10/10/2023";  
  lMainDataSet.FindField('Description').value = "Payment for Account";
  lMainDataSet.FindField('PaymentMethod').value = "310-001";
  lMainDataSet.FindField('ChequeNumber').value = "";
  lMainDataSet.FindField('DocAmt').AsFloat = 106.10;
  lMainDataSet.FindField('BankCharge').AsFloat = 0;
  lMainDataSet.FindField('UnappliedAmt').AsFloat = 0;
  lMainDataSet.FindField('Cancelled').value = 'F';
  
  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType*/
  v.SetItem(1, 'IV-00172'); /*Knock Off DocNo*/

  if (lKnockOffDataSet.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){ 
          lKnockOffDataSet.Edit();
          lKnockOffDataSet.FindField('KOAmt').AsFloat = 106.10;		  
          lKnockOffDataSet.FindField('KnockOff').AsString = 'T';
          lKnockOffDataSet.Post(); }
    /* Save document */  
    BizObject.Save();
    BizObject.Close();
    alert("Customer Payment - has been saved.");
}

function EditPayment(){
  var BizObject, lMainDataSet, lKnockOffDataSet, V, lDocNo, lDocKey;
  
  CreateSQLAccServer();

  BizObject = ComServer.BizObjects.Find('AR_PM');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
  
  lDocNo = "--OR Test--"
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
  BizObject.Params.Find('DocKey').Value = lDocKey;
  
  if (lDocKey != null) {
    BizObject.Open();
    BizObject.Edit();
    lMainDataSet.FindField('Description').value = "Payment for Account-Edited";
    lMainDataSet.FindField('PaymentMethod').value = "310-001";
    lMainDataSet.FindField('ChequeNumber').value = "";
    lMainDataSet.FindField('DocAmt').AsFloat = 200.00;
    lMainDataSet.FindField('BankCharge').AsFloat = 0;
    lMainDataSet.FindField('UnappliedAmt').AsFloat = 0;
    lMainDataSet.FindField('Cancelled').value = 'F';
  
    v = ComServer.CreateOleVariantArray(2);
    v.SetItem(0, 'IV'); /*Knock Off DocType*/
    v.SetItem(1, 'IV-00172'); /*Knock Off DocNo*/

    if (lKnockOffDataSet.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){ 
          lKnockOffDataSet.Edit();
          lKnockOffDataSet.FindField('KOAmt').AsFloat = 200;		  
          lKnockOffDataSet.FindField('KnockOff').AsString = 'T';
          lKnockOffDataSet.Post(); }
    /* Save document */  
      BizObject.Save();
      BizObject.Close();
      alert("Customer Payment - has been Edited & saved.");
   }
}

function DelPayment(){
  var BizObject, lMainDataSet, lKnockOffDataSet, V, lDocNo, lDocKey;
  
  CreateSQLAccServer();

  BizObject = ComServer.BizObjects.Find('AR_PM');
  lMainDataSet = BizObject.DataSets.Find('MainDataSet');
  lKnockOffDataSet = BizObject.DataSets.Find('cdsKnockOff');
  
  lDocNo = "--OR Test--"
  lDocKey = BizObject.FindKeyByRef('DocNo', lDocNo);
  BizObject.Params.Find('DocKey').Value = lDocKey;
  
  if (lDocKey != null) {
    BizObject.Open();
    BizObject.Delete();

    BizObject.Close();
    alert("Customer Payment - has been Deleted.");
   }
}
</script>
</head>
<body>
<input type="submit" value="Add Payment" name="btnSubmit" onclick="AddPayment()">
<input type="submit" value="Edit Payment" name="btnSubmit" onclick="EditPayment()">
<input type="submit" value="Delete Payment" name="btnSubmit" onclick="DelPayment()">
</body>
</html>

Customer.IV.RO

Customer.IV.RO Report Object Script
<html>
  <head>
    <title>Customer.IV.RO</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript">
var ComServer;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject("SQLAcc.BizApp");
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}      

function GetData() {  
  var lMain, lDetail, lRptVar, lDateFrom, lDateTo;
  
  elem = document.getElementById('txt1');
  
  CreateSQLAccServer();
   
  lDateFrom = new Date("January 1 2015");
  lDateTo = new Date("December 31, 2015"); 
  
  lRptVar = ComServer.RptObjects.Find('Customer.IV.RO');
  lRptVar.Params.Find('SelectDate').Value           = true;
  lRptVar.Params.Find('DateFrom').Value             = lDateFrom.valueOf();
  lRptVar.Params.Find('DateTo').Value               = lDateTo.valueOf();
  lRptVar.Params.Find('AllAgent').Value             = false;
  lRptVar.Params.Find('AgentData').Value            = "----\nLF"; /*Filter by Agent code ---- & HALIM */
  lRptVar.Params.Find('AllArea').Value              = true;
  lRptVar.Params.Find('AllCompany').Value           = true;
  lRptVar.Params.Find('AllCurrency').Value          = true;
  lRptVar.Params.Find('AllDocProject').Value        = true;
  lRptVar.Params.Find('AllCompanyCategory').Value   = true;
  lRptVar.Params.Find('AllDocument').Value          = true;
  lRptVar.Params.Find('IncludeCancelled').Value   = false;
  lRptVar.Params.Find('PrintDocumentStyle').Value = false;
  lRptVar.Params.Find('AllItemProject').Value     = true;
  lRptVar.Params.Find('AllPaymentMethod').Value   = true;
  lRptVar.CalculateReport();  
  
  lMain   = lRptVar.DataSets.Find('cdsMain');
  lDetail = lRptVar.DataSets.Find('cdsDocDetail');
  /*alert("Count -" + lRptVar.DataSets.Find('cdsDocDetail').RecordCount);*/
  elem.innerHTML += 'From Main'+'\n';
    
  lMain.First(); 
  while (!lMain.eof) {
    elem.innerHTML += lMain.FindField('DocKey').AsString + ' ' +
	                  lMain.FindField('DocNo').AsString + ' ' + lMain.FindField('DocDate').AsString + ' '+
                      lMain.FindField('CompanyName').AsString + ' ' + lMain.FindField('DocAmt').AsString + '\n';
	lMain.Next();  
  }
  elem.innerHTML += 'End Main'+'\n\n';
  
  elem.innerHTML += 'From Detail'+'\n';
  lDetail.First(); 
  while (!lDetail.eof) {
    elem.innerHTML += lDetail.FindField('Dockey').AsString + ' ' + lDetail.FindField('Account').AsString + ' ' + 
	                  lDetail.FindField('Description').AsString + ' ' + lDetail.FindField('Amount').AsString + '\n';
	lDetail.Next();  
  }  
  elem.innerHTML += 'End Detail'+'\n\n';
}
	  
    </script>
  </head>
  <body>
    <form>
      <textarea id="txt1" rows="30" cols="116"></textarea>
      <input type="button" value="Calculate" onclick="GetData()">
    </form>
  </body>
</html>

Customer.RO

Customer.RO Report Object Script
<html>
<head>
<title>Add Customer Invoice</title>
<script language='JScript'>
var ComServer;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function GetCustomerData() {
  var RptObject, lDataSet, lDataSet2;
  edOutput.value = '';
  edOutput2.value = '';
  //Step 1: Create Com Server object
  CreateSQLAccServer();
  
  //Step 2: Find and Create the Report Objects
  RptObject = ComServer.RptObjects.Find('Customer.RO');
  
  //Step 3: Spool parameters
  RptObject.Params.Find('AllAgent').Value = true;
  RptObject.Params.Find('AllArea').Value = true;
  RptObject.Params.Find('AllCompany').Value = true;
  RptObject.Params.Find('AllCompanyCategory').Value = true;
  RptObject.Params.Find('AllCurrency').Value = true;
  RptObject.Params.Find('AllTerms').Value = true;
  RptObject.Params.Find('SelectDate').Value = true;
  RptObject.Params.Find('PrintActive').Value = true;
  RptObject.Params.Find('PrintInactive').Value = false;
  RptObject.Params.Find('PrintPending').Value = false;
  RptObject.Params.Find('PrintProspect').Value = false;
  RptObject.Params.Find('PrintSuspend').Value = false;
  //RptObject.Params.Find('CompanyData').Value = '300-A0003';
  
  //Step 4: Perform Report calculation 
  RptObject.CalculateReport();
  lDataSet = RptObject.DataSets.Find('cdsMain');
  lDataSet2 = RptObject.DataSets.Find('cdsBranch');
  
  //alert('Count ' + lDataSet.RecordCount);

  //Step 5 Retrieve the output 
  lDataSet.First;
  while  (!lDataSet.eof){
    edOutput.value = edOutput.value + 
	                'Code : ' + lDataSet.FindField('Code').AsString + '\n' + 
	                'Company Name : ' + lDataSet.FindField('CompanyName').AsString +'\n\n';
	lDataSet.Next();
  }
  lDataSet2.First();
  while (!lDataSet2.eof){
	  edOutput2.value = edOutput2.value + 
	                   'Code : '+ lDataSet2.FindField('Code').AsString + '\n' + 
					   'Branch Name : '+ lDataSet2.FindField('BranchName').AsString + '\n' + 
	                   'Address 1 : '+ lDataSet2.FindField('Address1').AsString + '\n' + 
					   'Address 2 : '+ lDataSet2.FindField('Address2').AsString + '\n' + 
					   'Address 3 : '+ lDataSet2.FindField('Address3').AsString + '\n' + 
					   'Address 4 : '+ lDataSet2.FindField('Address4').AsString + '\n' + 
					   'Phone 1 : '+ lDataSet2.FindField('Phone1').AsString  +'\n\n';
	  lDataSet2.Next();
    }
	
}

</script>
</head>
<body>
  <table>
    <tr>
      <th>Main Table</th>
      <th>Branch Branch</th>
    </tr>
    <tr>
      <td>
        <TEXTAREA rows=15 cols=75 name="edOutput"></TEXTAREA>
	  </td>
      <td>
        <TEXTAREA rows=15 cols=75 name="edOutput2"></TEXTAREA>
	  </td>
    </tr>		
  </table>
		
  <table width="83%">
	<tr>
	  <td align="center">
		<input type='submit' value='Sync Data' name='btnSubmit' onclick='GetCustomerData()'>
	  </td>
	</tr>
  </table>
</body>
</html>

Get Next IV Number

Get Next IV Number Script
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer, lDataSet;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function zeroPad(num, places) {
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
  /*zeroPad(5, 2); // "05"*/
}

function GetData() {
  var lSQL;
  lSQL = "SELECT A.*, B.NEXTNUMBER FROM SY_DOCNO A ";
  lSQL = lSQL + "INNER JOIN SY_DOCNO_DTL B ON (A.DOCKEY=B.PARENTKEY) ";
  lSQL = lSQL + "WHERE A.DOCTYPE='IV' ";
  lSQL = lSQL + "AND A.DESCRIPTION='Customer Invoice' ";
  lSQL = lSQL + "AND A.STATESET=1 ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);  
}

function ShowNextNo() {
  var Desc, Fmt, NextNo, lResult, lPad;
  
  CreateSQLAccServer();  
  GetData();

  if (lDataSet.RecordCount > 0) {   
    lDataSet.First;
    Desc = lDataSet.FindField("Description").AsString;
	Fmt  = lDataSet.FindField("Format").AsString;
	NextNo = lDataSet.FindField("NEXTNUMBER").Value;
    alert(Desc);
	alert(Fmt);
	alert(NextNo);
	
	lPad = Fmt.substr(5, 1);
	lPad = zeroPad(NextNo, lPad)
	Desc = Fmt.substr(0, 3);
	alert(Desc + lPad);
  }	
}
</script>
</head>
<body>
<input type="submit" value="Show Next No" name="btnSubmit" onclick="ShowNextNo()">
</body>
</html>

Customer & Supplier Contra

Customer & Supplier Contra Script
<html>
<head>
<title>Add Customer Invoice</title>
<script language="JScript">
var ComServer;
 
function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}
 
function PostARCT() {
  var BizObject, lMain, lKO, V;
 
  CreateSQLAccServer();
 
  BizObject = ComServer.BizObjects.Find('AR_CT');
  lMain = BizObject.DataSets.Find('MainDataSet');
  lKO = BizObject.DataSets.Find('cdsKnockOff');
  BizObject.New();
 
  lMain.FindField('DocKey').value = -1;
  lMain.FindField('DocNo').value = "--CT Test--";
  lMain.FindField('DocDate').value = "01/10/2020";
  lMain.FindField('PostDate').value = "01/10/2020";
  lMain.FindField('Code').value = "300-A0002";
  lMain.FindField('Description').value = "Contra";
  lMain.FindField('DocAmt').value = "100.00";
  //lMain.FindField('UnappliedAmt').value = "0";

  v = ComServer.CreateOleVariantArray(2);
  v.SetItem(0, 'IV'); /*Knock Off DocType*/
  v.SetItem(1, 'IV-00021'); /*Knock Off DocNo*/

  if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){ 
          lKO.Edit();
          lKO.FindField('DocAmt').value = "100";		  
          lKO.FindField('KnockOff').AsString = 'T';
          lKO.Post(); }

  /* Save document */  
    BizObject.Save();
    BizObject.Close();
    alert('Customer Contra - has been saved.');
}

function PostAPST() {
  var BizObject, lMain, lKO, V, lDocNo, lDocKey;
 
  CreateSQLAccServer();
 
  BizObject = ComServer.BizObjects.Find('AP_ST');
  lMain = BizObject.DataSets.Find('MainDataSet');
  lKO = BizObject.DataSets.Find('cdsKnockOff');
  
  lDocNo = "--CT Test--"
  lDocKey = BizObject.FindKeyByRef("DocNo", lDocNo)
  BizObject.Params.Find("DocKey").Value = lDocKey  
  
  if (lDocKey != null) {
    BizObject.Open();
	BizObject.Edit();
	lMain.FindField('Code').value = "400-C0001";
	lMain.FindField('DocAmt').value = "100.00";
  //lMain.FindField('UnappliedAmt').value = "0";

   v = ComServer.CreateOleVariantArray(2);
   v.SetItem(0, 'PI'); /*Knock Off DocType*/
   v.SetItem(1, 'PI-00001'); /*Knock Off DocNo*/

    if (lKO.Locate('DocType;DocNo', v.AsOleVariant(), false, false)){ 
          lKO.Edit();
          lKO.FindField('DocAmt').value = "100";		  
          lKO.FindField('KnockOff').AsString = 'T';
          lKO.Post(); }

  /* Save document */  
    BizObject.Save();  
    BizObject.Close();
    alert('Supplier Contra - has been Updated.');	
  }
}
</script>
</head>
<body>
<button onclick="javascript:PostARCT();">PostARCT</button>&nbsp;&nbsp;
<button onclick="javascript:PostAPST();">PostAPST</button>&nbsp;&nbsp;
</body>
</html>

Add Stock Item

Add ST_Item Script
<html>
<head>
<title>Add Stock Item</title>
<script language="JScript">
var ComServer;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function InsertData() {
  var BizObject, lMain, lDetail;
  
  CreateSQLAccServer();

  /*Step 2: Find and Create the Biz Objects*/
  BizObject = ComServer.BizObjects.Find('ST_ITEM') ;

  /*Step 3: Set Dataset*/
  lMain   = BizObject.DataSets.Find('MainDataSet');  /*lMain contains master data*/
  lUOM = BizObject.DataSets.Find('cdsUOM'); /*lDetail contains detail data */  
  
  /*Begin Looping yr data*/
  /*Step 4 : Insert Data - Master*/
  BizObject.New();
  lMain.FindField('Code').AsString        = "Code JScript";
  lMain.FindField('DESCRIPTION').AsString = "Post from JScript"
  lMain.FindField('STOCKGROUP').AsString    = "DEFAULT"; /*Optional*/
  lMain.FindField('STOCKCONTROL').AsString    = "T"; /*Optional*/
  lMain.FindField('ISACTIVE').AsString    = "T"; /*Optional*/
    
  /*Step 5: Insert Data - UOM*/
  lUOM.Edit(); /*For 1St UOM*/
  lUOM.FindField('UOM').AsString = "PCS";
  lUOM.FindField('Rate').AsFloat = 1;
  lUOM.FindField('RefCost').AsFloat = 10.2;
  lUOM.FindField('RefPrice').AsFloat = 25;
  lUOM.Post();

  lUOM.Append(); /*For 2nd UOM*/
  lUOM.FindField('UOM').AsString = "CTN";
  lUOM.FindField('Rate').AsFloat = 12;
  lUOM.FindField('RefCost').AsFloat = 102;
  lUOM.FindField('RefPrice').AsFloat = 240;
  lUOM.Post();

  /*Step 6: Save*/
  BizObject.Save();
  BizObject.Close();
    alert('Item has been saved.');
}
</script>
</head>
<body>
<input type="submit" value="SYNC" name="btnSubmit" onclick="InsertData()">
</body>
</html>

Get Company Profile

Get Company Profile Script
<html>
<head>
<title>Add Cash Sales</title>
<script language="JScript">
var ComServer, lDataSet;

function CreateSQLAccServer() {
  ComServer = new ActiveXObject('SQLAcc.BizApp');
  if (!ComServer.IsLogin) {            /* check whether user has logon */
    ComServer.Login('ADMIN', 'ADMIN', 'C\:\\eStream\\SQLAccounting\\Share\\DEFAULT.DCF', 'SAMPLE.FDB');
 /* UserName, Password */
  }
}

function zeroPad(num, places) {
  var zero = places - num.toString().length + 1;
  return Array(+(zero > 0 && zero)).join("0") + num;
  /*zeroPad(5, 2); // "05"*/
}

function GetData() {
  var lSQL;
  lSQL = "SELECT COMPANYNAME, REMARK, BRN, BRN2, GSTNO, ";
  lSQL = lSQL + "SALESTAXNO, SERVICETAXNO, ";
  lSQL = lSQL + "ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4 FROM SY_PROFILE ";
  lDataSet = ComServer.DBManager.NewDataSet(lSQL);  
}

function ShowCoProfile() {
  var CoName, Rmk, BRN;
  
  CreateSQLAccServer();  
  GetData();

  if (lDataSet.RecordCount > 0) {   
    lDataSet.First;
    CoName = lDataSet.FindField("COMPANYNAME").AsString;
	Rmk  = lDataSet.FindField("REMARK").AsString;
	BRN = lDataSet.FindField("BRN").Value;
    alert(CoName);
	alert(Rmk);
	alert(BRN);
  }	
}
</script>
</head>
<body>
<input type="submit" value="Show Co Profile" name="btnSubmit" onclick="ShowCoProfile()">
</body>
</html>


Delphi

The below example is assuming after you had check the login status.

GL_JE

GL_JE Script
procedure TfmMain.dxbb_GL_JEClick(Sender: TObject);
var BizApp, lMain, lDtl, lBizObj, lDocKey : Variant;
    i : integer;
begin
  BizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := BizApp.BizObjects.Find('GL_JE');
    lMain   := lBizObj.DataSets.Find('MainDataSet');
    lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
    lBizObj.New;
    lMain.FindField('DOCKEY').Value        := -1;
    lMain.FindField('DocNo').Value         := '--JE Test--';
    lMain.FindField('DocDate').Value       := '28 Aug 2017';
    lMain.FindField('PostDate').Value      := '28 Aug 2017';
    lMain.FindField('TAXDATE').Value       := '28 Aug 2017';
    lMain.FindField('Description').Value   := 'Postage';
    lMain.FindField('Cancelled').Value     := 'F';
    lMain.FindField('DOCNOSETKEY').Value   := 0;
    lMain.Post;

    //For Tax Inclusive
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value       := -1;
    lDtl.FindField('DOCKEY').Value       := -1;
    lDtl.FindField('SEQ').Value          := 1;
    lDtl.FindField('CODE').Value         := '610-1000';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 1';
    lDtl.FindField('TAX').Value          := 'TX';
//    lDtl.FindField('LOCALTAXAMT').AsFloat := 17.32;//For JE you can't override (i.e. system auto calc)
    lDtl.FindField('TAXINCLUSIVE').Value  := 1;
    lDtl.FindField('LocalDR').AsFloat     := 306;//Including GST if TAXINCLUSIVE = 1
    lDtl.FindField('DR').AsFloat          := 306;//if wanted DR <> LocalDR
    lDtl.FindField('CHANGED').Value       := 'F';
    lDtl.Post;

    //For Tax Exclusive
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value       := -1;
    lDtl.FindField('DOCKEY').Value       := -1;
    lDtl.FindField('SEQ').Value          := 2;
    lDtl.FindField('CODE').Value         := '605-200';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 2';
    lDtl.FindField('TAX').Value          := 'TX';
    lDtl.FindField('TAXINCLUSIVE').Value := 0;
    lDtl.FindField('LocalCR').AsFloat    := 100;
    lDtl.FindField('CHANGED').Value      := 'F';
    lDtl.Post;

    //For No GST
    lDtl.Append;
    lDtl.FindField('DTLKEY').Value       := -1;
    lDtl.FindField('DOCKEY').Value       := -1;
    lDtl.FindField('SEQ').Value          := 3;
    lDtl.FindField('CODE').Value         := '610-002';
    lDtl.FindField('DESCRIPTION').Value  := 'Item Desc 3';
    lDtl.FindField('TAX').Value          := '';
    lDtl.FindField('TAXINCLUSIVE').Value  := 0;
    lDtl.FindField('LocalCR').AsFloat     := 200;
    lDtl.FindField('CHANGED').Value       := 'F';
    lDtl.Post;

    lBizObj.Save;
    MessageDlg('GL_JE-DocNo : ''--JE Test--'' Posted...', mtInformation, [mbOK],0);
  finally
    lBizObj.Close;
  end;
end;

GL_PV

GL_PV Script
procedure TfmMain.dxbb_GLPVClick(Sender: TObject);
var lMain, lDtl, lBizObj, BizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  BizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := BizApp.BizObjects.Find('GL_PV');
    lMain   := lBizObj.DataSets.Find('MainDataSet');
    lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
    lBizObj.New;
    lMain.FindField('DOCKEY').Value           := -1;
    lMain.FindField('DocNo').AsString         := '--CB PV Test1--';
    lMain.FindField('DocDate').Value          := '18 Aug 2015';
    lMain.FindField('PostDate').Value         := '18 Aug 2015';
    lMain.FindField('TAXDATE').Value          := '18 Aug 2015';
    lMain.FindField('Description').AsString   := 'Compacc System';
    lMain.FindField('PAYMENTMETHOD').AsString := '310-001';
    lMain.FindField('CHEQUENUMBER').AsString  := 'MBB 213245';
    lMain.FindField('DocAmt').AsFloat         := 2019;
    lMain.FindField('Cancelled').AsString     := 'F';
    lMain.FindField('CHANGED').AsString       := 'F';
    lMain.Post;

    lDtl.Append;
    lDtl.FindField('DTLKEY').Value         := -1;
    lDtl.FindField('DOCKEY').Value         := -1;
    lDtl.FindField('Code').AsString        := '200-300';
    lDtl.FindField('DESCRIPTION').AsString := 'Maybank - Asus A555LD-xx313H';
    lDtl.FindField('TAX').AsString         := 'TX';
    lDtl.FindField('TAXAMT').AsFloat       := 114.28;
    lDtl.FindField('TAXINCLUSIVE').Value   := 1;
    lDtl.FindField('AMOUNT').AsFloat       := 2019;
    lDtl.FindField('CHANGED').AsString     := 'F';
    lDtl.Post;
    lBizObj.Save;
    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;

AR_Customer

AR_Customer Script
procedure TfmMain.dxbb_CustomerClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');

  lBizObj := lBizApp.BizObjects.Find('AR_Customer');
  lMain   := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsBranch');

  try
    lBizObj.New;
    lMain.FindField('Code').value        := '300-Test';
    lMain.FindField('CompanyName').value := 'Testing 123';

    lDtl.Edit; //For 1st Branch
    lDtl.FindField('BranchName').AsString := 'BILLING';
    lDtl.FindField('Address1').AsString   := 'Address1';
    lDtl.FindField('Address2').AsString   := 'Address2';
    lDtl.FindField('Address3').AsString   := 'Address3';
    lDtl.FindField('Address4').AsString   := 'Address4';
    lDtl.FindField('Attention').AsString  := 'Attention';
    lDtl.FindField('Phone1').AsString     := 'Phone1';
    lDtl.FindField('Fax1').AsString       := 'Fax1';
    lDtl.FindField('Email').AsString      := 'EmailAddress';
    lDtl.Post;

    lDtl.Append; //For 2nd Branch
    lDtl.FindField('BranchName').AsString := 'Branch1';
    lDtl.FindField('Address1').AsString   := 'DAddress1';
    lDtl.FindField('Address2').AsString   := 'DAddress2';
    lDtl.FindField('Address3').AsString   := 'DAddress3';
    lDtl.FindField('Address4').AsString   := 'DAddress4';
    lDtl.FindField('Attention').AsString  := 'DAttention';
    lDtl.FindField('Phone1').AsString     := 'DPhone1';
    lDtl.FindField('Fax1').AsString       := 'DFax1';
    lDtl.FindField('Email').AsString      := 'DEmailAddress';
    lDtl.Post;
    lBizObj.Save;

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;

AR_PM

AR_PM Script
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain   := lBizObj.DataSets.Find('MainDataSet');
    lKO     := lBizObj.DataSets.Find('cdsKnockOff');

    lBizObj.New;
    lMain.FindField('DOCKEY').Value           := -1;
    lMain.FindField('DocNo').AsString         := '--PM Test--'; //Payment Document Number
    lMain.FindField('CODE').AsString          := '300-A0001';
    lMain.FindField('DocDate').Value          := '28 Aug 2016';
    lMain.FindField('PostDate').Value         := '28 Aug 2016';
    lMain.FindField('Description').AsString   := 'Payment for A/c';
    lMain.FindField('PaymentMethod').AsString := '320-000';
    lMain.FindField('DocAmt').AsFloat         := 1060;
    lMain.FindField('Cancelled').AsString     := 'F';

    V := lBizApp.CreateOleVariantArray(2);
    V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
    V.SetItem(1, '--IV Test--');  //Invoice Document Number

    if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
      begin
        lKO.Edit;
        lKO.FindField('KOAmt').ASFloat     := 500;
        lKO.FindField('KnockOff').AsString := 'T';
        lKO.Post;
      end;

    lBizObj.Save;
    MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
  finally
    lBizObj.Close;
  end;
end;

AR_PM-Edit

AR_PM Script
procedure TfmMain.dxbb_ARPMClick(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lBizObj := lBizApp.BizObjects.Find('AR_PM');
    lMain   := lBizObj.DataSets.Find('MainDataSet');
    lKO     := lBizObj.DataSets.Find('cdsKnockOff');

    lDocKey := lBizObj.FindKeyByRef('DocNo', '--PM Test--');
    lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);

    If not VarIsNull(lDocKey) Then begin
      lBizObj.Open;
      lBizObj.Edit;
      lMain.FindField('DOCKEY').Value           := -1;
      lMain.FindField('DocDate').Value          := '28 Aug 2016';
      lMain.FindField('PostDate').Value         := '28 Aug 2016';
      lMain.FindField('Description').AsString   := 'Payment for A/c';
      lMain.FindField('PaymentMethod').AsString := '310-000';
      lMain.FindField('DocAmt').AsFloat         := 800.28;
      lMain.FindField('UnappliedAmt').AsFloat   := 100.28;
      lMain.FindField('Cancelled').AsString     := 'F';
      lMain.FindField('CHANGED').AsString       := 'F';

      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
      V.SetItem(1, '--IV Test--');  //Document Number

      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
        begin
          lKO.Edit;
          lKO.FindField('KOAmt').AsFloat     := 700.28; // IV Knock Off/Offset Amount
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;

      lBizObj.Save;
      MessageDlg('AR_PM-DocNo : ''--PM Test--'' Updated...', mtInformation, [mbOK],0);
    end;
  finally
    lBizObj.Close;
  end;
end;

ST_Item

ST_Item Script
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain   := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsUOM');

  try
    lBizObj.New;
    lMain.FindField('Code').AsString        := 'Test-1';
    lMain.FindField('Description').AsString := 'Testing - Description';

    lDtl.Edit; //For 1st UOM
    lDtl.FindField('UOM').AsString     := 'PCS';
    lDtl.FindField('Rate').AsFloat     := 1;
    lDtl.FindField('RefCost').AsFloat  := 10.20;
    lDtl.FindField('RefPrice').AsFloat := 25.00;
    lDtl.Post;

    lDtl.Append; //For 2nd UOM
    lDtl.FindField('UOM').AsString     := 'CTN';
    lDtl.FindField('Rate').AsFloat     := 12;
    lDtl.FindField('RefCost').AsFloat  := 102.00;
    lDtl.FindField('RefPrice').AsFloat := 240.00;
    lDtl.Post;
    lBizObj.Save;

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
  end;
end;

ST_Item-Edit

ST_Item Script
procedure TfmMain.dxbb_ST_ItemClick(Sender: TObject);
var lMain, lDtl, lBizObj, lBizApp, lDocKey, V : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('ST_ITEM');
  lMain   := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsUOM');

  lDocKey := lBizObj.FindKeyByRef('Code', '--Stock Item Test--');
  lBizObj.Params.Find('DocKey').Value := VarToStr(lDocKey);
  try

    If not VarIsNull(lDocKey) Then begin
      lBizObj.Open;
      lBizObj.Edit;
      lMain.FindField('Description').value := 'Testing - Description';

      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'CTN'); //UOM
      V.SetItem(1, '12');  //Rate

      if lDtl.Locate('UOM;Rate', V.AsOleVariant, False, False) then
        begin
          lDtl.Edit;
          lDtl.FindField('RefCost').AsFloat  := 10.20;
          lDtl.FindField('RefPrice').AsFloat := 25.00;
          lDtl.Post;
        end;
      lBizObj.Save;

      MessageDlg('ST_Item-ItemCode : ''--Stock Item Test--'' Updated...', mtInformation, [mbOK],0);
    end;
  finally
    lBizObj.Close;
  end;
end;

SL_IV

SL_IV Script
procedure TfmMain.dxbb_SL_IVClick(Sender: TObject);
var lMain, lDtl, lSN, lBizObj, lBizApp : Variant;
    lTime : TDateTime;
begin
  lTime := Now;
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizObj := lBizApp.BizObjects.Find('SL_IV');
  lMain   := lBizObj.DataSets.Find('MainDataSet');
  lDtl    := lBizObj.DataSets.Find('cdsDocDetail');
  lSN     := lBizObj.DataSets.Find('cdsSerialNumber');

  try
    lBizObj.New;
    lMain.FindField('DOCKEY').Value         := -1;
    lMain.FindField('DocNo').AsString       := '--IV Test--';
    lMain.FindField('CODE').AsString        := '300-A0001';
    lMain.FindField('DocDate').Value        := '28 Aug 2020';
    lMain.FindField('PostDate').Value       := '28 Aug 2020';
    lMain.FindField('TAXDATE').Value        := '28 Aug 2020';
    lMain.FindField('Description').AsString := 'Sales';
    lMain.FindField('Cancelled').AsString   := 'F';
    lMain.Post;

    lDtl.Append; // For Tax Inclusive = True with override Tax Amount
    lDtl.FindField('DTLKEY').Value         := -1;
    lDtl.FindField('DOCKEY').Value         := -1;
    lDtl.FindField('SEQ').Value            := 1;
    lDtl.FindField('ItemCode').AsString    := 'ITEM A';
    lDtl.FindField('ACCOUNT').AsString     := '500-000'; //GL Sales Account
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item A';
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString         := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value   := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 435;//Including GST UnitPrice
    lDtl.FindField('AMOUNT').AsFloat       := 410.37; //Must Excluding GST (Qty * UnitPrice) // Less 0.01
    lDtl.FindField('TAXAMT').AsFloat       := 24.63; //Extra 0.01

    lDtl.DisableControls; //For Tax Inclusive Only where TaxAmt is not as Calc
    try
      lDtl.FindField('TAXINCLUSIVE').Value := 1;
    finally
      lDtl.EnableControls;
    end;
    lDtl.Post;

    lDtl.Append; // For Tax Inclusive = False with override Tax Amount
    lDtl.FindField('DTLKEY').Value         := -1;
    lDtl.FindField('DOCKEY').Value         := -1;
    lDtl.FindField('SEQ').Value            := 2;
    lDtl.FindField('ItemCode').AsString    := 'ITEM B';
    lDtl.FindField('ACCOUNT').AsString     := '500-000';
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Item B';
    lDtl.FindField('QTY').AsFloat          := 1;
    lDtl.FindField('TAX').AsString         := 'SV';
    lDtl.FindField('TAXINCLUSIVE').Value   := 0;
    lDtl.FindField('UNITPRICE').AsFloat    := 94.43;
    lDtl.FindField('AMOUNT').AsFloat       := 94.43;
    lDtl.FindField('TAXAMT').AsFloat       := 5.66; //Less 0.01
    lDtl.Post;

    lDtl.Append; // For Serial Number
    lDtl.FindField('DTLKEY').Value         := -1;
    lDtl.FindField('DOCKEY').Value         := -1;
    lDtl.FindField('SEQ').Value            := 3;
    lDtl.FindField('ItemCode').AsString    := 'SN1';
    lDtl.FindField('ACCOUNT').AsString     := '500-000';
    lDtl.FindField('DESCRIPTION').AsString := 'Sales Serial Number Item';

    lSN.Append;
    lSN.FindField('SERIALNUMBER').AsString  := 'SN-00001';
    lSN.Post;

    lSN.Append;
    lSN.FindField('SERIALNUMBER').AsString  := 'SN-00002';
    lSN.Post;

    lDtl.FindField('QTY').AsFloat        := 2;
    lDtl.FindField('TAX').AsString       := 'SR';
    lDtl.FindField('TAXINCLUSIVE').Value := 0;
    lDtl.FindField('UNITPRICE').AsFloat  := 94.43;
    lDtl.FindField('TAXAMT').AsFloat     := 11.33;
    lDtl.Post;

    lBizObj.Save;

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lBizObj.Close;
    lMain := null;
    lDtl := null;
    lSN := null;
    lBizObj := null;
    lBizApp := null;
  end;
end;

Customer.IV.RO

Customer.IV.RO Report Object Script
procedure TfmMain.dxbb_RptObjClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.IV.RO');
    lRptVar.Params.Find('SelectDate').AsBoolean           := True;
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    lRptVar.Params.Find('AllAgent').AsBoolean             := False;
    lRptVar.Params.Find('AgentData').AsBlob               := '----'#13#10'HALIM'; //Filter by Agent code ---- & HALIM
    lRptVar.Params.Find('AllArea').AsBoolean              := True;
//    lRptVar.Params.Find('AreaData').AsBlob                := ; //Not use if AllArea is True
    lRptVar.Params.Find('AllCompany').AsBoolean           := True;
//    lRptVar.Params.Find('CompanyData').AsBlob             := ; //Not use if AllCompany is True
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := ; //Not use if AllCurrenty is True
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
//    lRptVar.Params.Find('DocProjectData').AsBlob          := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean   := True;
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob     := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
//    lRptVar.Params.Find('DocumentData').AsBlob            := ; //Not use if AllDocument is True
    lRptVar.Params.Find('IncludeCancelled').AsBoolean   := True;
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean := False;
    lRptVar.Params.Find('AllItemProject').AsBoolean     := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean   := True;
    lRptVar.CalculateReport;

    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocDetail').XMLData; //Detail Data - To link Master Data use Dockey field

    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;

Stock.Item.RO

Stock.Item.RO Report Object Script
procedure TfmMain.dxbb_ST_ITEM_ROClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl, cdsCat : TClientDataset;
    lSQL : string;
begin
  lTime    := Now;
  cdsMain  := TClientDataset.Create(nil);
  cdsDtl   := TClientDataset.Create(nil);
  cdsCat   := TClientDataset.Create(nil);

  lBizApp := CreateOleObject('SQLAcc.BizApp');

  lSQL := 'SELECT * FROM ST_ITEM_CATEGORY ' +
          'WHERE Category IN (''B-MOTOLORA'',''B-MAXIS'')';
  cdsCat.Data := lBizApp.DBManager.Execute(lSQL); //For filtering Category only

  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Stock.Item.RO');
    lRptVar.Params.Find('AllItem').AsBoolean              := True;
    lRptVar.Params.Find('AllStockGroup').AsBoolean        := True;
    lRptVar.Params.Find('AllCustomerPriceTag').AsBoolean  := True;
    lRptVar.Params.Find('AllSupplierPriceTag').AsBoolean  := True;
//    lRptVar.Params.Find('CategoryData').AsBlob            := ; //Not use
//    lRptVar.Params.Find('CategoryTpl').AsBlob             := ; //Not use
//    lRptVar.Params.Find('CustomerPriceTagData').AsBlob    := ; //Not use if AllCustomerPriceTag is True
//    lRptVar.Params.Find('SupplierPriceTagData').AsBlob    := ; //Not use if AllSupplierPriceTag is True
//    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2015'; //Not use if SelectDate is False
//    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2015';
    lRptVar.Params.Find('HasAltStockItem').AsBoolean      := False;
    lRptVar.Params.Find('HasBarcode').AsBoolean           := False;
    lRptVar.Params.Find('HasBOM').AsBoolean               := False;
    lRptVar.Params.Find('HasCategory').AsBoolean          := False;
    lRptVar.Params.Find('HasCustomerItem').AsBoolean      := False;
    lRptVar.Params.Find('HasOpeningBalance').AsBoolean    := False;
    lRptVar.Params.Find('HasPurchasePrice').AsBoolean     := False;
    lRptVar.Params.Find('HasSellingPrice').AsBoolean      := False;
    lRptVar.Params.Find('HasSupplierItem').AsBoolean      := False;
//    lRptVar.Params.Find('ItemData').AsBlob                := 'ANT 1.0'#13#10'COVER'; //Filter by Item code ANT 1.0 & COVER
//    lRptVar.Params.Find('ItemCategoryData').AsBlob        := cdsCat.XMLData; //Not use if SelectCategory is False
    lRptVar.Params.Find('PrintActive').AsBoolean          := True;
    lRptVar.Params.Find('PrintInActive').AsBoolean        := True;
    lRptVar.Params.Find('PrintNonStockControl').AsBoolean := True;
    lRptVar.Params.Find('PrintStockControl').AsBoolean    := True;
    lRptVar.Params.Find('SelectCategory').AsBoolean       := False;
    lRptVar.Params.Find('SelectDate').AsBoolean           := False;
    lRptVar.Params.Find('SortBy').AsString                  := 'Code';
//    lRptVar.Params.Find('StockGroupData').AsBlob        := ; //Not use if AllStockGroup is True
    lRptVar.CalculateReport;

    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData; //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsUOM').XMLData;  //Detail Data - To link Master Data use Code field

    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
    cdsCat.Free;
  end;
end;

Customer.Statement.RO

Customer.Statement.RO Report Object Script
procedure TfmMain.dxbb_StatementClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
    s : string;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
       '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
       '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
       '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
       '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
       '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
       '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
       '</ROWDATA></DATAPACKET>';
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Statement.RO');
//  lRptVar.Params.Find('AgentData').AsBlob               := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString           := s; //Fixed
    lRptVar.Params.Find('AgingOn').AsString             := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean           := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean         := False;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob              := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob   := ; //Not use if AllCompanyCategory is True
    lRptVar.Params.Find('CompanyData').AsBlob           := '300-A0001'#13#10'300-C0001'; //Filter by Customer Code 300-A0001 & 300-C0001
//    lRptVar.Params.Find('ControlAccountData').AsBlob    := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob          := ; //Not use if AllCurrency is True
    lRptVar.Params.Find('DateFrom').AsDate              := '01 Aug 2016';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
//    lRptVar.Params.Find('DocProjectData').AsBlob        := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SelectDate').AsBoolean         := True;
    lRptVar.Params.Find('SortBy').AsString              := 'CompanyCategory;Code;CompanyName;Agent;Area;CurrencyCode;ControlAccount';
    lRptVar.Params.Find('StatementDate').AsDate         := '31 Aug 2016'; // Norm same as DateTo
    lRptVar.Params.Find('StatementType').AsString       := 'O'; //O := Open Item, B := B/F

    lRptVar.CalculateReport;

    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field

    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;

GL Account List For Sales & Purchase 1

GL_Acc Object Script
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
var BizApp : Variant;
    lDataSet : TClientDataSet;
    ASQL : String;
begin
  //For Debtor List => SpecialAccType = DR 
  //For Creditor List => SpecialAccType = CR 
  BizApp := CreateOleObject('SQLAcc.BizApp');
  lDataSet := TClientDataSet.Create(Self);
  try
     ASQL := 'SELECT A.Code, A.Description FROM GL_ACC A '+
             'LEFT OUTER JOIN GL_ACC B ON (A.Dockey=B.Parent) '+
             'WHERE A.Parent<>-1 ' +
             'AND B.Dockey IS NULL ' +
             'AND A.SpecialAccType = '''' '+
             'ORDER BY A.CODE ';
     lDataSet.Data := BizApp.DBManager.Execute(ASQL);
     lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet.Free;
  end;
end;

GL Account List For Sales & Purchase 2

GL_Acc Object Script
procedure TfmMain.dxbb_GLAccClick(Sender: TObject);
var BizApp, BizObj : Variant;
    lDataSet1, lDataSet2 : TClientDataSet;
    ASQL : String;
begin
  //For Debtor List => SpecialAccType = DR 
  //For Creditor List => SpecialAccType = CR 
  BizApp := CreateOleObject('SQLAcc.BizApp');
  BizObj := BizApp.BizObjects.Find('GL_Acc');

  lDataSet1 := TClientDataSet.Create(Self);
  lDataSet2 := TClientDataSet.Create(Self);
  try
    ASQL :='Parent<>-1 ' +
           'AND (SpecialAccType IS NULL OR SpecialAccType = '''' ' +
           'OR SpecialAccType = '''') ';
    lDataSet1.XMLData:= BizObj.Select('Dockey,Code,Description', ASQL, 'Code', 'SX', '', '');

    lDataSet2.XMLData:= BizObj.Select('Parent', '', 'Code', 'SX', '', '');

    lDataset2.First; // Remove Parent Account
    while not lDataset2.Eof do begin
      if lDataset1.Locate('Dockey', lDataSet2.FindField('Parent').AsString, []) then
        lDataset1.Delete;
      lDataset2.Next;
    end;
    lDataset1.MergeChangeLog;
    lDataset1.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file 
  finally
    lDataSet1.Free;
    lDataSet2.Free;
  end;
end;

Customer.Aging.RO

Customer Aging Report Object Script
procedure TfmMain.dxbb_AgingClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl : TClientDataset;
    s : string;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');

  s := '<?xml version="1.0" standalone="yes"?>  <DATAPACKET Version="2.0"><METADATA><FIELDS>'+
       '<FIELD attrname="ColumnNo" fieldtype="i4" required="true"/><FIELD attrname="ColumnType" fieldtype="string" WIDTH="1"/>'+
       '<FIELD attrname="Param1" fieldtype="i4" required="true"/><FIELD attrname="Param2" fieldtype="i4" required="true"/>'+
       '<FIELD attrname="IsLocal" fieldtype="boolean"/><FIELD attrname="HeaderScript" fieldtype="bin.hex" SUBTYPE="Text" WIDTH="1"/>'+
       '</FIELDS><PARAMS/></METADATA><ROWDATA><ROW ColumnNo="0" ColumnType="" Param1="0" Param2="0" IsLocal="FALSE"/>'+
       '<ROW ColumnNo="1" ColumnType="A" Param1="0" Param2="0" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;Current Mth&apos;&#013;end;"/>'+
       '<ROW ColumnNo="2" ColumnType="A" Param1="-1" Param2="-1" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;1 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="3" ColumnType="A" Param1="-2" Param2="-2" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;2 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="4" ColumnType="A" Param1="-3" Param2="-3" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;3 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="5" ColumnType="A" Param1="-4" Param2="-4" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;4 Months&apos;&#013;end;"/>'+
       '<ROW ColumnNo="6" ColumnType="B" Param1="-999999" Param2="-5" IsLocal="FALSE" HeaderScript="ObjectPascal&#013;begin&#013;Value:= &apos;5 Month &amp; above&apos;&#013;end;"/>'+
       '</ROWDATA></DATAPACKET>';
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('Customer.Aging.RO');
    lRptVar.Params.Find('ActualGroupBy').AsString       := 'Code;CompanyName'; //Fixed
//    lRptVar.Params.Find('AgentData').AsBlob               := ; //Not use if AllAgent is True
    lRptVar.Params.Find('AgingData').AsString           := s;
    lRptVar.Params.Find('AgingDate').AsDate             := '31 Aug 2016';
    lRptVar.Params.Find('AgingOn').AsString             := 'I'; //Fixed
    lRptVar.Params.Find('AllAgent').AsBoolean           := True;
    lRptVar.Params.Find('AllArea').AsBoolean            := True;
    lRptVar.Params.Find('AllCompany').AsBoolean         := True;
    lRptVar.Params.Find('AllCompanyCategory').AsBoolean := True;
    lRptVar.Params.Find('AllControlAccount').AsBoolean  := True;
    lRptVar.Params.Find('AllCurrency').AsBoolean        := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean      := True;
//    lRptVar.Params.Find('AreaData').AsBlob            := ; //Not use if AllArea is True
//    lRptVar.Params.Find('CompanyCategoryData').AsBlob := ; //Not use if AllCompanyCategory is True
//    lRptVar.Params.Find('CompanyData').AsBlob         := ; //Not use if AllCompany is True
//    lRptVar.Params.Find('ControlAccountData').AsBlob  := ; //Not use if AllControlAccount is True
//    lRptVar.Params.Find('CurrencyData').AsBlob        := ; //Not use if AllCurrency is True
//    lRptVar.Params.Find('DocProjectData').AsBlob      := ; //Not use if AllDocProject is True
    lRptVar.Params.Find('FilterPostDate').AsBoolean      := True;
//    lRptVar.Params.Find('GroupBy
    lRptVar.Params.Find('IncludePDC').AsBoolean         := False;
    lRptVar.Params.Find('IncludeZeroBalance').AsBoolean := False;
    lRptVar.Params.Find('SortBy').AsString              := 'Code;CompanyName';
    lRptVar.Params.Find('DateTo').AsDate                := '31 Aug 2016';
    lRptVar.Params.Find('IncludeKnockedOffDetail').AsBoolean := False;

    lRptVar.CalculateReport;

    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDocument').XMLData; //Detail Data - To link Master Data use Code field

    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;

GL.CB.RO

GL Cash Book Report Object Script
procedure TfmMain.dxBB_CBClick(Sender: TObject);
var lBizApp, lRptVar : Variant;
    lTime : TDateTime;
    cdsMain, cdsDtl, cdsTax : TClientDataset;
begin
  lTime := Now;
  cdsMain := TClientDataset.Create(nil);
  cdsDtl  := TClientDataset.Create(nil);
  cdsTax  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  try
    lRptVar := null;
    lRptVar := lBizApp.RptObjects.Find('GL.CB.RO');
    lRptVar.Params.Find('AllCurrency').AsBoolean          := True;
    lRptVar.Params.Find('AllDocProject').AsBoolean        := True;
    lRptVar.Params.Find('AllDocument').AsBoolean          := True;
    lRptVar.Params.Find('AllItemProject').AsBoolean       := True;
    lRptVar.Params.Find('AllItemArea').AsBoolean          := True;
    lRptVar.Params.Find('AllItemAgent').AsBoolean         := True;
    lRptVar.Params.Find('AllDocAgent').AsBoolean          := True;
    lRptVar.Params.Find('AllDocArea').AsBoolean           := True;
    lRptVar.Params.Find('AllPaymentMethod').AsBoolean     := False;
//    lRptVar.Params.Find('CurrencyData').AsBlob            := 'Not use if AllCurrency is true

//  For Post Date From & Date To'
    lRptVar.Params.Find('DateFrom').AsDate                := '01/01/2017';
    lRptVar.Params.Find('DateTo').AsDate                  := '31/12/2017';

//    lRptVar.Params.Find('DocProjectData').AsBlob          := //'Not use if AllDocProject is true
//    lRptVar.Params.Find('DocAreaData').AsBlob             := //Not use if AllDocArea is true
//    lRptVar.Params.Find('DocAgentData').AsBlob            := //Not use if AllDocAgent is true
//    lRptVar.Params.Find('ItemAgentData').AsBlob           := //Not use if AllItemAgent is true
    lRptVar.Params.Find('DocType').AsString               := 'PV'; //'PV for Payment Voucher & OR for Official Receipt
//    lRptVar.Params.Find('DocumentData').AsBlob            := //Not use if AllDocument is true
//    lRptVar.Params.Find('GroupBy').AsBlob                 := //If you wanted to grouping the data
    lRptVar.Params.Find('IncludeCancelled').AsBoolean     := False;
//    lRptVar.Params.Find('ItemAreaData').AsBlob            := //Not use if AllItemArea is true
//    lRptVar.Params.Find('ItemProjectData').AsBlob         := //Not use if AllItemProject is true
    lRptVar.Params.Find('PaymentMethodData').AsBlob       := '310-001';
    lRptVar.Params.Find('PrintDocumentStyle').AsBoolean   := True;
    lRptVar.Params.Find('SelectDate').AsBoolean           := True; //For Post Date
//  lRptVar.Params.Find('SelectDocDate').AsBoolean   := True; 'For Doc Date
    lRptVar.Params.Find('SortBy').AsString                := 'PostDate;DocNo';

    lRptVar.CalculateReport;

    cdsMain.XMLData := lRptVar.DataSets.Find('cdsMain').XMLData;      //Master Data
    cdsDtl.XMLData  := lRptVar.DataSets.Find('cdsDetail').XMLData; //Detail Data - To link Master Data use Dockey field
    cdsTax.XMLData  := lRptVar.DataSets.Find('cdsTax').XMLData; //Tax List

    cdsMain.SaveToFile('C:\Temp\_ListM.xml'); //Export To XML file
    cdsDtl.SaveToFile('C:\Temp\_ListD.xml');  //Export To XML file
    cdsTax.SaveToFile('C:\Temp\_ListT.xml');  //Export To XML file

    lTime := Now - lTime;
    MessageDlg(Format('[Elapsed Time: %s ]',[FormatDateTime ('hh:nn:ss:zzz', lTime)]),
               mtInformation, [mbOk], 0);
  finally
    lRptVar := null;
    cdsMain.Free;
    cdsDtl.Free;
  end;
end;

AR_DP

Customer Deposit Script
procedure TForm1.Button1Click(Sender: TObject);
var lMain, lBizObj, lBizApp : Variant;
begin
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');

  lBizObj := lBizApp.BizObjects.Find('AR_DP');
  lMain   := lBizObj.DataSets.Find('MainDataSet');

  try
    lBizObj.New;
    lMain.FindField('DOCKEY').Value         := -1;
    lMain.FindField('DocNo').AsString       := '--DP Test--';
    lMain.FindField('CODE').AsString        := '300-C0001';
    lMain.FindField('DocDate').Value        := '28 Oct 2019';
    lMain.FindField('PostDate').Value       := '28 Oct 2019';
    lMain.FindField('TAXDATE').Value        := '28 Oct 2019';
    lMain.FindField('DEPOSITACCOUNT').AsString := 'PREPAYMENT';
    lMain.FindField('PaymentMethod').AsString  := '320-000'; //Bank or Cash account
    lMain.FindField('Description').AsString    := 'Deposit For Account';
    lMain.FindField('ChequeNumber').AsString   := '';
    lMain.FindField('BankCharge').AsFloat      := 0;
    lMain.FindField('DocAmt').AsFloat          := 1000.00;
    lMain.FindField('Cancelled').AsString      := 'F';

    try
      lBizObj.Save;
    except
      on E: Exception do
        Memo1.Lines.Append(E.Message);
    end;
     lBizObj.Close;
     Memo1.Lines.Append('Done');
//     MessageDlg('Done', mtInformation, [mbOk], 0);
  finally
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;

Customer Deposit to Customer Payment

Customer Deposit to Customer Payment Script
procedure TForm1.Button2Click(Sender: TObject);
var lMain, lKO, lBizApp, lBizObj, V : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');

  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);

    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_PM');
      lMain   := lBizObj.DataSets.Find('MainDataSet');
      lKO     := lBizObj.DataSets.Find('cdsKnockOff');

      lBizObj.New;
      lMain.FindField('DOCKEY').Value           := -1;
      lMain.FindField('DocNo').AsString         := '--PM Test--'; //Payment Document Number
      lMain.FindField('CODE').AsString          := '300-C0001';
      lMain.FindField('DocDate').Value          := '29 Oct 2019';
      lMain.FindField('PostDate').Value         := '29 Oct 2019';
      lMain.FindField('Description').AsString   := 'Payment for A/c';
      lMain.FindField('PaymentMethod').AsString := 'PREPAYMENT';
      lMain.FindField('DocAmt').AsFloat         := 200;
      lMain.FindField('FROMDOCTYPE').AsString   := 'DP'; //Transfer from Deposit
      lMain.FindField('FROMDOCKEY').Value       := cdsTmp.FindField('Dockey').AsFloat; //Transfer from Deposit
      lMain.FindField('Cancelled').AsString     := 'F';
      lMain.FindField('CHANGED').AsString       := 'F';

      V := lBizApp.CreateOleVariantArray(2);
      V.SetItem(0, 'IV'); //Document Type is either is IV or DN for Sales & PI or SD for Purchase
      V.SetItem(1, 'IV-00003');  //Invoice Document Number

      if lKO.Locate('DocType;DocNo', V.AsOleVariant, False, False) then
        begin
          lKO.Edit;
          lKO.FindField('KOAmt').ASFloat     := 200;
          lKO.FindField('KnockOff').AsString := 'T';
          lKO.Post;
        end;

      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
        lBizObj.Close;
        Memo1.Lines.Append('Done');
      //MessageDlg('AR_PM-DocNo : ''--PM Test--'' Posted...', mtInformation, [mbOK],0);
    end else
       Memo1.Lines.Append('Deposit No. Not found');
  finally
    cdsTmp.Free;
    lBizApp.Logout;
    lMain := Null;
    lBizObj := Null;
    lBizApp := Null;
  end;
end;

AR_DPDTL_REFUND

Customer Deposit Refund Script
procedure TForm1.Button3Click(Sender: TObject);
var lMain, lBizApp, lBizObj : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');

  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);

    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_REFUND');
      lMain   := lBizObj.DataSets.Find('MainDataSet');

      lBizObj.New;
      lMain.FindField('DOCKEY').Value          := cdsTmp.FindField('Dockey').AsFloat;
      lMain.FindField('Account').AsString      := '320-000'; //Bank or Cash account
      lMain.FindField('DocDate').Value         := '28 Oct 2019';
      lMain.FindField('PostDate').Value        := '28 Oct 2019';
      lMain.FindField('Description').AsString  := 'Deposit Refund';
      lMain.FindField('ChequeNumber').AsString := '';
      lMain.FindField('BankCharge').AsFloat    := 0;
      lMain.FindField('PAYMENTAMOUNT').AsFloat := 500.00;

      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
       lBizObj.Close;
       Memo1.Lines.Append('Done');
  //     MessageDlg('Done', mtInformation, [mbOk], 0);
    end else
      Memo1.Lines.Append('Deposit No. Not Found');
  finally
    cdsTmp.Free;
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;

AR_DPDTL_FORFEIT

Customer Deposit Forfeit Script
procedure TForm1.Button4Click(Sender: TObject);
var lMain, lBizApp, lBizObj : Variant;
    cdsTmp : TClientDataset;
    lSQL : String;
begin
  cdsTmp  := TClientDataset.Create(nil);
  lBizApp := CreateOleObject('SQLAcc.BizApp');
  lBizApp.Login('ADMIN', 'ADMIN', 'D:\Happy\DB\Default.DCF', 'ACC-0110.FDB');

  try
    lSQL := 'SELECT DOCKEY FROM AR_DP ' +
            'WHERE DOCNO=''--DP Test--'' ';
    cdsTmp.Data := lBizApp.DBManager.Execute(lSQL);

    if cdsTmp.RecordCount > 0 then begin
      lBizObj := lBizApp.BizObjects.Find('AR_DPDTL_FORFEIT');
      lMain   := lBizObj.DataSets.Find('MainDataSet');

      lBizObj.New;
      lMain.FindField('DOCKEY').Value          := cdsTmp.FindField('Dockey').AsFloat;
      lMain.FindField('Account').AsString      := '532-000'; //Forfeit account
      lMain.FindField('DocDate').Value         := '28 Oct 2019';
      lMain.FindField('PostDate').Value        := '28 Oct 2019';
      lMain.FindField('Description').AsString  := 'Deposit Forfeit';
      lMain.FindField('Amount').AsFloat        := 150.00;

      try
        lBizObj.Save;
      except
        on E: Exception do
          Memo1.Lines.Append(E.Message);
      end;
       lBizObj.Close;
       Memo1.Lines.Append('Done');
  //     MessageDlg('Done', mtInformation, [mbOk], 0);
    end else
      Memo1.Lines.Append('Deposit No. Not Found');
  finally
    cdsTmp.Free;
    lMain := Null;
    lBizObj := Null;
    lBizApp.Logout;
    lBizApp := Null;
  end;
end;

FAQ

Problem with opening CHM Help files?

  1. Right click the chm file & select Properties
  2. At General tab Click Unblock button.
  3. Click Apply | Ok.

Still can't open CHM file?

  1. Login SQL Accounting
  2. Click Tools | Options
  3. Click Register & follow wizard
  4. Exit SQL Accounting
  5. Login SQL Accounting
  6. Run CHM File

Why when I compile my program with stated unknown method or unknown identifier?

If you compiler had error may try add the esfw10.dll file under the SQL Accounting\bin folder

How to make sure I login to correct database?

  • Can use the Common.Agent.RO Report Objects to get the Profile info.
  • Then use the cdsProfile Dataset
- CompanyName Field
- Remark Field

Why after post to SQL Accounting the Description3 (More Description)/Notes field it show like this "M y D e s c r i p t i o n" instead of "My Description"?

Make sure you use .AsString in your code (see example below)
Description3 Field Script/Code

...

 lDtl.FindField('DESCRIPTION3').AsString  := 'Sales Item A More Description'+ #13 + 'I in 2nd line';

...

Can I Ignore Doc No Field & let SQL Accounting to Auto Assign?

Yes but we not recommended as you will lost track when user wanted to know which Doc No in SQL Acc is posted.
To Set Auto Assign set it as below
DocNo Field Script/Code

...

 lMain.FindField('DocNo').AsString  := '<<New>>';

...

lDocNo := lMain.FindField('DocNo').AsString; //To Get docno after post 

Can I Auto Login & Logout SQL Accounting when doing & after Posting?

Yes can below is example script
Only work if that PC is no once is using SQL Accounting
C Sharp
Int32 lBuildNo;
dynamic ComServer;
		
public void CheckLogin()
{            
    lBizType = Type.GetTypeFromProgID("SQLAcc.BizApp");
    ComServer = Activator.CreateInstance(lBizType);
            
    if (!ComServer.IsLogin)
    {
        try
        {
            ComServer.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text);
            ComServer.Minimize();
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            FreeBiz(ComServer);
        }
    }
    if (ComServer.IsLogin)
    {
        lBuildNo = ComServer.BuildNo;
    }
}
		
public void FreeBiz(object AbizObj)
{
    System.Runtime.InteropServices.Marshal.ReleaseComObject(AbizObj);
}
		
private void btnExport_Click(object sender, EventArgs e)
{
    dynamic BizObject, lMain, lDocKey;

    CheckLogin();
    //'Step 2: Find and Create the Biz Objects
    BizObject = ComServer.BizObjects.Find("Agent");

    //Step 3: Set Dataset
    lMain = BizObject.DataSets.Find("MainDataSet");    //lMain contains master data

    //Step 4: Search
    lDocKey = BizObject.FindKeyByRef("CODE", edCode.Text);
    try
    {
        try
        {
            //Step 5 : Insert or Update
            if (Convert.IsDBNull(lDocKey))
            {
                BizObject.New();
                lMain.FindField("CODE").value = edCode.Text;
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
            }
            else
            {//Edit Data if found
                BizObject.Params.Find("CODE").Value = lDocKey;
                BizObject.Open();
                BizObject.Edit();
                lMain.FindField("DESCRIPTION").value = edDesc.Text;
            }
            //Step 6: Save & Close
            BizObject.Save();
            MessageBox.Show("Done", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
    }
    finally
    {
        BizObject.Close();

        //Step 7 : Logout after done             
        FreeBiz(BizObject);
        ComServer.Logout();
        FreeBiz(ComServer);
    }            
}
Delphi
....
  public
    { Public declarations }
    lBizApp : variant;
  end;
....

procedure TForm1.CheckLogin;
begin
  lBizApp := null;
  lBizApp := CreateOleObject('SQLAcc.BizApp');

  if not lBizApp.IsLogin then begin
    lBizApp.Login(edUN.Text, edPW.Text, edDCF.Text, edDB.Text); //Login with preset setting
    lBizApp.Minimize; //Mininise the SQLAccounting
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var BizObject, lMain : Variant;
begin
  try
    //Begin Loop your data
    try
      CheckLogin;
      BizObject := lBizApp.BizObjects.Find('Agent');
      lMain     := BizObject.DataSets.Find('MainDataSet');
      BizObject.New;
      lMain.FindField('CODE').AsString := 'HALIM';
      lMain.FindField('Description').AsString := 'HALIM 123';	
      BizObject.save;
    except
      on E: Exception do
        MmLog.Lines.Append(E.Message);
    end;
    //
  finally
    BizObject.close;
    BizObject := null;
    lBizApp.Logout;
    lBizApp := null;
  end;
end;
VB Script
'Copy below script & paste to notepad & name it as eg Agent.vbs
Call PostData
 
Function CreateSQLAccServer
  Set CreateSQLAccServer = CreateObject("SQLAcc.BizApp")
End Function
 
Function PostData
Dim ComServer, BizObject
 
  'Step 1: Create Com Server object
  Set ComServer = CreateSQLAccServer 'Create Com Server
  
  Set WScr = CreateObject("WScript.Shell")
  WScript.Sleep 1000 '//Wait 1 second for system loading before proceed

  'Step 2: Force Logout to make sure login correct database
  If ComServer.IsLogin Then 'if user hasn't logon to SQL application
    ComServer.Logout
  END IF
  'Step 3: Login 
  ComServer.Login "ADMIN", "ADMIN", "C:\estream\SQLAccounting\Share\Default.DCF", "ACC-0015.FDB" 

  'Step 4: Find and Create the Biz Objects
  Set BizObject = ComServer.BizObjects.Find("Agent") 
 
  'Step 5: Set Dataset
  Set lMain = BizObject.DataSets.Find("MainDataSet")    'lMainDataSet contains master data

  
  'Step 6 : Posting
    BizObject.New
    lMain.FindField("CODE").AsString          = "_Test_"
    lMain.FindField("Description").AsString   = "Testing 123"

  'Step 7: Save Document
    BizObject.Save
    BizObject.Close
	
  'Step 8: Logout	
    ComServer.Logout
	MsgBox "Done"
End Function

When Post System Prompt Operation aborted Error

This happen when the Login User ID don't had the to Override Sales Min/Max Price &
Use Last Price XXX (In Tools | Options | Unit Price) &
1 of record is below Min Price.

Solution

Can try change the Posting Seq like below (UOM then Qty)
Sequence Field Script/Code

...

   lDetail.Append();
   lDetail.FindField("DtlKey").value = -1;
   lDetail.FindField("DocKey").value = -1;
   lDetail.FindField("Seq").value = 3;
   lDetail.FindField("ItemCode").AsString = "ANT";
   lDetail.FindField("Description").AsString = "Sales Item B";
   //lDetail.FindField("Account").AsString = "500-000"; To override the Sales Account Code
   lDetail.FindField("UOM").AsString = "UNIT";
   lDetail.FindField("Qty").AsFloat = 2;
   //lDetail.FindField("DISC").AsString = "5%+3"; //Optional(eg 5% plus 3 Discount)
   lDetail.FindField("Tax").AsString = "SR";
   lDetail.FindField("TaxRate").AsString = "6%";
   lDetail.FindField("TaxInclusive").value = 0;
   lDetail.FindField("UnitPrice").AsFloat = 100;
   lDetail.FindField("Amount").AsFloat = 200;
   lDetail.FindField("TaxAmt").AsFloat = 12;
   lDetail.Post();

...

How do my system know there is a changes or update in SQLAccounting?

Data Entry

In all Document it had a field call UPDATECOUNT.
Default is null & each changes will +1.
So if you see 2 meaning it had being update 2 times

Master Data

Only available in
  • Version 842.765 & above
  • AP_SUPPLIER (Maintain Supplier)
  • AR_CUSTOMER (Maintain Customer)
  • ST_GROUP (Maintain Stock Group)
  • ST_ITEM (Maintain Stock Item)
  • ST_ITEM_TPL (Maintain Item Template)
  • ST_PRICETAG (Maintain Price Tag)
  • TAX (Maintain Tax)
In Each table it had a field call LASTMODIFIED.
The value is Epoch Time or Unix Time

You can use below function to get the field

vbs
...
Function GetData
Dim lDataSet, lSQL
  lSQL = "SELECT DOCNO, UPDATECOUNT FROM SL_CS "
  lSQL = lSQL & "WHERE UPDATECOUNT IS NOT NULL " 
  lSQL = lSQL & "ORDER BY DOCNO "
  Set lDataSet = ComServer.DBManager.NewDataSet(lSQL)
  
  lDataSet.First
  While (not lDataSet.eof)
    MsgBox "DocNo : " & lDataSet.FindField("DocNo").AsString
    MsgBox "UpdateCount : " & lDataSet.FindField("UPDATECOUNT").AsString
    lDataSet.Next
  Wend
End Function
...
Delphi
...   
procedure TfmMain.dxbb_GetFieldClick(Sender: TObject);
var BizApp : Variant;
    lDataSet : TClientDataSet;
    ASQL : String;
begin
  BizApp := CreateOleObject('SQLAcc.BizApp');
  lDataSet := TClientDataSet.Create(Self);
  try
     ASQL := 'SELECT DOCNO, UPDATECOUNT FROM SL_CS ' +
             'WHERE UPDATECOUNT IS NOT NULL ' +
             'ORDER BY DOCNO ';
     lDataSet.Data := BizApp.DBManager.Execute(ASQL);
     lDataset.SaveToFile('C:\Temp\_List.xml', dfXML); //Export To XML file
  finally
    lDataSet.Free;
  end;
end;
...

Can I control my Stock when I link with other Application?

Yes. We suggest to use Stock Transfer to (eg Location call MOBILE) transfer stock as Reserve to avoid stock over deduct in SQL Accounting
When other Application post to SQL Accounting they just need set the Location to the Reserve Location (eg MOBILE)
Below is example posting with location
Post Location Field Script/Code

...

 lDtl.FindField('UOM').AsString       := 'CTN';
 lDtl.FindField('QTY').AsFloat        := 6;
 lDtl.FindField('Location').AsString  := 'MOBILE';

...

Where to Check the SQL Accounting DCF Path, FileName & FDB FileName?

In Login Screen Click 3 Dot Button then you can see the information
For SQL Accounting Version 5.2023.957.831 and below
SDK-FAQ-01.jpg
For SQL Accounting Version 5.2023.958.832 and above
SDK-FAQ-03.jpg
SDK-FAQ-02.jpg

How to check & What is the value for Advance Credit Control in Maintain Customer

You can use ComServer.DBManager.NewDataSet(lSQL) function to Query the information
lSQL = SELECT * FROM AR_CUSTOMERCRCTRL
You may refer to ControlType column
ControlType Exceed Credit Limit Exceed OverDue Limit
0 UnBlock UnBlock
1 UnBlock Block
2 UnBlock Override
3 Block UnBlock
4 Block Block
5 Block Override
6 Override UnBlock
7 Override Block
8 Override Override
9 Suspended

How to get Error/Exception Message Return from SQL Accounting?

C Sharp
try
{
   BizObject.New();
....
   BizObject.Save();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
Python
   try:
       BizObject.Save()          
   except Exception as e:
       print("Oops!", e)   
VB.Net
Try
  BizObject.[New]
...
  BizObject.Save
Catch ex As Exception
  MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
Delphi
try
  lBizObj.New;
....
  lBizObj.Save;
except
  on E: Exception do
    Memo1.Lines.Text := E.Message;
end;


Why Post to SQL Accounting sometime prompt Catastrophic failure Error?

Possible Problem 1

Make sure you code don't cross over Call action during posting
Eg Posing SL_SO Header partly then suddenly call other object example Check Customer Code Validity
Summary action (Correct Steps)
01. Do Verify 1st (eg Check Customer Code Validity & etc)
02. Post Transactions

Possible Problem 2

Keep Login & Logout till windows not enough time to response
Summary action (Correct Steps)
01. Pull Data from Your application/web
02. Login SQL Accounting 1 time (Auto Login)
03. Do all your requirement actions (eg. verify, query & posting)
    eg Posting Cash Sales & Customer Payment
begin looping
  BizObject = ComServer.BizObjects.Find("SL_CS")
  ....
  BizObject.Save
  BizObject.Close
  FreeBiz(BizObject)
  
  BizObject = ComServer.BizObjects.Find("AR_PM")
  ....
  BizObject.Save
  BizObject.Close
  FreeBiz(BizObject)
  
  Next Record
End looping
04. Logout SQL Accounting 1 time (Auto Logout)
05. Push Data to Your application/web (if any)

Possible Problem 3

Company Profile Logo format had problem.
Solution
01. Click File | Company Profile
02. Export out the Logo by right Click the Company Logo
03. Open the Exported Logo with Photo Editor
04. Just Click File | Save again as jpg.
05. Load Back the Save Logo by right Click the Company Logo
06. Click Save

How to Get the GL Account List for Sales & Purchase?

You can use the function ComServer.DBManager.NewDataSet(lSQL) with the following SQL
SELECT  Code, Description, Description2 FROM GL_ACC A
WHERE (A.Parent<>-1
AND NOT (EXISTS (SELECT Parent FROM GL_ACC B
                 WHERE A.DocKey=B.Parent))
AND (A.SpecialAccType IS NULL OR A.SpecialAccType IN ('', 'AD')))
ORDER BY Code

Can I setup a testing/Staging environment for SQL Accounting?

Yes can, you can self setup or we can help you to setup.
There are 4 types of Testing/Staging
01. Install the Testing SQL Accounting version & Testing Database in the developer PC
02. Install the Live SQL Accounting version & User Backup Database in the developer PC
- Require User Permission for Backup
03. Setup at User PC/Server & using User Backup Database
- Require User Permission for Backup & PC/Server setup
04. Setup at User PC/Server & using Testing Database
- Require User Permission for PC/Server setup

How to Loop & post SQL Accounting?

Below summary how to loop
01. Call ComServer
02. Check Login
03. Call BizObject (eg SL_CS)
04. Begin Loop you data
05. Call Close BizObject (eg BizObject.Close)
06. Continue Call other BizObject (eg AR_PM)
07. Repeat Steps 4 & 5
08. Call Logout
09. Free ComServer

How to post Description3 with Unicode?

You have to convert it to rtf format before set to Description3 field
C Sharp
private static string FormatAsRTF(string DirtyText)
{
    System.Windows.Forms.RichTextBox rtf = new System.Windows.Forms.RichTextBox();
    rtf.Text = DirtyText;
    return rtf.Rtf;
}

....
 lDtl.FindField("DESCRIPTION3").AsString  = FormatAsRTF("ANTENNA ???");
...
VB.Net
Private Shared Function FormatAsRTF(ByVal DirtyText As String) As String
    Dim rtf As System.Windows.Forms.RichTextBox = New System.Windows.Forms.RichTextBox()
    rtf.Text = DirtyText
    Return rtf.Rtf
End Function

....
 lDtl.FindField("DESCRIPTION3").AsString  = FormatAsRTF("ANTENNA ???")
...
Delphi
function TfmMain.PlainTxtToRTF(const AValue:String):String;
var R:TRichEdit;
    M : TStringStream;
begin
  R := TRichEdit.CreateParented(HWND_MESSAGE);
  M := TStringStream.Create('');
  try
    R.WordWrap := False;
    R.Lines.Add(AValue);
    R.Lines.SaveToStream(M);
    Result := M.DataString;
  finally
    R.Free;
    M.Free;
  end;
end;

....
 lDtl.FindField('DESCRIPTION3').AsString  := PlainTxtToRTF('ANTENNA ???');
...
or Can use our build in Utility function (only available from 5.2022.941.822 & above)
....
 lDtl.FindField("Description3").AsString = ComServer.Utility.PlainTextToRichText("ANTENNA ??? ??")
...
PHP
<!DOCTYPE html>
<html>
<body>

<h1>SQL Acc SDK in PHP page</h1>

<?php
echo "Updated 14 Sep 2022<br>";
#This action to show & post Description3 with unicode

$ComServer = null;

function CheckLogin()
{
    global $ComServer;
    $ComServer = new COM("SQLAcc.BizApp", null, CP_UTF8) or die("Could not initialise SQLAcc.BizApp object.");
    $status = $ComServer->IsLogin();

    if ($status == true)
    {
        #$ComServer->Logout();
    }
    $ComServer->Login("ADMIN", "ADMIN", #UserName, Password
                      "C:\eStream\SQLAccounting\Share\Default.DCF",  #DCF file
                      "ACC-0082.FDB"); #Database Name
    
}

function GetData(){
    global $ComServer;
	
    $lSQL = "SELECT Description3 FROM ST_ITEM 
	     WHERE Code='ANT' ";
	
    $lDataSet = $ComServer->DBManager->NewDataSet($lSQL);

    if ($lDataSet->RecordCount > 0) {
	$lDataSet->First();
		
	$rtf = $lDataSet->FindField('Description3')->AsString();
		
        echo $rtf;		
	echo "<br>== <br>";
	echo "<br>Result after RTF: <br>";
	$txt = $ComServer->Utility->RichTextToPlainText($rtf);
	echo "<TEXTAREA rows=10 cols=80 id='edResult1' >".$txt. "</TEXTAREA>";
	echo "<br>== <br>";
	echo "??? ??";
	}else {
    echo "Record Not Found";
    }
}

function PostData(){
	global $ComServer;
	
	$BizObject = $ComServer->BizObjects->Find("ST_AJ");
    $lMain = $BizObject->DataSets->Find("MainDataSet"); 
    $lDetail = $BizObject->DataSets->Find("cdsDocDetail"); 
	
    $BizObject->New();
    $lMain->FindField("DocKey")->value = -1;
    $lMain->FindField("DocNo")->AsString = "<<New>>";
    $lMain->FindField("DocDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("PostDate")->value = "04/20/2020"; #MM/DD/YYYY
    $lMain->FindField("Description")->AsString = "Stock Adjustment";
	
    #Insert Data - Detail - Increase Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 1;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "Sales Item B";
    $lDetail->FindField("Qty")->AsFloat = 2;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
    #Insert Data - Detail - Reduce Stock Qty
    $lDetail->Append();
    $lDetail->FindField("DtlKey")->value = -1;
    $lDetail->FindField("DocKey")->value = -1;
    $lDetail->FindField("Seq")->value = 2;
    $lDetail->FindField("ItemCode")->AsString = "ANT";
    $lDetail->FindField("Description")->AsString = "NOKIA CHARGER  ???";
	$lDetail->FindField("Description3")->AsString = $ComServer->Utility->PlainTextToRichText("NOKIA CHARGER ??? ??");
    $lDetail->FindField("Qty")->AsFloat = -5;
    $lDetail->FindField("UOM")->AsString = "UNIT";
    $lDetail->Post();
	
    $BizObject->Save();
    $BizObject->Close();
	
	try{
        $BizObject->Save();
        $BizObject->Close();
	}catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    }	
}

if (isset($_POST['BtnData']))
{
    try
    {
        CheckLogin();
        GetData();
	echo "<br>";
        echo date("d M Y h:i:s A")." - Done";
	PostData();
	echo "<br>";
        echo date("d M Y h:i:s A")." - Done ST_AJ";			
    }
    finally
    {
        $ComServer->Logout();
        #free the object
        $ComServer = null;
    }
}

?> 
    <form method="post">           
        <input type="submit" name="BtnData"
                value="Get RTF n Post RTF"/> 
    </form> 
</body>
</html>

See also

  • Need assistance? May email to support@sql.com.my