////////////////////////////////////////////////////////////////////////////////
// Hook
// => Definition of variables
// File-Encoding: UTF-8 without BOM( Test: ü,ä,ö )
//------------------------------------------------------------------------------
// Created/Edited    	| Description
//------------------------------------------------------------------------------
// 08.2017              | dbs | invoice workflow 1.1.0
////////////////////////////////////////////////////////////////////////////////

// WFL PROCESS ID
global gDBS_INVOICE_WFL_ID             = "5utr82engsp9i09ljpf5gsk4jm"

// USERGROUPS (GRP) ( has to be ID !!! )
global gGRP_CLEARING                   = "Accounting"
global gGRP_ACCOUNTING                 = "Accounting"

// DOCUMTENT TYPES (DTS)
global gDTS_INVOICE                    = "DERGS"                                    // Document type short name for: Eingangsrechnung/Grutschrift
global gDTS_INVOICE_ATTACHMENT         = "DREAN"                                    // Document type short name for: Rechnungsanlage
global gDTS_CREDITOR_TRANS_FOLDER      = "AKRVG"                                    // Document type short name for: Kreditorenvorgangsakte
global gDTS_CREDITOR_FOLDER            = "AKR"                                      // Document type short name for: Kreditorenakte

// ATTRIBUTE FIELD NUMBERS (DDF)
global gDDF_CONTACT_ID                 = 81
global gDDF_CONTACT_NAME               = 43
global gDDF_STREET                     = 14			//3
global gDDF_ZIP                        = 9				//4
global gDDF_CITY                       = 10			//5
global gDDF_COUNTRY                    = 15			//6
global gDDF_INVOICE_ID                 = 21			//7
global gDDF_INVOICE_TYPE               = 8
global gDDF_DOCUMENT_CATEGORY          = 4				//9
global gDDF_COMPANY_CODE               = 5				//10
global gDDF_CURRENCY                   = 11
global gDDF_ERP_ID                     = 12
global gDDF_WFL_STATUS                 = 13
global gDDF_WFL_STEP                   = 3				//14
global gDDF_CLIENT                     = 31				//15
global gDDF_TRANSACTION_ID             = 2
global gDDF_STORAGE                    = 18
global gDDF_ACCOUNT_DESCRIPTION        = 19


global gDDF_DESCRIPTION		           = 23
global gDDF_DEPARTMENT		           = 35

global gDDF_GUID                       = 47
global gDDF_SYSTEM_ID                  = 48
global gDDF_TECH_ID                    = 49

global gDDF_INVOICE_DATE               = 52
global gDDF_DELIVERY_DATE              = 54
global gDDF_ACCOUNTING_DATE            = 50
global gDDF_PAYED_DATE                 = 53
global gDDF_CAPTURE_DATE               = 51

global gDDF_COST_CENTER                = 60
global gDDF_GL_ACCOUNT                 = 61
global gDDF_INTERNAL_ORDER             = 62
global gDDF_DESCRIPTION_LONG           = 63
global gDDF_NET_VALUE                  = 64
global gDDF_COST_UNIT		           = 65
global gDDF_VERIFIER_STAMP             = 66
global gDDF_MWST_PRODUCT_GROUP         = 67
global gDDF_WFL_MEMBER                 = 68
global gDDF_MWST_COMPANY_GROUP         = 69

global gDDF_APPROVER_STAMP             = 99
global gDDF_APPROVER_STAMP_2ND_LVL     = 99
global gDDF_TAX_KEY                    = 99

global gDDF_GROSS_AMOUNT               = 70
global gDDF_NET_AMOUNT                 = 71
global gDDF_TAX_AMOUNT                 = 72


