edoc invoice link for IGF Administration Guide
Breadcrumbs

Create individual functions in edoc invoice link for IGF

In the edoc invoice link for IGF administration (app menu edoc invoice link > edoc invoice link for IGF), you can add a specific function in the field configuration alongside the header data and line item data of the invoice, which is tailored to your needs. An individual function is always relevant if you want to make specific calculations or, for example, combine the value of several invoice fields.

You can save PHP files with your individual functions in the installation directory on the server with edoc invoice link for IGF at <app>\data\persistent\fieldFunctions. Always create a single PHP file for each function and save the PHP file with a meaningful file name. You need the file name for the field configuration.

You must follow these principles when creating individual functions:

  • The files must contain a class with the same name as the file itself.

  • The class must extend the App\CustomFunction class.

  • The function exec() is called from edoc invoice link for IGF and the return value is used for the field value.

  • You can access the following properties with the extension of the App\CustomFunction class:

    • logger: Is an object of the PSR\Log\LoggerInterface class. The logger object can be used to write debug information and error messages to the log file.

    • invoice: Is an object of the App\Invoice class and contains the following properties:

      • header: Header data of the current invoice.

      • status: Status information of the current invoice.

      • positions: Line item data of the current invoice with the transfer data of the invoice.

    • position: Is an array. If line item data is processed, this array is filled with the data of the current line item. Otherwise, the array contains the data of the first line item, if available.

    • api: Is an object of the edoc\appserver\ScriptAPI\Action class with the helper methods for data sources and actions. For more information about the actions see the edoc automate guide).

Example of an individual function

PHP
<?php

use App\CustomFunction;

class PrefixVendorId extends CustomFunction
{
    public function exec()
    {
        $this->logger->debug("Start processing PrefixVendorId");

        $data = "PREFIX_" . ($this->invoice->header["vendor_id"] ?? "");

        // Use position:
        //$account = $this->position["account"];

        // Use Script API i.E. do something with d.3
        //$this->api->getDatasource("d3");

        $this->logger->debug("End processing PrefixVendorId");

        return $data;
    }
}

Then add the individual function in the field configuration of your app.

Here's how

  1. Create a new field configuration or switch to an existing configuration.

  2. Under Mapping type, select the entry Individual function.

  3. Enter the name of the class under Mapping details. Enter the name of the PHP file without the file extension, e.g. ManipulateVendorName instead of ManipulateVendorName.php.

The function is executed when the field value is determined.