<?php

///////////////////////////////////////////////////////////////////////////////////////////////////
// Define each field of the current Entity - for each field you can set the following keys: ///////
// 'mandatory', 'invisible' and 'validation'. Use the '_special' field key code to allow adding ///
// extra validations that are not checked automatically. //////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

// invoiceDate
$CFG['globalEntity']['::Invoice']['invoiceDate']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['invoiceDate']['validation']= ['type'=>'date', 'minValue'=>date(MYSQL_FORMAT, strtotime('-5 years')), 'maxValue'=>date(MYSQL_FORMAT, strtotime('+1 year'))];

// dueDate
$CFG['globalEntity']['::Invoice']['dueDate']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['dueDate']['invisible']=false;
$CFG['globalEntity']['::Invoice']['dueDate']['validation']= ['type'=>'date'];

// fulfillmentDate
$CFG['globalEntity']['::Invoice']['fulfillmentDate']['mandatory']=false;
$CFG['globalEntity']['::Invoice']['fulfillmentDate']['invisible']=true;
$CFG['globalEntity']['::Invoice']['fulfillmentDate']['validation']= ['type'=>'date'];

// idBankAccount
$CFG['globalEntity']['::Invoice']['idBankAccount']['mandatory']=false;
$CFG['globalEntity']['::Invoice']['idBankAccount']['invisible']=false;
$CFG['globalEntity']['::Invoice']['idBankAccount']['validation']= ['type'=>'int'];

// idInvoiceSeries
$CFG['globalEntity']['::Invoice']['idInvoiceSeries']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['idInvoiceSeries']['invisible']=false;
$CFG['globalEntity']['::Invoice']['idInvoiceSeries']['validation']= ['type'=>'int'];

// comments
$CFG['globalEntity']['::Invoice']['comments']['mandatory']=false;
$CFG['globalEntity']['::Invoice']['comments']['invisible']=false;

// remarks
$CFG['globalEntity']['::Invoice']['remarks']['mandatory']=false;
$CFG['globalEntity']['::Invoice']['remarks']['invisible']=false;

// currency
$CFG['globalEntity']['::Invoice']['currency']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['currency']['invisible']=false;

// formOfPayment
$CFG['globalEntity']['::Invoice']['formOfPayment']['mandatory']=false; // the flag for 'mandatory' is configured in the app ; this setting remains false
$CFG['globalEntity']['::Invoice']['formOfPayment']['invisible']=false;

// idUser
$CFG['globalEntity']['::Invoice']['idUser']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['idUser']['invisible']=false;
$CFG['globalEntity']['::Invoice']['idUser']['validation']= ['type'=>'int', 'minValue'=>1];

// idOffice
$CFG['globalEntity']['::Invoice']['idOffice']['mandatory']=true;
$CFG['globalEntity']['::Invoice']['idOffice']['invisible']=false;
$CFG['globalEntity']['::Invoice']['idOffice']['validation']= ['type'=>'int', 'minValue'=>1];

// SPECIAL ----------------------------------------------------------------------------------------

// indicates how the original invoice is referenced on the reversed invoice rows: none, number, series+number, id, series+numberFromIssuedInvoice
$CFG['globalEntity']['::Invoice']['_special']['originalInvoiceReferenceOnCreditNoteRows']='number';

// service cancel reasons (max 20 chars); 'autoVoidBySystem' is hardcoded so it must always exist in the list
$CFG['globalEntity']['::Invoice']['_special']['voidReasons'] = ['clientReject', 'wrongData', 'wrongServices', 'issuedByMistake', 'autoVoidBySystem'];

// voidReason - checked only on "cancel" operation
$CFG['globalEntity']['::Invoice']['_special']['voidReasonMandatory'] = false;