// GENERAL MODIFICATION FLAGS (GMF)
global gGMF_FORCE_CLEARING_STEP        = "0"                                        // Step clearing is forced
global gGMF_FORCE_ACCOUNTING_STEP      = "0"                                        // Step accounting is forced
global gGMF_MULTILEVEL_APPROVAL        = "0"                                        // Multilevel approval is activated
global gGMF_FIT_MULTILVL_APPROVAL      = "1"                                        // Multilevel approval goes not through all levels, just to highest fitting level
global gGMF_DIRECT_ERP_ACCOUNTING      = "0"                                        // Direct accounting into ERP-System
global gGMF_REFUSE_IN_CHECK            = "0"                                        // Refuse of Invoice in step check enabled
global gGMF_BALANCE_NET_OR_GROSS       = "n"                                        // Interpretation of net or gross positions for calculation of balance (n, g) -> when calculation is configured for net amounts, the accounting step should be configures as necessary in gGMF_ACTIVE_ACCOUNTING_STEP
global gGMF_REFUSE_IN_ACCOUNTING       = "0"                                        // Refuse of Invoice in step  enabled
global gGMF_4_EYES_PRINCIPLE           = "0"                                        // 4-Eyes-Principle activated
global gGMF_CHECK_DUPLICATES           = "1"                                        // Determination of dublicates activated
global gGMF_REFUSAL_INFORM_USER        = "0"                                        // User can be manually informed about refusal of invoice
global gGMF_REFUSAL_INFORM_GROUP       = "RefusalI"                                 // Group with all users/groups that can be informed about refusal of invoice
global gGMF_ROUND_DIFF_AUTOMATIC       = "0"                                        // Shall rounding differences be balanced automatically
global gGMF_ROUND_DIFF_TOLERANCE       = "5"                                        // Maximum difference for automatic balance of rounding differences in cents

// GENERAL MODIFICATION FLAGS: Force client or company_code
global gGMF_CLIENT_EXISTS              = "1"                                        // When client is forced field will be automatically filled and not be shown in wfl
global gGMF_COMPANY_CODE_EXISTS        = "0"                                        // When company_code is forced field will be automatically filled and not be shown in wfl

// GENERAL MODIFICATION FLAGS: DETERMINATION OF VERIFIER AND APPROVER
global gGMF_PRIO_COST_CENTER           = "1"                                        // Priority of cost_center within determination of verifier and approver (1 - 4)
global gGMF_PRIO_GL_ACCOUNT            = "3"                                        // Priority of gl_account within determination of verifier and approver (1 - 4)
global gGMF_PRIO_INTERNAL_ORDER        = "2"                                        // Priority of internal_order within determination of verifier and approver (1 - 4)
global gGMF_PRIO_COST_UNIT             = "4"                                        // Priority of cost_unit within determination of verifier and approver (1 - 4)
global gGMF_NET_OR_GROSS               = "n"                                        // Interpretation of net or gross amount within determination of verifier and approver (n, g)
global gGMF_MANUALLY_CHOICE_1          = "1"                                        // Manually choice of verifier and approver on first level (0,1)

// GENERAL MODIFICATION FLAGS: MODIFICATION RELEVANT ATTRIBUTES IN ACCOUNTING 
global gGMF_ADD_ROWS_ACCOUNTING        = "1"                                        // User in accounting is allowed to add new rows proof and verify them an reduce amounts of other line items
global gGMF_MODR_COST_CENTER           = "0"                                        // Is modification of cost_center in position data relevant for return to step check
global gGMF_MODR_COST_UNIT             = "0"                                        // Is modification of cost_unit in position data relevant for return to step check
global gGMF_MODR_GL_ACCOUNT            = "0"                                        // Is modification of gl_account in position data relevant for return to step check
global gGMF_MODR_INTERNAL_ORDER        = "0"                                        // Is modification of internal_order in position data relevant for return to step check
global gGMF_MODR_POS_NET_VALUE         = "0"                                        // Is modification of net_value in position data relevant for return to step check
global gGMF_MODR_POS_GROSS_VALUE       = "0"                                        // Is modification of gross_value in position data relevant for return to step check
global gGMF_MODR_CLIENT                = "0"                                        // Is modification of client in header data relevant for return to step check
global gGMF_MODR_CREDITOR              = "0"                                        // Is modification of creditor in header data relevant for return to step check
global gGMF_MODR_COMPANY_CODE          = "0"                                        // Is modification of company_code in header data relevant for return to step check
global gGMF_MODR_INV_GROSS_VALUE       = "0"                                        // Is modification of gross_value in header data relevant for return to step check

// GENERAL MODIFICATION FLAGS: ESCALTION RELEVANT CONFIGURATIONS
global gGMF_ESCAL_TIME_CLEARING        = 0                                          // Days until escalation happens in step clearing
global gGMF_ESCAL_TIME_CHECK           = 7                                          // Days until escalation happens in step check
global gGMF_ESCAL_TIME_APPROVAL_1      = 7                                          // Days until escalation happens in step approval of position data
global gGMF_ESCAL_TIME_APPROVAL_N      = 0                                          // Days until escalation happens in step approval of invoice 
global gGMF_ESCAL_TIME_ACCOUNTING      = 0                                          // Days until escalation happens in step accounting

