LockboxImportCustomMethod
| Initial Build | 2006.01 or earlier |
| Module | Accounting |
| Current Setting Type | Text Box |
Use this system option to call a client-specific program for importing lockbox.
Example: Lockbox_ABC|Avectra.netForum.ABC.Components.Lockbox_ABC.Lockbox_ABC
Where the value to left of first pipe is the .NET Assembly and the value to the right of the pipe is the namespace of the class.
The default for this option is empty.
Current Setting
The current setting for LockboxImportCustomMethod is used as follows:
Values: This system option can be set to call a client-specific program for importing lockbox. For instructions on developing your custom class, see the Usage section below.
Default Value: empty
Fields
This system option includes the following fields:
Description: This field gives the description of the system option, including its use and default value.
Important! Do not modify the following fields after the system option is first created. Changing these fields after they have been used can invalidate existing data.
Category: This field sets the category (usually the module) where the system option is used.
Type: The Type field determines the display type of the Current setting field (check box, drop-down list, or text box).
Values: The values field indicates the allowed values for the Current setting field.
Availability
Each system option includes the following availability settings:
Entity Level Option?: Select this check box to make this system option available on an entity level.
Visible To External Systems?: Select this check box to make this system option available in xWeb.
Usage
Your custom class must have a public method called exactly Import (as NetForum will invoke this method by name). The Import method must accept a System.Collections.ArrayList parameter and must return a Avectra.netForum.Data.FacadeDetails containing a collection of facade objects of the Avectra.netForum.Components.AC.ac_lockbox_import type. The collection of FacadeDetails should contain one object for each line in the lockbox file.
Sample method:
{
}
The incoming ArrayList takes the following form: The first (zero-based) element is always a System.IO.StreamReader containing the file. The second element is an Avectra.netForum.Common.ErrorClass that you can use to set errors, if needed.
In the custom code, you must return a FacadeDetails collection that contains one facade detail for each row in the lockbox file. The facade details must be of the Avectra.netForum.Components.AC.ac_lockbox_import type. See ac_lockbox_import for the table structure of that object's mani data type.
Sample
Sample template code below. Adjust to the client's own namespace and format to the client's particular lockbox file. Based on the sample below, the value to put into the LockboxImportCustomMethod system option, assuming the assembly will be called ABCExtension, is:
ABCExtension|ABC.Lockbox
using System;
using System.Data;
using Avectra.netForum.Common;
using Avectra.netForum.Data;
using System.Data.OleDb;
using Avectra.netForum.Components.AC;
namespace ABC
{
public class Lockbox
{
public Lockbox()
{
}
public Avectra.netForum.Data.FacadeDetails Import(System.Collections.ArrayList oParams)
{
// StreamReader containing the file
// always the first (zero-based) parameter in the ArrayList
System.IO.StreamReader oStreamReader = (System.IO.StreamReader)oParams[0];
// ErrorClass
//always the second (zero-based) parameter in the Array List
ErrorClass oError = (ErrorClass)oParams[1];
OleDbConnection oConn;
OleDbTransaction oTrx;
oConn = DataUtils.GetConnection();
oTrx = null;
// This FacadeDetails will be the return of the method:
FacadeDetails oReturnDetails = new FacadeDetails();
string szLine = null;
string szSql = "";
string szBatchName = "";
string szBatchDate = "";
string szCustID = "";
string szInvoiceNo = "";
string szCheckNo = "";
string szPaidAmount = "";
string szSourceCode = "";
// iterate through the lines of the StreamReader
while ((szLine = oStreamReader.ReadLine()) != null)
{
szLine = szLine.Trim();
if (!UtilityFunctions.EmptyString(szLine))
{
//read from file depending on layout
szBatchDate = szLine.Substring(6, 10);
szBatchName = szLine.Substring(92, 6);
szPaidAmount = szLine.Substring(104, 13);
szCheckNo = szLine.Substring(117, 29).Trim();
szInvoiceNo = szLine.Substring(178, 29).Trim();
szCustID = szLine.Substring(627, 29).Trim();
// this is where you can write custom logic to set szInvoiceNo
//for example: if no invoice number in file, look at customer's open invoices to find the the invoice
szSql = "select cst_key,cst_id from ac_invoice " + DataUtils.NoLock() +
" join co_customer " + DataUtils.NoLock() + " on cst_key = inv_cst_key " +
" where inv_code = '" + szInvoiceNo + "'";
DataSet oDS = DataUtils.GetDataSet(szSql);
if (oDS.Tables[0].Rows.Count < 1)
{
ac_lockbox_import oLockboxImport = new ac_lockbox_import();
oLockboxImport.SetValue("lck_batch_name", szBatchName);
oLockboxImport.SetValue("lck_cst_id", szCustID);
oLockboxImport.SetValue("lck_pin_check_number", szCheckNo);
oLockboxImport.SetValue("lck_pin_check_amount", Convert.ToString(UtilityFunctions.ConvertToDecimal(szPaidAmount)));
oLockboxImport.SetValue("lck_inv_code", szInvoiceNo);
oLockboxImport.SetValue("lck_cst_found_key", "");
oLockboxImport.SetValue("lck_batch_date_ext", szBatchDate);
oLockboxImport.SetValue("lck_source_code_ext", szSourceCode);
oReturnDetails.Add(oLockboxImport);
}
foreach (DataRow oDR in oDS.Tables[0].Rows)
{
string szCstKey = oDR["cst_key"].ToString();
string szCstId = oDR["cst_id"].ToString();
ac_lockbox_import oLockboxImport = new ac_lockbox_import();
oLockboxImport.SetValue("lck_batch_name", szBatchName);
oLockboxImport.SetValue("lck_cst_id", szCstId);
oLockboxImport.SetValue("lck_pin_check_number", szCheckNo);
oLockboxImport.SetValue("lck_pin_check_amount", Convert.ToString(UtilityFunctions.ConvertToDecimal(szPaidAmount)));
oLockboxImport.SetValue("lck_inv_code", szInvoiceNo);
oLockboxImport.SetValue("lck_cst_found_key", szCstKey);
oLockboxImport.SetValue("lck_batch_date_ext", szBatchDate);
oLockboxImport.SetValue("lck_source_code_ext", szSourceCode);
oReturnDetails.Add(oLockboxImport);
}
}
}
return oReturnDetails;
}
}}