Override of a Method: Customizing the Release Process for CA Documents

In this topic, you can learn how to customize the release process for CA documents.

Customizing the Release Process for CA Documents

You can customize the release process for CA documents by overriding the Insert***Transaction methods. In the override method, you can modify the process of inserting a line to the general ledger.

In this way, you can customize the actions that include the ReleaseDocProc<TCADocument> method call. For example, you can customize the actions executed with the Release button on the following forms:

Overriding the Insert***Transaction methods

You can override the following methods:

  • public virtual GLTran InsertDocumentTransaction(
        JournalEntry, GLTran, GLTranInsertionContext)

    The method inserts GL transactions of the document.

  • public virtual GLTran InsertSplitTransaction(
        JournalEntry, GLTran, GLTranInsertionContext)

    The method inserts GL transactions of the document details.

  • public virtual GLTran InsertRoundingTransaction(
        JournalEntry, GLTran, GLTranInsertionContext)

    The method processes the rounding of the document lines sum and document total.

  • public virtual GLTran InsertDepositChargeTransaction(
        JournalEntry, GLTran, GLTranInsertionContext)

    The method inserts GL transactions for deposit charges. The method is available only for the Bank Deposits (CA305000) form.

The GLTranInsertionContext parameter of the methods contains the context of the release process—that is, a field or multiple fields of the GLTranInsertionContext class instance have values assigned by the system. The context depends on the document being released. For example, for the InsertDocumentTransaction method, the CATranRecord field contains the context of the release process. See the class members below.

public class GLTranInsertionContext
{
	public virtual CAAdj CAAdjRecord { get; set; }
	public virtual CASplit CASplitRecord { get; set; }
	public virtual CATaxTran CATaxTranRecord { get; set; }

	public virtual CATransfer CATransferRecord { get; set; }
	public virtual CAExpense CAExpenseRecord { get; set; }

	public virtual CADeposit CADepositRecord { get; set; }
	public virtual CADepositDetail CADepositDetailRecord { get; set; }
	public virtual CADepositCharge CADepositChargeRecord { get; set; }

	public virtual CATran CATranRecord { get; set; }
}

Example

The following code shows the override of the InsertDocumentTransaction method. In this code, you at first check whether the current context (a record of the CATranRecord type) is not empty.
public delegate GLTran InsertDocumentTransactionDelegate(
    JournalEntry je, 
    GLTran tran, 
    CAReleaseProcess.GLTranInsertionContext context);
/// Overrides <seealso cref="CAReleaseProcess.InsertDocumentTransaction(JournalEntry, GLTran, CAReleaseProcess.GLTranInsertionContext)"/>
[PXOverride]
public GLTran InsertDocumentTransaction(
    JournalEntry je, 
    GLTran tran, 
    CAReleaseProcess.GLTranInsertionContext context, 
    InsertDocumentTransactionDelegate base_InsertDocumentTransaction)
{
    if (context.CATranRecord!= null)
    {
        // Add your code
    }
    return base_InsertDocumentTransaction(je,tran,context);
}