generate/cbs2.gifInvoice Creation Hook (R-INVn.MAC)

Enterprise & Corporate Edition Only


 

The script file must be located in your CAPITAL program directory and must have a file name of the format R-INVn.MAC. Any file name from R-INV0.MAC through to R-INV9.MAC is valid. Up to 10 invoice creation scripts may be defined at any one time. This script is executed when the Issue Invoices Utility is run.

The first line of the script must be a comment line beginning with the symbol * (asterisk). The text that follows the script will be used as the task name. For example:

* Customer Volume Discounts

Entry Values

Variable

Purpose

lFirst

If this variable is set to TRUE then processing has started. The first transaction has been found and is being presented to the script.

lLast

If this variable is set to TRUE then processing is about to end. The last transaction to inspect is being presented to the system.

dIssueDate

The date new transactions should be issued.
This is useful when calling the TranWrite() function. E.g., TranWrite("Date", dIssueDate)

cTranNumber

The transaction number to issue.
If this is not blank it is normally supplied to the TranCreate() function. E.g., TranCreate(cTranNumber). It should be noted that if the transaction number already exists, the TranCreate() function will issue the next closest number to the one requested automatically.

Invoice->X

Invoice transaction fields.

Custrec->X

Customer account fields.

Cuaux000->X

Customer user defined fields, if applicable.

Return Values

Return FALSE at any time to cancel the invoice issue process.

Comments

This script is called for each invoice found in the user specified invoicing range. If the user has specified filter conditions, such as a specific account code, account category, transaction type, etc., then the script will only be presented with the transactions that match this criteria.

The Invoice Creation Hook will never be presented with transactions that have been created using this script. For example, let's say you create an invoice in the current period based on transaction data in the prior period. When this script is executed for the following period, CAPITAL ignores (does not present to the script) any transactions that were created by this hook.

Special Features

If the operator selects Non-Invoicing as the invoicing mode before pressing the Generate button on the Generate Invoices window, the invoicing utility will tranverse a user specified database file in place of the standard invoice file. In this case you must define the database table that will be traversed when the variable lFirst is set to TRUE. You must also open this table. For example:

If lFirst

   Table := "Cardfile1"

   OpenTable("Cardfile1")

Endif

Example

This is the skeleton framework for a basic invoicing script:

If lFirst

   * Declare and initialise variables here

Endif

* Normal processing here

If lLast

   * Call TranCreate() here

Endif

____________________________

Related Topics:

Issue Invoices

Scripting Hooks

Script Programming



Help Topic Map