global gGMF_ESCAL_USER_CLEARING        = "Accounting"                                 // User or group to be informed about escalation in step clearing
global gGMF_ESCAL_USER_CHECK           = "Accounting"                                 // User or group to be informed about escalation in step check
global gGMF_ESCAL_USER_APPROVAL_1      = "Accounting"                                   // User or group to be informed about escalation in step approval of position data
global gGMF_ESCAL_USER_APPROVAL_N      = "Accounting"                                   // User or group to be informed about escalation in step approval of invoice 
global gGMF_ESCAL_USER_ACCOUNTING      = "Accounting"                               // User or group to be informed about escalation in step accounting

// GENERAL MODIFICATION FLAGS: FOR AUTO TRANSACTION ID GENERATION
global gGMF_TRANSACTION_ID_PRAEFIX     = "RE"                                       // Prefix of automaticly generated transaction id
global gGMF_TRANSACTION_ID_SIZE        = 6                                          // Length of leading nulls in transaction id counter

// GENERAL MODIFICATION FLAGS: SMTP SERVER
global gGMF_SEND_QUEST_MAIL            = "0"                                        // Shall mails be send when receiving answer in question function
global gGMF_SMTP_SERVER                = ""                          // SMTP-Server for mail sending

// GENERAL MODIFICATION FLAGS: FOR ERP INTERFACE
global gGMF_CALL_INTERFACE             = "1"                                        // Shall the ERP-Interface be called in workflow or not
global gGMF_ERP_VALIDATE_POS_DATA      = "0"                                        // Validate item lines against ERP-System
global gGMF_ERP_WRITE_LAST_STEP        = "0"                                        // only write or book records in last step of workflow into ERP-System
global gGMF_CONFIG_INTERFACE           = "NAVContext.xml"                           // Name of interface configuration file
global gGMF_WEB_SERVICE_URL            = "http\://localhost\:8081/DecsERPServlet/DecsERPServlet"      // webservice url (wfWebServiceURL)
global gDBS_RET_CODE_SERVLET_JAVA	   = ""
global gDBS_RET_MSG_SERVLET_JAVA	   = ""

// GENERAL MODIFICATION FLAGS: FOR ERP CONNECTION VIA HOOK  -> see 51_erp_dbs_invoice.jpl
global gGMF_GET_ERP_META_DATA_HOOK     = "1"                                        // Shall the meta data be loaded from erp system

// GENERAL MODIFICATION FLAGS: FOR DATABASE TYPE AND SCHEME NAME
vars lGMF_DATABASE_ARRAY[3]            = { "MSSQL", "ORACLE", "DB2" }               // init array for database type
vars lGMF_DATABASE_TYPE_ID             = 1                                          // Microsoft SQL: 1, Oracle: 2, DB2: 3, configure the database type
global gGMF_DATABASE_TYPE              = lGMF_DATABASE_ARRAY[lGMF_DATABASE_TYPE_ID]

global gGMF_SCHEME_NAME                = ""                                         //Scheme name of master data tables in masterdatabase, necessary for DB2
global gGMF_SCHEME_NAME_RUN_TIME       = ""                                         //Scheme name of run-time data tables in database, necessary for DB2

//GENERAL MODIFICATION FLAGS : FOR TABLE NAMES OF RUN-TIME DATA TABLES
global gGMF_TABLE_CHECK_FST_APPR       = "dbs_inv_auth_check_fst_appr"
global gGMF_TABLE_SND_APPROVAL         = "dbs_inv_auth_snd_approval"
global gGMF_TABLE_CUSTOM_COUNTER       = "dbs_inv_custom_counter"

//GENERAL MODIFICATION FLAGS : FOR TABLE NAMES OF MASTER DATA TABLES
global gGMF_TABLE_CREDITORS            = "dbs_inv_creditors"
global gGMF_TABLE_COMPANY_CODE         = "dbs_inv_company_code"
global gGMF_TABLE_CURRENCIES           = "dbs_inv_currencies"
global gGMF_TABLE_COST_CENTERS         = "dbs_inv_cost_centers"
global gGMF_TABLE_COST_UNITS           = "dbs_inv_cost_unit"
global gGMF_TABLE_GL_ACCOUNT           = "dbs_inv_gl_account"
global gGMF_TABLE_INTERNAL_ORDERS      = "dbs_inv_internal_orders"
global gGMF_TABLE_PAYMENT_TERMS        = "dbs_inv_payment_terms"
global gGMF_TABLE_TAX_KEY              = "dbs_inv_tax_key"

// WORKFLOW (WFL)
// !!! specified in dataset
global gSTORAGE_WORKFLOW = "dbsInvoiceWorkflow"
global gSTORAGE_ARCHIVE = "dbsInvoiceArchive"
// !!! wfl_steps are specified in dataset
global gWFL_STEP_UNDEFINED             = "Undefined"
global gWFL_STEP_CLEARING              = "dbsInvoiceClearing"
global gWFL_STEP_CHECK                 = "dbsInvoiceCheck"
global gWFL_STEP_APPROVAL              = "dbsInvoiceApproval"
global gWFL_STEP_ACCOUNTING            = "dbsInvoiceAccounting"

// !!! wfl_status are specified in dataset
global gWFL_STATUS_NEW                 = "dbsInvoiceNew"
global gWFL_STATUS_IN_PROGRESS         = "dbsInvoiceInProgress"
global gWFL_STATUS_FINISHED            = "dbsInvoiceFinished"
global gWFL_STATUS_REFUSED             = "dbsInvoiceRefused"
global gWFL_STATUS_SEND_TO_ERP         = "dbsInvoiceSendToERP"
global gWFL_STATUS_ACCOUNTED           = "dbsInvoiceAccounted"

vars lWFL_TITLE_CLRG_ARRAY[2]                                                       // init array for titles of hold files in step clearing
vars lWFL_TITLE_CHEC_ARRAY[2]                                                       // init array for titles of hold files in step check
vars lWFL_TITLE_APPR_ARRAY[2]                                                       // init array for titles of hold files in step approval
vars lWFL_TITLE_ACCT_ARRAY[2]                                                       // init array for titles of hold files in step accounting

lWFL_TITLE_CLRG_ARRAY[1]               = "dbs|invoice workflow - Vorkontierung"     // german title of hold files in step clearing
lWFL_TITLE_CHEC_ARRAY[1]               = "dbs|invoice workflow - Sachliche Prüfung" // german title of hold files in step check
lWFL_TITLE_APPR_ARRAY[1]               = "dbs|invoice workflow - Freigabe Stufe"    // german title of hold files in step approval
lWFL_TITLE_ACCT_ARRAY[1]               = "dbs|invoice workflow - Kontierung"        // german title of hold files in step accounting

lWFL_TITLE_CLRG_ARRAY[2]               = "dbs|invoice workflow - Clearing"          // english title of hold files in step clearing
lWFL_TITLE_CHEC_ARRAY[2]               = "dbs|invoice workflow - Verification"      // english title of hold files in step check
lWFL_TITLE_APPR_ARRAY[2]               = "dbs|invoice workflow - Approval Level"    // english title of hold files in step approval
lWFL_TITLE_ACCT_ARRAY[2]               = "dbs|invoice workflow - Accounting"        // english title of hold files in step accounting

global gWFL_MAIN_LANGUAGE              = 1                                          // German: 1, English: 2, configuration of title and history language in holdfiles
global gWFL_TITLE_CLEARING             = lWFL_TITLE_CLRG_ARRAY[gWFL_MAIN_LANGUAGE]  // configured title of hold files in step clearing
global gWFL_TITLE_CHECK                = lWFL_TITLE_CHEC_ARRAY[gWFL_MAIN_LANGUAGE]  // configured title of hold files in step check
global gWFL_TITLE_APPROVAL             = lWFL_TITLE_APPR_ARRAY[gWFL_MAIN_LANGUAGE]  // configured title of hold files in step approval
global gWFL_TITLE_ACCOUNTING           = lWFL_TITLE_ACCT_ARRAY[gWFL_MAIN_LANGUAGE]  // configured title of hold files in step accounting

global gWFL_RESP_ADMIN_USER            = "sa"                                   // Workflow responsible
global gWFL_RESP_ESCAL_USER            = "sa"                                   // Total escalation responsible

// ERROR CODES (ERR)
global gERR_IMPORT_DUPLICATE_ERR       = 310
global gERR_IMPORT_DUPLICATE_FOUND     = 315
global gERR_ERP_SVLT_WRITE_USER        = 320
global gERR_ERP_SVLT_WRITE_STATE       = 325
global gERR_ERP_SVLT_CREATE_RECORD     = 330

// Loglevel
global gLOGLEVEL                       = 9